Bug 90033 - rpm --rebuilddb --root=somewhere doesn't work
rpm --rebuilddb --root=somewhere doesn't work
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
6
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Paul Nasrat
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-01 09:59 EDT by Michael Young
Modified: 2007-11-30 17:10 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-06-28 08:35:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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 08:17 EDT, Michael Young
no flags Details | Diff

  None (edit)
Description Michael Young 2003-05-01 09:59:42 EDT
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.
Comment 1 Jeff Johnson 2003-05-01 10:54:42 EDT
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 11:13:08 EDT
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 11:38:07 EDT
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 12:41:56 EDT
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 13:20:11 EDT
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.
Comment 6 Jeff Johnson 2003-05-01 13:20:27 EDT
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.
Comment 7 Michael Young 2003-05-03 12:36:54 EDT
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 08:17:24 EDT
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-04 23:37:18 EDT
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.
Comment 10 Michael Young 2006-10-10 06:07:59 EDT
Still broken in FC6test3
Comment 11 Jeff Johnson 2007-01-14 08:12:28 EST
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
Comment 12 Matthew Miller 2007-04-06 12:26:48 EDT
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 08:54:24 EDT
Fixed in rpm.org tree as well
Comment 14 Panu Matilainen 2007-06-28 08:35:32 EDT
Fixed by 4.4.2.1 (rc1) now in rawhide.

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