added ability to install a source package and find the spec file name
authorewt <devnull@localhost>
Wed, 14 Feb 1996 20:09:14 +0000 (20:09 +0000)
committerewt <devnull@localhost>
Wed, 14 Feb 1996 20:09:14 +0000 (20:09 +0000)
CVS patchset: 269
CVS date: 1996/02/14 20:09:14

install.c
install.h
lib/install.c
lib/rpmlib.h

index 48be717..7ab8027 100644 (file)
--- a/install.c
+++ b/install.c
@@ -128,3 +128,26 @@ void doUninstall(char * prefix, char * arg, int test, int uninstallFlags) {
 
     rpmdbClose(db);
 }
+
+int doSourceInstall(char * prefix, char * arg, char ** specFile) {
+    int fd;
+    int rc;
+
+    fd = open(arg, O_RDONLY);
+    if (fd < 0) {
+       fprintf(stderr, "error: cannot open %s\n", arg);
+       return 1;
+    }
+
+    if (isVerbose())
+       printf("Installing %s\n", arg);
+
+    rc = rpmInstallSourcePackage(prefix, fd, specFile);
+    if (rc == 1) {
+       fprintf(stderr, "error: %s cannot be installed\n", arg);
+    }
+
+    close(fd);
+
+    return rc;
+}
index 34b3fa0..0588b73 100644 (file)
--- a/install.h
+++ b/install.h
@@ -6,6 +6,7 @@
 
 void doInstall(char * prefix, char * arg, int installFlags,
               int interfaceFlags);
+int doSourceInstall(char * prefix, char * arg, char ** specFile);
 void doUninstall(char * prefix, char * arg, int test, int uninstallFlags);
 
 #endif
index 970249d..fc67719 100644 (file)
@@ -45,7 +45,25 @@ static int instHandleSharedFiles(rpmdb db, int ignoreOffset, char ** fileList,
                                 enum instActions * instActions, 
                                 char ** prefixedFileList, int flags);
 static int fileCompare(const void * one, const void * two);
-static int installSources(char * prefix, int fd);
+static int installSources(char * prefix, int fd, char ** specFilePtr);
+
+/* 0 success */
+/* 1 bad magic */
+/* 2 error */
+int rpmInstallSourcePackage(char * prefix, int fd, char ** specFile) {
+    int rc, isSource;
+    Header h;
+
+    rc = pkgReadHeader(fd, &h, &isSource);
+    if (rc) return rc;
+
+    if (!isSource) {
+       error(RPMERR_NOTSRPM, "source package expected, binary found");
+       return 2;
+    }
+
+    return installSources(prefix, fd, specFile);
+}
 
 /* 0 success */
 /* 1 bad magic */
@@ -81,14 +99,12 @@ int rpmInstallPackage(char * prefix, rpmdb db, int fd, int flags,
           is the easiest way. It's to bad the notify stuff doesn't work
           though  */
 
-       message(MESS_DEBUG, "installing a source package\n");
-
        if (flags & INSTALL_TEST) {
            message(MESS_DEBUG, "stopping install as we're running --test\n");
            return 0;
        }
 
-       return installSources(prefix, fd);
+       return installSources(prefix, fd, NULL);
     }
 
     /* we make a copy of the header here so we have one which we can add
@@ -816,12 +832,14 @@ static int fileCompare(const void * one, const void * two) {
 }
 
 
-static int installSources(char * prefix, int fd) {
+static int installSources(char * prefix, int fd, char ** specFilePtr) {
     char * specFile;
     char * sourceDir, * specDir;
     char * realSourceDir, * realSpecDir;
     char * instSpecFile, * correctSpecFile;
 
+    message(MESS_DEBUG, "installing a source package\n");
+
     sourceDir = getVar(RPMVAR_SOURCEDIR);
     specDir = getVar(RPMVAR_SPECDIR);
 
@@ -866,5 +884,8 @@ static int installSources(char * prefix, int fd) {
        return 1;
     }
 
+    if (specFilePtr)
+       *specFilePtr = strdup(correctSpecFile);
+
     return 0;
 }
index f6345b1..ad979cd 100644 (file)
@@ -118,6 +118,7 @@ int rpmdbFindByFile(rpmdb db, char * filespec, dbIndexSet * matches);
 int rpmdbFindByGroup(rpmdb db, char * group, dbIndexSet * matches);
 int rpmdbFindPackage(rpmdb db, char * name, dbIndexSet * matches);
 
+int rpmInstallSourcePackage(char * prefix, int fd, char ** specFile);
 int rpmInstallPackage(char * prefix, rpmdb db, int fd, int flags, 
                      notifyFunction notify);
 int rpmRemovePackage(char * prefix, rpmdb db, unsigned int offset, int test);