Bug 108745 - Multiple --relocate options don't work on RPM installation
Multiple --relocate options don't work on RPM installation
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: rpm (Show other bugs)
2.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-31 16:10 EST by Daniel Berrange
Modified: 2007-11-30 17:06 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-12-26 12:58:23 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2003-10-31 16:10:25 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.9 (X11; Linux i686; U;) Gecko/20030314

Description of problem:
I've got an RPM spec file (see attached) containing two 'Prefix:' tags, (one for
/etc, and another for /usr) in the header. For purposes of bootstrapping an
automated build process I want to install this into a virtual root directory,
using a dedicated package DB too.

Now, the I've build my package & try to install it, using a couple
of --relocate options to translate each of the paths listed in the
'Prefix:' tags, but it failed:

 bash$ rpm -ivh \
           --relocate /etc=$VIRTUAL_ROOT/etc \
           --relocate /usr=$VIRTUAL_ROOT \
           --dbpath $VIRTUAL_ROOT/rpmdb \
           ~dan/rpm/RPMS/noarch/ccm-tools-0.9.0-1.noarch.rpm

   1:ccm-tools              error: unpacking of archive failed on
     file /etc/profile.d/ccm-tools.sh;3fa2a7ce: cpio: open failed -
     Permission denied

This was wierd - because it worked fine with similar spec files only
containing a single 'Prefix:' to be relocated.

For some reason I decided to play around with the order of command
line arguments & found that it would always fail *except* when I
had the '-ivh' in between the two --relocate options:

 bash$ rpm --relocate /etc=$VIRTUAL_ROOT/etc \
           -ivh \
           --relocate /usr=$VIRTUAL_ROOT \
           --dbpath $VIRTUAL_ROOT/rpmdb \
           ~dan/rpm/RPMS/noarch/ccm-tools-0.9.0-1.noarch.rpm

   1:ccm-tools              ########################################### [100%]

Other options such as changing "--dbpath XXX" to --define '_dbpath XXX' gave
even wierder output:

path /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb in package
ccm-devel-2.0.0-1 is not relocateable
path /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb in package
ccm-devel-2.0.0-1 is not relocateable
path /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb in package
ccm-devel-2.0.0-1 is not relocateable



Running both of these commands again with the -vv option, the first
one (which fails) shows:

  D:     0 relocate /usr -> /var/ccm-devel/dev/dan/aplaws-builds/root
  D:     1 relocate /usr -> /var/ccm-devel/dev/dan/aplaws-builds/root

The second (which works) shows:

  D:     0 relocate /etc -> /var/ccm-devel/dev/dan/aplaws-builds/root/etc
  D:     1 relocate /usr -> /var/ccm-devel/dev/dan/aplaws-builds/root

Other combinations of args produced even wierder results:

  bash$ rpm --relocate /etc=$VIRTUAL_ROOT/etc \
            -ivh \
            --relocate /usr=$VIRTUAL_ROOT \
            --define '_dbpath $VIRTUAL_ROOT/rpmdb' \
            ~dan/rpm/RPMS/noarch/ccm-tools-0.9.0-1.noarch.rpm

Produced:

  D:     0 relocate /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb ->
ccm-devel/dev/dan/aplaws-builds/root/rpmdb
  D:     1 relocate /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb ->
ccm-devel/dev/dan/aplaws-builds/root/rpmdb
  D:     2 relocate /var/ccm-devel/dev/dan/aplaws-builds/root/rpmdb ->
ccm-devel/dev/dan/aplaws-builds/root/rpmdb

This suggested a bug in the command line parsing, so I took a look at
the popt/poptI.c file saw that the installArgCallback function does
essentially:

    newPath = strchr(arg, '=');
    *newPath++ = '\0';
    ia->relocations[ia->numRelocations].oldPath = arg;
    ia->relocations[ia->numRelocations].newPath = newPath;

Now the 'arg' parameter is declared 'const char * arg' so,
I changed the last two lines to use 'strdup':

    ia->relocations[ia->numRelocations].oldPath = strdup(arg);
    ia->relocations[ia->numRelocations].newPath = strdup(newPath);

And now, everything works just fine (at least for the simple test cases shown
above).


Version-Release number of selected component (if applicable):
rpm-4.0.4-7x.20

How reproducible:
Sometimes

Steps to Reproduce:
1. Create an RPM spec with files in three different directories, eg /etc, /usr, /var
2. Add 'Prefix:' tags for each directory
3. Build the RPM.
4. Install the RPM using --relocate /foo=/bar for each Prefix tag


Actual Results:  Messages such as 

     file /etc/profile.d/ccm-tools.sh;3fa2a7ce: cpio: open failed -
     Permission denied

For a file that should have been relocated.


Additional info:

http://post-office.corp.redhat.com/archives/tech-list/2003-October/msg00318.html
Comment 1 Jeff Johnson 2003-12-26 12:58:23 EST
Bootstrapping a build tree is far more likely to
work with --root than with --relocate, i.e. use chroot(2),
not changing all the bleeping paths.

WONTFIX because rpm-4.0.4 is end-of-life, what's done is done.

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