Backup root.img

Just in case template %post scriptlet doesn't unlink during reinstall, or if reinstall fails.
This commit is contained in:
ttasket 2016-06-18 03:02:46 -04:00 committed by GitHub
parent 17627cdf3c
commit 6c7c25d9e7

View File

@ -66,6 +66,17 @@ done
if [ "$YUM_ACTION" == "reinstall" ] && [[ "$PKGS" == *"qubes-template-"* ]]; then if [ "$YUM_ACTION" == "reinstall" ] && [[ "$PKGS" == *"qubes-template-"* ]]; then
TEMPLATE_EXCLUDE_OPTS="" TEMPLATE_EXCLUDE_OPTS=""
echo "WARNING: Reinstalling a template will erase files in /home and /rw !" echo "WARNING: Reinstalling a template will erase files in /home and /rw !"
$ONEPKG=`cut -f 1 -d ' ' <<<$PKGS`
if [[ "$ONEPKG" == "qubes-template-"* ]] ; then
# Prepare to backup template root.img in case reinstall doesn't complete.
TEMPLATE=${ONEPKG#qubes-template-}
BAK_TEMPLATE_ROOT=`qvm-prefs $TEMPLATE root_img` || exit 1
else
echo "ERROR: Specify only one template package for reinstall"
exit 1
fi
else else
TEMPLATE_EXCLUDE_OPTS="--exclude=`rpm -qa --qf '%{NAME},' qubes-template-\*`" TEMPLATE_EXCLUDE_OPTS="--exclude=`rpm -qa --qf '%{NAME},' qubes-template-\*`"
fi fi
@ -173,8 +184,25 @@ elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
$guiapp $guiapp
else else
yum check-update yum check-update
if [ $? -eq 100 ]; then if [ $? -eq 100 ]; then # Run yum with options
yum $YUM_OPTS $YUM_ACTION
if [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
# Backup root.img just in case
echo -n "Renaming template root.img to root.img-bak..."
if mv "$BAK_TEMPLATE_ROOT" "$BAK_TEMPLATE_ROOT-bak" ; then
echo "OK"
else
echo; echo "ERROR: Could not rename root.img"
exit 1
fi
fi
yum $YUM_OPTS $YUM_ACTION ; RETCODE=$?
if [ $RETCODE -eq 0 ] && [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
# Reinstall went OK, remove backup file.
rm -f "$BAK_TEMPLATE_ROOT-bak"
fi
fi fi
fi fi
yum -q check-update && rm -f $UPDATES_STAT_FILE yum -q check-update && rm -f $UPDATES_STAT_FILE