2 const char *__progname;
4 #include <rpm/rpmbuild.h>
13 static int print_provides;
15 static int print_requires;
17 static void rpmdsPrint(const char * msg, rpmds ds, FILE * fp)
19 if (fp == NULL) fp = stderr;
22 fprintf(fp, "===================================== %s\n", msg);
25 while (rpmdsNext(ds) >= 0)
26 fprintf(fp, "%s\n", rpmdsDNEVR(ds)+2);
29 static struct poptOption optionsTable[] = {
31 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
32 N_("Common options for all rpm modes and executables:"),
35 { "provides", 'P', POPT_ARG_VAL, &print_provides, -1,
37 { "requires", 'R', POPT_ARG_VAL, &print_requires, -1,
46 main(int argc, char *argv[])
48 poptContext optCon = NULL;
54 if ((progname = strrchr(argv[0], '/')) != NULL)
59 optCon = rpmcliInit(argc, argv, optionsTable);
63 /* normally files get passed through stdin but also accept files as args */
64 if (poptPeekArg(optCon)) {
66 while ((arg = poptGetArg(optCon)) != NULL) {
70 while (fgets(buf, sizeof(buf), stdin) != NULL) {
71 char *be = buf + strlen(buf) - 1;
72 while (strchr("\r\n", *be) != NULL)
77 /* Make sure file names are sorted. */
80 /* Build file/package class and dependency dictionaries. */
81 fc = rpmfcCreate(getenv("RPM_BUILD_ROOT"), 0);
82 if (rpmfcClassify(fc, av, NULL) || rpmfcApply(fc))
86 rpmfcPrint(buf, fc, NULL);
89 rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
91 rpmdsPrint(NULL, rpmfcRequires(fc), stdout);