From 215e57adee9080b5756e63192f2ff374c7b051c9 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh@fedoraproject.org>
Date: Thu, 25 Jun 2009 12:35:23 +0530
Subject: [PATCH 1/5] Remove not used RPMGI_TSADD, RPMGI_TSORDER & RPMGI_NOHEADE
  -New RPMGI_NOBINFILE to differentiate between installed pkgs & bin file
  -Fixed indentation in rpmgiNext

---
 lib/poptQV.c |    7 +-----
 lib/query.c  |   10 +-------
 lib/rpmgi.c  |   70 ++++++++++++++-------------------------------------------
 lib/rpmgi.h  |    8 ++----
 4 files changed, 22 insertions(+), 73 deletions(-)

diff --git a/lib/poptQV.c b/lib/poptQV.c
index 09e2d3f..ccd3d4f 100644
--- a/lib/poptQV.c
+++ b/lib/poptQV.c
@@ -130,17 +130,12 @@ struct poptOption rpmQVSourcePoptTable[] = {
  { "whatprovides", '\0', 0, 0, POPT_WHATPROVIDES, 
 	N_("query/verify the package(s) which provide a dependency"), "CAPABILITY" },
 
- { "transaction", 'T', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, (RPMGI_TSADD|RPMGI_TSORDER),
-	N_("create transaction set"), NULL},
- { "noorder", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, RPMGI_TSORDER,
+ { "noorder", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, 0,
 	N_("do not order transaction set"), NULL},
  { "noglob", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, RPMGI_NOGLOB,
 	N_("do not glob arguments"), NULL},
  { "nomanifest", '\0', POPT_BIT_SET, &giFlags, RPMGI_NOMANIFEST,
 	N_("do not process non-package files as manifests"), NULL},
- { "noheader", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, RPMGI_NOHEADER,
-	N_("do not read headers"), NULL},
-
 
    POPT_TABLEEND
 };
diff --git a/lib/query.c b/lib/query.c
index a11d29c..a55c65a 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -560,19 +560,11 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
 
 static int rpmcliArgIterHelper(rpmts ts, QVA_t qva, rpmTag tag, ARGV_const_t argv, rpmgiFlags gFlgs)
 {
-    rpmRC rpmrc = RPMRC_NOTFOUND;
     int ec = 0;
 
     qva->qva_gi = rpmgiNew(ts, tag, NULL, 0);
     qva->qva_rc = rpmgiSetArgs(qva->qva_gi, argv, ftsOpts, gFlgs);
     
-    if (qva->qva_gi != NULL && (rpmgiGetFlags(qva->qva_gi) & RPMGI_TSADD))	/* Load the ts with headers. */
-        while ((rpmrc = rpmgiNext(qva->qva_gi)) == RPMRC_OK)
-	    {};
-    if (rpmrc != RPMRC_NOTFOUND) {
-        qva->qva_gi = rpmgiFree(qva->qva_gi);
-	return 1;	/* XXX should be no. of failures. */
-    }
     /* FIX: argv can be NULL, cast to pass argv array */
     ec = rpmQueryVerify(qva, ts, (tag == RPMDBI_PACKAGES)? (const char *) argv : NULL);
     rpmtsEmpty(ts);
@@ -602,7 +594,7 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv)
     default:
 	qva->qva_gi = rpmgiNew(ts, RPMDBI_ARGLIST, NULL, 0);
 	qva->qva_rc = rpmgiSetArgs(qva->qva_gi, argv, ftsOpts,
-		(giFlags | (RPMGI_NOGLOB|RPMGI_NOHEADER)));
+		(giFlags | (RPMGI_NOGLOB|RPMGI_NOBINFILE)));
 	while (rpmgiNext(qva->qva_gi) == RPMRC_OK) {
 	    ec += rpmQueryVerify(qva, ts, rpmgiHdrPath(qva->qva_gi));
 	    rpmtsEmpty(ts);
diff --git a/lib/rpmgi.c b/lib/rpmgi.c
index 011076a..a73c719 100644
--- a/lib/rpmgi.c
+++ b/lib/rpmgi.c
@@ -170,7 +170,7 @@ static rpmRC rpmgiLoadReadHeader(rpmgi gi)
 	char * fn;	/* XXX gi->hdrPath? */
 
 	fn = gi->argv[gi->i];
-	if (!(gi->flags & RPMGI_NOHEADER)) {
+	if (!(gi->flags & RPMGI_NOBINFILE)) {
 	    h = rpmgiReadHeader(gi, fn);
 	    if (h != NULL)
 		rpmrc = RPMRC_OK;
@@ -254,11 +254,10 @@ static rpmRC rpmgiWalkReadHeader(rpmgi gi)
 
     if (rpmrc == RPMRC_OK) {
 	Header h = NULL;
-	if (!(gi->flags & RPMGI_NOHEADER)) {
-	    /* XXX rpmrc = rpmgiLoadReadHeader(gi); */
-	    if (gi->fts != NULL)	/* XXX can't happen */
+
+	if (gi->fts != NULL)
 		h = rpmgiReadHeader(gi, gi->fts->fts_path);
-	}
+
 	if (h != NULL)
 	    gi->h = headerLink(h);
 	h = headerFree(h);
@@ -479,12 +478,11 @@ rpmRC rpmgiNext(rpmgi gi)
 	if (gi->mi != NULL) {	/* XXX unnecessary */
 	    Header h = rpmdbNextIterator(gi->mi);
 	    if (h != NULL) {
-		if (!(gi->flags & RPMGI_NOHEADER))
 		    gi->h = headerLink(h);
-		sprintf(hnum, "%u", rpmdbGetIteratorOffset(gi->mi));
-		gi->hdrPath = rpmExpand("rpmdb h# ", hnum, NULL);
-		rpmrc = RPMRC_OK;
-		/* XXX header reference held by iterator, so no headerFree */
+		    sprintf(hnum, "%u", rpmdbGetIteratorOffset(gi->mi));
+		    gi->hdrPath = rpmExpand("rpmdb h# ", hnum, NULL);
+		    rpmrc = RPMRC_OK;
+		    /* XXX header reference held by iterator, so no headerFree */
 	    } else
 	        rpmrc = RPMRC_NOTFOUND;
 	}
@@ -501,13 +499,12 @@ rpmRC rpmgiNext(rpmgi gi)
 	}
 	if ((p = rpmtsiNext(gi->tsi, TR_ADDED)) != NULL) {
 	    Header h = rpmteHeader(p);
-	    if (h != NULL)
-		if (!(gi->flags & RPMGI_NOHEADER)) {
+		if (h != NULL) {
 		    gi->h = headerLink(h);
-		sprintf(hnum, "%u", (unsigned)gi->i);
-		gi->hdrPath = rpmExpand("added h# ", hnum, NULL);
-		rpmrc = RPMRC_OK;
-		h = headerFree(h);
+		    sprintf(hnum, "%u", (unsigned)gi->i);
+		    gi->hdrPath = rpmExpand("added h# ", hnum, NULL);
+		    rpmrc = RPMRC_OK;
+		    h = headerFree(h);
 	    }
 	}
 	if (rpmrc != RPMRC_OK) {
@@ -524,12 +521,11 @@ rpmRC rpmgiNext(rpmgi gi)
 	if (gi->fd != NULL) {
 	    Header h = headerRead(gi->fd, HEADER_MAGIC_YES);
 	    if (h != NULL) {
-		if (!(gi->flags & RPMGI_NOHEADER))
 		    gi->h = headerLink(h);
-		sprintf(hnum, "%u", (unsigned)gi->i);
-		gi->hdrPath = rpmExpand("hdlist h# ", hnum, NULL);
-		rpmrc = RPMRC_OK;
-		h = headerFree(h);
+		    sprintf(hnum, "%u", (unsigned)gi->i);
+		    gi->hdrPath = rpmExpand("hdlist h# ", hnum, NULL);
+		    rpmrc = RPMRC_OK;
+		    h = headerFree(h);
 	    }
 	}
 	if (rpmrc != RPMRC_OK) {
@@ -584,43 +580,11 @@ fprintf(stderr, "*** gi %p\t%p[%d]: %s\n", gi, gi->argv, gi->i, gi->argv[gi->i])
 	break;
     }
 
-    if ((gi->flags & RPMGI_TSADD) && gi->h != NULL) {
-	/* XXX rpmgi hack: Save header in transaction element. */
-	xx = rpmtsAddInstallElement(gi->ts, gi->h, (fnpyKey)gi->hdrPath, 2, NULL);
-    }
 
     return rpmrc;
 
 enditer:
     gi->mi = rpmdbFreeIterator(gi->mi);
-    if (gi->flags & RPMGI_TSORDER) {
-	rpmts ts = gi->ts;
-	rpmps ps;
-
-	/* XXX installed database needs close here. */
-	xx = rpmtsCloseDB(ts);
-	xx = rpmtsSetDBMode(ts, -1);	/* XXX disable lazy opens */
-
-	xx = rpmtsCheck(ts);
-
-	/* XXX query/verify will need the glop added to a buffer instead. */
-	ps = rpmtsProblems(ts);
-	if (rpmpsNumProblems(ps) > 0) {
-	    /* XXX rpminstall will need RPMLOG_ERR */
-	    rpmlog(RPMLOG_INFO, _("Failed dependencies:\n"));
-	    if (rpmIsVerbose())
-		rpmpsPrint(NULL, ps);
-	}
-	ps = rpmpsFree(ps);
-	rpmtsCleanProblems(ts);
-
-	xx = rpmtsOrder(ts);
-
-	gi->tag = RPMDBI_ADDED;			/* XXX hackery */
-	gi->flags &= ~(RPMGI_TSADD|RPMGI_TSORDER);
-
-    }
-
     gi->h = headerFree(gi->h);
     gi->hdrPath = _free(gi->hdrPath);
     gi->i = -1;
diff --git a/lib/rpmgi.h b/lib/rpmgi.h
index 8dfc6f2..2e5f7a8 100644
--- a/lib/rpmgi.h
+++ b/lib/rpmgi.h
@@ -20,11 +20,9 @@ extern int _rpmgi_debug;
  */
 typedef enum rpmgiFlags_e {
     RPMGI_NONE		= 0,
-    RPMGI_TSADD		= (1 << 0),
-    RPMGI_TSORDER	= (1 << 1),
-    RPMGI_NOGLOB	= (1 << 2),
-    RPMGI_NOMANIFEST	= (1 << 3),
-    RPMGI_NOHEADER	= (1 << 4)
+    RPMGI_NOGLOB	= (1 << 0),
+    RPMGI_NOMANIFEST	= (1 << 1),
+    RPMGI_NOBINFILE	= (1 << 2)
 } rpmgiFlags;
 
 /** \ingroup rpmgi
-- 
1.6.2.2

