3 #include <rpm/rpmbuild.h>
10 static int print_provides;
12 static int print_requires;
14 static int print_recommends;
16 static int print_suggests;
18 static int print_supplements;
20 static int print_enhances;
22 static int print_conflicts;
24 static int print_obsoletes;
26 static int print_alldeps;
28 static void rpmdsPrint(const char * msg, rpmds ds, FILE * fp)
30 if (fp == NULL) fp = stderr;
33 fprintf(fp, "===================================== %s\n", msg);
36 while (rpmdsNext(ds) >= 0)
37 fprintf(fp, "%s\n", rpmdsDNEVR(ds)+2);
40 static struct poptOption optionsTable[] = {
42 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
43 N_("Common options for all rpm modes and executables:"),
46 { "provides", 'P', POPT_ARG_VAL, &print_provides, -1,
48 { "requires", 'R', POPT_ARG_VAL, &print_requires, -1,
50 { "recommends", '\0', POPT_ARG_VAL, &print_recommends, -1,
52 { "suggests", '\0', POPT_ARG_VAL, &print_suggests, -1,
54 { "supplements", '\0', POPT_ARG_VAL, &print_supplements, -1,
56 { "enhances", '\0', POPT_ARG_VAL, &print_enhances, -1,
58 { "conflicts", '\0', POPT_ARG_VAL, &print_conflicts, -1,
60 { "obsoletes", '\0', POPT_ARG_VAL, &print_obsoletes, -1,
62 { "alldeps", '\0', POPT_ARG_VAL, &print_alldeps, -1,
71 main(int argc, char *argv[])
73 poptContext optCon = NULL;
79 xsetprogname(argv[0]); /* Portability call -- see system.h */
81 optCon = rpmcliInit(argc, argv, optionsTable);
85 /* normally files get passed through stdin but also accept files as args */
86 if (poptPeekArg(optCon)) {
88 while ((arg = poptGetArg(optCon)) != NULL) {
92 while (fgets(buf, sizeof(buf), stdin) != NULL) {
93 char *be = buf + strlen(buf) - 1;
94 while (strchr("\r\n", *be) != NULL)
99 /* Make sure file names are sorted. */
102 /* Build file/package class and dependency dictionaries. */
103 fc = rpmfcCreate(getenv("RPM_BUILD_ROOT"), 0);
104 if (rpmfcClassify(fc, av, NULL) || rpmfcApply(fc))
107 if (print_alldeps || _rpmfc_debug)
108 rpmfcPrint(NULL, fc, print_alldeps ? stdout : NULL);
110 if (!print_alldeps) {
112 rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
114 rpmdsPrint(NULL, rpmfcRequires(fc), stdout);
115 if (print_recommends)
116 rpmdsPrint(NULL, rpmfcRecommends(fc), stdout);
118 rpmdsPrint(NULL, rpmfcSuggests(fc), stdout);
119 if (print_supplements)
120 rpmdsPrint(NULL, rpmfcSupplements(fc), stdout);
122 rpmdsPrint(NULL, rpmfcEnhances(fc), stdout);
124 rpmdsPrint(NULL, rpmfcConflicts(fc), stdout);
126 rpmdsPrint(NULL, rpmfcObsoletes(fc), stdout);