RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 02-Feb-2008 18:53:28
Branch: HEAD Handle: 2008020217532800
Added files:
rpm/lib tgi.c
Modified files:
rpm/lib Makefile.am
Log:
- resurrect tgi.c.
Summary:
Revision Changes Path
2.174 +4 -1 rpm/lib/Makefile.am
2.16 +176 -0 rpm/lib/tgi.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/lib/Makefile.am
============================================================================
$ cvs diff -u -r2.173 -r2.174 Makefile.am
--- rpm/lib/Makefile.am 30 Jan 2008 13:12:51 -0000 2.173
+++ rpm/lib/Makefile.am 2 Feb 2008 17:53:28 -0000 2.174
@@ -28,7 +28,7 @@
EXTRA_DIST = genpgp.sh getdate.y librpm.vers tpgp.c
-EXTRA_PROGRAMS = tpgp tsbt
+EXTRA_PROGRAMS = tgi tpgp tsbt
pkgincdir = $(pkgincludedir)$(WITH_PATH_VERSIONED_SUFFIX)
pkginc_HEADERS = \
@@ -126,6 +126,9 @@
lint:
$(LINT) $(DEFS) $(INCLUDES) $(librpm_la_SOURCES)
+tgi_SOURCES = tgi.c
+tgi_LDADD = $(RPM_LDADD)
+
tpgp_SOURCES = genpgp.h tpgp.c
tpgp_LDADD = $(RPM_LDADD)
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/tgi.c
============================================================================
$ cvs diff -u -r0 -r2.16 tgi.c
--- /dev/null 2008-02-02 18:48:56 +0100
+++ tgi.c 2008-02-02 18:53:28 +0100
@@ -0,0 +1,176 @@
+#include "system.h"
+
+#include <rpmio.h>
+#include <rpmmacro.h>
+#include <rpmcb.h>
+#include <rpmgi.h>
+#include <rpmcli.h>
+
+#include <rpmte.h>
+
+#include <popt.h>
+
+#include "debug.h"
+
+static const char * gitagstr = "packages";
+static const char * gikeystr = NULL;
+static rpmtransFlags transFlags = 0;
+#ifdef DYING
+static rpmgiFlags giFlags = 0;
+#endif
+
+static const char * queryFormat = NULL;
+static const char * defaultQueryFormat =
+ "%{name}-%{version}-%{release}.%|SOURCERPM?{%{arch}.rpm}:{%|ARCH?{src.rpm}:{pubkey}|}|";
+
+/*@only@*/ /*@null@*/
+static const char * rpmgiPathOrQF(const rpmgi gi)
+ /*@*/
+{
+ const char * fmt = ((queryFormat != NULL)
+ ? queryFormat : defaultQueryFormat);
+ const char * val = NULL;
+ Header h = rpmgiHeader(gi);
+
+ if (h != NULL)
+ val = headerSprintf(h, fmt, rpmTagTable, rpmHeaderFormats, NULL);
+ else {
+ const char * fn = rpmgiHdrPath(gi);
+ val = (fn != NULL ? xstrdup(fn) : NULL);
+ }
+
+ return val;
+}
+
+static struct poptOption optionsTable[] = {
+ { "rpmgidebug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmgi_debug, -1,
+ N_("debug generalized iterator"), NULL},
+
+ { "tag", '\0', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &gitagstr, 0,
+ N_("iterate tag index"), NULL },
+ { "key", '\0', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &gikeystr, 0,
+ N_("tag value key"), NULL },
+
+ { "transaction", 'T', POPT_BIT_SET, &giFlags, (RPMGI_TSADD|RPMGI_TSORDER),
+ N_("create transaction set"), NULL},
+ { "noorder", '\0', POPT_BIT_CLR, &giFlags, RPMGI_TSORDER,
+ N_("do not order transaction set"), NULL},
+ { "noglob", '\0', POPT_BIT_SET, &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, &giFlags, RPMGI_NOHEADER,
+ N_("do not read headers"), NULL},
+
+ { "qf", '\0', POPT_ARG_STRING, &queryFormat, 0,
+ N_("use the following query format"), "QUERYFORMAT" },
+ { "queryformat", '\0', POPT_ARG_STRING, &queryFormat, 0,
+ N_("use the following query format"), "QUERYFORMAT" },
+
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliFtsPoptTable, 0,
+ N_("File tree walk options for fts(3):"),
+ NULL },
+
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
+ N_("Common options for all rpm modes and executables:"),
+ NULL },
+
+ POPT_AUTOALIAS
+ POPT_AUTOHELP
+ POPT_TABLEEND
+};
+
+int
+main(int argc, char *const argv[])
+{
+ poptContext optCon;
+ rpmts ts = NULL;
+ rpmVSFlags vsflags;
+ rpmgi gi = NULL;
+ int gitag = RPMDBI_PACKAGES;
+ const char ** av;
+ int ac;
+ int rc = 0;
+
+ optCon = rpmcliInit(argc, argv, optionsTable);
+ if (optCon == NULL)
+ exit(EXIT_FAILURE);
+
+ if (ftsOpts == 0)
+ ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
+
+ if (gitagstr != NULL) {
+ gitag = tagValue(gitagstr);
+ if (gitag < 0) {
+ fprintf(stderr, _("unknown --tag argument: %s\n"), gitagstr);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* XXX ftswalk segfault with no args. */
+
+ ts = rpmtsCreate();
+ (void) rpmtsSetFlags(ts, transFlags);
+
+ vsflags = rpmExpandNumeric("%{?_vsflags_query}");
+ if (rpmcliQueryFlags & VERIFY_DIGEST)
+ vsflags |= _RPMVSF_NODIGESTS;
+ if (rpmcliQueryFlags & VERIFY_SIGNATURE)
+ vsflags |= _RPMVSF_NOSIGNATURES;
+ if (rpmcliQueryFlags & VERIFY_HDRCHK)
+ vsflags |= RPMVSF_NOHDRCHK;
+ (void) rpmtsSetVSFlags(ts, vsflags);
+
+ { uint32_t tid = (uint32_t) time(NULL);
+ (void) rpmtsSetTid(ts, tid);
+ }
+
+ gi = rpmgiNew(ts, gitag, gikeystr, 0);
+
+ av = poptGetArgs(optCon);
+ (void) rpmgiSetArgs(gi, av, ftsOpts, giFlags);
+
+ ac = 0;
+ while (rpmgiNext(gi) == RPMRC_OK) {
+ if (!(giFlags & RPMGI_TSADD)) {
+ const char * arg = rpmgiPathOrQF(gi);
+
+ fprintf(stdout, "%5d %s\n", ac, arg);
+ arg = _free(arg);
+ }
+ ac++;
+ }
+
+ if (giFlags & RPMGI_TSORDER) {
+ rpmtsi tsi;
+ rpmte q;
+ int i;
+
+fprintf(stdout, "======================= %d transaction elements\n\
+ # Tree Depth Degree Package\n\
+=======================\n", rpmtsNElements(ts));
+
+ i = 0;
+ tsi = rpmtsiInit(ts);
+ while((q = rpmtsiNext(tsi, 0)) != NULL) {
+ char deptypechar;
+
+ if (i == rpmtsUnorderedSuccessors(ts, -1))
+ fprintf(stdout, "======================= leaf nodes only:\n");
+
+ deptypechar = (rpmteType(q) == TR_REMOVED ? '-' : '+');
+ fprintf(stdout, "%5d%5d%6d%7d %*s%c%s\n",
+ i, rpmteTree(q), rpmteDepth(q), rpmteDegree(q),
+ (2 * rpmteDepth(q)), "",
+ deptypechar, rpmteNEVRA(q));
+ i++;
+ }
+ tsi = rpmtsiFree(tsi);
+ }
+
+ gi = rpmgiFree(gi);
+ ts = rpmtsFree(ts);
+ optCon = rpmcliFini(optCon);
+
+ return rc;
+}
@@ .
Received on Sat Feb 2 18:53:28 2008