dom0-updates: use dnf when available

Since yum-deprecated is slowly removed from Fedora (in Fedora 23 is not
installed by default), we're forced to migrate to dnf. The main problem
with dnf here is lack of --downloaddir option
(https://bugzilla.redhat.com/show_bug.cgi?id=1279001). As nobody is
going to implement it, simply extract downloaded packages from cache
directory (thanks to provided config file, it is always /var/cache/yum).

This basically replaces "dom0-updates: use yum-deprecated instead of dnf
in all calls" with a set of workarounds for dnf missing parts.

Related to QubesOS/qubes-issues#1574
This commit is contained in:
Marek Marczykowski-Górecki 2016-06-01 04:40:56 +02:00
parent 3db93cdc87
commit 07c442f534
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -7,6 +7,8 @@ GUI=1
CLEAN=0
CHECK_ONLY=0
OPTS="--installroot $DOM0_UPDATES_DIR --config=$DOM0_UPDATES_DIR/etc/yum.conf"
# DNF uses /etc/yum.repos.d, even when --installroot is specified
OPTS="$OPTS --setopt=reposdir=$DOM0_UPDATES_DIR/etc/yum.repos.d"
PKGLIST=
YUM_ACTION=
@ -50,11 +52,8 @@ if [ -z "$YUM_ACTION" ]; then
fi
YUM="yum"
# prefer yum-deprecated over dnf, because of still missing features in dnf (at least --downloaddir)
if type dnf >/dev/null 2>&1 && type yum-deprecated >/dev/null 2>&1; then
echo "(Note: dnf will complain that the yum command has been deprecated." >&2
echo "This message is safe to ignore.)" >&2
YUM="yum-deprecated"
if type dnf >/dev/null 2>&1; then
YUM="dnf"
fi
if ! [ -d "$DOM0_UPDATES_DIR" ]; then
@ -78,6 +77,7 @@ rpm --root=$DOM0_UPDATES_DIR --rebuilddb
if [ "$CLEAN" = "1" ]; then
$YUM $OPTS clean all
rm -f $DOM0_UPDATES_DIR/packages/*
rm -f $DOM0_UPDATES_DIR/var/cache/yum/*
fi
if [ "x$PKGLIST" = "x" ]; then
@ -119,7 +119,7 @@ if [ "$DOIT" != "1" -a "$PKGS_FROM_CMDLINE" != "1" ]; then
--text="There are updates for dom0 available, do you want to download them now?" || exit 0
fi
YUM_COMMAND="fakeroot $YUM $YUM_ACTION -y --downloadonly --downloaddir=$DOM0_UPDATES_DIR/packages"
YUM_COMMAND="fakeroot $YUM $YUM_ACTION -y --downloadonly"
# check for --downloadonly option - if not supported (Debian), fallback to
# yumdownloader
if ! $YUM --help | grep -q downloadonly; then
@ -150,6 +150,9 @@ else
$YUM_COMMAND $OPTS $PKGLIST
fi
find $DOM0_UPDATES_DIR/var/cache/yum -name '*.rpm' -print0 |\
xargs -0 -r ln -f -t $DOM0_UPDATES_DIR/packages/
if ls $DOM0_UPDATES_DIR/packages/*.rpm > /dev/null 2>&1; then
cmd="/usr/lib/qubes/qrexec-client-vm dom0 qubes.ReceiveUpdates /usr/lib/qubes/qfile-agent"
qrexec_exit_code=0