malmond / rpms / rpm

Forked from rpms/rpm 4 years ago
Clone

Blame SOURCES/rpm-4.11.1-instprefix.patch

5860f5
commit 1ac9e84d9a4a04df7c8f659a8df676fc4f8544f0
5860f5
Author: Panu Matilainen <pmatilai@redhat.com>
5860f5
Date:   Fri Jul 5 10:27:18 2013 +0300
5860f5
5860f5
    Ensure relocatable packages always get install-prefix(es) set (RhBug:979443)
5860f5
    
5860f5
    - Scriptlets from relocatable packages should always run with
5860f5
      $RPM_INSTALL_PREFIX* defined, whether actually being relocated or not.
5860f5
    - Fixes regression introduced by the optimization in commit
5860f5
      5d3018c4ed476b1b7ac18e2573af517f872cb303. We always need to call
5860f5
      addPrefixes() but return early from rpmRelocateFileList() when
5860f5
      no relocations are taking place, fixing the performance regression
5860f5
      introduced all the way back in cb8241dda783f7e8c143b08fecf57fe89a39c3a6
5860f5
      which is what 5d3018c4ed476b1b7ac18e2573af517f872cb303 was trying
5860f5
      to fix. Pooh :)
5860f5
    
5860f5
    (cherry picked from commit 88d24b14a8e0e33e768cb74a3487acf0925b012a)
5860f5
5860f5
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
5860f5
index 0bfb5dd..185deae 100644
5860f5
--- a/lib/rpmfi.c
5860f5
+++ b/lib/rpmfi.c
5860f5
@@ -793,7 +793,8 @@ static int addPrefixes(Header h, rpmRelocation *relocations, int numRelocations)
5860f5
 	headerPutStringArray(h, RPMTAG_INSTPREFIXES, actualRelocations, numActual);
5860f5
     }
5860f5
     free(actualRelocations);
5860f5
-    return numActual;
5860f5
+    /* When any relocations are present there'll be more work to do */
5860f5
+    return 1;
5860f5
 }
5860f5
 
5860f5
 static void saveRelocs(Header h, rpmtd bnames, rpmtd dnames, rpmtd dindexes)
5860f5
@@ -835,7 +836,8 @@ void rpmRelocateFileList(rpmRelocation *relocations, int numRelocations,
5860f5
     int i, j;
5860f5
     struct rpmtd_s bnames, dnames, dindexes, fmodes;
5860f5
 
5860f5
-    addPrefixes(h, relocations, numRelocations);
5860f5
+    if (!addPrefixes(h, relocations, numRelocations))
5860f5
+	return;
5860f5
 
5860f5
     if (!_printed) {
5860f5
 	_printed = 1;
5860f5
diff --git a/lib/rpmte.c b/lib/rpmte.c
5860f5
index 6afd69e..87fb391 100644
5860f5
--- a/lib/rpmte.c
5860f5
+++ b/lib/rpmte.c
5860f5
@@ -98,7 +98,7 @@ static rpmfi getFI(rpmte p, Header h)
5860f5
 				      (RPMFI_NOHEADER | RPMFI_FLAGS_ERASE);
5860f5
 
5860f5
     /* relocate stuff in header if necessary */
5860f5
-    if (rpmteType(p) == TR_ADDED && rpmfsFC(p->fs) > 0 && p->nrelocs) {
5860f5
+    if (rpmteType(p) == TR_ADDED && rpmfsFC(p->fs) > 0) {
5860f5
 	if (!headerIsSource(h) && !headerIsEntry(h, RPMTAG_ORIGBASENAMES)) {
5860f5
 	    rpmRelocateFileList(p->relocs, p->nrelocs, p->fs, h);
5860f5
 	}