1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-28 17:27:28 +02:00

Avoid undefined variables in activation script

This commit is contained in:
Robert Helgesson 2017-03-29 00:10:30 +02:00
parent fea693ba16
commit 4f1eec8180
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
3 changed files with 17 additions and 8 deletions

View file

@ -47,10 +47,15 @@ else
fi
$VERBOSE_ECHO "Activation variables:"
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
$VERBOSE_ECHO " newGenNum=$newGenNum"
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
if [[ -v oldGenNum ]] ; then
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
else
$VERBOSE_ECHO " oldGenNum undefined (first run?)"
$VERBOSE_ECHO " oldGenPath undefined (first run?)"
fi
$VERBOSE_ECHO " newGenPath=$newGenPath"
$VERBOSE_ECHO " newGenNum=$newGenNum"
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
$VERBOSE_ECHO " genProfilePath=$genProfilePath"

View file

@ -281,7 +281,7 @@ in
}
function cleanOldGen() {
if [[ -z "$oldGenPath" ]] ; then
if [[ ! -v oldGenPath ]] ; then
return
fi
@ -294,7 +294,7 @@ in
| 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 "$newGenProfilePath" "$genProfilePath"
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"

View file

@ -74,17 +74,21 @@ in
local workDir
workDir="$(mktemp -d)"
if [[ -v oldGenPath ]] ; then
local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user"
fi
local newUserServicePath="$newGenPath/home-files/.config/systemd/user"
local oldServiceFiles="$workDir/old-files"
local newServiceFiles="$workDir/new-files"
local servicesDiffFile="$workDir/diff-files"
if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \
&& ! -d "$newUserServicePath" ]]; then
return
fi
if [[ ! -d "$oldUserServicePath" ]]; then
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then
touch "$oldServiceFiles"
else
find "$oldUserServicePath" \