[Rpm-maint] [PATCH] Moved manifest checking from rpmInstall to rpmCheckManifest

Rakesh Pandit rakesh.pandit at gmail.com
Mon Jan 19 19:25:55 UTC 2009


$subject

Moving out parts which can be logically separated slowly out of
rpmInstall. That will make this beast function more clean,
maintainable and at some point we can untangle the complex flow it
uses (using labels) to simple algorithm giving us some chance to think
about solving some more complex big issues ;)

Comments and suggestions ?

-- 
rakesh

diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index 0b37349..7f3b7db 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -234,6 +234,37 @@ struct rpmEIU {
     rpmRC rpmrc;
 };

+static int rpmCheckManifest(struct rpmEIU * eiu)
+{
+    int rc, xx;
+
+    /* Try to read a package manifest. */
+    eiu->fd = Fopen(*eiu->fnp, "r.fpio");
+    if (eiu->fd == NULL || Ferror(eiu->fd)) {
+        rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
+	       Fstrerror(eiu->fd));
+	if (eiu->fd != NULL) {
+	    xx = Fclose(eiu->fd);
+	    eiu->fd = NULL;
+	}
+	eiu->numFailed++; *eiu->fnp = NULL;
+	return RPMRC_FAIL;
+    }
+
+    /* Read list of packages from manifest. */
+    rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
+    if (rc != RPMRC_OK)
+        rpmlog(RPMLOG_ERR, _("%s: not an rpm package (or package
manifest): %s\n"),
+	       *eiu->fnp, Fstrerror(eiu->fd));
+    xx = Fclose(eiu->fd);
+    eiu->fd = NULL;
+
+    if (rc != RPMRC_OK)
+        eiu->numFailed++; *eiu->fnp = NULL;
+
+    return rc;
+}
+
 /** @todo Generalize --freshen policies. */
 int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
 {
@@ -386,7 +417,11 @@ restart:
 	    continue;
 	    break;
 	case RPMRC_NOTFOUND:
-	    goto maybe_manifest;
+	    rc = rpmCheckManifest(eiu);
+	    if (rc == RPMRC_OK) {
+	        eiu->prevx++;
+		goto restart;
+	    }
 	    break;
 	case RPMRC_NOTTRUSTED:
 	case RPMRC_NOKEY:
@@ -485,39 +520,6 @@ restart:
 	}

 	eiu->numRPMS++;
-	continue;
-
-maybe_manifest:
-	/* Try to read a package manifest. */
-	eiu->fd = Fopen(*eiu->fnp, "r.fpio");
-	if (eiu->fd == NULL || Ferror(eiu->fd)) {
-	    rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
-			Fstrerror(eiu->fd));
-	    if (eiu->fd != NULL) {
-		xx = Fclose(eiu->fd);
-		eiu->fd = NULL;
-	    }
-	    eiu->numFailed++; *eiu->fnp = NULL;
-	    break;
-	}
-
-	/* Read list of packages from manifest. */
-/* FIX: *eiu->argv can be NULL */
-	rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
-	if (rc != RPMRC_OK)
-	    rpmlog(RPMLOG_ERR, _("%s: not an rpm package (or package
manifest): %s\n"),
-			*eiu->fnp, Fstrerror(eiu->fd));
-	xx = Fclose(eiu->fd);
-	eiu->fd = NULL;
-
-	/* If successful, restart the query loop. */
-	if (rc == RPMRC_OK) {
-	    eiu->prevx++;
-	    goto restart;
-	}
-
-	eiu->numFailed++; *eiu->fnp = NULL;
-	break;
     }

     rpmlog(RPMLOG_DEBUG, "found %d source and %d binary packages\n",
-- 
1.6.0.6


More information about the Rpm-maint mailing list