2011-06-22 00:44:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DOM0_UPDATES_DIR=/var/lib/qubes/dom0-updates
|
|
|
|
|
|
|
|
DOIT=0
|
|
|
|
GUI=1
|
2011-09-12 14:34:41 +02:00
|
|
|
OPTS="--installroot $DOM0_UPDATES_DIR"
|
2011-09-12 14:32:56 +02:00
|
|
|
PKGLIST=
|
2011-06-22 00:44:48 +02:00
|
|
|
while [ -n "$1" ]; do
|
2011-09-12 14:32:56 +02:00
|
|
|
case "$1" in
|
|
|
|
--doit)
|
|
|
|
DOIT=1
|
|
|
|
;;
|
|
|
|
--nogui)
|
|
|
|
GUI=0
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
OPTS="$OPTS $1"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PKGLIST="$PKGLIST $1"
|
|
|
|
;;
|
|
|
|
esac
|
2011-06-22 00:44:48 +02:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! [ -d "$DOM0_UPDATES_DIR" ]; then
|
|
|
|
echo "Dom0 updates dir does not exists: $DOM0_UPDATES_DIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $DOM0_UPDATES_DIR/etc
|
|
|
|
cp /etc/yum.conf $DOM0_UPDATES_DIR/etc/
|
|
|
|
|
2011-07-16 01:57:27 +02:00
|
|
|
if [ "x$PKGLIST" = "x" ]; then
|
|
|
|
echo "Checking for dom0 updates..."
|
2011-09-12 14:34:41 +02:00
|
|
|
PKGLIST=`yum $OPTS check-update -q | cut -f 1 -d ' '`
|
2011-07-24 21:54:10 +02:00
|
|
|
else
|
|
|
|
PKGS_FROM_CMDLINE=1
|
2011-07-16 01:57:27 +02:00
|
|
|
fi
|
2011-06-22 00:44:48 +02:00
|
|
|
|
2011-07-16 01:57:27 +02:00
|
|
|
if [ -z "$PKGLIST" ]; then
|
2011-06-22 00:44:48 +02:00
|
|
|
# No new updates
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-07-24 21:54:10 +02:00
|
|
|
if [ "$DOIT" != "1" -a "$PKGS_FROM_CMDLINE" != "1" ]; then
|
2011-07-16 01:57:27 +02:00
|
|
|
PKGCOUNT=`echo $PKGLIST|wc -w`
|
2011-06-22 00:44:48 +02:00
|
|
|
zenity --question --title="Qubes Dom0 updates" \
|
2011-07-16 01:57:27 +02:00
|
|
|
--text="$PKGCOUNT updates for dom0 available. Do you want to download its now?" || exit 0
|
2011-06-22 00:44:48 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-24 21:54:10 +02:00
|
|
|
if [ "$PKGS_FROM_CMDLINE" == 1 ]; then
|
2011-09-12 14:32:56 +02:00
|
|
|
OPTS="$OPTS --resolve"
|
2011-07-24 21:54:10 +02:00
|
|
|
GUI=0
|
|
|
|
fi
|
|
|
|
|
2011-06-22 00:44:48 +02:00
|
|
|
mkdir -p "$DOM0_UPDATES_DIR/packages"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$GUI" = 1 ]; then
|
|
|
|
( echo "1"
|
2011-09-12 14:34:41 +02:00
|
|
|
yumdownloader --destdir "$DOM0_UPDATES_DIR/packages" $OPTS $PKGLIST
|
2011-06-22 00:44:48 +02:00
|
|
|
echo 100 ) | zenity --progress --pulsate --auto-close --auto-kill \
|
|
|
|
--text="Downloading updates for Dom0, please wait..." --title="Qubes Dom0 updates"
|
|
|
|
else
|
2011-09-12 14:34:41 +02:00
|
|
|
yumdownloader --destdir "$DOM0_UPDATES_DIR/packages" $OPTS $PKGLIST
|
2011-06-22 00:44:48 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-24 21:54:10 +02:00
|
|
|
if ls $DOM0_UPDATES_DIR/packages/*.rpm > /dev/null 2>&1; then
|
|
|
|
/usr/lib/qubes/qrexec_client_vm dom0 qubes.ReceiveUpdates /usr/lib/qubes/qfile-agent $DOM0_UPDATES_DIR/packages/*.rpm
|
|
|
|
else
|
|
|
|
echo "No packages downloaded"
|
|
|
|
fi
|