mirror of
https://github.com/nix-community/home-manager
synced 2024-11-16 16:19:44 +01:00
Avoid undefined variables in activation script
This commit is contained in:
parent
fea693ba16
commit
4f1eec8180
3 changed files with 17 additions and 8 deletions
|
@ -47,10 +47,15 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$VERBOSE_ECHO "Activation variables:"
|
$VERBOSE_ECHO "Activation variables:"
|
||||||
|
if [[ -v oldGenNum ]] ; then
|
||||||
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
|
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
|
||||||
$VERBOSE_ECHO " newGenNum=$newGenNum"
|
|
||||||
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
|
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
|
||||||
|
else
|
||||||
|
$VERBOSE_ECHO " oldGenNum undefined (first run?)"
|
||||||
|
$VERBOSE_ECHO " oldGenPath undefined (first run?)"
|
||||||
|
fi
|
||||||
$VERBOSE_ECHO " newGenPath=$newGenPath"
|
$VERBOSE_ECHO " newGenPath=$newGenPath"
|
||||||
|
$VERBOSE_ECHO " newGenNum=$newGenNum"
|
||||||
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
|
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
|
||||||
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
|
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
|
||||||
$VERBOSE_ECHO " genProfilePath=$genProfilePath"
|
$VERBOSE_ECHO " genProfilePath=$genProfilePath"
|
||||||
|
|
|
@ -281,7 +281,7 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanOldGen() {
|
function cleanOldGen() {
|
||||||
if [[ -z "$oldGenPath" ]] ; then
|
if [[ ! -v oldGenPath ]] ; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ in
|
||||||
| xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles"
|
| xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$oldGenPath" != "$newGenPath" ]] ; then
|
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then
|
||||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
|
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
|
||||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath"
|
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath"
|
||||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
|
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
|
||||||
|
|
|
@ -74,17 +74,21 @@ in
|
||||||
local workDir
|
local workDir
|
||||||
workDir="$(mktemp -d)"
|
workDir="$(mktemp -d)"
|
||||||
|
|
||||||
|
if [[ -v oldGenPath ]] ; then
|
||||||
local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user"
|
local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user"
|
||||||
|
fi
|
||||||
|
|
||||||
local newUserServicePath="$newGenPath/home-files/.config/systemd/user"
|
local newUserServicePath="$newGenPath/home-files/.config/systemd/user"
|
||||||
local oldServiceFiles="$workDir/old-files"
|
local oldServiceFiles="$workDir/old-files"
|
||||||
local newServiceFiles="$workDir/new-files"
|
local newServiceFiles="$workDir/new-files"
|
||||||
local servicesDiffFile="$workDir/diff-files"
|
local servicesDiffFile="$workDir/diff-files"
|
||||||
|
|
||||||
if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then
|
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \
|
||||||
|
&& ! -d "$newUserServicePath" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$oldUserServicePath" ]]; then
|
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then
|
||||||
touch "$oldServiceFiles"
|
touch "$oldServiceFiles"
|
||||||
else
|
else
|
||||||
find "$oldUserServicePath" \
|
find "$oldUserServicePath" \
|
||||||
|
|
Loading…
Reference in a new issue