From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 Description of problem: If I try to rebuild a database away from the standard location, I get an immediate error as in the following example # cp -pr /var/lib/rpm /tmp/test/var/lib/ # rpm --rebuilddb --root=/tmp/test error: temporary database /tmp/test/var/lib/rpm already exists Running rpm --rebuilddb works (with the expected unimportant db4 error). Presumably whatever sets the temporary database location doesn't quite work with --root.
Sure it doesn't work, as you need the path to the temp dir location set up in the chroot as well.
Sorry, bad example, but it still does the same thing in my testing when --root points to a complete image of a RedHat system.
What are you trying to do? As described, this problem seems like a candidate for worst abuse of system utilities rather than something serious ...
Actually, I was just testing some rpm commands on a safe copy of the database rather than the live one (in particular I was checking someones claim that rpm --initdb doesn't overwrite an existing database, contrary to what I previously believed). However, I believe the --rebuilddb problem I spotted is more general, and would apply to any situation where you need to work on a chrooted system, including patching a problem system from a rescue disk, where using a literal chroot might not work.
Try rpm --rebuilddb --dbpath /path/to/root/var/lib/rpm FWIW, chroot(2) has many problems, not the least of which is that it is a root-only command.
Try rpm --rebuilddb --dbpath /path/to/root/var/lib/rpm FWIW, chroot(2) has many problems, not the least of which is that it is a root-only syscall.
I agree the --dbpath option works and is functionally equivalent, but I still think the rpmdbRebuild function is broken with prefixes, which seems to be because it is stripping off one too many characters from the dbpath variable (setting the macro %_dbpath_rebuild to var/lib/rpm allows --root=something to work), though I haven't worked out why yet.
Created attachment 91492 [details] Sample patch The problem is that the prefix variable has acquired a trailing / from somewhere by the time it gets to the rpmdbRebuild, hence the code that tries to strip off the prefix takes off too many characters. The simplest fix is to use rpmGetPath to normalize prefix somewhere early in the rpmdbRebuild function, eg. as in the attached patch (created from 4.2-1 from the ftp.rpm.org site), which also avoids problems for most weird values of --root.
Red Hat apologizes that these issues have not been resolved yet. We do want to make sure that no important bugs slip through the cracks. Red Hat Linux 7.3 and Red Hat Linux 9 are no longer supported by Red Hat, Inc. They are maintained by the Fedora Legacy project (http://www.fedoralegacy.org/) for security updates only. If this is a security issue, please reassign to the 'Fedora Legacy' product in bugzilla. Please note that Legacy security update support for these products will stop on December 31st, 2006. If this is not a security issue, please check if this issue is still present in a current Fedora Core release. If so, please change the product and version to match, and check the box indicating that the requested information has been provided. If you are currently still running Red Hat Linux 7.3 or 9, please note that Fedora Legacy security update support for these products will stop on December 31st, 2006. You are strongly advised to upgrade to a current Fedora Core release or Red Hat Enterprise Linux or comparable. Some information on which option may be right for you is available at http://www.redhat.com/rhel/migrate/redhatlinux/. Any bug still open against Red Hat Linux 7.3 or 9 at the end of 2006 will be closed 'CANTFIX'. Again, if this bug still exists in a current release, or is a security issue, please change the product as necessary. We thank you for your help, and apologize again that we haven't handled these issues to this point.
Still broken in FC6test3
The patch is added in rpm cvs, will be in rpm-4.4.8-0.10 when built. Note that I still think that the command rpm --rebuilddb --root /chroot --define '_dbpath_rebuild /rebuild' is semantically meaningless and woefully obscure. The "official" command is rpm --rebuilddb --dbpath /chroot which "works" just fine. But the patch hurts nothing ... UPSTREAM UPSTREAM
Fedora Core 5 and Fedora Core 6 are, as we're sure you've noticed, no longer test releases. We're cleaning up the bug database and making sure important bug reports filed against these test releases don't get lost. It would be helpful if you could test this issue with a released version of Fedora or with the latest development / test release. Thanks for your help and for your patience. [This is a bulk message for all open FC5/FC6 test release bugs. I'm adding myself to the CC list for each bug, so I'll see any comments you make after this and do my best to make sure every issue gets proper attention.]
Fixed in rpm.org tree as well
Fixed by 4.4.2.1 (rc1) now in rawhide.