Sunday, September 4, 2022

[SOLVED] DNF fails to synchronize cache when using --installroot option

Issue

I am trying to install a bunch of software in a dummy root, so I can copy it into new systems quickly. However whenever I use dnf install or dnf builddep with the --installroot option it fails to synchronize cache for repositories.

I thought it's missing some configuration, so I copied yum and dnf configuration files into the installroot dir:

cp /etc/dnf/dnf.conf     /path/to/root_fs/etc/dnf
cp /etc/yum.conf         /path/to/root_fs/etc/
cp -R /etc/yum.repos.d/  /path/to/root_fs/etc/

But still what I get is

sudo dnf -c $ROOT_FS_DIR/etc/dnf/dnf.conf install gcc --installroot=$ROOT_FS_DIR -releasever=23
Error: Failed to synchronize cache for repo 'updates'

Dnf works fine updating my host system. So how do I configure dnf to install packages into a different root dir.


Solution

DNF is not so clever and needs a releasever if you installs in chroots (bug). You miss single - in front of that option:

sudo dnf -c $ROOT_FS_DIR/etc/dnf/dnf.conf install gcc \
  --installroot=$ROOT_FS_DIR --releasever=23

but the release 23 is already EOL so the mirrors do not have to exist anymore. You should use supported release version.



Answered By - Jakuje
Answer Checked By - Willingham (WPSolving Volunteer)