4 #include <rpm/rpmcli.h>
8 #if !defined(__GLIBC__) && !defined(__APPLE__)
9 char ** environ = NULL;
13 MODE_CHECKSIG = (1 << 0),
14 MODE_IMPORTKEY = (1 << 1),
15 MODE_DELKEY = (1 << 2),
16 MODE_LISTKEY = (1 << 3),
22 static struct poptOption keyOptsTable[] = {
23 { "checksig", 'K', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_CHECKSIG,
24 N_("verify package signature(s)"), NULL },
25 { "import", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_IMPORTKEY,
26 N_("import an armored public key"), NULL },
27 { "test", '\0', POPT_ARG_NONE, &test, 0,
28 N_("don't import, but tell if it would work or not"), NULL },
30 { "delete-key", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_DELKEY,
31 N_("list keys from RPM keyring"), NULL },
32 { "list-keys", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_LISTKEY,
33 N_("list keys from RPM keyring"), NULL },
38 static struct poptOption optionsTable[] = {
39 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, keyOptsTable, 0,
40 N_("Keyring options:"), NULL },
41 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
42 N_("Common options for all rpm modes and executables:"), NULL },
49 int main(int argc, char *argv[])
51 int ec = EXIT_FAILURE;
52 poptContext optCon = rpmcliInit(argc, argv, optionsTable);
53 rpmts ts = rpmtsCreate();
54 ARGV_const_t args = NULL;
57 printUsage(optCon, stderr, 0);
61 args = (ARGV_const_t) poptGetArgs(optCon);
63 if (mode != MODE_LISTKEY && args == NULL)
64 argerror(_("no arguments given"));
66 rpmtsSetRootDir(ts, rpmcliRootDir);
70 ec = rpmcliVerifySignatures(ts, args);
74 rpmtsSetFlags(ts, (rpmtsFlags(ts)|RPMTRANS_FLAG_TEST));
75 ec = rpmcliImportPubkeys(ts, args);
77 /* XXX TODO: actually implement these... */
82 argerror(_("only one major mode may be specified"));