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;
+}
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
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 */
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
}
-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);
return 1;
}
+ if (specFilePtr)
+ *specFilePtr = strdup(correctSpecFile);
+
return 0;
}
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);