From 382dafb6cd3727d1ef68b500535510ab16dcf23a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 16 Jul 2011 01:57:27 +0200 Subject: [PATCH] vm: Split updates check and download into separate scripts (#198) --- common/qubes_check_for_updates.sh | 20 +++++++++++++++++ common/qubes_download_dom0_updates.sh | 32 +++++++++------------------ rpm_spec/core-commonvm.spec | 2 ++ 3 files changed, 32 insertions(+), 22 deletions(-) create mode 100755 common/qubes_check_for_updates.sh diff --git a/common/qubes_check_for_updates.sh b/common/qubes_check_for_updates.sh new file mode 100755 index 0000000..038637a --- /dev/null +++ b/common/qubes_check_for_updates.sh @@ -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" diff --git a/common/qubes_download_dom0_updates.sh b/common/qubes_download_dom0_updates.sh index df67b92..244462e 100755 --- a/common/qubes_download_dom0_updates.sh +++ b/common/qubes_download_dom0_updates.sh @@ -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" diff --git a/rpm_spec/core-commonvm.spec b/rpm_spec/core-commonvm.spec index bd927c9..d387132 100644 --- a/rpm_spec/core-commonvm.spec +++ b/rpm_spec/core-commonvm.spec @@ -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