Bug 828784

Summary: rpm --relocate not working as expected
Product: Red Hat Enterprise Linux 7 Reporter: Patrik Kis <pkis>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED CURRENTRELEASE QA Contact: Patrik Kis <pkis>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: rvokal
Target Milestone: rcKeywords: Regression, Upstream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: rpm-4.10.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 09:26:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Patrik Kis 2012-06-05 11:34:24 UTC
Description of problem:
rpm -ivh --badreloc --relocate '/usr/bin=/tmp/tmp.gVVF7ufa4M/bin' --relocate '/usr/share=/tmp/tmp.gVVF7ufa4M/share' relocatable-package*.rpm
does not install the pkg and return error

Version-Release number of selected component (if applicable):
rpm-4.9.1.3-7.el7.x86_64

How reproducible:
always

Steps to Reproduce:

1. Build the following spec file
Name:           relocatable-package
Version:        1.0
Release:        1
Summary:        This package is a relocatable-package
Group:          test
License:        test
URL:            none
#Source0:        relocatable-package.txt
BuildArch:      noarch
Prefix: %{_prefix}

%description
This is a test package only used for testing.

%prep
#touch relocatable-package.txt
#[ ! -d bin ] && mkdir bin
#[ ! -d lib ] && mkdir lib
mkdir -p bin
mkdir -p lib
mkdir -p share/doc/relocatable-package
touch bin/a-test-file
touch lib/a-test-file
touch share/doc/relocatable-package/a-test-file

%build
#do nothing

%install
rm -rf $RPM_BUILD_ROOT
mkdir $RPM_BUILD_ROOT
mkdir $RPM_BUILD_ROOT/%{prefix}
cp -ar bin $RPM_BUILD_ROOT/%{prefix}
cp -ar lib $RPM_BUILD_ROOT/%{prefix}
cp -ar share $RPM_BUILD_ROOT/%{prefix}

%clean
echo RPM_BUILD_ROOT=$RPM_BUILD_ROOT
echo BUILD=%{buildroot}
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
/%{prefix}/bin/a-test-file
/%{prefix}/lib/a-test-file
/%{prefix}/share/doc/relocatable-package
/%{prefix}/share/doc/relocatable-package/a-test-file

2. This works:
# rpm -qip relocatable-package-1.0-1.noarch.rpm 
Name        : relocatable-package
Version     : 1.0
Release     : 1
Architecture: noarch
Install Date: (not installed)
Group       : test
Size        : 0
License     : test
Signature   : (none)
Source RPM  : relocatable-package-1.0-1.src.rpm
Build Date  : Tue 05 Jun 2012 12:34:44 PM CEST
Build Host  : rhel70
Relocations : /usr 
URL         : none
Summary     : This package is a relocatable-package
Description :
This is a test package only used for testing.
# rpm -ivh --relocate '/usr=/tmp'  relocatable-package-1.0-1.noarch.rpm Preparing...                ########################################### [100%]
   1:relocatable-package    ########################################### [100%]
# rpm -e relocatable-package
# rpm -ivh --prefix '/tmp'  relocatable-package-1.0-1.noarch.rpm 
Preparing...                ########################################### [100%]
   1:relocatable-package    ########################################### [100%]
# rpm -e relocatable-package

3. But this fail on RHEL7:
# rpm -ivh --badreloc --relocate '/usr/bin=/tmp/bin' --relocate '/usr/share=/tmp/share' relocatable-package-1.0-1.noarch.rpm 
error: Failed dependencies:
	path /usr/bin in package relocatable-package-1.0-1.noarch is not relocatable
	path /usr/share in package relocatable-package-1.0-1.noarch is not relocatable

4. On RHEL6 the above command install the pkg to defined path
  
Actual results:
rpm install fail

Expected results:
the package is installed to required destination

Additional info:

Comment 2 Bill Nottingham 2012-06-08 15:49:33 UTC
Isn't the answer to any --relocate question "don't use --relocate"?

More seriously, what are you using relocation support for?

Comment 3 Patrik Kis 2012-06-11 06:58:00 UTC
(In reply to comment #2)
> Isn't the answer to any --relocate question "don't use --relocate"?
> 
> More seriously, what are you using relocation support for?

Well, I agree that it is not really used by package mainteiners (I have not found any relocatable package in current RHEL7 and one maybe two in RHEL6). The issue is that it is a feature that worked in RHEL6, so it suppose to work also in RHEL7.

Comment 4 Panu Matilainen 2012-06-18 08:08:13 UTC
--relocate is indeed a grande PITA but its not something we can just rip out as numerous 3rd party packages pretty much rely on it being there :-/ 

The issue here is not --relocate itself, its --badreloc that's not working. Easily reprocuced, I'll have a look.

Comment 5 Panu Matilainen 2012-08-07 07:34:46 UTC
FWIW fixed upstream now, should be easily backportable: http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=4fbb58c7e6ee7d1bb565b27e4f81dcf2fee93995

Comment 6 Panu Matilainen 2012-10-08 07:12:53 UTC
Fixed in rpm-4.10.1-1.el7.

Comment 8 Ludek Smid 2014-06-13 09:26:15 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.