2 const char *__progname;
6 #if defined(IAM_RPM) || defined(__LCLINT__)
23 #define GETOPT_REBUILD 1003
24 #define GETOPT_RECOMPILE 1004
27 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
28 #include "signature.h"
35 MODE_QUERY = (1 << 0),
36 MODE_VERIFY = (1 << 3),
37 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
39 MODE_INSTALL = (1 << 1),
40 MODE_ERASE = (1 << 2),
41 #define MODES_IE (MODE_INSTALL | MODE_ERASE)
43 MODE_BUILD = (1 << 4),
44 MODE_REBUILD = (1 << 5),
45 MODE_RECOMPILE = (1 << 8),
46 MODE_TARBUILD = (1 << 11),
47 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
49 MODE_CHECKSIG = (1 << 6),
50 MODE_RESIGN = (1 << 7),
51 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
53 MODE_INITDB = (1 << 10),
54 MODE_REBUILDDB = (1 << 12),
55 MODE_VERIFYDB = (1 << 13),
56 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
62 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
63 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
64 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
65 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
67 /* the structure describing the options we take and the defaults */
69 static struct poptOption optionsTable[] = {
72 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
73 N_("Query options (with -q or --query):"),
75 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
76 N_("Verify options (with -V or --verify):"),
79 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliQVSourcePoptTable, 0,
80 N_("Source options (with --query or --verify):"),
83 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliFtsPoptTable, 0,
84 N_("File tree walk options (with --ftswalk):"),
86 #endif /* IAM_RPMQV */
89 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
90 N_("Signature options:"),
95 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
96 N_("Database options:"),
98 #endif /* IAM_RPMDB */
101 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
102 N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
104 #endif /* IAM_RPMBT */
107 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
108 N_("Install/Upgrade/Erase options:"),
110 #endif /* IAM_RPMEIU */
112 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
113 N_("Common options for all rpm modes and executables:"),
122 /* MiNT cannot dynamically increase the stack. */
123 long _stksize = 64 * 1024L;
126 /*@exits@*/ static void argerror(const char * desc)
127 /*@globals __assert_program_name, fileSystem @*/
128 /*@modifies fileSystem @*/
130 fprintf(stderr, _("%s: %s\n"), __progname, desc);
134 static void printVersion(FILE * fp)
135 /*@globals rpmEVR, fileSystem @*/
136 /*@modifies *fp, fileSystem @*/
138 fprintf(fp, _("RPM version %s\n"), rpmEVR);
141 static void printBanner(FILE * fp)
142 /*@globals fileSystem @*/
143 /*@modifies *fp, fileSystem @*/
145 fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
146 fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
149 static void printUsage(poptContext con, FILE * fp, int flags)
150 /*@globals rpmEVR, fileSystem, internalState @*/
151 /*@modifies *fp, fileSystem, internalState @*/
158 poptPrintHelp(con, fp, flags);
160 poptPrintUsage(con, fp, flags);
163 /*@-bounds@*/ /* LCL: segfault */
164 /*@-mods@*/ /* FIX: shrug */
165 #if !defined(__GLIBC__) && !defined(__LCLINT__)
166 int main(int argc, const char ** argv, /*@unused@*/ char ** envp)
168 int main(int argc, const char ** argv)
170 /*@globals __assert_program_name, rpmEVR, RPMVERSION,
171 rpmGlobalMacroContext, rpmCLIMacroContext,
172 h_errno, fileSystem, internalState@*/
173 /*@modifies __assert_program_name,
174 fileSystem, internalState@*/
177 enum modes bigMode = MODE_UNKNOWN;
179 #if defined(IAM_RPMQV)
180 QVA_t qva = &rpmQVKArgs;
184 BTA_t ba = &rpmBTArgs;
188 struct rpmInstallArguments_s * ia = &rpmIArgs;
191 #if defined(IAM_RPMDB)
192 struct rpmDatabaseArguments_s * da = &rpmDBArgs;
195 #if defined(IAM_RPMK)
196 QVA_t ka = &rpmQVKArgs;
199 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
200 char * passPhrase = "";
215 #if HAVE_MCHECK_H && HAVE_MTRACE
217 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
220 setprogname(argv[0]); /* Retrofit glibc __progname */
222 #if !defined(__GLIBC__) && !defined(__LCLINT__)
226 /* XXX glibc churn sanity */
227 if (__progname == NULL) {
228 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
229 else __progname = argv[0];
232 /* Set the major mode based on argv[0] */
235 if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
236 if (!strcmp(__progname, "lt-rpmb")) bigMode = MODE_BUILD;
237 if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
238 if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
241 if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
242 if (!strcmp(__progname, "lt-rpmq")) bigMode = MODE_QUERY;
243 if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
244 if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
245 if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
248 if (!strcmp(__progname, "rpme")) bigMode = MODE_ERASE;
249 if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
250 if (!strcmp(__progname, "lt-rpmi")) bigMode = MODE_INSTALL;
251 if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
255 #if defined(IAM_RPMQV)
256 /* Jumpstart option from argv[0] if necessary. */
258 case MODE_QUERY: qva->qva_mode = 'q'; break;
259 case MODE_VERIFY: qva->qva_mode = 'V'; break;
260 case MODE_CHECKSIG: qva->qva_mode = 'K'; break;
261 case MODE_RESIGN: qva->qva_mode = 'R'; break;
277 #if defined(ENABLE_NLS)
278 /* set up the correct locale */
279 (void) setlocale(LC_ALL, "" );
282 #define LOCALEDIR "/usr/share/locale"
284 bindtextdomain(PACKAGE, LOCALEDIR);
288 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
290 /* Make a first pass through the arguments, looking for --rcfile */
291 /* We need to handle that before dealing with the rest of the arguments. */
292 /*@-nullpass -temptrans@*/
293 optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
294 /*@=nullpass =temptrans@*/
295 (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
296 (void) poptReadDefaultConfig(optCon, 1);
297 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
299 while ((arg = poptGetNextOpt(optCon)) > 0) {
300 optArg = poptGetOptArg(optCon);
304 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
310 fprintf(stderr, "%s: %s\n",
311 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
319 switch (ba->buildMode) {
320 case 'b': bigMode = MODE_BUILD; break;
321 case 't': bigMode = MODE_TARBUILD; break;
322 case 'B': bigMode = MODE_REBUILD; break;
323 case 'C': bigMode = MODE_RECOMPILE; break;
326 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
327 bigMode = MODE_BUILD;
329 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
330 bigMode = MODE_BUILD;
332 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
333 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
334 argerror("--buildroot may only be used during package builds");
336 #endif /* IAM_RPMBT */
339 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
341 if (bigMode != MODE_UNKNOWN)
342 argerror(_("only one major mode may be specified"));
344 bigMode = MODE_INITDB;
347 if (bigMode != MODE_UNKNOWN)
348 argerror(_("only one major mode may be specified"));
350 bigMode = MODE_REBUILDDB;
353 if (bigMode != MODE_UNKNOWN)
354 argerror(_("only one major mode may be specified"));
356 bigMode = MODE_VERIFYDB;
359 #endif /* IAM_RPMDB */
362 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
363 switch (qva->qva_mode) {
364 case 'q': bigMode = MODE_QUERY; break;
365 case 'V': bigMode = MODE_VERIFY; break;
368 if (qva->qva_sourceCount) {
369 if (qva->qva_sourceCount > 2)
370 argerror(_("one type of query/verify may be performed at a "
373 if (qva->qva_flags && (bigMode & ~MODES_QV))
374 argerror(_("unexpected query flags"));
376 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
377 argerror(_("unexpected query format"));
379 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
380 argerror(_("unexpected query source"));
382 #endif /* IAM_RPMQV */
385 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
386 { int iflags = (ia->installInterfaceFlags &
387 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL));
388 int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
391 argerror(_("only one major mode may be specified"));
393 bigMode = MODE_INSTALL;
395 bigMode = MODE_ERASE;
397 #endif /* IAM_RPMEIU */
400 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
401 switch (ka->qva_mode) {
405 case RPMSIGN_IMPORT_PUBKEY:
406 case RPMSIGN_CHK_SIGNATURE:
407 bigMode = MODE_CHECKSIG;
410 case RPMSIGN_ADD_SIGNATURE:
411 case RPMSIGN_NEW_SIGNATURE:
412 case RPMSIGN_DEL_SIGNATURE:
413 bigMode = MODE_RESIGN;
414 ka->sign = (ka->qva_mode != RPMSIGN_DEL_SIGNATURE);
418 #endif /* IAM_RPMK */
420 #if defined(IAM_RPMEIU)
421 if (!( bigMode == MODE_INSTALL ) &&
422 (ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_OLDPACKAGE)))
423 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
424 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
425 argerror(_("files may only be relocated during package installation"));
427 if (ia->relocations && ia->prefix)
428 argerror(_("cannot use --prefix with --relocate or --excludepath"));
430 if (bigMode != MODE_INSTALL && ia->relocations)
431 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
433 if (bigMode != MODE_INSTALL && ia->prefix)
434 argerror(_("--prefix may only be used when installing new packages"));
436 if (ia->prefix && ia->prefix[0] != '/')
437 argerror(_("arguments to --prefix must begin with a /"));
439 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
440 argerror(_("--hash (-h) may only be specified during package "
443 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
444 argerror(_("--percent may only be specified during package "
447 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
448 argerror(_("--replacepkgs may only be specified during package "
451 if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
452 argerror(_("--excludedocs may only be specified during package "
455 if (bigMode != MODE_INSTALL && ia->incldocs)
456 argerror(_("--includedocs may only be specified during package "
459 if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
460 argerror(_("only one of --excludedocs and --includedocs may be "
463 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
464 argerror(_("--ignorearch may only be specified during package "
467 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
468 argerror(_("--ignoreos may only be specified during package "
471 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
472 (ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
473 argerror(_("--ignoresize may only be specified during package "
476 if ((ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
477 argerror(_("--allmatches may only be specified during package "
480 if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
481 argerror(_("--allfiles may only be specified during package "
484 if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
485 bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
486 argerror(_("--justdb may only be specified during package "
487 "installation and erasure"));
489 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
490 (ia->transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
491 argerror(_("script disabling options may only be specified during "
492 "package installation and erasure"));
494 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
495 (ia->transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
496 argerror(_("trigger disabling options may only be specified during "
497 "package installation and erasure"));
499 if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
500 argerror(_("--nodeps may only be specified during package "
501 "building, rebuilding, recompilation, installation,"
502 "erasure, and verification"));
504 if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
505 argerror(_("--test may only be specified during package installation, "
506 "erasure, and building"));
507 #endif /* IAM_RPMEIU */
509 if (rpmcliRootDir && rpmcliRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
510 argerror(_("--root (-r) may only be specified during "
511 "installation, erasure, querying, and "
512 "database rebuilds"));
515 switch (urlIsURL(rpmcliRootDir)) {
517 if (bigMode & MODES_FOR_ROOT)
521 if (rpmcliRootDir[0] != '/')
522 argerror(_("arguments to --root (-r) must begin with a /"));
527 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
529 #if defined(IAM_RPMBT)
532 #if defined(IAM_RPMK)
538 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
539 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD)
545 if ((av = poptGetArgs(optCon)) == NULL) {
546 fprintf(stderr, _("no files to sign\n"));
550 if (stat(*av, &sb)) {
551 fprintf(stderr, _("cannot access file %s\n"), *av);
562 if (poptPeekArg(optCon)) {
563 int sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY);
568 #ifdef DYING /* XXX gpg can now be used for RSA signatures. */
569 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
570 !rpmDetectPGPVersion(NULL)) {
571 fprintf(stderr, _("pgp not found: "));
579 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
580 if (passPhrase == NULL) {
581 fprintf(stderr, _("Pass phrase check failed\n"));
585 fprintf(stderr, _("Pass phrase is good.\n"));
586 passPhrase = xstrdup(passPhrase);
590 _("Invalid %%_signature spec in macro file.\n"));
593 /*@notreached@*/ break;
597 argerror(_("--sign may only be used during package building"));
600 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
601 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
604 #endif /* IAM_RPMBT || IAM_RPMK */
606 if (rpmcliPipeOutput) {
609 if (!(pipeChild = fork())) {
611 (void) dup2(p[0], STDIN_FILENO);
613 (void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
614 fprintf(stderr, _("exec failed\n"));
618 (void) dup2(p[1], STDOUT_FILENO);
623 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
627 ec = rpmtsInitDB(ts, 0644);
631 { rpmVSFlags vsflags = rpmExpandNumeric("%{_vsflags_rebuilddb}");
632 rpmVSFlags ovsflags = rpmtsSetVSFlags(ts, vsflags);
633 ec = rpmtsRebuildDB(ts);
634 vsflags = rpmtsSetVSFlags(ts, ovsflags);
637 ec = rpmtsVerifyDB(ts);
639 #endif /* IAM_RPMDB */
646 while (!rpmIsVerbose())
647 rpmIncreaseVerbosity();
649 if (!poptPeekArg(optCon))
650 argerror(_("no packages files given for rebuild"));
653 RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK;
654 if (bigMode == MODE_REBUILD) {
655 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
656 ba->buildAmount |= RPMBUILD_RMSOURCE;
657 ba->buildAmount |= RPMBUILD_RMSPEC;
658 ba->buildAmount |= RPMBUILD_CLEAN;
659 ba->buildAmount |= RPMBUILD_RMBUILD;
662 while ((pkg = poptGetArg(optCon))) {
663 const char * specFile = NULL;
666 ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
668 ba->rootdir = rpmcliRootDir;
669 ba->passPhrase = passPhrase;
670 ec = build(ts, specFile, ba, rpmcliRcfile);
672 ba->cookie = _free(ba->cookie);
673 specFile = _free(specFile);
676 /*@loopbreak@*/ break;
684 while (!rpmIsVerbose())
685 rpmIncreaseVerbosity();
687 switch (ba->buildChar) {
689 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
692 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
693 ba->buildAmount |= RPMBUILD_CLEAN;
696 ba->buildAmount |= RPMBUILD_INSTALL;
697 ba->buildAmount |= RPMBUILD_CHECK;
698 if ((ba->buildChar == 'i') && ba->shortCircuit)
699 /*@innerbreak@*/ break;
702 ba->buildAmount |= RPMBUILD_BUILD;
703 if ((ba->buildChar == 'c') && ba->shortCircuit)
704 /*@innerbreak@*/ break;
707 ba->buildAmount |= RPMBUILD_PREP;
708 /*@innerbreak@*/ break;
711 ba->buildAmount |= RPMBUILD_FILECHECK;
712 /*@innerbreak@*/ break;
714 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
715 /*@innerbreak@*/ break;
718 if (!poptPeekArg(optCon)) {
719 if (bigMode == MODE_BUILD)
720 argerror(_("no spec files given for build"));
722 argerror(_("no tar files given for build"));
725 while ((pkg = poptGetArg(optCon))) {
726 ba->rootdir = rpmcliRootDir;
727 ba->passPhrase = passPhrase;
729 ec = build(ts, pkg, ba, rpmcliRcfile);
731 /*@loopbreak@*/ break;
733 (void) rpmReadConfigFiles(rpmcliRcfile, NULL);
736 #endif /* IAM_RPMBT */
740 if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
742 if (!poptPeekArg(optCon)) {
744 argerror(_("no packages given for erase"));
745 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
746 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
747 ec += rpmRollback(ts, ia, NULL);
749 ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
755 /* RPMTRANS_FLAG_KEEPOBSOLETE */
758 if (ia->transFlags & RPMTRANS_FLAG_NODOCS) {
760 } else if (rpmExpandNumeric("%{_excludedocs}"))
761 ia->transFlags |= RPMTRANS_FLAG_NODOCS;
764 if (ia->noDeps) ia->installInterfaceFlags |= INSTALL_NODEPS;
766 /* we've already ensured !(!ia->prefix && !ia->relocations) */
769 ia->relocations = xmalloc(2 * sizeof(*ia->relocations));
770 ia->relocations[0].oldPath = NULL; /* special case magic */
771 ia->relocations[0].newPath = ia->prefix;
772 ia->relocations[1].oldPath = NULL;
773 ia->relocations[1].newPath = NULL;
774 } else if (ia->relocations) {
775 ia->relocations = xrealloc(ia->relocations,
776 sizeof(*ia->relocations) * (ia->numRelocations + 1));
777 ia->relocations[ia->numRelocations].oldPath = NULL;
778 ia->relocations[ia->numRelocations].newPath = NULL;
782 if (!poptPeekArg(optCon)) {
784 argerror(_("no packages given for install"));
785 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
786 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
787 /*@i@*/ ec += rpmRollback(ts, ia, NULL);
789 /*@-compdef -compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */
790 ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon));
791 /*@=compdef =compmempass@*/
795 #endif /* IAM_RPMEIU */
799 if (!poptPeekArg(optCon)
800 && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
801 argerror(_("no arguments given for query"));
803 qva->qva_specQuery = rpmspecQuery;
804 ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
805 qva->qva_specQuery = NULL;
809 { rpmVerifyFlags verifyFlags = VERIFY_ALL;
811 verifyFlags &= ~qva->qva_flags;
812 qva->qva_flags = (rpmQueryFlags) verifyFlags;
814 if (!poptPeekArg(optCon)
815 && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
816 argerror(_("no arguments given for verify"));
817 ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
819 #endif /* IAM_RPMQV */
823 { rpmVerifyFlags verifyFlags =
824 (VERIFY_MD5|VERIFY_DIGEST|VERIFY_SIGNATURE);
826 verifyFlags &= ~ka->qva_flags;
827 ka->qva_flags = (rpmQueryFlags) verifyFlags;
830 if (!poptPeekArg(optCon))
831 argerror(_("no arguments given"));
832 ka->passPhrase = passPhrase;
833 ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
835 #endif /* IAM_RPMK */
837 #if !defined(IAM_RPMQV)
841 #if !defined(IAM_RPMK)
845 #if !defined(IAM_RPMDB)
850 #if !defined(IAM_RPMBT)
856 #if !defined(IAM_RPMEIU)
861 if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
862 printUsage(optCon, stdout, 0);
868 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
870 #endif /* IAM_RPMBT || IAM_RPMK */
874 optCon = poptFreeContext(optCon);
876 /*@i@*/ rpmFreeMacros(rpmCLIMacroContext);
880 (void) fclose(stdout);
881 (void) waitpid(pipeChild, &status, 0);
884 /* keeps memory leak checkers quiet */
886 /*@i@*/ urlFreeCache();
888 dbiTags = _free(dbiTags);
891 qva->qva_queryFormat = _free(qva->qva_queryFormat);
896 ba->buildRootOverride = _free(ba->buildRootOverride);
897 ba->targets = _free(ba->targets);
901 if (ia->relocations != NULL)
902 for (i = 0; i < ia->numRelocations; i++)
903 ia->relocations[i].oldPath = _free(ia->relocations[i].oldPath);
904 ia->relocations = _free(ia->relocations);
907 #if HAVE_MCHECK_H && HAVE_MTRACE
909 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
913 /* XXX don't overflow single byte exit status */
914 if (ec > 255) ec = 255;