vm: Split updates check and download into separate scripts (#198)

This commit is contained in:
Marek Marczykowski 2011-07-16 01:57:27 +02:00
parent ac61edf880
commit 382dafb6cd
3 changed files with 32 additions and 22 deletions

View File

@ -0,0 +1,20 @@
#!/bin/sh
DOM0_UPDATES_DIR=/var/lib/qubes/dom0-updates
if ! [ -d "$DOM0_UPDATES_DIR" ]; then
echo "Dom0 updates dir does not exists: $DOM0_UPDATES_DIR" >&2
exit 1
fi
mkdir -p $DOM0_UPDATES_DIR/etc
cp /etc/yum.conf $DOM0_UPDATES_DIR/etc/
# check also for template updates
echo "Checking for template updates..." >&2
TEMPLATEPKGLIST=`yum check-update -q | cut -f 1 -d ' '`
echo "template:$TEMPLATEPKGLIST"
echo "Checking for dom0 updates..." >&2
PKGLIST=`yum --installroot $DOM0_UPDATES_DIR check-update -q | cut -f 1 -d ' '`
echo "dom0:$PKGLIST"

View File

@ -9,6 +9,8 @@ while [ -n "$1" ]; do
DOIT=1
elif [ "x--nogui" = "x$1" ]; then
GUI=0
else
break
fi
shift
done
@ -21,36 +23,22 @@ fi
mkdir -p $DOM0_UPDATES_DIR/etc
cp /etc/yum.conf $DOM0_UPDATES_DIR/etc/
# check also for template updates
echo "Checking for template updates..."
TEMPLATEPKGLIST=`yum check-update -q | cut -f 1 -d ' '`
if [ -n "$TEMPLATEPKGLIST" ] && [ "$GUI" = 1 ]; then
TEMPLATE_UPDATE_COUNT=`echo "$TEMPLATEPKGLIST" | wc -w`
NOTIFY_UPDATE_COUNT=`cat /var/run/qubes/template_update_last_notify_count 2> /dev/null`
if [ "$NOTIFY_UPDATE_COUNT" != "$TEMPLATE_UPDATE_COUNT" ]; then
echo -n $TEMPLATE_UPDATE_COUNT > /var/run/qubes/template_update_last_notify_count
NOTIFY_PID=`cat /var/run/qubes/template_update_notify.pid 2> /dev/null`
if [ -z "$NOTIFY_PID" ] || ! kill -0 $NOTIFY_PID; then
NOTIFY_TITLE="Template update"
NOTIFY_TEXT="There are $TEMPLATE_UPDATE_COUNT updates available for TemplateVM"
NOTIFY_INFO="$NOTIFY_TEXT. Start TemplateVM to update it."
( zenity --notification --text "$NOTIFY_TEXT"; zenity --warning --title "$NOTIFY_TITLE" --text "$NOTIFY_INFO") &
echo $! > /var/run/qubes/template_update_notify.pid
fi
fi
PKGLIST="$*"
if [ "x$PKGLIST" = "x" ]; then
echo "Checking for dom0 updates..."
PKGLIST=`yum --installroot $DOM0_UPDATES_DIR check-update -q | cut -f 1 -d ' '`
fi
echo "Checking for dom0 updates..."
PKGLIST=`yum --installroot $DOM0_UPDATES_DIR check-update -q | cut -f 1 -d ' '`
if [ -z $PKGLIST ]; then
if [ -z "$PKGLIST" ]; then
# No new updates
exit 0
fi
if [ "$DOIT" != "1" ]; then
PKGCOUNT=`echo $PKGLIST|wc -w`
zenity --question --title="Qubes Dom0 updates" \
--text="Updates for dom0 available. Do you want to download its now?" || exit 0
--text="$PKGCOUNT updates for dom0 available. Do you want to download its now?" || exit 0
fi
mkdir -p "$DOM0_UPDATES_DIR/packages"

View File

@ -80,6 +80,7 @@ cp qubes_network.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_network.rules
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes/
cp setup_ip $RPM_BUILD_ROOT/usr/lib/qubes/
cp qubes_download_dom0_updates.sh $RPM_BUILD_ROOT/usr/lib/qubes/
cp qubes_check_for_updates.sh $RPM_BUILD_ROOT/usr/lib/qubes/
mkdir -p $RPM_BUILD_ROOT/etc/yum/post-actions
cp qubes_trigger_sync_appmenus.action $RPM_BUILD_ROOT/etc/yum/post-actions/
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
@ -242,4 +243,5 @@ rm -rf $RPM_BUILD_ROOT
/etc/yum/post-actions/qubes_trigger_sync_appmenus.action
/usr/lib/qubes/qubes_trigger_sync_appmenus.sh
/usr/lib/qubes/qubes_download_dom0_updates.sh
/usr/lib/qubes/qubes_check_for_updates.sh
/lib/firmware/updates