5 #if defined(IAM_RPM) || defined(__LCLINT__)
22 #define GETOPT_REBUILD 1003
23 #define GETOPT_RECOMPILE 1004
26 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
27 #include "signature.h"
34 MODE_QUERY = (1 << 0),
35 MODE_VERIFY = (1 << 3),
36 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
38 MODE_INSTALL = (1 << 1),
39 MODE_ERASE = (1 << 2),
40 #define MODES_IE (MODE_INSTALL | MODE_ERASE)
42 MODE_BUILD = (1 << 4),
43 MODE_REBUILD = (1 << 5),
44 MODE_RECOMPILE = (1 << 8),
45 MODE_TARBUILD = (1 << 11),
46 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
48 MODE_CHECKSIG = (1 << 6),
49 MODE_RESIGN = (1 << 7),
50 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
52 MODE_INITDB = (1 << 10),
53 MODE_REBUILDDB = (1 << 12),
54 MODE_VERIFYDB = (1 << 13),
55 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
61 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
62 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
63 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
64 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
66 /* the structure describing the options we take and the defaults */
68 static struct poptOption optionsTable[] = {
71 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
72 N_("Query options (with -q or --query):"),
74 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
75 N_("Verify options (with -V or --verify):"),
77 #endif /* IAM_RPMQV */
80 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
81 N_("Signature options:"),
86 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
87 N_("Database options:"),
89 #endif /* IAM_RPMDB */
92 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
93 N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
95 #endif /* IAM_RPMBT */
98 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
99 N_("Install/Upgrade/Erase options:"),
101 #endif /* IAM_RPMEIU */
103 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
104 N_("Common options for all rpm modes:"),
113 /* MiNT cannot dynamically increase the stack. */
114 long _stksize = 64 * 1024L;
117 /*@exits@*/ static void argerror(const char * desc)
118 /*@globals __assert_program_name, fileSystem @*/
119 /*@modifies fileSystem @*/
121 fprintf(stderr, _("%s: %s\n"), __progname, desc);
125 static void printVersion(FILE * fp)
126 /*@globals rpmEVR, fileSystem @*/
127 /*@modifies *fp, fileSystem @*/
129 fprintf(fp, _("RPM version %s\n"), rpmEVR);
132 static void printBanner(FILE * fp)
133 /*@globals fileSystem @*/
134 /*@modifies *fp, fileSystem @*/
136 fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
137 fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
140 static void printUsage(poptContext con, FILE * fp, int flags)
141 /*@globals rpmEVR, fileSystem, internalState @*/
142 /*@modifies *fp, fileSystem, internalState @*/
149 poptPrintHelp(con, fp, flags);
151 poptPrintUsage(con, fp, flags);
154 /*@-bounds@*/ /* LCL: segfault */
155 /*@-mods@*/ /* FIX: shrug */
156 #if !defined(__GLIBC__) && !defined(__LCLINT__)
157 int main(int argc, const char ** argv, /*@unused@*/ char ** envp)
159 int main(int argc, const char ** argv)
161 /*@globals __assert_program_name, rpmEVR, RPMVERSION,
162 rpmGlobalMacroContext, rpmCLIMacroContext,
163 fileSystem, internalState@*/
164 /*@modifies __assert_program_name,
165 fileSystem, internalState@*/
168 enum modes bigMode = MODE_UNKNOWN;
170 #if defined(IAM_RPMQV)
171 QVA_t qva = &rpmQVKArgs;
175 BTA_t ba = &rpmBTArgs;
179 struct rpmInstallArguments_s * ia = &rpmIArgs;
182 #if defined(IAM_RPMDB)
183 struct rpmDatabaseArguments_s * da = &rpmDBArgs;
186 #if defined(IAM_RPMK)
187 QVA_t ka = &rpmQVKArgs;
190 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
191 char * passPhrase = "";
206 #if HAVE_MCHECK_H && HAVE_MTRACE
208 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
211 setprogname(argv[0]); /* Retrofit glibc __progname */
213 #if !defined(__GLIBC__) && !defined(__LCLINT__)
217 /* XXX glibc churn sanity */
218 if (__progname == NULL) {
219 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
220 else __progname = argv[0];
223 /* Set the major mode based on argv[0] */
226 if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
227 if (!strcmp(__progname, "lt-rpmb")) bigMode = MODE_BUILD;
228 if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
229 if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
232 if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
233 if (!strcmp(__progname, "lt-rpmq")) bigMode = MODE_QUERY;
234 if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
235 if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
236 if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
239 if (!strcmp(__progname, "rpme")) bigMode = MODE_ERASE;
240 if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
241 if (!strcmp(__progname, "lt-rpmi")) bigMode = MODE_INSTALL;
242 if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
246 #if defined(IAM_RPMQV)
247 /* Jumpstart option from argv[0] if necessary. */
249 case MODE_QUERY: qva->qva_mode = 'q'; break;
250 case MODE_VERIFY: qva->qva_mode = 'V'; break;
251 case MODE_CHECKSIG: qva->qva_mode = 'K'; break;
252 case MODE_RESIGN: qva->qva_mode = 'R'; break;
267 /* XXX Eliminate query linkage loop */
268 /*@-type@*/ /* FIX: casts? */
269 parseSpecVec = parseSpec;
270 freeSpecVec = freeSpec;
274 #if defined(ENABLE_NLS)
275 /* set up the correct locale */
276 (void) setlocale(LC_ALL, "" );
279 #define LOCALEDIR "/usr/share/locale"
281 bindtextdomain(PACKAGE, LOCALEDIR);
285 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
287 /* Make a first pass through the arguments, looking for --rcfile */
288 /* We need to handle that before dealing with the rest of the arguments. */
289 /*@-nullpass -temptrans@*/
290 optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
291 /*@=nullpass =temptrans@*/
292 (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
293 (void) poptReadDefaultConfig(optCon, 1);
294 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
296 while ((arg = poptGetNextOpt(optCon)) > 0) {
297 optArg = poptGetOptArg(optCon);
301 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
307 fprintf(stderr, "%s: %s\n",
308 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
316 switch (ba->buildMode) {
317 case 'b': bigMode = MODE_BUILD; break;
318 case 't': bigMode = MODE_TARBUILD; break;
319 case 'B': bigMode = MODE_REBUILD; break;
320 case 'C': bigMode = MODE_RECOMPILE; break;
323 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
324 bigMode = MODE_BUILD;
326 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
327 bigMode = MODE_BUILD;
329 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
330 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
331 argerror("--buildroot may only be used during package builds");
333 #endif /* IAM_RPMBT */
336 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
338 if (bigMode != MODE_UNKNOWN)
339 argerror(_("only one major mode may be specified"));
341 bigMode = MODE_INITDB;
344 if (bigMode != MODE_UNKNOWN)
345 argerror(_("only one major mode may be specified"));
347 bigMode = MODE_REBUILDDB;
350 if (bigMode != MODE_UNKNOWN)
351 argerror(_("only one major mode may be specified"));
353 bigMode = MODE_VERIFYDB;
356 #endif /* IAM_RPMDB */
359 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
360 switch (qva->qva_mode) {
361 case 'q': bigMode = MODE_QUERY; break;
362 case 'V': bigMode = MODE_VERIFY; break;
365 if (qva->qva_sourceCount) {
366 if (qva->qva_sourceCount > 2)
367 argerror(_("one type of query/verify may be performed at a "
370 if (qva->qva_flags && (bigMode & ~MODES_QV))
371 argerror(_("unexpected query flags"));
373 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
374 argerror(_("unexpected query format"));
376 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
377 argerror(_("unexpected query source"));
379 #endif /* IAM_RPMQV */
382 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
383 { int iflags = (ia->installInterfaceFlags &
384 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL));
385 int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
388 argerror(_("only one major mode may be specified"));
390 bigMode = MODE_INSTALL;
392 bigMode = MODE_ERASE;
394 #endif /* IAM_RPMEIU */
397 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
398 switch (ka->qva_mode) {
402 case RPMSIGN_IMPORT_PUBKEY:
403 case RPMSIGN_CHK_SIGNATURE:
404 bigMode = MODE_CHECKSIG;
407 case RPMSIGN_ADD_SIGNATURE:
408 case RPMSIGN_NEW_SIGNATURE:
409 bigMode = MODE_RESIGN;
414 #endif /* IAM_RPMK */
416 #if defined(IAM_RPMEIU)
417 if (!( bigMode == MODE_INSTALL ) &&
418 (ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE)))
419 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
420 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
421 argerror(_("files may only be relocated during package installation"));
423 if (ia->relocations && ia->prefix)
424 argerror(_("cannot use --prefix with --relocate or --excludepath"));
426 if (bigMode != MODE_INSTALL && ia->relocations)
427 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
429 if (bigMode != MODE_INSTALL && ia->prefix)
430 argerror(_("--prefix may only be used when installing new packages"));
432 if (ia->prefix && ia->prefix[0] != '/')
433 argerror(_("arguments to --prefix must begin with a /"));
435 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
436 argerror(_("--hash (-h) may only be specified during package "
439 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
440 argerror(_("--percent may only be specified during package "
443 if (bigMode != MODE_INSTALL &&
444 (ia->probFilter & (RPMPROB_FILTER_REPLACEOLDFILES|RPMPROB_FILTER_REPLACENEWFILES)))
445 argerror(_("--replacefiles may only be specified during package "
448 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
449 argerror(_("--replacepkgs may only be specified during package "
452 if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
453 argerror(_("--excludedocs may only be specified during package "
456 if (bigMode != MODE_INSTALL && ia->incldocs)
457 argerror(_("--includedocs may only be specified during package "
460 if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
461 argerror(_("only one of --excludedocs and --includedocs may be "
464 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
465 argerror(_("--ignorearch may only be specified during package "
468 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
469 argerror(_("--ignoreos may only be specified during package "
472 if (bigMode != MODE_INSTALL &&
473 (ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
474 argerror(_("--ignoresize may only be specified during package "
477 if ((ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
478 argerror(_("--allmatches may only be specified during package "
481 if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
482 argerror(_("--allfiles may only be specified during package "
485 if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
486 bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
487 argerror(_("--justdb may only be specified during package "
488 "installation and erasure"));
490 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
491 (ia->transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
492 argerror(_("script disabling options may only be specified during "
493 "package installation and erasure"));
495 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
496 (ia->transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
497 argerror(_("trigger disabling options may only be specified during "
498 "package installation and erasure"));
500 if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
501 argerror(_("--nodeps may only be specified during package "
502 "building, rebuilding, recompilation, installation,"
503 "erasure, and verification"));
505 if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
506 argerror(_("--test may only be specified during package installation, "
507 "erasure, and building"));
508 #endif /* IAM_RPMEIU */
510 if (rpmcliRootDir && rpmcliRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
511 argerror(_("--root (-r) may only be specified during "
512 "installation, erasure, querying, and "
513 "database rebuilds"));
516 switch (urlIsURL(rpmcliRootDir)) {
518 if (bigMode & MODES_FOR_ROOT)
522 if (rpmcliRootDir[0] != '/')
523 argerror(_("arguments to --root (-r) must begin with a /"));
528 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
530 #if defined(IAM_RPMBT)
533 #if defined(IAM_RPMK)
539 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
540 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD)
546 if ((av = poptGetArgs(optCon)) == NULL) {
547 fprintf(stderr, _("no files to sign\n"));
551 if (stat(*av, &sb)) {
552 fprintf(stderr, _("cannot access file %s\n"), *av);
563 if (poptPeekArg(optCon)) {
565 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
569 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
570 !rpmDetectPGPVersion(NULL)) {
571 fprintf(stderr, _("pgp not found: "));
576 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
577 if (passPhrase == NULL) {
578 fprintf(stderr, _("Pass phrase check failed\n"));
582 fprintf(stderr, _("Pass phrase is good.\n"));
583 passPhrase = xstrdup(passPhrase);
587 _("Invalid %%_signature spec in macro file.\n"));
590 /*@notreached@*/ break;
594 argerror(_("--sign may only be used during package building"));
597 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
598 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
601 #endif /* IAM_RPMBT || IAM_RPMK */
603 if (rpmcliPipeOutput) {
606 if (!(pipeChild = fork())) {
608 (void) dup2(p[0], STDIN_FILENO);
610 (void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
611 fprintf(stderr, _("exec failed\n"));
615 (void) dup2(p[1], STDOUT_FILENO);
620 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
624 (void) rpmtsInitDB(ts, 0644);
628 { rpmVSFlags vsflags = rpmExpandNumeric("%{_vsflags_rebuilddb}");
629 rpmVSFlags ovsflags = rpmtsSetVSFlags(ts, vsflags);
630 ec = rpmtsRebuildDB(ts);
631 vsflags = rpmtsSetVSFlags(ts, ovsflags);
634 ec = rpmtsVerifyDB(ts);
636 #endif /* IAM_RPMDB */
643 while (!rpmIsVerbose())
644 rpmIncreaseVerbosity();
646 if (!poptPeekArg(optCon))
647 argerror(_("no packages files given for rebuild"));
650 RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK;
651 if (bigMode == MODE_REBUILD) {
652 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
653 ba->buildAmount |= RPMBUILD_RMSOURCE;
654 ba->buildAmount |= RPMBUILD_RMSPEC;
655 ba->buildAmount |= RPMBUILD_CLEAN;
656 ba->buildAmount |= RPMBUILD_RMBUILD;
659 while ((pkg = poptGetArg(optCon))) {
660 const char * specFile = NULL;
663 ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
665 ba->rootdir = rpmcliRootDir;
666 ba->passPhrase = passPhrase;
667 ec = build(ts, specFile, ba, rpmcliRcfile);
669 ba->cookie = _free(ba->cookie);
670 specFile = _free(specFile);
673 /*@loopbreak@*/ break;
681 while (!rpmIsVerbose())
682 rpmIncreaseVerbosity();
684 switch (ba->buildChar) {
686 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
689 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
690 ba->buildAmount |= RPMBUILD_CLEAN;
693 ba->buildAmount |= RPMBUILD_INSTALL;
694 ba->buildAmount |= RPMBUILD_CHECK;
695 if ((ba->buildChar == 'i') && ba->shortCircuit)
696 /*@innerbreak@*/ break;
699 ba->buildAmount |= RPMBUILD_BUILD;
700 if ((ba->buildChar == 'c') && ba->shortCircuit)
701 /*@innerbreak@*/ break;
704 ba->buildAmount |= RPMBUILD_PREP;
705 /*@innerbreak@*/ break;
708 ba->buildAmount |= RPMBUILD_FILECHECK;
709 /*@innerbreak@*/ break;
711 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
712 /*@innerbreak@*/ break;
715 if (!poptPeekArg(optCon)) {
716 if (bigMode == MODE_BUILD)
717 argerror(_("no spec files given for build"));
719 argerror(_("no tar files given for build"));
722 while ((pkg = poptGetArg(optCon))) {
723 ba->rootdir = rpmcliRootDir;
724 ba->passPhrase = passPhrase;
726 ec = build(ts, pkg, ba, rpmcliRcfile);
728 /*@loopbreak@*/ break;
730 (void) rpmReadConfigFiles(rpmcliRcfile, NULL);
733 #endif /* IAM_RPMBT */
737 if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
739 if (!poptPeekArg(optCon)) {
741 argerror(_("no packages given for erase"));
742 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
743 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
744 ec += rpmRollback(ts, ia, NULL);
746 ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
752 /* RPMTRANS_FLAG_KEEPOBSOLETE */
755 if (ia->transFlags & RPMTRANS_FLAG_NODOCS) {
757 } else if (rpmExpandNumeric("%{_excludedocs}"))
758 ia->transFlags |= RPMTRANS_FLAG_NODOCS;
761 if (ia->noDeps) ia->installInterfaceFlags |= INSTALL_NODEPS;
763 /* we've already ensured !(!ia->prefix && !ia->relocations) */
766 ia->relocations = xmalloc(2 * sizeof(*ia->relocations));
767 ia->relocations[0].oldPath = NULL; /* special case magic */
768 ia->relocations[0].newPath = ia->prefix;
769 ia->relocations[1].oldPath = NULL;
770 ia->relocations[1].newPath = NULL;
771 } else if (ia->relocations) {
772 ia->relocations = xrealloc(ia->relocations,
773 sizeof(*ia->relocations) * (ia->numRelocations + 1));
774 ia->relocations[ia->numRelocations].oldPath = NULL;
775 ia->relocations[ia->numRelocations].newPath = NULL;
779 if (!poptPeekArg(optCon)) {
781 argerror(_("no packages given for install"));
782 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
783 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
784 /*@i@*/ ec += rpmRollback(ts, ia, NULL);
786 /*@-compdef -compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */
787 ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon));
788 /*@=compdef =compmempass@*/
792 #endif /* IAM_RPMEIU */
796 if (qva->qva_source != RPMQV_ALL && !poptPeekArg(optCon))
797 argerror(_("no arguments given for query"));
798 ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
799 /* XXX don't overflow single byte exit status */
800 if (ec > 255) ec = 255;
804 { rpmVerifyFlags verifyFlags = VERIFY_ALL;
806 verifyFlags &= ~qva->qva_flags;
807 qva->qva_flags = (rpmQueryFlags) verifyFlags;
809 if (qva->qva_source != RPMQV_ALL && !poptPeekArg(optCon))
810 argerror(_("no arguments given for verify"));
811 ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
812 /* XXX don't overflow single byte exit status */
813 if (ec > 255) ec = 255;
815 #endif /* IAM_RPMQV */
819 { rpmVerifyFlags verifyFlags =
820 (VERIFY_MD5|VERIFY_DIGEST|VERIFY_SIGNATURE);
822 verifyFlags &= ~ka->qva_flags;
823 ka->qva_flags = (rpmQueryFlags) verifyFlags;
826 if (!poptPeekArg(optCon))
827 argerror(_("no arguments given"));
828 ka->passPhrase = passPhrase;
829 ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
830 /* XXX don't overflow single byte exit status */
831 if (ec > 255) ec = 255;
833 #endif /* IAM_RPMK */
835 #if !defined(IAM_RPMQV)
839 #if !defined(IAM_RPMK)
843 #if !defined(IAM_RPMDB)
848 #if !defined(IAM_RPMBT)
854 #if !defined(IAM_RPMEIU)
859 if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose())
860 printUsage(optCon, stdout, 0);
864 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
866 #endif /* IAM_RPMBT || IAM_RPMK */
870 optCon = poptFreeContext(optCon);
872 /*@i@*/ rpmFreeMacros(rpmCLIMacroContext);
876 (void) fclose(stdout);
877 (void) waitpid(pipeChild, &status, 0);
880 /* keeps memory leak checkers quiet */
882 /*@i@*/ urlFreeCache();
884 dbiTags = _free(dbiTags);
887 qva->qva_queryFormat = _free(qva->qva_queryFormat);
892 ba->buildRootOverride = _free(ba->buildRootOverride);
893 ba->targets = _free(ba->targets);
897 if (ia->relocations != NULL)
898 for (i = 0; i < ia->numRelocations; i++)
899 ia->relocations[i].oldPath = _free(ia->relocations[i].oldPath);
900 ia->relocations = _free(ia->relocations);
903 #if HAVE_MCHECK_H && HAVE_MTRACE
905 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */