2 const char *__progname;
18 #include "rpmdb_internal.h" /* XXX for freeing dbiTags */
24 #define GETOPT_REBUILD 1003
25 #define GETOPT_RECOMPILE 1004
28 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
29 #include "signature.h"
36 MODE_QUERY = (1 << 0),
37 MODE_VERIFY = (1 << 3),
38 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
40 MODE_INSTALL = (1 << 1),
41 MODE_ERASE = (1 << 2),
42 #define MODES_IE (MODE_INSTALL | MODE_ERASE)
44 MODE_BUILD = (1 << 4),
45 MODE_REBUILD = (1 << 5),
46 MODE_RECOMPILE = (1 << 8),
47 MODE_TARBUILD = (1 << 11),
48 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
50 MODE_CHECKSIG = (1 << 6),
51 MODE_RESIGN = (1 << 7),
52 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
54 MODE_INITDB = (1 << 10),
55 MODE_REBUILDDB = (1 << 12),
56 MODE_VERIFYDB = (1 << 13),
57 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
63 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
64 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
65 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
66 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
68 /* 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 static void argerror(const char * desc)
128 fprintf(stderr, _("%s: %s\n"), __progname, desc);
132 static void printVersion(FILE * fp)
134 fprintf(fp, _("RPM version %s\n"), rpmEVR);
137 static void printBanner(FILE * fp)
139 fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
140 fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
143 static void printUsage(poptContext con, FILE * fp, int flags)
150 poptPrintHelp(con, fp, flags);
152 poptPrintUsage(con, fp, flags);
155 int main(int argc, char *argv[])
158 enum modes bigMode = MODE_UNKNOWN;
160 #if defined(IAM_RPMQV)
161 QVA_t qva = &rpmQVKArgs;
165 BTA_t ba = &rpmBTArgs;
169 struct rpmInstallArguments_s * ia = &rpmIArgs;
172 #if defined(IAM_RPMDB)
173 struct rpmDatabaseArguments_s * da = &rpmDBArgs;
176 #if defined(IAM_RPMK)
177 QVA_t ka = &rpmQVKArgs;
180 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
181 char * passPhrase = "";
196 #if HAVE_MCHECK_H && HAVE_MTRACE
197 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
199 setprogname(argv[0]); /* Retrofit glibc __progname */
201 /* XXX glibc churn sanity */
202 if (__progname == NULL) {
203 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
204 else __progname = argv[0];
207 /* Set the major mode based on argv[0] */
209 if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
210 if (!strcmp(__progname, "lt-rpmb")) bigMode = MODE_BUILD;
211 if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
212 if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
215 if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
216 if (!strcmp(__progname, "lt-rpmq")) bigMode = MODE_QUERY;
217 if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
218 if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
219 if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
222 if (!strcmp(__progname, "rpme")) bigMode = MODE_ERASE;
223 if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
224 if (!strcmp(__progname, "lt-rpmi")) bigMode = MODE_INSTALL;
225 if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
228 #if defined(IAM_RPMQV)
229 /* Jumpstart option from argv[0] if necessary. */
231 case MODE_QUERY: qva->qva_mode = 'q'; break;
232 case MODE_VERIFY: qva->qva_mode = 'V'; break;
233 case MODE_CHECKSIG: qva->qva_mode = 'K'; break;
234 case MODE_RESIGN: qva->qva_mode = 'R'; break;
250 #if defined(ENABLE_NLS)
251 /* set up the correct locale */
252 (void) setlocale(LC_ALL, "" );
254 bindtextdomain(PACKAGE, LOCALEDIR);
258 rpmSetVerbosity(RPMLOG_NOTICE); /* XXX silly use by showrc */
260 /* Make a first pass through the arguments, looking for --rcfile */
261 /* We need to handle that before dealing with the rest of the arguments. */
262 /* XXX popt argv definition should be fixed instead of casting... */
263 optCon = poptGetContext(__progname, argc, (const char **)argv, optionsTable, 0);
264 (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
265 #if RPM_USES_POPTREADDEFAULTCONFIG
266 (void) poptReadDefaultConfig(optCon, 1);
268 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
270 while ((arg = poptGetNextOpt(optCon)) > 0) {
271 optArg = poptGetOptArg(optCon);
275 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
281 fprintf(stderr, "%s: %s\n",
282 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
290 switch (ba->buildMode) {
291 case 'b': bigMode = MODE_BUILD; break;
292 case 't': bigMode = MODE_TARBUILD; break;
293 case 'B': bigMode = MODE_REBUILD; break;
294 case 'C': bigMode = MODE_RECOMPILE; break;
297 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
298 bigMode = MODE_BUILD;
300 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
301 bigMode = MODE_BUILD;
303 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
304 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
305 argerror("--buildroot may only be used during package builds");
307 #endif /* IAM_RPMBT */
310 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
312 if (bigMode != MODE_UNKNOWN)
313 argerror(_("only one major mode may be specified"));
315 bigMode = MODE_INITDB;
318 if (bigMode != MODE_UNKNOWN)
319 argerror(_("only one major mode may be specified"));
321 bigMode = MODE_REBUILDDB;
324 if (bigMode != MODE_UNKNOWN)
325 argerror(_("only one major mode may be specified"));
327 bigMode = MODE_VERIFYDB;
330 #endif /* IAM_RPMDB */
333 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
334 switch (qva->qva_mode) {
335 case 'q': bigMode = MODE_QUERY; break;
336 case 'V': bigMode = MODE_VERIFY; break;
339 if (qva->qva_sourceCount) {
340 if (qva->qva_sourceCount > 2)
341 argerror(_("one type of query/verify may be performed at a "
344 if (qva->qva_flags && (bigMode & ~MODES_QV))
345 argerror(_("unexpected query flags"));
347 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
348 argerror(_("unexpected query format"));
350 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
351 argerror(_("unexpected query source"));
353 #endif /* IAM_RPMQV */
356 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
357 { int iflags = (ia->installInterfaceFlags &
358 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL));
359 int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
362 argerror(_("only one major mode may be specified"));
364 bigMode = MODE_INSTALL;
366 bigMode = MODE_ERASE;
368 #endif /* IAM_RPMEIU */
371 if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
372 switch (ka->qva_mode) {
376 case RPMSIGN_IMPORT_PUBKEY:
377 case RPMSIGN_CHK_SIGNATURE:
378 bigMode = MODE_CHECKSIG;
381 case RPMSIGN_ADD_SIGNATURE:
382 case RPMSIGN_NEW_SIGNATURE:
383 case RPMSIGN_DEL_SIGNATURE:
384 bigMode = MODE_RESIGN;
385 ka->sign = (ka->qva_mode != RPMSIGN_DEL_SIGNATURE);
389 #endif /* IAM_RPMK */
391 #if defined(IAM_RPMEIU)
392 if (!( bigMode == MODE_INSTALL ) &&
393 (ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_OLDPACKAGE)))
394 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
395 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
396 argerror(_("files may only be relocated during package installation"));
398 if (ia->relocations && ia->prefix)
399 argerror(_("cannot use --prefix with --relocate or --excludepath"));
401 if (bigMode != MODE_INSTALL && ia->relocations)
402 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
404 if (bigMode != MODE_INSTALL && ia->prefix)
405 argerror(_("--prefix may only be used when installing new packages"));
407 if (ia->prefix && ia->prefix[0] != '/')
408 argerror(_("arguments to --prefix must begin with a /"));
410 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
411 argerror(_("--hash (-h) may only be specified during package "
414 if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
415 argerror(_("--percent may only be specified during package "
418 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
419 argerror(_("--replacepkgs may only be specified during package "
422 if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
423 argerror(_("--excludedocs may only be specified during package "
426 if (bigMode != MODE_INSTALL && ia->incldocs)
427 argerror(_("--includedocs may only be specified during package "
430 if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
431 argerror(_("only one of --excludedocs and --includedocs may be "
434 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
435 argerror(_("--ignorearch may only be specified during package "
438 if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
439 argerror(_("--ignoreos may only be specified during package "
442 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
443 (ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
444 argerror(_("--ignoresize may only be specified during package "
447 if ((ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
448 argerror(_("--allmatches may only be specified during package "
451 if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
452 argerror(_("--allfiles may only be specified during package "
455 if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
456 bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
457 argerror(_("--justdb may only be specified during package "
458 "installation and erasure"));
460 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
461 (ia->transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
462 argerror(_("script disabling options may only be specified during "
463 "package installation and erasure"));
465 if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
466 (ia->transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
467 argerror(_("trigger disabling options may only be specified during "
468 "package installation and erasure"));
470 if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
471 argerror(_("--nodeps may only be specified during package "
472 "building, rebuilding, recompilation, installation,"
473 "erasure, and verification"));
475 if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
476 argerror(_("--test may only be specified during package installation, "
477 "erasure, and building"));
478 #endif /* IAM_RPMEIU */
480 if (rpmcliRootDir && rpmcliRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
481 argerror(_("--root (-r) may only be specified during "
482 "installation, erasure, querying, and "
483 "database rebuilds"));
486 switch (urlIsURL(rpmcliRootDir)) {
488 if (bigMode & MODES_FOR_ROOT)
491 if (rpmcliRootDir[0] != '/')
492 argerror(_("arguments to --root (-r) must begin with a /"));
497 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
499 #if defined(IAM_RPMBT)
502 #if defined(IAM_RPMK)
507 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
508 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD)
514 if ((av = poptGetArgs(optCon)) == NULL) {
515 fprintf(stderr, _("no files to sign\n"));
519 if (stat(*av, &sb)) {
520 fprintf(stderr, _("cannot access file %s\n"), *av);
531 if (poptPeekArg(optCon)) {
532 int sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY);
537 #ifdef DYING /* XXX gpg can now be used for RSA signatures. */
538 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
539 !rpmDetectPGPVersion(NULL)) {
540 fprintf(stderr, _("pgp not found: "));
548 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
549 if (passPhrase == NULL) {
550 fprintf(stderr, _("Pass phrase check failed\n"));
554 fprintf(stderr, _("Pass phrase is good.\n"));
555 passPhrase = xstrdup(passPhrase);
559 _("Invalid %%_signature spec in macro file.\n"));
566 argerror(_("--sign may only be used during package building"));
569 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
570 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
572 #endif /* IAM_RPMBT || IAM_RPMK */
574 if (rpmcliPipeOutput) {
577 if (!(pipeChild = fork())) {
579 (void) dup2(p[0], STDIN_FILENO);
581 (void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
582 fprintf(stderr, _("exec failed\n"));
586 (void) dup2(p[1], STDOUT_FILENO);
591 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
595 ec = rpmtsInitDB(ts, 0644);
599 { rpmVSFlags vsflags = rpmExpandNumeric("%{_vsflags_rebuilddb}");
600 rpmVSFlags ovsflags = rpmtsSetVSFlags(ts, vsflags);
601 ec = rpmtsRebuildDB(ts);
602 vsflags = rpmtsSetVSFlags(ts, ovsflags);
605 ec = rpmtsVerifyDB(ts);
607 #endif /* IAM_RPMDB */
614 while (!rpmIsVerbose())
615 rpmIncreaseVerbosity();
617 if (!poptPeekArg(optCon))
618 argerror(_("no packages files given for rebuild"));
621 RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK;
622 if (bigMode == MODE_REBUILD) {
623 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
624 ba->buildAmount |= RPMBUILD_RMSOURCE;
625 ba->buildAmount |= RPMBUILD_RMSPEC;
626 ba->buildAmount |= RPMBUILD_CLEAN;
627 ba->buildAmount |= RPMBUILD_RMBUILD;
630 while ((pkg = poptGetArg(optCon))) {
631 const char * specFile = NULL;
634 ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
636 ba->rootdir = rpmcliRootDir;
637 ba->passPhrase = passPhrase;
638 ec = build(ts, specFile, ba, rpmcliRcfile);
640 ba->cookie = _free(ba->cookie);
641 specFile = _free(specFile);
652 while (!rpmIsVerbose())
653 rpmIncreaseVerbosity();
655 switch (ba->buildChar) {
657 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
659 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
660 ba->buildAmount |= RPMBUILD_CLEAN;
662 ba->buildAmount |= RPMBUILD_INSTALL;
663 ba->buildAmount |= RPMBUILD_CHECK;
664 if ((ba->buildChar == 'i') && ba->shortCircuit)
667 ba->buildAmount |= RPMBUILD_BUILD;
668 if ((ba->buildChar == 'c') && ba->shortCircuit)
671 ba->buildAmount |= RPMBUILD_PREP;
675 ba->buildAmount |= RPMBUILD_FILECHECK;
678 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
682 if (!poptPeekArg(optCon)) {
683 if (bigMode == MODE_BUILD)
684 argerror(_("no spec files given for build"));
686 argerror(_("no tar files given for build"));
689 while ((pkg = poptGetArg(optCon))) {
690 ba->rootdir = rpmcliRootDir;
691 ba->passPhrase = passPhrase;
693 ec = build(ts, pkg, ba, rpmcliRcfile);
697 (void) rpmReadConfigFiles(rpmcliRcfile, NULL);
700 #endif /* IAM_RPMBT */
704 if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
706 if (!poptPeekArg(optCon)) {
708 argerror(_("no packages given for erase"));
709 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
710 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
711 ec += rpmRollback(ts, ia, NULL);
713 ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
719 /* RPMTRANS_FLAG_KEEPOBSOLETE */
722 if (ia->transFlags & RPMTRANS_FLAG_NODOCS) {
724 } else if (rpmExpandNumeric("%{_excludedocs}"))
725 ia->transFlags |= RPMTRANS_FLAG_NODOCS;
728 if (ia->noDeps) ia->installInterfaceFlags |= INSTALL_NODEPS;
730 /* we've already ensured !(!ia->prefix && !ia->relocations) */
732 ia->relocations = xmalloc(2 * sizeof(*ia->relocations));
733 ia->relocations[0].oldPath = NULL; /* special case magic */
734 ia->relocations[0].newPath = ia->prefix;
735 ia->relocations[1].oldPath = NULL;
736 ia->relocations[1].newPath = NULL;
737 } else if (ia->relocations) {
738 ia->relocations = xrealloc(ia->relocations,
739 sizeof(*ia->relocations) * (ia->numRelocations + 1));
740 ia->relocations[ia->numRelocations].oldPath = NULL;
741 ia->relocations[ia->numRelocations].newPath = NULL;
744 if (!poptPeekArg(optCon)) {
746 argerror(_("no packages given for install"));
747 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
748 ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
749 ec += rpmRollback(ts, ia, NULL);
751 /* FIX: ia->relocations[0].newPath undefined */
752 ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon));
756 #endif /* IAM_RPMEIU */
760 if (!poptPeekArg(optCon)
761 && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
762 argerror(_("no arguments given for query"));
764 qva->qva_specQuery = rpmspecQuery;
765 ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
766 qva->qva_specQuery = NULL;
770 { rpmVerifyFlags verifyFlags = VERIFY_ALL;
772 verifyFlags &= ~qva->qva_flags;
773 qva->qva_flags = (rpmQueryFlags) verifyFlags;
775 if (!poptPeekArg(optCon)
776 && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
777 argerror(_("no arguments given for verify"));
778 ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
780 #endif /* IAM_RPMQV */
784 { rpmVerifyFlags verifyFlags =
785 (VERIFY_MD5|VERIFY_DIGEST|VERIFY_SIGNATURE);
787 verifyFlags &= ~ka->qva_flags;
788 ka->qva_flags = (rpmQueryFlags) verifyFlags;
791 if (!poptPeekArg(optCon))
792 argerror(_("no arguments given"));
793 ka->passPhrase = passPhrase;
794 ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
796 #endif /* IAM_RPMK */
798 #if !defined(IAM_RPMQV)
802 #if !defined(IAM_RPMK)
806 #if !defined(IAM_RPMDB)
811 #if !defined(IAM_RPMBT)
817 #if !defined(IAM_RPMEIU)
822 if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
823 printUsage(optCon, stdout, 0);
829 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
831 #endif /* IAM_RPMBT || IAM_RPMK */
835 optCon = poptFreeContext(optCon);
837 rpmFreeMacros(rpmCLIMacroContext);
841 (void) fclose(stdout);
842 (void) waitpid(pipeChild, &status, 0);
845 /* keeps memory leak checkers quiet */
846 rpmFreeFilesystems();
848 /* XXX FIXME: hide this in the api */
849 dbiTags = _free(dbiTags);
852 qva->qva_queryFormat = _free(qva->qva_queryFormat);
857 ba->buildRootOverride = _free(ba->buildRootOverride);
858 ba->targets = _free(ba->targets);
862 if (ia->relocations != NULL)
863 for (i = 0; i < ia->numRelocations; i++)
864 ia->relocations[i].oldPath = _free(ia->relocations[i].oldPath);
865 ia->relocations = _free(ia->relocations);
868 #if HAVE_MCHECK_H && HAVE_MTRACE
869 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
872 /* XXX don't overflow single byte exit status */
873 if (ec > 255) ec = 255;