[Bug 395177] Re: rpm/poldek --root is broken

Elan Ruusamäe glen at delfi.ee
Fri Oct 16 01:24:50 CEST 2009


This patch is a brutally simple solution to
illustrate the logic needed in Open(2) to
solve the
        chroot /root/temp rpm -q foo
issue.

Index: rpmrpc.c
===================================================================
RCS file: /v/rpm/cvs/rpm/rpmio/rpmrpc.c,v
retrieving revision 2.93
diff -p -u -w -r2.93 rpmrpc.c
--- rpmrpc.c        4 Oct 2009 22:47:42 -0000        2.93
+++ rpmrpc.c        15 Oct 2009 21:53:37 -0000
@@ -249,6 +249,12 @@ int Open(const char * path, int flags, m
         mode = 0644;
 #endif
     fdno = open(path, flags, mode);
+    /* XXX if the open(2) fails, try to strip a possible chroot(2) prefix. */
+    if (fdno < 0) {
+        const char * fn = strstr(path, "/var/lib/rpm/");
+        if (fn)
+            fdno = open(fn, flags, mode);
+    }
     if (fdno >= 0) {
         if (fcntl(fdno, F_SETFD, FD_CLOEXEC) < 0) {
             (void) close(fdno);

-- 
rpm/poldek --root is broken
https://bugs.launchpad.net/bugs/395177
You received this bug notification because you are subscribed to PLD
Linux.

Status in PLD Linux Distribution: New

Bug description:
Simply reproducer:

# rm -rf /root/test
# mkdir /root/test
# rpm --init-rpm-dir --root /root/test
# poldek -r /root/test
# poldek> install pdksh
...
# rpm -qa
... (correct list of packages)
But inside chroot:
# chroot /root/test
# rpm -qa
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm

Workaround is to link create symlink inside chroot:
# ln -s / /root/test

The same bug occurs when creating database with poldek --install-dist instead of rpm --init-rpm-dir

So rpm for some reason expects rpm database in wrong location (/root/test/var/lib/rpm).
Is it related to https://bugs.launchpad.net/pld-linux/+bug/347749 ?

Tested on th/x86_64 (without ready/test)

Packages inside chroot:
[root at beach /]# rpm -qa | grep rpm
rpm-whiteout-1.26-1.noarch
rpm-base-4.5-22.x86_64
rpm-lib-4.5-22.x86_64
rpm-4.5-22.x86_64
rpm-utils-4.5-22.x86_64

Packages outside chroot:
[root at beach /]# [root at beach ~]# rpm -qa | grep rpm
rpm-4.5-22.x86_64
rpm-javaprov-4.5-22.x86_64
rpm-base-4.5-22.x86_64
rpmlist-1.5-1.noarch
rpm-build-4.5-22.x86_64
rpm-php-pearprov-4.5-22.x86_64
rpmorphan-1.4-1.noarch
rpm-build-macros-1.520-2.noarch
rpm-specdump-0.3-6.x86_64
rpm-utils-4.5-22.x86_64
rpm-build-tools-4.4.35-1.noarch
rpm-perlprov-4.5-22.x86_64
rpm-whiteout-1.26-1.noarch
rpm-lib-4.5-22.x86_64
python-rpm-4.5-22.x86_64
rpm-devel-4.5-22.x86_64
rpm-utils-perl-4.5-22.x86_64
rpm-apidocs-4.5-22.x86_64
[root at beach ~]# rpm -qa | grep poldek
poldek-libs-0.30-0.20080820.23.25.x86_64
python-poldek-0.30-0.20080820.23.25.x86_64
poldek-0.30-0.20080820.23.25.x86_64


More information about the pld-bugs mailing list