2011-06-22 00:44:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
UPDATEVM=`qvm-get-updatevm`
|
|
|
|
if [ -z "$UPDATEVM" ]; then
|
|
|
|
echo "UpdateVM not set, exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-09-12 14:57:38 +02:00
|
|
|
if [ "$1" = "--help" ]; then
|
|
|
|
echo "This tool is used to download packages for dom0. Without package list"
|
|
|
|
echo "it checks for updates for installed packages"
|
|
|
|
echo ""
|
|
|
|
echo "Usage: $0 [--clean] [<pkg list>]"
|
|
|
|
echo " --clean clean yum cache before doing anything"
|
|
|
|
echo " <pkg list> download (and install if run by root) new packages"
|
|
|
|
echo " in dom0 instead of updating"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2011-08-02 14:14:50 +02:00
|
|
|
# We should ensure the clocks in Dom0 and UpdateVM are in sync
|
|
|
|
# becuase otherwise yum might complain about future timestamps
|
|
|
|
qvm-sync-dom0-clock
|
|
|
|
|
2011-06-22 00:44:48 +02:00
|
|
|
echo "Checking for dom0 updates"
|
|
|
|
|
|
|
|
# Start VM if not running already
|
|
|
|
qvm-run -a $UPDATEVM true || exit 1
|
|
|
|
/usr/lib/qubes/sync_rpmdb_updatevm.sh || exit 1
|
2011-09-12 15:05:26 +02:00
|
|
|
qvm-run --pass_io $UPDATEVM "/usr/lib/qubes/qubes_download_dom0_updates.sh --doit --nogui $*" || exit 1
|
2011-07-16 01:58:23 +02:00
|
|
|
# Wait for download completed
|
|
|
|
while pidof -x qubes-receive-updates >/dev/null; do sleep 0.5; done
|
2011-07-24 21:54:10 +02:00
|
|
|
if [ $# -gt 0 ]; then
|
2011-09-08 14:12:56 +02:00
|
|
|
|
|
|
|
ID=$(id -ur)
|
|
|
|
if [ $ID != 0 ] ; then
|
|
|
|
echo "This script should be run as root, use sudo next time."
|
|
|
|
echo "Now you can manually run yum install (use sudo again)."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2011-09-03 16:43:22 +02:00
|
|
|
yum install $@
|
2011-07-24 21:54:10 +02:00
|
|
|
elif [ -f /var/lib/qubes/updates/repodata/repomd.xml ]; then
|
2011-09-12 15:04:27 +02:00
|
|
|
# Above file exists only when at least one package was downloaded
|
2011-07-24 21:54:10 +02:00
|
|
|
yum check-update
|
|
|
|
if [ $? -eq 100 ]; then
|
2011-09-12 15:04:27 +02:00
|
|
|
|
|
|
|
ID=$(id -ur)
|
|
|
|
if [ $ID != 0 ] ; then
|
|
|
|
echo "This script should be run as root, use sudo next time."
|
|
|
|
echo "Now you can manually run yum update (use sudo again)."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
yum update
|
2011-07-24 21:54:10 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "No updates avaliable"
|
2011-06-22 00:44:48 +02:00
|
|
|
fi
|