Backup root.img
Just in case template %post scriptlet doesn't unlink during reinstall, or if reinstall fails. Also preserves Netvm prefs setting.
This commit is contained in:
parent
d316624f61
commit
32a4269f4a
@ -65,15 +65,15 @@ done
|
|||||||
# but do allow explicit template reinstalls
|
# but do allow explicit template reinstalls
|
||||||
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 all files in template's /home and /rw !"
|
||||||
|
|
||||||
$ONEPKG=`cut -f 1 -d ' ' <<<$PKGS`
|
ONEPKG=`cut -f 1 -d ' ' <<<$PKGS`
|
||||||
if [[ "$ONEPKG" == "qubes-template-"* ]] && [[ "$ONEPKG" == "${PKGS#\ }" ]]; then # test "$PKGS" minus space
|
if [[ "$ONEPKG" == "qubes-template-"* ]] && [[ "$ONEPKG" == "${PKGS#\ }" ]]; then # test "$PKGS" minus space
|
||||||
# Prepare to backup template root.img in case reinstall doesn't complete.
|
# Prepare to backup template root.img in case reinstall doesn't complete.
|
||||||
TEMPLATE=${ONEPKG#qubes-template-}
|
TEMPLATE=${ONEPKG#qubes-template-}
|
||||||
TEMPLATE_NETVM=`qvm-prefs $TEMPLATE netvm` || exit 1
|
TEMPLATE_NETVM=`qvm-prefs --force-root $TEMPLATE netvm` || exit 1
|
||||||
if [[ "$TEMPLATE_NETVM" == *"(default)" ]] ; then TEMPLATE_NETVM="default"
|
[[ "$TEMPLATE_NETVM" == *"(default)" ]] && TEMPLATE_NETVM="default"
|
||||||
BAK_TEMPLATE_ROOT=`qvm-prefs $TEMPLATE root_img` || exit 1
|
BAK_TEMPLATE_ROOT=`qvm-prefs --force-root $TEMPLATE root_img` || exit 1
|
||||||
else
|
else
|
||||||
echo "ERROR: Specify only one package to reinstall template"
|
echo "ERROR: Specify only one package to reinstall template"
|
||||||
exit 1
|
exit 1
|
||||||
@ -179,15 +179,6 @@ if [ -z "$YUM_ACTION" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x$PKGS" != "x" ]; then
|
if [ "x$PKGS" != "x" ]; then
|
||||||
yum $YUM_OPTS $YUM_ACTION $PKGS
|
|
||||||
elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
|
|
||||||
# Above file exists only when at least one package was downloaded
|
|
||||||
if [ "$GUI" == "1" ]; then
|
|
||||||
$guiapp
|
|
||||||
else
|
|
||||||
yum check-update
|
|
||||||
if [ $? -eq 100 ]; then # Run yum with options
|
|
||||||
|
|
||||||
if [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
|
if [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
|
||||||
# Backup root.img just in case
|
# Backup root.img just in case
|
||||||
echo -n "Renaming template root.img to root.img-bak..."
|
echo -n "Renaming template root.img to root.img-bak..."
|
||||||
@ -199,16 +190,24 @@ elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yum $YUM_OPTS $YUM_ACTION ; RETCODE=$?
|
yum $YUM_OPTS $YUM_ACTION $PKGS ; RETCODE=$?
|
||||||
|
|
||||||
if [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
|
if [[ -n "$BAK_TEMPLATE_ROOT" ]] ; then
|
||||||
qvm-prefs -s $TEMPLATE netvm $TEMPLATE_NETVM
|
qvm-prefs --force-root -s $TEMPLATE netvm $TEMPLATE_NETVM
|
||||||
if [ $RETCODE -eq 0 ] ; then
|
if [ $RETCODE -eq 0 ] ; then
|
||||||
# Reinstall went OK, remove backup file.
|
# Reinstall went OK, remove backup file.
|
||||||
echo "Removing $BAK_TEMPLATE_ROOT-bak"
|
echo "Removing $BAK_TEMPLATE_ROOT-bak"
|
||||||
rm -f "$BAK_TEMPLATE_ROOT-bak"
|
rm -f "$BAK_TEMPLATE_ROOT-bak"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
|
||||||
|
# Above file exists only when at least one package was downloaded
|
||||||
|
if [ "$GUI" == "1" ]; then
|
||||||
|
$guiapp
|
||||||
|
else
|
||||||
|
yum check-update
|
||||||
|
if [ $? -eq 100 ]; then # Run yum with options
|
||||||
|
yum $YUM_OPTS $YUM_ACTION
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
yum -q check-update && rm -f $UPDATES_STAT_FILE
|
yum -q check-update && rm -f $UPDATES_STAT_FILE
|
||||||
|
Loading…
Reference in New Issue
Block a user