changes to set RPMTAG_INSTALLPREFIX correctly
authorewt <devnull@localhost>
Wed, 10 Jul 1996 14:11:19 +0000 (14:11 +0000)
committerewt <devnull@localhost>
Wed, 10 Jul 1996 14:11:19 +0000 (14:11 +0000)
CVS patchset: 765
CVS date: 1996/07/10 14:11:19

lib/install.c

index 32acad3..72a7eb1 100644 (file)
@@ -145,22 +145,29 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location,
        return installSources(rootdir, fd, NULL);
     }
 
-    if (location && !getEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *)
+    if (!getEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *)
                              &defaultPrefix, &fileCount)) {
+       defaultPrefix = NULL;
+    }
+
+    if (location && !defaultPrefix) {
        error(RPMERR_NORELOCATE, "package %s-%s-%s is not relocatable",
                      name, version, release);
        freeHeader(h);
        return 2;
-    }
-
+    } else if (!location && defaultPrefix)
+       location = defaultPrefix;
+    
     if (location) {
        relocateFilelist(&h, defaultPrefix, location, &relocationSize);
         getEntry(h, RPMTAG_DEFAULTPREFIX, &type, (void *) &defaultPrefix, 
                &fileCount);
        archivePrefix = alloca(strlen(rootdir) + strlen(location) + 2);
        sprintf(archivePrefix, "%s/%s", rootdir, location);
-    } else
+    } else {
        archivePrefix = rootdir;
+       relocationSize = 1;
+    }
 
     getEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount);
     getEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount);
@@ -512,6 +519,8 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files,
 
     /* fd should be a gzipped cpio archive */
 
+    message(MESS_DEBUG, "installing archive into %s\n", prefix);
+
     needSecondPipe = (notify != NULL) || specFile;
 
     if (specFile) *specFile = NULL;
@@ -1400,14 +1409,15 @@ static int relocateFilelist(Header * hp, char * defaultPrefix,
     newPrefix = strcpy(alloca(strlen(newPrefix) + 1), newPrefix);
     stripTrailingSlashes(newPrefix);
 
-    if (!strcmp(newPrefix, defaultPrefix)) {
-       *relocationLength = strlen(defaultPrefix);
-       return 0;               /* NOP */
-    }
-
     message(MESS_DEBUG, "relocating files from %s to %s\n", defaultPrefix,
                         newPrefix);
 
+    if (!strcmp(newPrefix, defaultPrefix)) {
+       addEntry(h, RPMTAG_INSTALLPREFIX, STRING_TYPE, defaultPrefix, 1);
+       *relocationLength = strlen(defaultPrefix) + 1;
+       return 0;
+    }
+
     defaultPrefixLength = strlen(defaultPrefix);
     newPrefixLength = strlen(newPrefix);