1) got --prefix working (again)
authorewt <devnull@localhost>
Sun, 23 May 1999 18:34:30 +0000 (18:34 +0000)
committerewt <devnull@localhost>
Sun, 23 May 1999 18:34:30 +0000 (18:34 +0000)
2) rpmtransAddPackage() makes a copy of the relocation list

CVS patchset: 3073
CVS date: 1999/05/23 18:34:30

CHANGES
install.c
lib/depends.c
rpm.c

diff --git a/CHANGES b/CHANGES
index 10ccb62..d7666ac 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -22,6 +22,7 @@
        - fix: prevent return code wrap during packagage checking/resigning.
        - permit multiple %lang(xx) markers on elements in %files.
        - permit %lang(xx,yy,zz) constructs --  2 more dead strtoks.
+       - fix: --prefix should work properly during package installs
 
 2.94 -> 2.95
        - fix: last update transaction set segfault bug in installer.
index 6b01717..840d5e9 100644 (file)
--- a/install.c
+++ b/install.c
@@ -233,7 +233,7 @@ int doInstall(const char * rootdir, const char ** argv, int transFlags,
 
                    if (headerGetEntry(h, RPMTAG_PREFIXES, NULL,
                                       (void **) &paths, &c) && (c == 1)) {
-                       defaultReloc->oldPath = paths[0];
+                       defaultReloc->oldPath = strdup(paths[0]);
                        free(paths);
                    } else {
                        headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name,
@@ -259,8 +259,10 @@ int doInstall(const char * rootdir, const char ** argv, int transFlags,
                    return numPackages;
                }
 
-               if (defaultReloc)
+               if (defaultReloc) {
+                   free(defaultReloc->oldPath);
                    defaultReloc->oldPath = NULL;
+               }
 
                fdClose(fd);
                numBinaryPackages++;
index a6095b6..552d1bd 100644 (file)
@@ -63,6 +63,7 @@ static void alFreeIndex(struct availableList * al) {
 
 static void alFree(struct availableList * al) {
     int i;
+    rpmRelocation * r;
 
     for (i = 0; i < al->size; i++) {
        if (al->list[i].provides)
@@ -70,6 +71,17 @@ static void alFree(struct availableList * al) {
        if (al->list[i].files)
            free(al->list[i].files);
        headerFree(al->list[i].h);
+
+       if (al->list[i].relocs) {
+           r = al->list[i].relocs;
+           while (r->oldPath || r->newPath) {
+               if (r->oldPath) free(r->oldPath);
+               if (r->newPath) free(r->newPath);
+               r++;
+           }
+
+           free(al->list[i].relocs);
+       }
     }
 
     if (al->alloced) free(al->list);
@@ -80,6 +92,8 @@ static struct availablePackage * alAddPackage(struct availableList * al,
                                              Header h, const void * key,
                                              FD_t fd, rpmRelocation * relocs) {
     struct availablePackage * p;
+    rpmRelocation * r;
+    int i;
 
     if (al->size == al->alloced) {
        al->alloced += 5;
@@ -116,9 +130,22 @@ static struct availablePackage * alAddPackage(struct availableList * al,
        headerRemoveEntry(h, RPMTAG_FILEGIDS);
     
     p->key = key;
-    p->relocs = relocs;
     p->fd = fd;
 
+    if (relocs) {
+       for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++);
+       p->relocs = malloc(sizeof(*p->relocs) * (i + 1));
+
+       for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
+           p->relocs[i].oldPath = r->oldPath ? strdup(r->oldPath) : NULL;
+           p->relocs[i].newPath = r->newPath ? strdup(r->newPath) : NULL;
+       }
+       p->relocs[i].oldPath = NULL;
+       p->relocs[i].newPath = NULL;
+    } else {
+       p->relocs = NULL;
+    }
+    
     alFreeIndex(al);
 
     return p;
diff --git a/rpm.c b/rpm.c
index 0d011f5..b621f61 100755 (executable)
--- a/rpm.c
+++ b/rpm.c
@@ -20,7 +20,6 @@
 #define GETOPT_SHOWRC          1018
 #define GETOPT_EXCLUDEPATH     1019
 #define        GETOPT_DEFINEMACRO      1020
-#define        GETOPT_PREFIX           1021    /* XXX hack to avoid prefix dump */
 
 char * version = VERSION;
 
@@ -121,7 +120,7 @@ static struct poptOption optionsTable[] = {
  { "oldpackage", '\0', 0, &oldPackage, 0,      NULL, NULL},
  { "percent", '\0', 0, &showPercents, 0,       NULL, NULL},
  { "pipe", '\0', POPT_ARG_STRING, &pipeOutput, 0,      NULL, NULL},
- { "prefix", '\0', POPT_ARG_STRING, &prefix, GETOPT_PREFIX,    NULL, NULL},
+ { "prefix", '\0', POPT_ARG_STRING, &prefix, 0,        NULL, NULL},
  { "query", 'q', 0, NULL, 'q',                 NULL, NULL},
  { "querytags", '\0', 0, &queryTags, 0,                NULL, NULL},
  { "quiet", '\0', 0, &quiet, 0,                        NULL, NULL},
@@ -833,13 +832,6 @@ int main(int argc, char ** argv)
            rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
            break;
 
-         case GETOPT_PREFIX:
-           relocations = realloc(relocations, 
-                                 sizeof(*relocations) * (numRelocations + 1));
-           relocations[numRelocations].oldPath = NULL;
-           relocations[numRelocations++].newPath = optArg;
-           break;
-
          case GETOPT_TIMECHECK:
            tce = NULL;
            timeCheck = strtoul(optArg, &tce, 10);