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:36:53 +02:00
|
|
|
CLEAN=0
|
2011-09-15 00:18:56 +02:00
|
|
|
CHECK_ONLY=0
|
2012-02-14 21:08:48 +01:00
|
|
|
OPTS="--installroot $DOM0_UPDATES_DIR --config=$DOM0_UPDATES_DIR/etc/yum.conf"
|
2011-09-12 14:32:56 +02:00
|
|
|
PKGLIST=
|
2014-01-10 03:34:16 +01:00
|
|
|
export LC_ALL=C
|
|
|
|
|
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
|
|
|
|
;;
|
2011-10-07 21:13:00 +02:00
|
|
|
--gui)
|
|
|
|
GUI=1
|
|
|
|
;;
|
2011-09-12 14:36:53 +02:00
|
|
|
--clean)
|
|
|
|
CLEAN=1
|
|
|
|
;;
|
2011-09-15 00:18:56 +02:00
|
|
|
--check-only)
|
|
|
|
CHECK_ONLY=1
|
|
|
|
;;
|
2011-09-12 14:32:56 +02:00
|
|
|
-*)
|
|
|
|
OPTS="$OPTS $1"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PKGLIST="$PKGLIST $1"
|
|
|
|
;;
|
|
|
|
esac
|
2011-06-22 00:44:48 +02:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! [ -d "$DOM0_UPDATES_DIR" ]; then
|
2011-09-15 00:19:48 +02:00
|
|
|
echo "Dom0 updates dir does not exists: $DOM0_UPDATES_DIR" >&2
|
2011-06-22 00:44:48 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $DOM0_UPDATES_DIR/etc
|
2011-09-14 00:35:49 +02:00
|
|
|
sed -i '/^reposdir\s*=/d' $DOM0_UPDATES_DIR/etc/yum.conf
|
2011-06-22 00:44:48 +02:00
|
|
|
|
2012-06-13 01:59:25 +02:00
|
|
|
# Rebuild rpm database in case of different rpm version
|
|
|
|
rm -f $DOM0_UPDATES_DIR/var/lib/rpm/__*
|
|
|
|
rpm --root=$DOM0_UPDATES_DIR --rebuilddb
|
|
|
|
|
2011-09-15 00:14:13 +02:00
|
|
|
if [ "$CLEAN" = "1" ]; then
|
2011-09-12 14:36:53 +02:00
|
|
|
yum $OPTS clean all
|
2011-09-14 20:19:53 +02:00
|
|
|
rm -f $DOM0_UPDATES_DIR/packages/*
|
2011-09-12 14:36:53 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-16 01:57:27 +02:00
|
|
|
if [ "x$PKGLIST" = "x" ]; then
|
2011-09-15 00:19:48 +02:00
|
|
|
echo "Checking for dom0 updates..." >&2
|
2014-01-10 03:34:16 +01:00
|
|
|
PKGLIST=`yum $OPTS check-update -q | cut -f 1 -d ' ' | grep -v "^Obsoleting"`
|
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
|
2012-04-25 00:25:54 +02:00
|
|
|
if [ "$GUI" = 1 ]; then
|
|
|
|
zenity --info --text="No new updates available"
|
|
|
|
fi
|
2011-06-22 00:44:48 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-09-15 13:34:14 +02:00
|
|
|
if [ "$CHECK_ONLY" = "1" ]; then
|
|
|
|
echo "Available updates: $PKGLIST"
|
|
|
|
exit 100
|
|
|
|
fi
|
|
|
|
|
2011-07-24 21:54:10 +02:00
|
|
|
if [ "$DOIT" != "1" -a "$PKGS_FROM_CMDLINE" != "1" ]; then
|
2011-06-22 00:44:48 +02:00
|
|
|
zenity --question --title="Qubes Dom0 updates" \
|
2011-09-12 15:08:29 +02:00
|
|
|
--text="There are updates for dom0 available, do you want to download them 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
|
|
|
|
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"
|
2012-03-02 00:15:28 +01:00
|
|
|
yumdownloader --resolve --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
|
2012-03-02 00:15:28 +01:00
|
|
|
yumdownloader --resolve --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
|
2013-03-14 04:28:13 +01:00
|
|
|
/usr/lib/qubes/qrexec-client-vm dom0 qubes.ReceiveUpdates /usr/lib/qubes/qfile-agent $DOM0_UPDATES_DIR/packages/*.rpm
|
2011-07-24 21:54:10 +02:00
|
|
|
else
|
|
|
|
echo "No packages downloaded"
|
|
|
|
fi
|