dom0-updates: improve dnf config handling

Dom0 may not sent /etc/yum.conf but only /etc/dnf/dnf.conf - handle this
case too. Since dom0 use dnf for a long time, prefer dnf.conf.

Not all versions of dnf supports cachedir option, so handle also the
case when it's set by default to /var/cache/dnf (instead of overriden
with /var/cache/yum with yum.conf). Simply look for packages in whole
/var/cache.

QubesOS/qubes-issues#4225
This commit is contained in:
Marek Marczykowski-Górecki 2019-04-01 18:18:22 +02:00
parent 1aeec025e0
commit 10399e8ab3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -5,7 +5,12 @@ DOM0_UPDATES_DIR=/var/lib/qubes/dom0-updates
GUI=1 GUI=1
CLEAN=0 CLEAN=0
CHECK_ONLY=0 CHECK_ONLY=0
OPTS="--installroot $DOM0_UPDATES_DIR --config=$DOM0_UPDATES_DIR/etc/yum.conf" OPTS="--installroot $DOM0_UPDATES_DIR"
if [ -f "$DOM0_UPDATES_DIR/etc/dnf/dnf.conf" ]; then
OPTS="$OPTS --config=$DOM0_UPDATES_DIR/etc/yum.conf"
elif [ -f "$DOM0_UPDATES_DIR/etc/yum.conf" ]; then
OPTS="$OPTS --config=$DOM0_UPDATES_DIR/etc/yum.conf"
fi
# DNF uses /etc/yum.repos.d, even when --installroot is specified # DNF uses /etc/yum.repos.d, even when --installroot is specified
OPTS="$OPTS --setopt=reposdir=$DOM0_UPDATES_DIR/etc/yum.repos.d" OPTS="$OPTS --setopt=reposdir=$DOM0_UPDATES_DIR/etc/yum.repos.d"
PKGLIST= PKGLIST=
@ -159,7 +164,7 @@ else
$YUM_COMMAND $OPTS $PKGLIST $YUM_COMMAND $OPTS $PKGLIST
fi fi
find "$DOM0_UPDATES_DIR/var/cache/yum" -name '*.rpm' -print0 |\ find "$DOM0_UPDATES_DIR/var/cache" -name '*.rpm' -print0 |\
xargs -0 -r ln -f -t "$DOM0_UPDATES_DIR/packages/" xargs -0 -r ln -f -t "$DOM0_UPDATES_DIR/packages/"
if ls "$DOM0_UPDATES_DIR"/packages/*.rpm > /dev/null 2>&1; then if ls "$DOM0_UPDATES_DIR"/packages/*.rpm > /dev/null 2>&1; then