summaryrefslogtreecommitdiff
path: root/lib/tgi.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2004-10-20 02:34:17 +0000
committerjbj <devnull@localhost>2004-10-20 02:34:17 +0000
commite47ccc321adb157633bddb9b17c75deb6ee875d8 (patch)
tree180bc5becdc5a59a3ccc2041c460050017d56a78 /lib/tgi.c
parent7a34fdc4a2b4fbfae85e4bc7e67f5da59ab7c732 (diff)
downloadrpm-e47ccc321adb157633bddb9b17c75deb6ee875d8.tar.gz
rpm-e47ccc321adb157633bddb9b17c75deb6ee875d8.tar.bz2
rpm-e47ccc321adb157633bddb9b17c75deb6ee875d8.zip
Add rpmtsCheck() and rpmtsOrder() to iterator.
Add rpmgi.[ch] to Dpxyfiles.in and POTFOLES.in CVS patchset: 7492 CVS date: 2004/10/20 02:34:17
Diffstat (limited to 'lib/tgi.c')
-rw-r--r--lib/tgi.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/lib/tgi.c b/lib/tgi.c
index e3e7ff216..e7c84df9e 100644
--- a/lib/tgi.c
+++ b/lib/tgi.c
@@ -4,6 +4,8 @@
#include <rpmgi.h>
#include <rpmcli.h>
+#include <rpmte.h>
+
#include <rpmmacro.h>
#include <rpmmessages.h>
#include <popt.h>
@@ -12,6 +14,8 @@
static const char * gitagstr = "packages";
static const char * gikeystr = NULL;
+static rpmtransFlags transFlags = 0;
+static int giflags = 0x3;
static int ftsOpts = 0;
static const char * queryFormat = NULL;
@@ -44,6 +48,10 @@ static struct poptOption optionsTable[] = {
{ "key", '\0', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &gikeystr, 0,
N_("tag value key"), NULL },
+ { "anaconda", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
+ &transFlags, RPMTRANS_FLAG_ANACONDA|RPMTRANS_FLAG_DEPLOOPS,
+ N_("use anaconda \"presentation order\""), NULL},
+
{ "qf", '\0', POPT_ARG_STRING, &queryFormat, 0,
N_("use the following query format"), "QUERYFORMAT" },
{ "queryformat", '\0', POPT_ARG_STRING, &queryFormat, 0,
@@ -86,7 +94,6 @@ main(int argc, char *const argv[])
const char ** av;
int ac;
int rc = 0;
- int xx;
optCon = rpmcliInit(argc, argv, optionsTable);
if (optCon == NULL)
@@ -106,6 +113,8 @@ main(int argc, char *const argv[])
/* XXX ftswalk segfault with no args. */
ts = rpmtsCreate();
+ (void) rpmtsSetFlags(ts, transFlags);
+
vsflags = rpmExpandNumeric("%{?_vsflags_query}");
if (rpmcliQueryFlags & VERIFY_DIGEST)
vsflags |= _RPMVSF_NODIGESTS;
@@ -122,20 +131,49 @@ main(int argc, char *const argv[])
gi = rpmgiNew(ts, gitag, gikeystr, 0);
av = poptGetArgs(optCon);
- (void) rpmgiSetArgs(gi, av, ftsOpts);
+ (void) rpmgiSetArgs(gi, av, ftsOpts, giflags);
ac = 0;
while (rpmgiNext(gi) == RPMRC_OK) {
- const char * arg = rpmgiPathOrQF(gi);
- Header h = rpmgiHeader(gi);
- const char * fn = rpmgiHdrPath(gi);
-
- fprintf(stderr, "%5d %s\n", ac, arg);
- arg = _free(arg);
+ if (!(giflags & 0x3)) {
+ const char * arg = rpmgiPathOrQF(gi);
+#ifdef UNUSED
+ Header h = rpmgiHeader(gi);
+ const char * fn = rpmgiHdrPath(gi);
+ int xx;
+#endif
+
+ fprintf(stderr, "%5d %s\n", ac, arg);
+ arg = _free(arg);
+ }
ac++;
+ }
- xx = rpmtsAddInstallElement(ts, h, (fnpyKey)fn, 0, NULL);
-
+ if (giflags & 0x3) {
+ rpmtsi tsi;
+ rpmte q;
+ int i;
+
+fprintf(stderr, "======================= ordered %d 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(stderr, "======================= leaf nodes only:\n");
+
+ deptypechar = (rpmteType(q) == TR_REMOVED ? '-' : '+');
+ fprintf(stderr, "%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);