relocating packages didn't work when the package contained a directory
authorewt <devnull@localhost>
Wed, 15 Jan 1997 22:45:36 +0000 (22:45 +0000)
committerewt <devnull@localhost>
Wed, 15 Jan 1997 22:45:36 +0000 (22:45 +0000)
equivalent to the prefix

CVS patchset: 1281
CVS date: 1997/01/15 22:45:36

lib/install.c

index 11717ab..debee62 100644 (file)
@@ -1616,20 +1616,26 @@ static int relocateFilelist(Header * hp, char * defaultPrefix,
     newh = headerNew();
     it = headerInitIterator(h);
     while (headerNextIterator(it, &tag, &type, &data, &count))
-       if (tag != RPMTAG_FILENAMES)
+       if (tag != RPMTAG_FILENAMES) {
            headerAddEntry(newh, tag, type, data, count);
+       if (type == RPM_STRING_ARRAY_TYPE) free(data);
+    }
 
     headerFreeIterator(it);
 
     newFileList = alloca(sizeof(char *) * fileCount);
     for (i = 0; i < fileCount; i++) {
-       if (!strncmp(fileList[i], defaultPrefix, defaultPrefixLength)) {
+       if (!strcmp(fileList[i], defaultPrefix)) {
+           /* special case as there is no '/' on this */
+           newFileList[i] = newPrefix;
+       } else if (!strncmp(fileList[i], defaultPrefix, defaultPrefixLength)) {
            newFileList[i] = alloca(strlen(fileList[i]) + newPrefixLength -
                                 defaultPrefixLength + 2);
            sprintf(newFileList[i], "%s/%s", newPrefix, 
                    fileList[i] + defaultPrefixLength + 1);
        } else {
-           rpmMessage(RPMMESS_DEBUG, "BAD - unprefixed file in relocatable package");
+           rpmMessage(RPMMESS_DEBUG, "BAD - unprefixed file in relocatable "
+                       "package");
            newFileList[i] = alloca(strlen(fileList[i]) - 
                                        defaultPrefixLength + 2);
            sprintf(newFileList[i], "/%s", fileList[i] + 
@@ -1637,7 +1643,8 @@ static int relocateFilelist(Header * hp, char * defaultPrefix,
        }
     }
 
-    headerAddEntry(newh, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, newFileList, fileCount);
+    headerAddEntry(newh, RPMTAG_FILENAMES, RPM_STRING_ARRAY_TYPE, newFileList, 
+                  fileCount);
     headerAddEntry(newh, RPMTAG_INSTALLPREFIX, RPM_STRING_TYPE, newPrefix, 1);
 
     *relocationLength = newPrefixLength + 1;