Bug 979443

Summary: RPM: scriptlet: RPM_INSTALL_PREFIX not defined by default
Product: [Fedora] Fedora Reporter: Yann Droneaud <yann>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: ffesti, jzeleny, novyjindrich, packaging-team-maint, pknirsch, pmatilai
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rpm-4.11.1-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-08 00:54:48 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:
Attachments:
Description Flags
SPEC: empty package with Prefix:
none
SPEC: non empty package with Prefix:
none
Script: git bisect script none

Description Yann Droneaud 2013-06-28 14:26:36 UTC
Intro:
------

I've noticed that 'rpm' (rpm-4.11.0.1 on Fedora 19) is no more defining environment variable RPM_INSTALL_PREFIX[1] by default.

[1] http://www.rpm.org/max-rpm/s1-rpm-reloc-building-relocatable.html#AEN9694

Description:
------------

Previous version of 'rpm' (rpm-4.9.1.3 on Fedora 17) were always defining 
RPM_INSTALL_PREFIX* for %pre and %post installation scripts:
RPM_INSTALL_PREFIX and RPM_INSTALL_PREFIX0 are supposed to match Prefix:[2] tag line in the package SPEC file or --prefix[3][4] command line argument when asking rpm to relocate a package.

I've seen a misleading old message[5] on RPM mailing list stating that RPM_INSTALL_PREFIX was removed, but it's not.
I've found no ChangeLog/Release Note about change on RPM_INSTALL_PREFIX[6].


[2] http://www.rpm.org/max-rpm/s1-rpm-reloc-prefix-tag.html
[3] http://www.rpm.org/max-rpm/s1-rpm-install-additional-options.html#S2-RPM-INSTALL-PREFIX
[4] http://www.rpm.org/max-rpm/s1-rpm-reloc-building-relocatable.html#S2-RPM-RELOC-TEST-DRIVE
[5] http://thread.gmane.org/gmane.linux.redhat.rpm.devel/497
[6] Release Notes:
    http://rpm.org/wiki/Releases/4.11.1
    http://rpm.org/wiki/Releases/4.11.0.1
    http://rpm.org/wiki/Releases/4.11.0
    http://rpm.org/wiki/Releases/4.10.3.1
    http://rpm.org/wiki/Releases/4.10.3
    http://rpm.org/wiki/Releases/4.10.2
    http://rpm.org/wiki/Releases/4.10.1
    http://rpm.org/wiki/Releases/4.10.0

How to reproduce:
-----------------

I've used test package based on SPEC file[7] sent to a mailing list to report a bug against RPM_INSTALL_PREFIX.

I modified this SPEC file to:
 - report RPM_INSTALL_PREFIX{0..15}
 - have a file inside of it.
   Empty package doesn't get at all RPM_INSTALL_PREFIX, even on older rpm.

I was able to produce the following results:

- Fedora 17, rpm 4.9.1.3

  # rpm -i test-package-1.0-2.noarch.rpm
  pre - RPM_INSTALL_PREFIX = "/opt/test-package"
  pre - RPM_INSTALL_PREFIX0 = "/opt/test-package"
  ...
  post - RPM_INSTALL_PREFIX = "/opt/test-package"
  post - RPM_INSTALL_PREFIX0 = "/opt/test-package"
  ...

  # rpm -i --prefix=/usr/local test-package-1.0-2.noarch.rpm 
  pre - RPM_INSTALL_PREFIX = "/usr/local"
  pre - RPM_INSTALL_PREFIX0 = "/usr/local"
  ...
  post - RPM_INSTALL_PREFIX = "/usr/local"
  post - RPM_INSTALL_PREFIX0 = "/usr/local"
  ...

- Fedora 19, rpm 4.11.0.1

  # rpm -i test-package-1.0-2.noarch.rpm
  pre - RPM_INSTALL_PREFIX = ""
  pre - RPM_INSTALL_PREFIX0 = ""
  ...
  post - RPM_INSTALL_PREFIX = ""
  post - RPM_INSTALL_PREFIX0 = ""

  # rpm -i --prefix=/usr/local test-package-1.0-2.noarch.rpm
  pre - RPM_INSTALL_PREFIX = "/usr/local"
  pre - RPM_INSTALL_PREFIX0 = "/usr/local"
  ...
  post - RPM_INSTALL_PREFIX = "/usr/local"
  post - RPM_INSTALL_PREFIX0 = "/usr/local"


On Fedora 19, without --prefix, RPM_INSTAL_PREFIX is not set.

[7] http://www.redhat.com/archives/rpm-list/2003-May/msg00486.html


Git bisect:
-----------

I've use git bisect with a custom script to locate a possible commit that change the RPM_INSTALL_PREFIX behavor.

Git bisect returns following commit[8]:

  5d3018c4ed476b1b7ac18e2573af517f872cb303 is the first bad commit
  commit 5d3018c4ed476b1b7ac18e2573af517f872cb303
  Author: Panu Matilainen <pmatilai>
  Date:   Tue Oct 2 16:17:05 2012 +0300

      Dont bother with rpmRelocateFileList() if relocations have been specified
    
      - rpmRelocateFileList() doesn't modify anything when no relocations
        are to be done, but what it does is not exactly free, unnecessarily
        calling it is dumb.

[8] http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=5d3018c4ed476b1b7ac18e2573af517f872cb303


Summarize:
----------

I think 'rpm' should define RPM_INSTALL_PREFIX if a prefix is defined in the SPEC file. It's looking like a regression.

Regards.

Comment 1 Yann Droneaud 2013-06-28 14:41:15 UTC
Created attachment 766592 [details]
SPEC: empty package with Prefix:

This SPEC file produces an empty package. The Prefix: tag line in SPEC and --prefix on command line is ignored by RPM in Fedora 17 and Fedora 19 when installing (rpm -i) and uninstalling (rpm -e).

This package is not showing a regression between Fedora 17 and Fedora 19,
but it could be good to have RPM_INSTALL_PREFIX for scriptlets ...

Comment 2 Yann Droneaud 2013-06-28 14:45:48 UTC
Created attachment 766593 [details]
SPEC: non empty package with Prefix:

This SPEC file produces a test package.

Tested when installing (rpm -i) and uninstalling (rpm -e).

The Prefix: tag line in SPEC is reported in RPM_INSTALL_PREFIX variable on Fedora 17 but not on Fedora 19.

--prefix on command line is reported in RPM_INSTALL_PREFIX variable on Fedora 17 and Fedora 19.

This package demonstrates a regression between Fedora 17 and Fedora 19.

Note: like attachment #766592 [details], this SPEC file is a derivative work of http://www.redhat.com/archives/rpm-list/2003-May/msg00486.html

Comment 3 Yann Droneaud 2013-06-28 15:34:39 UTC
Created attachment 766602 [details]
Script: git bisect script

This is the script I used to find the commit 5d3018c4ed476b1b7ac18e2573af517f872cb303,
using git bisect.

git bisect was ran inside a dedicated "mock" chroot in order to not clobber a real system: the script backup the RPM database, install/remove a package, restore the RPM database:

    git bisect start
    git bisect good rpm-4.9.1.3-release
    git bisect bad rpm-4.11.0.1-release
    git bisect run /tmp/BISECT-979443.sh /builddir/build/RPMS/test-package-nonempty-1.0-2.noarch.rpm

Comment 4 Panu Matilainen 2013-07-02 07:56:28 UTC
Right, its indeed an unintended behavior change, aka regression. Thanks for the extremely detailed report :) Will fix.

Comment 5 Fedora Update System 2013-07-05 09:00:19 UTC
rpm-4.11.1-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/rpm-4.11.1-1.fc19

Comment 6 Fedora Update System 2013-07-06 00:54:22 UTC
Package rpm-4.11.1-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing rpm-4.11.1-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-12411/rpm-4.11.1-1.fc19
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2013-07-08 00:54:48 UTC
rpm-4.11.1-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.