[Rpm-maint] Remove not used RPMGI_TSADD and RPMGI_TSORDER.

Panu Matilainen pmatilai at laiskiainen.org
Wed Jun 3 09:12:01 UTC 2009


On Fri, 24 Apr 2009, Rakesh Pandit wrote:

> Link: http://rakesh.fedorapeople.org/rpm/0004-Remove-not-used-RPMGI_TSADD-and-RPMGI_TSORDER.patch
>
> ---
> lib/poptQV.c |    4 ++--
> lib/query.c  |    3 ---
> lib/rpmgi.c  |   32 --------------------------------
> lib/rpmgi.h  |    8 +++-----
> 4 files changed, 5 insertions(+), 42 deletions(-)
>
> diff --git a/lib/poptQV.c b/lib/poptQV.c
> index 09e2d3f..ef411f8 100644
> --- a/lib/poptQV.c
> +++ b/lib/poptQV.c
> @@ -130,9 +130,9 @@ 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),
> + { "transaction", 'T', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &giFlags, 0,
> 	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},

If we're to remove these, then remove the popt options for them too, 
entirely. This actually points out another flaw: the --noorder query 
option clobbers the install option of same name now that install, erase, 
query etc are all lumped into same binary again. No wonder I've had this 
feeling --noorder has been broken for some time...

The "use case" for --transaction is that it gives a way to easily see how 
a transaction would be ordered for a given package set. Nice for debugging 
ordering issues but worth the hackery ... I dunno.

Just for giggles, attached is a patch that eliminates the 
rpmtsAddInstallElement() "save header" hack and makes the gi "transaction" 
behave more like a real transaction does: load headers from package files 
as we walk the transaction set. It's slower of course due to opening every 
package twice, but runs in half the memory and with current HEAD it runs 
roughly in half the time of any released version anyway thanks to other 
improvements.

>  { "noglob", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &giFlags,
> RPMGI_NOGLOB,
> 	N_("do not glob arguments"), NULL},
> diff --git a/lib/query.c b/lib/query.c
> index a11d29c..921b081 100644
> --- a/lib/query.c
> +++ b/lib/query.c
> @@ -566,9 +566,6 @@ static int rpmcliArgIterHelper(rpmts ts, QVA_t
> qva, rpmTag tag, ARGV_const_t arg
>     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. */
> diff --git a/lib/rpmgi.c b/lib/rpmgi.c
> index 9719cdd..9eff7a6 100644
> --- a/lib/rpmgi.c
> +++ b/lib/rpmgi.c
> @@ -597,43 +597,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..408e907 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_NOHEADER	= (1 << 2)
        ^^^^^^^^^^^^^^

Btw there's a pointless flag if I ever saw any: for a piece of machinery 
thats supposed to be used for walking over rpm headers, I cant think of a
case where it would make sense not to load the headers.

 	- Panu -
-------------- next part --------------
diff --git a/lib/depends.c b/lib/depends.c
index 326556f..c47e772 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -247,10 +247,6 @@ addheader:
 	ts->numAddedPackages++;
     }
 
-    /* XXX rpmgi hack: Save header in transaction element if requested. */
-    if (upgrade & 0x2)
-	(void) rpmteSetHeader(p, h);
-
     /* If not upgrading, then we're done. */
     if (!(upgrade & 0x1))
 	goto exit;
diff --git a/lib/rpmgi.c b/lib/rpmgi.c
index 011076a..25a7b8c 100644
--- a/lib/rpmgi.c
+++ b/lib/rpmgi.c
@@ -12,9 +12,11 @@
 #include <rpm/rpmmacro.h>		/* XXX rpmExpand */
 #include <rpm/rpmfileutil.h>
 #include <rpm/rpmlog.h>
+#include <rpm/rpmcli.h>
 
 #include "rpmio/fts.h"
 #include "lib/manifest.h"
+#include "lib/rpmte_internal.h"
 
 #include "debug.h"
 
@@ -498,16 +500,15 @@ rpmRC rpmgiNext(rpmgi gi)
 	if (!gi->active) {
 	    gi->tsi = rpmtsiInit(gi->ts);
 	    gi->active = 1;
+	    rpmtsSetNotifyCallback(gi->ts, rpmShowProgress, 0);
 	}
 	if ((p = rpmtsiNext(gi->tsi, TR_ADDED)) != NULL) {
-	    Header h = rpmteHeader(p);
-	    if (h != NULL)
-		if (!(gi->flags & RPMGI_NOHEADER)) {
-		    gi->h = headerLink(h);
+	    if (!(gi->flags & RPMGI_NOHEADER) && rpmteOpen(p, gi->ts, 0)) {
+		gi->h = rpmteHeader(p);
 		sprintf(hnum, "%u", (unsigned)gi->i);
 		gi->hdrPath = rpmExpand("added h# ", hnum, NULL);
 		rpmrc = RPMRC_OK;
-		h = headerFree(h);
+		rpmteClose(p, gi->ts, 0);
 	    }
 	}
 	if (rpmrc != RPMRC_OK) {
@@ -585,8 +586,13 @@ fprintf(stderr, "*** gi %p\t%p[%d]: %s\n", gi, gi->argv, gi->i, gi->argv[gi->i])
     }
 
     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);
+	/* Find the path in argv, key needs to be persistent pointer */
+	for (char **arg = gi->argv; *arg; arg++) {
+	    if (strcmp(gi->hdrPath, *arg) == 0) {
+	    	(void) rpmtsAddInstallElement(gi->ts, gi->h, *arg, 0, NULL);
+		break;
+	    }
+	}
     }
 
     return rpmrc;


More information about the Rpm-maint mailing list