1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

files: simplify cleanup script slightly

The cleanup script now takes relative paths as arguments, not absolute
paths into the old generation. This uses a GNU specific feature of
find.
This commit is contained in:
Robert Helgesson 2017-11-11 14:16:45 +01:00
parent 2b2e20da24
commit 145aefc9d1
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -116,10 +116,8 @@ in
. ${./lib-bash/color-echo.sh} . ${./lib-bash/color-echo.sh}
newGenFiles="$1" newGenFiles="$1"
oldGenFiles="$2" shift 1
shift 2 for relativePath in "$@" ; do
for sourcePath in "$@" ; do
relativePath="''${sourcePath#$oldGenFiles/}"
targetPath="$HOME/$relativePath" targetPath="$HOME/$relativePath"
if [[ -e "$newGenFiles/$relativePath" ]] ; then if [[ -e "$newGenFiles/$relativePath" ]] ; then
$VERBOSE_ECHO "Checking $targetPath: exists" $VERBOSE_ECHO "Checking $targetPath: exists"
@ -165,8 +163,12 @@ in
local newGenFiles oldGenFiles local newGenFiles oldGenFiles
newGenFiles="$(readlink -e "$newGenPath/home-files")" newGenFiles="$(readlink -e "$newGenPath/home-files")"
oldGenFiles="$(readlink -e "$oldGenPath/home-files")" oldGenFiles="$(readlink -e "$oldGenPath/home-files")"
find "$oldGenFiles" -type f -print0 -or -type l -print0 \
| xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles" # Apply the cleanup script on each leaf in the old
# generation. The find command below will print the
# relative path of the entry.
find "$oldGenFiles" '(' -type f -or -type l ')' -printf '%P\0' \
| xargs -0 bash ${cleanup} "$newGenFiles"
} }
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then