23 lines
916 B
Bash
Executable File
23 lines
916 B
Bash
Executable File
#! /bin/bash
|
|
|
|
set -eu
|
|
|
|
repo_root=$(git rev-parse --show-toplevel)
|
|
|
|
# Test for newer changes in the dotfiles. Protection against clobbering changes you might want to preserve.
|
|
dry_run=$(rsync -avu --itemize-changes --dry-run --files-from=./tracked-files --exclude-from=./.gitignore . ~)
|
|
if echo "${dry_run}" | grep -q '^<'; then
|
|
echo "Some installed files have newer mtimes than the repository versions. Please import the changes first."
|
|
exit 1
|
|
elif echo "${dry_run}" | grep -q '^>'; then
|
|
echo "Some installed files differ from the repository versions. Creating a backup..."
|
|
backup_dir=$(mktemp -d -t backupXXXXXXXX)
|
|
${repo_root}/import ${backup_dir} y > /dev/null
|
|
mkdir -p ${repo_root}/.backup/
|
|
tar -czf ${repo_root}/.backup/$(basename $backup_dir).tgz $backup_dir
|
|
fi
|
|
|
|
# Actually perform the copy
|
|
rsync -avu --itemize-changes --files-from=./tracked-files --exclude-from=./.gitignore . ~
|
|
|