[Rpm-maint] PATCH:re-factoring rpmInstall & rpmErase - merging similar rpmInstall rpmErase transaction part

Rakesh Pandit rakesh.pandit at gmail.com
Sat Dec 6 06:02:06 UTC 2008


2008/12/3 Rakesh Pandit <rakesh.pandit at gmail.com>:
> +           rpmcliPackagesTotal += eiu->numSRPMS;
>            continue;

Though it was already in wrong place ... I put it in another wrong
place ...  fixed below. Also reused rpmInstallSource for MODE_INSTALL.
It was just used for MODE_REBUILD. It helped remove 12 lines of
repeated stuff from rpmInstall.

    - Remove stopinstall variable and moved rpmcliPackagesTotal
calculation to correct place.
    - changes in rpmInstallSource for getting reused in install mode
and removed duplicate code from rpmInstall.


-- 
rakesh

commit cdc82744b716ec4dee9e795ca33a99d0dcf6309c
Author: Rakesh Pandit <rakesh at fedoraproject.org>
Date:   Fri Dec 5 23:23:11 2008 +0530

    - Remove stopinstall variable and moved rpmcliPackagesTotal to
correct place.
    - changes in rpmInstallSource for getting reused in install mode
and removed duplicate code from rpmInstall.

diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 87ad1be..8ed3a63 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -212,7 +212,6 @@ int rpmInstall(rpmts ts, struct
rpmInstallArguments_s * ia, ARGV_t fileArgv)
     rpmprobFilterFlags probFilter;
     rpmRelocation * relocations;
     char * fileURL = NULL;
-    int stopInstall = 0;
     rpmVSFlags vsflags, ovsflags, tvsflags;
     int rc;
     int xx;
@@ -393,7 +392,6 @@ restart:
 	    *eiu->fnp = NULL;
 	    eiu->numSRPMS++;
 	    eiu->sourceURL[eiu->numSRPMS] = NULL;
-	    rpmcliPackagesTotal += eiu->numSRPMS;
 	    continue;
 	}

@@ -515,43 +513,33 @@ maybe_manifest:

     if (eiu->numRPMS) {
         eiu->numFailed = rpmCliTransaction(ts, ia, eiu->numPkgs);
-        if (eiu->numFailed < 0)
+        if (eiu->numFailed < 0) {
             eiu->numFailed += eiu->numRPMS;
+	}
     }

-    if (eiu->numSRPMS && !stopInstall) {
-	if (eiu->sourceURL != NULL)
+    if (eiu->numSRPMS && (eiu->sourceURL != NULL)) {
+	rpmcliPackagesTotal += eiu->numSRPMS;
 	for (i = 0; i < eiu->numSRPMS; i++) {
 	    rpmdbCheckSignals();
-	    if (eiu->sourceURL[i] == NULL) continue;
-	    eiu->fd = Fopen(eiu->sourceURL[i], "r.ufdio");
-	    if (eiu->fd == NULL || Ferror(eiu->fd)) {
-		rpmlog(RPMLOG_ERR, _("cannot open file %s: %s\n"),
-			   eiu->sourceURL[i], Fstrerror(eiu->fd));
-		if (eiu->fd != NULL) {
-		    xx = Fclose(eiu->fd);
-		    eiu->fd = NULL;
-		}
-		continue;
+	    if (eiu->sourceURL[i] != NULL) {
+	       rc = RPMRC_OK;
+	       if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST))
+	           rc = rpmInstallSource(ts, eiu->sourceURL[i], NULL, NULL);
+	       if (rc != 0)
+	            eiu->numFailed++;
 	    }
-
-	    if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
-		eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, NULL);
-		if (eiu->rpmrc != RPMRC_OK) eiu->numFailed++;
-	    }
-
-	    xx = Fclose(eiu->fd);
-	    eiu->fd = NULL;
 	}
     }

 exit:
-    if (eiu->pkgURL != NULL)
-    for (i = 0; i < eiu->numPkgs; i++) {
-	if (eiu->pkgURL[i] == NULL) continue;
-	if (eiu->pkgState[i] == 1)
-	    (void) unlink(eiu->pkgURL[i]);
-	eiu->pkgURL[i] = _free(eiu->pkgURL[i]);
+    if (eiu->pkgURL != NULL) {
+	for (i = 0; i < eiu->numPkgs; i++) {
+	    if (eiu->pkgURL[i] == NULL) continue;
+	    if (eiu->pkgState[i] == 1)
+	        (void) unlink(eiu->pkgURL[i]);
+	    eiu->pkgURL[i] = _free(eiu->pkgURL[i]);
+	}
     }
     eiu->pkgState = _free(eiu->pkgState);
     eiu->pkgURL = _free(eiu->pkgURL);
@@ -717,12 +705,12 @@ int rpmInstallSource(rpmts ts, const char * arg,
 	return 1;
     }

-    if (rpmIsVerbose())
+    if (rpmIsVerbose() && specFilePtr != NULL)
 	fprintf(stdout, _("Installing %s\n"), arg);

     {
 	rpmVSFlags ovsflags =
-		rpmtsSetVSFlags(ts, (rpmtsVSFlags(ts) | RPMVSF_NEEDPAYLOAD));
+		rpmtsSetVSFlags(ts, (specFilePtr) ? (rpmtsVSFlags(ts) |
RPMVSF_NEEDPAYLOAD) : rpmtsVSFlags(ts));
 	rpmRC rpmrc = rpmInstallSourcePackage(ts, fd, specFilePtr, cookie);
 	rc = (rpmrc == RPMRC_OK ? 0 : 1);
 	ovsflags = rpmtsSetVSFlags(ts, ovsflags);


More information about the Rpm-maint mailing list