2002-11-09 06:27:08 +08:00
|
|
|
#include "system.h"
|
2005-01-18 07:58:09 +08:00
|
|
|
const char *__progname;
|
2002-11-09 06:27:08 +08:00
|
|
|
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmbuild.h>
|
|
|
|
#include <rpm/argv.h>
|
|
|
|
#include <rpm/rpmds.h>
|
|
|
|
#include <rpm/rpmfc.h>
|
2002-11-09 06:27:08 +08:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
2002-11-20 02:40:21 +08:00
|
|
|
char *progname;
|
|
|
|
|
2002-11-09 06:27:08 +08:00
|
|
|
static int print_provides;
|
2002-11-20 02:40:21 +08:00
|
|
|
|
2002-11-09 06:27:08 +08:00
|
|
|
static int print_requires;
|
|
|
|
|
2002-12-07 13:48:45 +08:00
|
|
|
static void rpmdsPrint(const char * msg, rpmds ds, FILE * fp)
|
|
|
|
{
|
|
|
|
if (fp == NULL) fp = stderr;
|
|
|
|
|
|
|
|
if (msg)
|
|
|
|
fprintf(fp, "===================================== %s\n", msg);
|
|
|
|
|
|
|
|
ds = rpmdsInit(ds);
|
|
|
|
while (rpmdsNext(ds) >= 0)
|
|
|
|
fprintf(fp, "%s\n", rpmdsDNEVR(ds)+2);
|
|
|
|
}
|
|
|
|
|
2002-11-09 06:27:08 +08:00
|
|
|
static struct poptOption optionsTable[] = {
|
|
|
|
|
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
|
|
|
|
N_("Common options for all rpm modes and executables:"),
|
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ "provides", 'P', POPT_ARG_VAL, &print_provides, -1,
|
|
|
|
NULL, NULL },
|
|
|
|
{ "requires", 'R', POPT_ARG_VAL, &print_requires, -1,
|
|
|
|
NULL, NULL },
|
|
|
|
|
|
|
|
POPT_AUTOALIAS
|
|
|
|
POPT_AUTOHELP
|
|
|
|
POPT_TABLEEND
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2007-09-18 11:53:37 +08:00
|
|
|
main(int argc, char *argv[])
|
2002-11-09 06:27:08 +08:00
|
|
|
{
|
|
|
|
poptContext optCon;
|
|
|
|
ARGV_t av = NULL;
|
|
|
|
rpmfc fc;
|
|
|
|
int ac = 0;
|
|
|
|
int ec = 1;
|
|
|
|
int xx;
|
|
|
|
char buf[BUFSIZ];
|
2002-11-20 02:40:21 +08:00
|
|
|
|
|
|
|
if ((progname = strrchr(argv[0], '/')) != NULL)
|
|
|
|
progname++;
|
|
|
|
else
|
|
|
|
progname = argv[0];
|
2002-11-09 06:27:08 +08:00
|
|
|
|
|
|
|
optCon = rpmcliInit(argc, argv, optionsTable);
|
|
|
|
if (optCon == NULL)
|
|
|
|
goto exit;
|
|
|
|
|
2008-04-07 17:11:16 +08:00
|
|
|
av = (ARGV_t) poptGetArgs(optCon);
|
2002-11-09 06:27:08 +08:00
|
|
|
ac = argvCount(av);
|
|
|
|
|
|
|
|
if (ac == 0) {
|
|
|
|
char * b, * be;
|
|
|
|
av = NULL;
|
|
|
|
while ((b = fgets(buf, sizeof(buf), stdin)) != NULL) {
|
|
|
|
buf[sizeof(buf)-1] = '\0';
|
|
|
|
be = b + strlen(buf) - 1;
|
|
|
|
while (strchr("\r\n", *be) != NULL)
|
|
|
|
*be-- = '\0';
|
|
|
|
xx = argvAdd(&av, b);
|
|
|
|
}
|
|
|
|
ac = argvCount(av);
|
|
|
|
}
|
|
|
|
|
2002-11-27 06:44:47 +08:00
|
|
|
/* Make sure file names are sorted. */
|
2002-11-20 02:40:21 +08:00
|
|
|
xx = argvSort(av, NULL);
|
|
|
|
|
2002-11-09 06:27:08 +08:00
|
|
|
/* Build file class dictionary. */
|
|
|
|
fc = rpmfcNew();
|
2005-03-20 04:07:12 +08:00
|
|
|
xx = rpmfcClassify(fc, av, NULL);
|
2002-11-09 06:27:08 +08:00
|
|
|
|
|
|
|
/* Build file/package dependency dictionary. */
|
|
|
|
xx = rpmfcApply(fc);
|
|
|
|
|
|
|
|
if (_rpmfc_debug) {
|
|
|
|
rpmfcPrint(buf, fc, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_provides)
|
2007-09-26 03:46:02 +08:00
|
|
|
rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
|
2002-11-09 06:27:08 +08:00
|
|
|
if (print_requires)
|
2007-09-26 03:46:02 +08:00
|
|
|
rpmdsPrint(NULL, rpmfcRequires(fc), stdout);
|
2002-11-09 06:27:08 +08:00
|
|
|
|
|
|
|
fc = rpmfcFree(fc);
|
|
|
|
|
2002-11-20 23:13:03 +08:00
|
|
|
ec = 0;
|
2002-11-09 06:27:08 +08:00
|
|
|
|
|
|
|
exit:
|
|
|
|
optCon = rpmcliFini(optCon);
|
|
|
|
return ec;
|
|
|
|
}
|