activation-init: sanity check oldGenNum and oldGenPath
Something is terribly wrong if one is set but not the other so error out with a message if that happens.
This commit is contained in:
parent
fa7d63d9d1
commit
567b21b1d6
|
@ -11,27 +11,38 @@ function setupVars() {
|
||||||
| sort -rn \
|
| sort -rn \
|
||||||
| head -1)
|
| head -1)
|
||||||
|
|
||||||
if [[ -n "$greatestGenNum" ]] ; then
|
if [[ -n $greatestGenNum ]] ; then
|
||||||
oldGenNum=$greatestGenNum
|
oldGenNum=$greatestGenNum
|
||||||
newGenNum=$((oldGenNum + 1))
|
newGenNum=$((oldGenNum + 1))
|
||||||
else
|
else
|
||||||
newGenNum=1
|
newGenNum=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e "$gcPath/current-home" ]] ; then
|
if [[ -e $gcPath/current-home ]] ; then
|
||||||
oldGenPath="$(readlink -e "$gcPath/current-home")"
|
oldGenPath="$(readlink -e "$gcPath/current-home")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
$VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath"
|
||||||
|
if [[ -v oldGenNum && ! -v oldGenPath
|
||||||
|
|| ! -v oldGenNum && -v oldGenPath ]]; then
|
||||||
|
errorEcho "Invalid profile number and GC root values! These must be"
|
||||||
|
errorEcho "either both empty or both set but are now set to"
|
||||||
|
errorEcho " '${oldGenNum:-}' and '${oldGenPath:-}'"
|
||||||
|
errorEcho "If you don't mind losing previous profile generations then"
|
||||||
|
errorEcho "the easiest solution is probably to run"
|
||||||
|
errorEcho " rm $profilesPath/home-manager*"
|
||||||
|
errorEcho " rm $gcPath/current-home"
|
||||||
|
errorEcho "and trying home-manager switch again. Good luck!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
genProfilePath="$profilesPath/home-manager"
|
genProfilePath="$profilesPath/home-manager"
|
||||||
newGenPath="@GENERATION_DIR@";
|
newGenPath="@GENERATION_DIR@";
|
||||||
newGenProfilePath="$profilesPath/home-manager-$newGenNum-link"
|
newGenProfilePath="$profilesPath/home-manager-$newGenNum-link"
|
||||||
newGenGcPath="$gcPath/current-home"
|
newGenGcPath="$gcPath/current-home"
|
||||||
}
|
}
|
||||||
|
|
||||||
setupVars
|
|
||||||
|
|
||||||
echo "Starting home manager activation"
|
|
||||||
|
|
||||||
if [[ -v VERBOSE ]]; then
|
if [[ -v VERBOSE ]]; then
|
||||||
export VERBOSE_ECHO=echo
|
export VERBOSE_ECHO=echo
|
||||||
export VERBOSE_ARG="--verbose"
|
export VERBOSE_ARG="--verbose"
|
||||||
|
@ -40,6 +51,10 @@ else
|
||||||
export VERBOSE_ARG=""
|
export VERBOSE_ARG=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Starting home manager activation"
|
||||||
|
|
||||||
|
setupVars
|
||||||
|
|
||||||
if [[ -v DRY_RUN ]] ; then
|
if [[ -v DRY_RUN ]] ; then
|
||||||
echo "This is a dry run"
|
echo "This is a dry run"
|
||||||
export DRY_RUN_CMD=echo
|
export DRY_RUN_CMD=echo
|
||||||
|
|
Loading…
Reference in a new issue