Bug 90033 - rpm --rebuilddb --root=somewhere doesn't work
Summary: rpm --rebuilddb --root=somewhere doesn't work
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
(Show other bugs)
Version: 6
Hardware: i386 Linux
Target Milestone: ---
Assignee: Paul Nasrat
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-05-01 13:59 UTC by Michael Young
Modified: 2007-11-30 22:10 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-06-28 12:35:32 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Sample patch (365 bytes, patch)
2003-05-04 12:17 UTC, Michael Young
no flags Details | Diff

Description Michael Young 2003-05-01 13:59:42 UTC
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

Comment 1 Jeff Johnson 2003-05-01 14:54:42 UTC
Sure it doesn't work, as you need the path to the temp dir
location set up in the chroot as well.

Comment 2 Michael Young 2003-05-01 15:13:08 UTC
Sorry, bad example, but it still does the same thing in my testing when --root
points to a complete image of a RedHat system.

Comment 3 Jeff Johnson 2003-05-01 15:38:07 UTC
What are you trying to do? As described, this problem seems
like a candidate for worst abuse of system utilities rather
than something serious ...

Comment 4 Michael Young 2003-05-01 16:41:56 UTC
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.

Comment 5 Jeff Johnson 2003-05-01 17:20:11 UTC
    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.

Comment 6 Jeff Johnson 2003-05-01 17:20:27 UTC
    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.

Comment 7 Michael Young 2003-05-03 16:36:54 UTC
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.

Comment 8 Michael Young 2003-05-04 12:17:24 UTC
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.

Comment 9 Bill Nottingham 2006-08-05 03:37:18 UTC
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

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.

Comment 10 Michael Young 2006-10-10 10:07:59 UTC
Still broken in FC6test3

Comment 11 Jeff Johnson 2007-01-14 13:12:28 UTC
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 ...



Comment 12 Matthew Miller 2007-04-06 16:26:48 UTC
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.]

Comment 13 Panu Matilainen 2007-06-05 12:54:24 UTC
Fixed in rpm.org tree as well

Comment 14 Panu Matilainen 2007-06-28 12:35:32 UTC
Fixed by (rc1) now in rawhide.

Note You need to log in before you can comment on or make changes to this bug.