Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: After first use dnf with installroot - no show list installed #2022

Open
generationext opened this issue Nov 29, 2023 · 7 comments
Open

Comments

@generationext
Copy link

In my case:
On Debian trixie, i build a minimal Oracle Linux 9 distribution in a container.

  dnf install oraclelinux-release-el9 dnf \
  --releasever=9 --nodocs -4 --assumeyes \
  --installroot=/var/lib/machines/oel9.home.lab \
  --setopt=install_weak_deps=False --nogpgcheck  \
  --setopt=module_platform_id=platform:el9 \
  --repofrompath=ol9_baseos_latest,"https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64"

After dnf install completed, i run

systemd-nspawn -D /var/lib/machines/oel9.home.lab dnf --releasever=9 list installed

dnf not show list of installed packages.

I need again re-install my installed packages.

  systemd-nspawn -D /var/lib/machines/oel9.home.lab \
  dnf install --assumeyes --releasever=9 \
  --setopt=ol9_appstream.module_hotfixes=true --allowerasing  \
  oraclelinux-release-el9 dnf systemd systemd-udev ....

When it is done, dnf will show the list of installed packages.

Is it possible to avoid this?

@jan-kolarik
Copy link
Member

Hi, at first glance, I don't see a reason why dnf shouldn't display the installed packages.

After dnf install completed, i run

At this point, could you try running dnf list installed --releasever=9 --installroot=/var/lib/machines/oel9.home.lab? Alternatively, you can chroot into /var/lib/machines/oel9.home.lab and run dnf list installed there. I tested a similar use case locally (with different packages), and these commands worked correctly for me.

@generationext
Copy link
Author

Could you test it out, here's an case ?

# Create container
dnf install                                    \
--releasever=9 --nodocs -4 --assumeyes         \
--installroot=/var/lib/machines/oel9.home.lab  \
--setopt=install_weak_deps=False --nogpgcheck  \
--setopt=module_platform_id=platform:el9       \
--repofrompath=ol9_baseos_latest,"https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64" \
oraclelinux-release-el9 systemd systemd-udev systemd-container initscripts \
openssl passwd glibc-langpack-en dnf iproute iputils net-tools tree nano \
lsof hostname unzip tzdata basesystem ca-certificates tar file \
filesystem less

# Set password for root
systemd-nspawn -D /var/lib/machines/oel9.home.lab passwd

# Boot container
systemd-nspawn -b -D /var/lib/machines/oel9.home.lab

# Login and run
dnf list installed --releasever=9

In fresh created container, dnf - not listed installed packages

@jan-kolarik
Copy link
Member

Could you test it out, here's an case ?

# Create container
dnf install                                    \
--releasever=9 --nodocs -4 --assumeyes         \
--installroot=/var/lib/machines/oel9.home.lab  \
--setopt=install_weak_deps=False --nogpgcheck  \
--setopt=module_platform_id=platform:el9       \
--repofrompath=ol9_baseos_latest,"https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64" \
oraclelinux-release-el9 systemd systemd-udev systemd-container initscripts \
openssl passwd glibc-langpack-en dnf iproute iputils net-tools tree nano \
lsof hostname unzip tzdata basesystem ca-certificates tar file \
filesystem less

# Set password for root
systemd-nspawn -D /var/lib/machines/oel9.home.lab passwd

# Boot container
systemd-nspawn -b -D /var/lib/machines/oel9.home.lab

# Login and run
dnf list installed --releasever=9

In fresh created container, dnf - not listed installed packages

I've tried to replicate the issue in the Fedora Rawhide VM as the host system. I've needed to add a cracklib-dicts package to setup the password later. I've also changed the installroot directory, but everything else was kept. The installed packages are listed there:

[root@test ~]# dnf list installed --releasever=9
Installed Packages
alternatives.x86_64                        1.25-1.fc39                      @rawhide
audit-libs.x86_64                          3.1.2-5.fc40                     @rawhide
authselect.x86_64                          1.4.3-1.fc40                     @rawhide
authselect-libs.x86_64                     1.4.3-1.fc40                     @rawhide
basesystem.noarch                          11-18.fc39                       @rawhide
bash.x86_64                                5.2.21-2.fc40                    @rawhide
bzip2-libs.x86_64                          1.0.8-16.fc39                    @rawhide
ca-certificates.noarch                     2023.2.62_v7.0.401-4.fc40        @rawhide
chkconfig.x86_64                           1.25-1.fc39                      @rawhide
coreutils.x86_64                           9.4-1.fc40                       @rawhide
coreutils-common.x86_64                    9.4-1.fc40                       @rawhide
cracklib.x86_64                            2.9.11-2.fc39                    @rawhide
cracklib-dicts.x86_64                      2.9.11-2.fc39                    @rawhide
crypto-policies.noarch                     20231204-1.git1e3a2e4.fc40       @rawhide
cryptsetup-libs.x86_64                     2.7.0~rc0-1.fc40                 @rawhide
curl.x86_64                                8.4.0-1.fc40                     @rawhide
cyrus-sasl-lib.x86_64                      2.1.28-11.fc39                   @rawhide
dbus.x86_64                                1:1.14.10-1.fc40                 @rawhide
dbus-broker.x86_64                         33-2.fc39                        @rawhide
dbus-common.noarch                         1:1.14.10-1.fc40                 @rawhide
device-mapper.x86_64                       9:1.02.195-3.el9                 @ol9_baseos_latest
device-mapper-libs.x86_64                  9:1.02.195-3.el9                 @ol9_baseos_latest
dnf.noarch                                 4.18.1-2.fc40                    @rawhide
dnf-data.noarch                            4.18.1-2.fc40                    @rawhide
elfutils-default-yama-scope.noarch         0.190-4.fc40                     @rawhide
elfutils-libelf.x86_64                     0.190-4.fc40                     @rawhide
elfutils-libs.x86_64                       0.190-4.fc40                     @rawhide
expat.x86_64                               2.5.0-3.fc39                     @rawhide
fedora-gpg-keys.noarch                     40-0.2                           @rawhide
fedora-release-budgie.noarch               40-0.20                          @rawhide
fedora-release-common.noarch               40-0.20                          @rawhide
fedora-release-identity-budgie.noarch      40-0.20                          @rawhide
fedora-repos.noarch                        40-0.2                           @rawhide
fedora-repos-rawhide.noarch                40-0.2                           @rawhide
file.x86_64                                5.45-1.fc40                      @rawhide
file-libs.x86_64                           5.45-1.fc40                      @rawhide
filesystem.x86_64                          3.18-6.fc39                      @rawhide
findutils.x86_64                           1:4.9.0-6.fc40                   @rawhide
gawk.x86_64                                5.2.2-2.fc39                     @rawhide
gdbm.x86_64                                1:1.23-4.fc39                    @rawhide
gdbm-libs.x86_64                           1:1.23-4.fc39                    @rawhide
glib2.x86_64                               2.78.1-1.fc40                    @rawhide
glibc.x86_64                               2.38.9000-26.fc40                @rawhide
glibc-common.x86_64                        2.38.9000-26.fc40                @rawhide
glibc-langpack-en.x86_64                   2.38.9000-26.fc40                @rawhide
gmp.x86_64                                 1:6.2.1-5.fc39                   @rawhide
gnupg2.x86_64                              2.4.3-4.fc40                     @rawhide
gnutls.x86_64                              3.8.2-2.fc40                     @rawhide
grep.x86_64                                3.11-5.fc40                      @rawhide
gzip.x86_64                                1.12-6.fc39                      @rawhide
hostname.x86_64                            3.23-10.fc40                     @rawhide
ima-evm-utils.x86_64                       1.5-2.fc39                       @rawhide
initscripts.x86_64                         10.19-2.fc39                     @rawhide
initscripts-rename-device.x86_64           10.19-2.fc39                     @rawhide
initscripts-service.noarch                 10.19-2.fc39                     @rawhide
iproute.x86_64                             6.5.0-1.fc40                     @rawhide
iputils.x86_64                             20221126-4.fc39                  @rawhide
json-c.x86_64                              0.17-1.fc40                      @rawhide
kbd.x86_64                                 2.6.3-1.fc40                     @rawhide
kbd-legacy.noarch                          2.6.3-1.fc40                     @rawhide
kbd-misc.noarch                            2.6.3-1.fc40                     @rawhide
keyutils-libs.x86_64                       1.6.3-1.el9                      @ol9_baseos_latest
kmod.x86_64                                31-3.fc40                        @rawhide
kmod-libs.x86_64                           31-3.fc40                        @rawhide
krb5-libs.x86_64                           1.21.2-2.fc40                    @rawhide
less.x86_64                                643-1.fc40                       @rawhide
libacl.x86_64                              2.3.1-11.fc40                    @rawhide
libarchive.x86_64                          3.7.2-1.fc40                     @rawhide
libargon2.x86_64                           20190702-3.fc39                  @rawhide
libassuan.x86_64                           2.5.6-2.fc39                     @rawhide
libattr.x86_64                             2.5.1-9.fc40                     @rawhide
libb2.x86_64                               0.98.1-9.fc39                    @rawhide
libblkid.x86_64                            2.39.2-1.fc40                    @rawhide
libbpf.x86_64                              2:1.2.0-1.fc40                   @rawhide
libcap.x86_64                              2.69-1.fc40                      @rawhide
libcap-ng.x86_64                           0.8.3-8.fc40                     @rawhide
libcom_err.x86_64                          1.47.0-2.fc39                    @rawhide
libcomps.x86_64                            0.1.20-1.fc40                    @rawhide
libcurl-minimal.x86_64                     8.4.0-1.fc40                     @rawhide
libdb.x86_64                               5.3.28-58.fc40                   @rawhide
libdnf.x86_64                              0.72.0-1.fc40                    @rawhide
libeconf.x86_64                            0.5.2-1.fc40                     @rawhide
libevent.x86_64                            2.1.12-9.fc39                    @rawhide
libfdisk.x86_64                            2.39.2-1.fc40                    @rawhide
libffi.x86_64                              3.4.4-4.fc39                     @rawhide
libfsverity.x86_64                         1.4-10.fc39                      @rawhide
libgcc.x86_64                              13.2.1-5.fc40                    @rawhide
libgcrypt.x86_64                           1.10.3-1.fc40                    @rawhide
libgomp.x86_64                             13.2.1-5.fc40                    @rawhide
libgpg-error.x86_64                        1.47-2.fc39                      @rawhide
libidn2.x86_64                             2.3.4-3.fc39                     @rawhide
libksba.x86_64                             1.6.5-1.fc40                     @rawhide
libmnl.x86_64                              1.0.5-3.fc39                     @rawhide
libmodulemd.x86_64                         2.15.0-5.fc39                    @rawhide
libmount.x86_64                            2.39.2-1.fc40                    @rawhide
libnghttp2.x86_64                          1.58.0-1.fc40                    @rawhide
libnsl2.x86_64                             2.0.0-6.fc39                     @rawhide
libpwquality.x86_64                        1.4.5-6.fc39                     @rawhide
librepo.x86_64                             1.17.0-1.fc40                    @rawhide
libreport-filesystem.noarch                2.17.11-3.fc39                   @rawhide
libseccomp.x86_64                          2.5.3-6.fc39                     @rawhide
libselinux.x86_64                          3.6-0.rc2.1.fc40                 @rawhide
libsemanage.x86_64                         3.6-0.rc2.1.fc40                 @rawhide
libsepol.x86_64                            3.6-0.rc2.1.fc40                 @rawhide
libsigsegv.x86_64                          2.14-5.fc39                      @rawhide
libsmartcols.x86_64                        2.39.2-1.fc40                    @rawhide
libsolv.x86_64                             0.7.27-1.fc40                    @rawhide
libstdc++.x86_64                           13.2.1-5.fc40                    @rawhide
libtasn1.x86_64                            4.19.0-3.fc39                    @rawhide
libtirpc.x86_64                            1.3.4-0.fc40                     @rawhide
libunistring.x86_64                        1.1-5.fc40                       @rawhide
libuser.x86_64                             0.64-5.fc40                      @rawhide
libutempter.x86_64                         1.2.1-10.fc39                    @rawhide
libuuid.x86_64                             2.39.2-1.fc40                    @rawhide
libverto.x86_64                            0.3.2-6.fc39                     @rawhide
libxcrypt.x86_64                           4.4.36-2.fc39                    @rawhide
libxml2.x86_64                             2.12.1-1.fc40                    @rawhide
libyaml.x86_64                             0.2.5-12.fc39                    @rawhide
libzstd.x86_64                             1.5.5-4.fc39                     @rawhide
lsof.x86_64                                4.98.0-2.fc40                    @rawhide
lua-libs.x86_64                            5.4.6-3.fc39                     @rawhide
lz4-libs.x86_64                            1.9.4-4.fc39                     @rawhide
mpdecimal.x86_64                           2.5.1-7.fc39                     @rawhide
mpfr.x86_64                                4.2.1-1.fc40                     @rawhide
nano.x86_64                                7.2-4.fc39                       @rawhide
ncurses-base.noarch                        6.4-8.20231001.fc40              @rawhide
ncurses-libs.x86_64                        6.4-8.20231001.fc40              @rawhide
net-tools.x86_64                           2.0-0.67.20160912git.fc39        @rawhide
nettle.x86_64                              3.9.1-2.fc39                     @rawhide
npth.x86_64                                1.6-14.fc39                      @rawhide
openldap.x86_64                            2.6.6-1.fc39                     @rawhide
openssl.x86_64                             1:3.1.4-1.fc40                   @rawhide
openssl-libs.x86_64                        1:3.1.4-1.fc40                   @rawhide
oraclelinux-release-el9.x86_64             1.0-12.el9                       @ol9_baseos_latest
p11-kit.x86_64                             0.25.3-1.fc40                    @rawhide
p11-kit-trust.x86_64                       0.25.3-1.fc40                    @rawhide
pam.x86_64                                 1.5.3-8.fc40                     @rawhide
pam-libs.x86_64                            1.5.3-8.fc40                     @rawhide
passwd.x86_64                              0.80-15.fc39                     @rawhide
pcre2.x86_64                               10.42-2.fc40                     @rawhide
pcre2-syntax.noarch                        10.42-2.fc40                     @rawhide
popt.x86_64                                1.19-3.fc39                      @rawhide
procps-ng.x86_64                           4.0.4-1.fc40                     @rawhide
psmisc.x86_64                              23.6-4.fc39                      @rawhide
python-pip-wheel.noarch                    23.2.1-1.fc39                    @rawhide
python3.x86_64                             3.12.0-2.fc40                    @rawhide
python3-dnf.noarch                         4.18.1-2.fc40                    @rawhide
python3-hawkey.x86_64                      0.72.0-1.fc40                    @rawhide
python3-libcomps.x86_64                    0.1.20-1.fc40                    @rawhide
python3-libdnf.x86_64                      0.72.0-1.fc40                    @rawhide
python3-libs.x86_64                        3.12.0-2.fc40                    @rawhide
python3-rpm.x86_64                         4.19.0-3.fc40                    @rawhide
readline.x86_64                            8.2-4.fc39                       @rawhide
rpm.x86_64                                 4.19.0-3.fc40                    @rawhide
rpm-build-libs.x86_64                      4.19.0-3.fc40                    @rawhide
rpm-libs.x86_64                            4.19.0-3.fc40                    @rawhide
rpm-sequoia.x86_64                         1.5.0-2.fc40                     @rawhide
rpm-sign-libs.x86_64                       4.19.0-3.fc40                    @rawhide
sed.x86_64                                 4.8-14.fc39                      @rawhide
setup.noarch                               2.14.5-1.fc40                    @rawhide
shadow-utils.x86_64                        2:4.14.0-2.fc40                  @rawhide
sqlite-libs.x86_64                         3.44.1-1.fc40                    @rawhide
systemd.x86_64                             255~rc4-3.fc40                   @rawhide
systemd-container.x86_64                   255~rc4-3.fc40                   @rawhide
systemd-libs.x86_64                        255~rc4-3.fc40                   @rawhide
systemd-pam.x86_64                         255~rc4-3.fc40                   @rawhide
systemd-udev.x86_64                        255~rc4-3.fc40                   @rawhide
tar.x86_64                                 2:1.35-2.fc40                    @rawhide
tpm2-tss.x86_64                            4.0.1-6.fc40                     @rawhide
tree.x86_64                                2.1.0-4.fc39                     @rawhide
tzdata.noarch                              2023c-4.fc40                     @rawhide
unzip.x86_64                               6.0-62.fc39                      @rawhide
util-linux.x86_64                          2.39.2-1.fc40                    @rawhide
util-linux-core.x86_64                     2.39.2-1.fc40                    @rawhide
xz-libs.x86_64                             5.4.5-1.fc40                     @rawhide
zchunk-libs.x86_64                         1.3.2-1.fc40                     @rawhide
zlib.x86_64                                1.2.13-5.fc40                    @rawhide

@generationext
Copy link
Author

Perhaps one of us is doing something wrong.

For the sake of the experiment, let's take a third-party image from https://hub.nspawn.org/images/.

So, let's try it:

# Import keys
gpg --no-default-keyring \
       --keyring=/etc/systemd/import-pubring.gpg \
       --fingerprint

gpg --no-default-keyring \
       --keyserver=keys.openpgp.org \
       --keyring=/etc/systemd/import-pubring.gpg \
       --search 9E31BD4963FC2D19815FA7180E2A1E4B25A425F6

# Import the image
machinectl pull-tar https://hub.nspawn.org/storage/debian/sid/tar/image.tar.xz debsid.home.lab

# set root password
systemd-nspawn -D /var/lib/machines/debsid.home.lab passwd

# start our container
systemd-nspawn --resolv-conf=bind-host -b -D /var/lib/machines/debsid.home.lab

# Install the necessary packages in the freshly created container
apt update && apt install -y dnf systemd-container

# Let's install Fedora 40
# Create the necessary folder
mkdir -p /var/lib/machines/f40.home.lab/

# fix invocation environment
cd /
for i in proc sys dev; do mkdir /var/lib/machines/f40.home.lab/$i;done
for i in proc sys dev; do mount -o bind $i /var/lib/machines/f40.home.lab/$i; done

dnf install passwd dnf fedora-release util-linux systemd \
  --installroot=/var/lib/machines/f40.home.lab    \
  --nogpgcheck --releasever=40  \
  --setopt=install_weak_deps=False  \
  --assumeyes -4 --nodocs --forcearch=x86_64        \
  --repofrompath=fedora40,"https://ask4.mm.fcix.net/fedora/linux/development/rawhide/Everything/x86_64/os/"

#
for i in proc sys dev; do umount /var/lib/machines/f40.home.lab/$i; done

# Try to get a list of installed packages
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf list --installed --releasever=40
#
chroot /var/lib/machines/f40.home.lab

dnf list --installed --releasever=40

I don't see any installed packages ...

I have to reinstall all the packages, only then I get a list of installed packages

# Again install
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf install --releasever=40 -y passwd dnf fedora-release util-linux systemd

# Returns a list of installed packages
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf list --installed --releasever=40

@jan-kolarik
Copy link
Member

Perhaps one of us is doing something wrong.

For the sake of the experiment, let's take a third-party image from https://hub.nspawn.org/images/.

So, let's try it:

# Import keys
gpg --no-default-keyring \
       --keyring=/etc/systemd/import-pubring.gpg \
       --fingerprint

gpg --no-default-keyring \
       --keyserver=keys.openpgp.org \
       --keyring=/etc/systemd/import-pubring.gpg \
       --search 9E31BD4963FC2D19815FA7180E2A1E4B25A425F6

# Import the image
machinectl pull-tar https://hub.nspawn.org/storage/debian/sid/tar/image.tar.xz debsid.home.lab

# set root password
systemd-nspawn -D /var/lib/machines/debsid.home.lab passwd

# start our container
systemd-nspawn --resolv-conf=bind-host -b -D /var/lib/machines/debsid.home.lab

# Install the necessary packages in the freshly created container
apt update && apt install -y dnf systemd-container

# Let's install Fedora 40
# Create the necessary folder
mkdir -p /var/lib/machines/f40.home.lab/

# fix invocation environment
cd /
for i in proc sys dev; do mkdir /var/lib/machines/f40.home.lab/$i;done
for i in proc sys dev; do mount -o bind $i /var/lib/machines/f40.home.lab/$i; done

dnf install passwd dnf fedora-release util-linux systemd \
  --installroot=/var/lib/machines/f40.home.lab    \
  --nogpgcheck --releasever=40  \
  --setopt=install_weak_deps=False  \
  --assumeyes -4 --nodocs --forcearch=x86_64        \
  --repofrompath=fedora40,"https://ask4.mm.fcix.net/fedora/linux/development/rawhide/Everything/x86_64/os/"

#
for i in proc sys dev; do umount /var/lib/machines/f40.home.lab/$i; done

# Try to get a list of installed packages
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf list --installed --releasever=40
#
chroot /var/lib/machines/f40.home.lab

dnf list --installed --releasever=40

I don't see any installed packages ...

I have to reinstall all the packages, only then I get a list of installed packages

# Again install
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf install --releasever=40 -y passwd dnf fedora-release util-linux systemd

# Returns a list of installed packages
systemd-nspawn -D /var/lib/machines/f40.home.lab dnf list --installed --releasever=40

Sorry, but this is too complex for testing. We need a simple reproducer to analyse the potential issue. In the first OL9 example, have you tried running the list --installed --installroot=... immediately after creating the installroot as I've suggested? Or doing a chroot into the installroot and running it from there? Because this was working for me. It could also be some issue in the host environment...

@ver4a
Copy link

ver4a commented Oct 25, 2024

I just ran into this issue. (I'll assume the root cause is the same)

The problem is that host's dnf/dnf5 uses a different path to rpmdb than the container. For example on Fedora Kinoite 40 where I ran into it has rpmdb in /usr/share/rpm instead of /var/lib/rpm and that's where dnf/dnf5 with --installroot writes the rpmdb (in the installroot of course). This is why host's dnf/rpm and container's see a different database or lack thereof. The container's dnf/rpm expect a different dbpath.

Simply running "find <path_to_installroot> -name rpmdb.sqlite" should give you the path host's dnf used. Then you can simply cp the rpmdb files into /var/lib/rpm. (I haven't yet figured out if there is a parameter to dnf/dnf5 to change the dbpath)

@tobias-urdin
Copy link

I just ran into this issue. (I'll assume the root cause is the same)

The problem is that host's dnf/dnf5 uses a different path to rpmdb than the container. For example on Fedora Kinoite 40 where I ran into it has rpmdb in /usr/share/rpm instead of /var/lib/rpm and that's where dnf/dnf5 with --installroot writes the rpmdb (in the installroot of course). This is why host's dnf/rpm and container's see a different database or lack thereof. The container's dnf/rpm expect a different dbpath.

Simply running "find <path_to_installroot> -name rpmdb.sqlite" should give you the path host's dnf used. Then you can simply cp the rpmdb files into /var/lib/rpm. (I haven't yet figured out if there is a parameter to dnf/dnf5 to change the dbpath)

Thanks! I was at the same problem for some hours until this solved it.

In my case it was placed in /root/.rpmdb/rpmdb.sqlite due to dnf running on Ubuntu, then just mv root/.rpmdb/rpmdb.sqlite /var/lib/rpm/ and everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants