Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

rpmqv.c

Go to the documentation of this file.
00001 #include "system.h"
00002 
00003 #define _AUTOHELP
00004 
00005 #if defined(IAM_RPM) || defined(__LCLINT__)
00006 #define IAM_RPMBT
00007 #define IAM_RPMDB
00008 #define IAM_RPMEIU
00009 #define IAM_RPMQV
00010 #define IAM_RPMK
00011 #endif
00012 
00013 #include <rpmcli.h>
00014 #include <rpmbuild.h>
00015 
00016 #define POPT_NODEPS             1025
00017 #define POPT_FORCE              1026
00018 #define POPT_NOMD5              1027
00019 #define POPT_NOSCRIPTS          1028
00020 
00021 #ifdef  IAM_RPMBT
00022 #include "build.h"
00023 #define GETOPT_REBUILD          1003
00024 #define GETOPT_RECOMPILE        1004
00025 #endif
00026 
00027 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
00028 #include "signature.h"
00029 #endif
00030 
00031 #include "debug.h"
00032 
00033 #define GETOPT_DBPATH           1010
00034 #define GETOPT_SHOWRC           1018
00035 #define GETOPT_DEFINEMACRO      1020
00036 #define GETOPT_EVALMACRO        1021
00037 #ifdef  NOTYET
00038 #define GETOPT_RCFILE           1022
00039 #endif
00040 
00041 enum modes {
00042 
00043     MODE_QUERY          = (1 <<  0),
00044     MODE_VERIFY         = (1 <<  3),
00045     MODE_QUERYTAGS      = (1 <<  9),
00046 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
00047 
00048     MODE_INSTALL        = (1 <<  1),
00049     MODE_ERASE          = (1 <<  2),
00050     MODE_ROLLBACK       = (1 << 14),
00051 #define MODES_IE (MODE_INSTALL | MODE_ERASE | MODE_ROLLBACK)
00052 
00053     MODE_BUILD          = (1 <<  4),
00054     MODE_REBUILD        = (1 <<  5),
00055     MODE_RECOMPILE      = (1 <<  8),
00056     MODE_TARBUILD       = (1 << 11),
00057 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
00058 
00059     MODE_CHECKSIG       = (1 <<  6),
00060     MODE_RESIGN         = (1 <<  7),
00061 #define MODES_K  (MODE_CHECKSIG | MODE_RESIGN)
00062 
00063     MODE_INITDB         = (1 << 10),
00064     MODE_REBUILDDB      = (1 << 12),
00065     MODE_VERIFYDB       = (1 << 13),
00066 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
00067 
00068 
00069     MODE_UNKNOWN        = 0
00070 };
00071 
00072 #define MODES_FOR_DBPATH        (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
00073 #define MODES_FOR_NODEPS        (MODES_BT | MODES_IE | MODE_VERIFY)
00074 #define MODES_FOR_TEST          (MODES_BT | MODES_IE)
00075 #define MODES_FOR_ROOT          (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
00076 
00077 /*@-exportheadervar@*/
00078 extern int _ftp_debug;
00079 extern int noLibio;
00080 extern int _rpmio_debug;
00081 extern int _url_debug;
00082 
00083 /*@-varuse@*/
00084 /*@observer@*/ extern const char * rpmNAME;
00085 /*@=varuse@*/
00086 /*@observer@*/ extern const char * rpmEVR;
00087 /*@-varuse@*/
00088 extern int rpmFLAGS;
00089 /*@=varuse@*/
00090 
00091 extern struct MacroContext_s rpmCLIMacroContext;
00092 /*@=exportheadervar@*/
00093 
00094 /* options for all executables */
00095 
00096 static int help = 0;
00097 static int noUsageMsg = 0;
00098 /*@observer@*/ /*@null@*/ static const char * pipeOutput = NULL;
00099 static int quiet = 0;
00100 /*@observer@*/ /*@null@*/ static const char * rcfile = NULL;
00101 /*@observer@*/ /*@null@*/ static char * rootdir = "/";
00102 static int showrc = 0;
00103 static int showVersion = 0;
00104 
00105 static struct poptOption rpmAllPoptTable[] = {
00106  { "version", '\0', 0, &showVersion, 0,
00107         N_("print the version of rpm being used"),
00108         NULL },
00109  { "quiet", '\0', 0, &quiet, 0,
00110         N_("provide less detailed output"), NULL},
00111  { "verbose", 'v', 0, 0, 'v',
00112         N_("provide more detailed output"), NULL},
00113  { "define", '\0', POPT_ARG_STRING, 0, GETOPT_DEFINEMACRO,
00114         N_("define macro <name> with value <body>"),
00115         N_("'<name> <body>'") },
00116  { "eval", '\0', POPT_ARG_STRING, 0, GETOPT_EVALMACRO,
00117         N_("print macro expansion of <expr>+"),
00118         N_("<expr>+") },
00119  { "pipe", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &pipeOutput, 0,
00120         N_("send stdout to <cmd>"),
00121         N_("<cmd>") },
00122  { "root", 'r', POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT, &rootdir, 0,
00123         N_("use <dir> as the top level directory"),
00124         N_("<dir>") },
00125  { "macros", '\0', POPT_ARG_STRING, &macrofiles, 0,
00126         N_("read <file:...> instead of default macro file(s)"),
00127         N_("<file:...>") },
00128 #if !defined(GETOPT_RCFILE)
00129  { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
00130         N_("read <file:...> instead of default rpmrc file(s)"),
00131         N_("<file:...>") },
00132 #else
00133  { "rcfile", '\0', 0, 0, GETOPT_RCFILE, 
00134         N_("read <file:...> instead of default rpmrc file(s)"),
00135         N_("<file:...>") },
00136 #endif
00137  { "showrc", '\0', 0, &showrc, GETOPT_SHOWRC,
00138         N_("display final rpmrc and macro configuration"),
00139         NULL },
00140 
00141 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
00142  { "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1,
00143         N_("disable use of libio(3) API"), NULL},
00144 #endif
00145  { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
00146         N_("debug protocol data stream"), NULL},
00147  { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
00148         N_("debug rpmio I/O"), NULL},
00149  { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
00150         N_("debug URL cache handling"), NULL},
00151 
00152    POPT_TABLEEND
00153 };
00154 
00155 /* the structure describing the options we take and the defaults */
00156 static struct poptOption optionsTable[] = {
00157 
00158  /* XXX colliding options */
00159 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
00160  {  NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i',                 NULL, NULL},
00161  {  "nodeps", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NODEPS,       NULL, NULL},
00162  {  "noscripts", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOSCRIPTS, NULL, NULL},
00163  {  "nomd5", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOMD5,         NULL, NULL},
00164  {  "force", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_FORCE,         NULL, NULL},
00165 #endif
00166 
00167 #ifdef  IAM_RPMQV
00168  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
00169         N_("Query options (with -q or --query):"),
00170         NULL },
00171  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
00172         N_("Verify options (with -V or --verify):"),
00173         NULL },
00174 #endif  /* IAM_RPMQV */
00175 
00176 #ifdef  IAM_RPMK
00177  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
00178         N_("Signature options:"),
00179         NULL },
00180 #endif  /* IAM_RPMK */
00181 
00182 #ifdef  IAM_RPMDB
00183  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
00184         N_("Database options:"),
00185         NULL },
00186 #endif  /* IAM_RPMDB */
00187 
00188 #ifdef  IAM_RPMBT
00189  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
00190         N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
00191         NULL },
00192 #endif  /* IAM_RPMBT */
00193 
00194 #ifdef  IAM_RPMEIU
00195  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
00196         N_("Install/Upgrade/Erase options:"),
00197         NULL },
00198 #endif  /* IAM_RPMEIU */
00199 
00200  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmAllPoptTable, 0,
00201         N_("Common options for all rpm modes:"),
00202         NULL },
00203 
00204    POPT_AUTOALIAS
00205    POPT_AUTOHELP
00206    POPT_TABLEEND
00207 };
00208 
00209 #ifdef __MINT__
00210 /* MiNT cannot dynamically increase the stack.  */
00211 long _stksize = 64 * 1024L;
00212 #endif
00213 
00214 /*@exits@*/ static void argerror(const char * desc)
00215         /*@modifies fileSystem @*/
00216 {
00217     fprintf(stderr, _("%s: %s\n"), __progname, desc);
00218     exit(EXIT_FAILURE);
00219 }
00220 
00221 static void printVersion(void)
00222         /*@modifies fileSystem @*/
00223 {
00224     fprintf(stdout, _("RPM version %s\n"), rpmEVR);
00225 }
00226 
00227 static void printBanner(void)
00228         /*@modifies fileSystem @*/
00229 {
00230     (void) puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
00231     (void) puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
00232 }
00233 
00234 static void printUsage(void)
00235         /*@modifies fileSystem @*/
00236 {
00237     FILE * fp = stdout;
00238     printVersion();
00239     printBanner();
00240     (void) puts("");
00241 
00242     fprintf(fp, _("Usage: %s {--help}\n"), __progname);
00243     fprintf(fp,  ("       %s {--version}\n"), __progname);
00244 
00245 #ifdef  IAM_RPMEIU
00246 #ifdef  DYING
00247 --dbpath        all
00248 --ftpproxy etc  all
00249 --force         alias for --replacepkgs --replacefiles
00250 --includedocs   handle as option in table
00251                 --erase forbids many options
00252 #endif  /* DYING */
00253 #endif  /* IAM_RPMEIU */
00254 
00255 #ifdef  IAM_RPMQV
00256 #ifdef  DYING   /* XXX popt glue needing --help doco. */
00257 --dbpath        all
00258 --ftpproxy etc  all
00259 -i,--info       Q
00260 -R,--requires   Q
00261 -P,--provides   Q
00262 --scripts       Q
00263 --triggeredby   Q
00264 --changelog     Q
00265 --triggers      Q
00266 --querytags     !V
00267 --setperms      V
00268 --setugids      V
00269 #endif  /* DYING */
00270 #endif  /* IAM_RPMQV */
00271 
00272 }
00273 
00274 int main(int argc, const char ** argv)
00275 {
00276     enum modes bigMode = MODE_UNKNOWN;
00277 
00278 #ifdef  IAM_RPMQV
00279     QVA_t qva = &rpmQVArgs;
00280 #endif
00281 
00282 #ifdef  IAM_RPMBT
00283     BTA_t ba = &rpmBTArgs;
00284 #endif
00285 
00286 #ifdef  IAM_RPMEIU
00287    struct rpmInstallArguments_s * ia = &rpmIArgs;
00288 #endif
00289 
00290 #if defined(IAM_RPMDB)
00291    struct rpmDatabaseArguments_s * da = &rpmDBArgs;
00292 #endif
00293 
00294 #if defined(IAM_RPMK)
00295    struct rpmSignArguments_s * ka = &rpmKArgs;
00296 #endif
00297 
00298 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
00299     char * passPhrase = "";
00300 #endif
00301 
00302     int arg;
00303     int gotDbpath = 0;
00304 
00305     const char * optArg;
00306     pid_t pipeChild = 0;
00307     poptContext optCon;
00308     int ec = 0;
00309     int status;
00310     int p[2];
00311         
00312 #if HAVE_MCHECK_H && HAVE_MTRACE
00313     mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
00314 #endif
00315     setprogname(argv[0]);       /* Retrofit glibc __progname */
00316 
00317     /* XXX glibc churn sanity */
00318     if (__progname == NULL) {
00319         if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
00320         else __progname = argv[0];
00321     }
00322 
00323     /* Set the major mode based on argv[0] */
00324     /*@-nullpass@*/
00325 #ifdef  IAM_RPMBT
00326     if (!strcmp(__progname, "rpmb"))    bigMode = MODE_BUILD;
00327     if (!strcmp(__progname, "rpmt"))    bigMode = MODE_TARBUILD;
00328     if (!strcmp(__progname, "rpmbuild"))        bigMode = MODE_BUILD;
00329 #endif
00330 #ifdef  IAM_RPMQV
00331     if (!strcmp(__progname, "rpmq"))    bigMode = MODE_QUERY;
00332     if (!strcmp(__progname, "rpmv"))    bigMode = MODE_VERIFY;
00333     if (!strcmp(__progname, "rpmquery"))        bigMode = MODE_QUERY;
00334     if (!strcmp(__progname, "rpmverify"))       bigMode = MODE_VERIFY;
00335 #endif
00336 #ifdef  RPMEIU
00337     if (!strcmp(__progname, "rpme"))    bigMode = MODE_ERASE;
00338     if (!strcmp(__progname, "rpmi"))    bigMode = MODE_INSTALL;
00339     if (!strcmp(__progname, "rpmu"))    bigMode = MODE_INSTALL;
00340 #endif
00341     /*@=nullpass@*/
00342 
00343     /* set the defaults for the various command line options */
00344     _ftp_debug = 0;
00345 
00346 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
00347     noLibio = 0;
00348 #else
00349     noLibio = 1;
00350 #endif
00351     _rpmio_debug = 0;
00352     _url_debug = 0;
00353 
00354     /* XXX Eliminate query linkage loop */
00355     specedit = 0;
00356     parseSpecVec = parseSpec;
00357     freeSpecVec = freeSpec;
00358 
00359     /* set up the correct locale */
00360     (void) setlocale(LC_ALL, "" );
00361 
00362 #ifdef  __LCLINT__
00363 #define LOCALEDIR       "/usr/share/locale"
00364 #endif
00365     bindtextdomain(PACKAGE, LOCALEDIR);
00366     textdomain(PACKAGE);
00367 
00368     rpmSetVerbosity(RPMMESS_NORMAL);    /* XXX silly use by showrc */
00369 
00370     /* Make a first pass through the arguments, looking for --rcfile */
00371     /* We need to handle that before dealing with the rest of the arguments. */
00372     /*@-nullpass -temptrans@*/
00373     optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
00374     /*@=nullpass =temptrans@*/
00375     (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
00376     (void) poptReadDefaultConfig(optCon, 1);
00377     poptSetExecPath(optCon, RPMCONFIGDIR, 1);
00378 
00379     /* reading rcfile early makes it easy to override */
00380     /* XXX only --rcfile (and --showrc) need this pre-parse */
00381 
00382     while ((arg = poptGetNextOpt(optCon)) > 0) {
00383         switch(arg) {
00384         case 'v':
00385             rpmIncreaseVerbosity();     /* XXX silly use by showrc */
00386             break;
00387         default:
00388             break;
00389       }
00390     }
00391 
00392     if (rpmReadConfigFiles(rcfile, NULL))  
00393         exit(EXIT_FAILURE);
00394 
00395     if (showrc) {
00396         (void) rpmShowRC(stdout);
00397         exit(EXIT_SUCCESS);
00398     }
00399 
00400     rpmSetVerbosity(RPMMESS_NORMAL);    /* XXX silly use by showrc */
00401 
00402     poptResetContext(optCon);
00403 
00404 #ifdef  IAM_RPMQV
00405     qva->qva_queryFormat = _free(qva->qva_queryFormat);
00406     memset(qva, 0, sizeof(*qva));
00407     qva->qva_source = RPMQV_PACKAGE;
00408     qva->qva_fflags = RPMFILE_ALL;
00409     qva->qva_mode = ' ';
00410     qva->qva_char = ' ';
00411 #endif
00412 
00413 #ifdef  IAM_RPMBT
00414     ba->buildRootOverride = _free(ba->buildRootOverride);
00415     ba->targets = _free(ba->targets);
00416     memset(ba, 0, sizeof(*ba));
00417     ba->buildMode = ' ';
00418     ba->buildChar = ' ';
00419 #endif
00420 
00421 #ifdef  IAM_RPMDB
00422     memset(da, 0, sizeof(*da));
00423 #endif
00424 
00425 #ifdef  IAM_RPMK
00426     memset(ka, 0, sizeof(*ka));
00427     ka->addSign = RESIGN_NONE;
00428     ka->checksigFlags = CHECKSIG_ALL;
00429 #endif
00430 
00431 #ifdef  IAM_RPMEIU
00432     ia->relocations = _free(ia->relocations);
00433     memset(ia, 0, sizeof(*ia));
00434     ia->transFlags = RPMTRANS_FLAG_NONE;
00435     ia->probFilter = RPMPROB_FILTER_NONE;
00436     ia->installInterfaceFlags = INSTALL_NONE;
00437     ia->eraseInterfaceFlags = UNINSTALL_NONE;
00438 #endif
00439 
00440     while ((arg = poptGetNextOpt(optCon)) > 0) {
00441         optArg = poptGetOptArg(optCon);
00442 
00443         switch (arg) {
00444             
00445         case 'v':
00446             rpmIncreaseVerbosity();
00447             break;
00448 
00449 /* XXX options used in multiple rpm modes */
00450 #if defined(IAM_RPMQV) || defined(IAM_RPMK)
00451         case POPT_NOMD5:
00452 #ifdef  IAM_RPMQV
00453             if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
00454                 qva->qva_flags |= VERIFY_MD5;
00455             else
00456 #endif
00457 #ifdef  IAM_RPMK
00458             if (bigMode & MODES_K)
00459                 ka->checksigFlags &= ~CHECKSIG_MD5;
00460             else
00461 #endif
00462                 /*@-ifempty@*/ ;
00463             break;
00464 #endif  /* IAM_RPMQV || IAM_RPMK */
00465 
00466 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
00467         case POPT_NODEPS:
00468 #ifdef  IAM_RPMQV
00469             if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
00470                 qva->qva_flags |= VERIFY_DEPS;
00471             else
00472 #endif
00473 #ifdef  IAM_RPMEIU
00474             if ((bigMode & MODES_IE) ||
00475                 (ia->installInterfaceFlags &
00476             (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
00477                 ia->noDeps = 1;
00478             else
00479 #endif
00480 #ifdef  IAM_RPMBT
00481             if ((bigMode & MODES_BT) || ba->buildMode != ' ')
00482                 ba->noDeps = 1;
00483             else
00484 #endif
00485                 /*@-ifempty@*/ ;
00486             break;
00487 
00488         case POPT_FORCE:
00489 #ifdef  IAM_RPMEIU
00490             if ((bigMode & MODES_IE) ||
00491                 (ia->installInterfaceFlags &
00492             (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
00493                 ia->probFilter |=
00494                         ( RPMPROB_FILTER_REPLACEPKG
00495                         | RPMPROB_FILTER_REPLACEOLDFILES
00496                         | RPMPROB_FILTER_REPLACENEWFILES
00497                         | RPMPROB_FILTER_OLDPACKAGE);
00498             else
00499 #endif
00500 #ifdef  IAM_RPMBT
00501             if ((bigMode & MODES_BT) || ba->buildMode != ' ')
00502                 ba->force = 1;
00503             else
00504 #endif
00505                 /*@-ifempty@*/ ;
00506             break;
00507 
00508         case 'i':
00509 #ifdef  IAM_RPMQV
00510             if (bigMode == MODE_QUERY || qva->qva_mode == 'q') {
00511                 /*@-nullassign -readonlytrans@*/
00512                 const char * infoCommand[] = { "--info", NULL };
00513                 /*@=nullassign =readonlytrans@*/
00514                 (void) poptStuffArgs(optCon, infoCommand);
00515             } else
00516 #endif
00517 #ifdef  IAM_RPMEIU
00518             if (bigMode == MODE_INSTALL ||
00519                 (ia->installInterfaceFlags &
00520                     (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL)))
00521                 /*@-ifempty@*/ ;
00522             else if (bigMode == MODE_UNKNOWN) {
00523                 /*@-nullassign -readonlytrans@*/
00524                 const char * installCommand[] = { "--install", NULL };
00525                 /*@=nullassign =readonlytrans@*/
00526                 (void) poptStuffArgs(optCon, installCommand);
00527             } else
00528 #endif
00529                 /*@-ifempty@*/ ;
00530             break;
00531 
00532         case POPT_NOSCRIPTS:
00533 #ifdef  IAM_RPMQV
00534             if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
00535                 qva->qva_flags |= VERIFY_SCRIPT;
00536             else
00537 #endif
00538 #ifdef  IAM_RPMEIU
00539             if ((bigMode & MODES_IE) ||
00540                 (ia->installInterfaceFlags &
00541             (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
00542                 ia->transFlags |= (_noTransScripts | _noTransTriggers);
00543             else
00544 #endif
00545                 /*@-ifempty@*/ ;
00546             break;
00547 
00548 #endif  /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */
00549 
00550         case GETOPT_DEFINEMACRO:
00551             if (optArg) {
00552                 (void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
00553                 (void) rpmDefineMacro(&rpmCLIMacroContext, optArg,RMIL_CMDLINE);
00554             }
00555             noUsageMsg = 1;
00556             break;
00557 
00558         case GETOPT_EVALMACRO:
00559             if (optArg) {
00560                 const char *val = rpmExpand(optArg, NULL);
00561                 fprintf(stdout, "%s\n", val);
00562                 val = _free(val);
00563             }
00564             noUsageMsg = 1;
00565             break;
00566 
00567 #if defined(GETOPT_RCFILE)
00568         case GETOPT_RCFILE:
00569             fprintf(stderr, _("The --rcfile option has been eliminated.\n"));
00570             fprintf(stderr, _("Use \"--macros <file:...>\" instead.\n"));
00571             exit(EXIT_FAILURE);
00572             /*@notreached@*/ break;
00573 #endif
00574 
00575         default:
00576             fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
00577             exit(EXIT_FAILURE);
00578         }
00579     }
00580 
00581     if (quiet)
00582         rpmSetVerbosity(RPMMESS_QUIET);
00583 
00584     if (showVersion) printVersion();
00585 
00586     if (arg < -1) {
00587         fprintf(stderr, "%s: %s\n", 
00588                 poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
00589                 poptStrerror(arg));
00590         exit(EXIT_FAILURE);
00591     }
00592 
00593 #ifdef  IAM_RPMBT
00594     switch (ba->buildMode) {
00595     case 'b':   bigMode = MODE_BUILD;           break;
00596     case 't':   bigMode = MODE_TARBUILD;        break;
00597     case 'B':   bigMode = MODE_REBUILD;         break;
00598     case 'C':   bigMode = MODE_RECOMPILE;       break;
00599     }
00600 
00601     if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
00602         bigMode = MODE_BUILD;
00603 
00604     if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
00605         bigMode = MODE_BUILD;
00606 
00607     if (ba->buildRootOverride && bigMode != MODE_BUILD &&
00608         bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
00609         argerror("--buildroot may only be used during package builds");
00610     }
00611 #endif  /* IAM_RPMBT */
00612     
00613 #ifdef  IAM_RPMDB
00614   if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
00615     if (da->init) {
00616         if (bigMode != MODE_UNKNOWN) 
00617             argerror(_("only one major mode may be specified"));
00618         else
00619             bigMode = MODE_INITDB;
00620     } else
00621     if (da->rebuild) {
00622         if (bigMode != MODE_UNKNOWN) 
00623             argerror(_("only one major mode may be specified"));
00624         else
00625             bigMode = MODE_REBUILDDB;
00626     } else
00627     if (da->verify) {
00628         if (bigMode != MODE_UNKNOWN) 
00629             argerror(_("only one major mode may be specified"));
00630         else
00631             bigMode = MODE_VERIFYDB;
00632     }
00633   }
00634 #endif  /* IAM_RPMDB */
00635 
00636 #ifdef  IAM_RPMQV
00637   if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
00638     switch (qva->qva_mode) {
00639     case 'q':   bigMode = MODE_QUERY;           break;
00640     case 'V':   bigMode = MODE_VERIFY;          break;
00641     case 'Q':   bigMode = MODE_QUERYTAGS;       break;
00642     }
00643 
00644     if (qva->qva_sourceCount) {
00645         if (qva->qva_sourceCount > 2)
00646             argerror(_("one type of query/verify may be performed at a "
00647                         "time"));
00648     }
00649     if (qva->qva_flags && (bigMode & ~MODES_QV)) 
00650         argerror(_("unexpected query flags"));
00651 
00652     if (qva->qva_queryFormat && (bigMode & ~MODES_QV)) 
00653         argerror(_("unexpected query format"));
00654 
00655     if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV)) 
00656         argerror(_("unexpected query source"));
00657   }
00658 #endif  /* IAM_RPMQV */
00659 
00660 #ifdef  IAM_RPMEIU
00661   if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
00662     {   int iflags = (ia->installInterfaceFlags &
00663                 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL));
00664         int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
00665 
00666         if (iflags & eflags)
00667             argerror(_("only one major mode may be specified"));
00668         else if (iflags)
00669             bigMode = MODE_INSTALL;
00670         else if (eflags)
00671             bigMode = MODE_ERASE;
00672     }
00673 #endif  /* IAM_RPMQV */
00674 
00675 #ifdef  IAM_RPMK
00676   if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
00677         switch (ka->addSign) {
00678         case RESIGN_NONE:
00679             break;
00680         case RESIGN_CHK_SIGNATURE:
00681             bigMode = MODE_CHECKSIG;
00682             break;
00683         case RESIGN_ADD_SIGNATURE:
00684         case RESIGN_NEW_SIGNATURE:
00685             bigMode = MODE_RESIGN;
00686             break;
00687 
00688         }
00689   }
00690 #endif  /* IAM_RPMK */
00691 
00692     /* XXX TODO: never happens. */
00693     if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
00694         argerror(_("--dbpath given for operation that does not use a "
00695                         "database"));
00696 
00697 #if defined(IAM_RPMEIU)
00698     if (!( bigMode == MODE_INSTALL ) &&
00699 (ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE)))
00700         argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
00701     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
00702         argerror(_("files may only be relocated during package installation"));
00703 
00704     if (ia->relocations && ia->prefix)
00705         argerror(_("only one of --prefix or --relocate may be used"));
00706 
00707     if (bigMode != MODE_INSTALL && ia->relocations)
00708         argerror(_("--relocate and --excludepath may only be used when installing new packages"));
00709 
00710     if (bigMode != MODE_INSTALL && ia->prefix)
00711         argerror(_("--prefix may only be used when installing new packages"));
00712 
00713     if (ia->prefix && ia->prefix[0] != '/') 
00714         argerror(_("arguments to --prefix must begin with a /"));
00715 
00716     if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
00717         argerror(_("--hash (-h) may only be specified during package "
00718                         "installation"));
00719 
00720     if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
00721         argerror(_("--percent may only be specified during package "
00722                         "installation"));
00723 
00724     if (bigMode != MODE_INSTALL &&
00725  (ia->probFilter & (RPMPROB_FILTER_REPLACEOLDFILES|RPMPROB_FILTER_REPLACENEWFILES)))
00726         argerror(_("--replacefiles may only be specified during package "
00727                         "installation"));
00728 
00729     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
00730         argerror(_("--replacepkgs may only be specified during package "
00731                         "installation"));
00732 
00733     if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
00734         argerror(_("--excludedocs may only be specified during package "
00735                    "installation"));
00736 
00737     if (bigMode != MODE_INSTALL && ia->incldocs)
00738         argerror(_("--includedocs may only be specified during package "
00739                    "installation"));
00740 
00741     if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
00742         argerror(_("only one of --excludedocs and --includedocs may be "
00743                  "specified"));
00744   
00745     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
00746         argerror(_("--ignorearch may only be specified during package "
00747                    "installation"));
00748 
00749     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
00750         argerror(_("--ignoreos may only be specified during package "
00751                    "installation"));
00752 
00753     if (bigMode != MODE_INSTALL &&
00754         (ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
00755         argerror(_("--ignoresize may only be specified during package "
00756                    "installation"));
00757 
00758     if ((ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
00759         argerror(_("--allmatches may only be specified during package "
00760                    "erasure"));
00761 
00762     if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
00763         argerror(_("--allfiles may only be specified during package "
00764                    "installation"));
00765 
00766     if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
00767         bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
00768         argerror(_("--justdb may only be specified during package "
00769                    "installation and erasure"));
00770 
00771     if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
00772         (ia->transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
00773         argerror(_("script disabling options may only be specified during "
00774                    "package installation and erasure"));
00775 
00776     if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
00777         (ia->transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
00778         argerror(_("trigger disabling options may only be specified during "
00779                    "package installation and erasure"));
00780 
00781     if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
00782         argerror(_("--nodeps may only be specified during package "
00783                    "building, rebuilding, recompilation, installation,"
00784                    "erasure, and verification"));
00785 
00786     if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
00787         argerror(_("--test may only be specified during package installation, "
00788                  "erasure, and building"));
00789 #endif  /* IAM_RPMEIU */
00790 
00791     if (rootdir && rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
00792         argerror(_("--root (-r) may only be specified during "
00793                  "installation, erasure, querying, and "
00794                  "database rebuilds"));
00795 
00796     if (rootdir) {
00797         switch (urlIsURL(rootdir)) {
00798         default:
00799             if (bigMode & MODES_FOR_ROOT)
00800                 break;
00801             /*@fallthrough@*/
00802         case URL_IS_UNKNOWN:
00803             if (rootdir[0] != '/')
00804                 argerror(_("arguments to --root (-r) must begin with a /"));
00805             break;
00806         }
00807     }
00808 
00809 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
00810     if (0
00811 #if defined(IAM_RPMBT)
00812     || ba->sign 
00813 #endif
00814 #if defined(IAM_RPMK)
00815     || ka->sign
00816 #endif
00817     ) {
00818         if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
00819             bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
00820             const char ** av;
00821             struct stat sb;
00822             int errors = 0;
00823 
00824             if ((av = poptGetArgs(optCon)) == NULL) {
00825                 fprintf(stderr, _("no files to sign\n"));
00826                 errors++;
00827             } else
00828             while (*av) {
00829                 if (stat(*av, &sb)) {
00830                     fprintf(stderr, _("cannot access file %s\n"), *av);
00831                     errors++;
00832                 }
00833                 av++;
00834             }
00835 
00836             if (errors) {
00837                 ec = errors;
00838                 goto exit;
00839             }
00840 
00841             if (poptPeekArg(optCon)) {
00842                 int sigTag;
00843                 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
00844                   case 0:
00845                     break;
00846                   case RPMSIGTAG_PGP:
00847                     if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
00848                         !rpmDetectPGPVersion(NULL)) {
00849                         fprintf(stderr, _("pgp not found: "));
00850                         ec = EXIT_FAILURE;
00851                         goto exit;
00852                     }   /*@fallthrough@*/
00853                   case RPMSIGTAG_GPG:
00854                     passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
00855                     if (passPhrase == NULL) {
00856                         fprintf(stderr, _("Pass phrase check failed\n"));
00857                         ec = EXIT_FAILURE;
00858                         goto exit;
00859                     }
00860                     fprintf(stderr, _("Pass phrase is good.\n"));
00861                     passPhrase = xstrdup(passPhrase);
00862                     break;
00863                   default:
00864                     fprintf(stderr,
00865                             _("Invalid %%_signature spec in macro file.\n"));
00866                     ec = EXIT_FAILURE;
00867                     goto exit;
00868                     /*@notreached@*/ break;
00869                 }
00870             }
00871         } else {
00872             argerror(_("--sign may only be used during package building"));
00873         }
00874     } else {
00875         /* Make rpmLookupSignatureType() return 0 ("none") from now on */
00876         (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
00877     }
00878 #endif  /* IAM_RPMBT || IAM_RPMK */
00879 
00880     if (pipeOutput) {
00881         (void) pipe(p);
00882 
00883         if (!(pipeChild = fork())) {
00884             (void) close(p[1]);
00885             (void) dup2(p[0], STDIN_FILENO);
00886             (void) close(p[0]);
00887             (void) execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
00888             fprintf(stderr, _("exec failed\n"));
00889         }
00890 
00891         (void) close(p[0]);
00892         (void) dup2(p[1], STDOUT_FILENO);
00893         (void) close(p[1]);
00894     }
00895         
00896     switch (bigMode) {
00897 #ifdef  IAM_RPMDB
00898     case MODE_INITDB:
00899         (void) rpmdbInit(rootdir, 0644);
00900         break;
00901 
00902     case MODE_REBUILDDB:
00903         ec = rpmdbRebuild(rootdir);
00904         break;
00905     case MODE_VERIFYDB:
00906         ec = rpmdbVerify(rootdir);
00907         break;
00908 #endif  /* IAM_RPMDB */
00909 
00910 #ifdef  IAM_RPMBT
00911     case MODE_REBUILD:
00912     case MODE_RECOMPILE:
00913       { const char * pkg;
00914         while (!rpmIsVerbose())
00915             rpmIncreaseVerbosity();
00916 
00917         if (!poptPeekArg(optCon))
00918             argerror(_("no packages files given for rebuild"));
00919 
00920         ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
00921         if (bigMode == MODE_REBUILD) {
00922             ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
00923             ba->buildAmount |= RPMBUILD_RMSOURCE;
00924             ba->buildAmount |= RPMBUILD_RMSPEC;
00925             ba->buildAmount |= RPMBUILD_CLEAN;
00926             ba->buildAmount |= RPMBUILD_RMBUILD;
00927         }
00928 
00929         while ((pkg = poptGetArg(optCon))) {
00930             const char * specFile = NULL;
00931             char * cookie = NULL;
00932 
00933             ec = rpmInstallSource("", pkg, &specFile, &cookie);
00934             if (ec)
00935                 /*@loopbreak@*/ break;
00936 
00937             ba->rootdir = rootdir;
00938             ec = build(specFile, ba, passPhrase, cookie, rcfile);
00939             free(cookie);
00940             cookie = NULL;
00941             free((void *)specFile);
00942             specFile = NULL;
00943 
00944             if (ec)
00945                 /*@loopbreak@*/ break;
00946         }
00947       } break;
00948 
00949       case MODE_BUILD:
00950       case MODE_TARBUILD:
00951       { const char * pkg;
00952         while (!rpmIsVerbose())
00953             rpmIncreaseVerbosity();
00954        
00955         switch (ba->buildChar) {
00956         case 'a':
00957             ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
00958             /*@fallthrough@*/
00959         case 'b':
00960             ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
00961             ba->buildAmount |= RPMBUILD_CLEAN;
00962             /*@fallthrough@*/
00963         case 'i':
00964             ba->buildAmount |= RPMBUILD_INSTALL;
00965             if ((ba->buildChar == 'i') && ba->shortCircuit)
00966                 break;
00967             /*@fallthrough@*/
00968         case 'c':
00969             ba->buildAmount |= RPMBUILD_BUILD;
00970             if ((ba->buildChar == 'c') && ba->shortCircuit)
00971                 break;
00972             /*@fallthrough@*/
00973         case 'p':
00974             ba->buildAmount |= RPMBUILD_PREP;
00975             break;
00976             
00977         case 'l':
00978             ba->buildAmount |= RPMBUILD_FILECHECK;
00979             break;
00980         case 's':
00981             ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
00982             break;
00983         }
00984 
00985         if (!poptPeekArg(optCon)) {
00986             if (bigMode == MODE_BUILD)
00987                 argerror(_("no spec files given for build"));
00988             else
00989                 argerror(_("no tar files given for build"));
00990         }
00991 
00992         while ((pkg = poptGetArg(optCon))) {
00993             ba->rootdir = rootdir;
00994             ec = build(pkg, ba, passPhrase, NULL, rcfile);
00995             if (ec)
00996                 /*@loopbreak@*/ break;
00997             rpmFreeMacros(NULL);
00998             (void) rpmReadConfigFiles(rcfile, NULL);
00999         }
01000       } break;
01001 #endif  /* IAM_RPMBT */
01002 
01003 #ifdef  IAM_RPMEIU
01004     case MODE_ERASE:
01005         if (!poptPeekArg(optCon))
01006             argerror(_("no packages given for uninstall"));
01007 
01008         if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
01009 
01010         ec = rpmErase(rootdir, (const char **)poptGetArgs(optCon), 
01011                          ia->transFlags, ia->eraseInterfaceFlags);
01012         break;
01013 
01014     case MODE_INSTALL:
01015 
01016         if (!poptPeekArg(optCon))
01017             argerror(_("no packages given for install"));
01018 
01019         /* RPMTRANS_FLAG_BUILD_PROBS */
01020         /* RPMTRANS_FLAG_KEEPOBSOLETE */
01021 
01022         if (!ia->incldocs) {
01023             if (ia->transFlags & RPMTRANS_FLAG_NODOCS)
01024                 ;
01025             else if (rpmExpandNumeric("%{_excludedocs}"))
01026                 ia->transFlags |= RPMTRANS_FLAG_NODOCS;
01027         }
01028 
01029         if (ia->noDeps) ia->installInterfaceFlags |= INSTALL_NODEPS;
01030 
01031         /* we've already ensured !(!ia->prefix && !ia->relocations) */
01032         if (ia->prefix) {
01033             ia->relocations = xmalloc(2 * sizeof(*ia->relocations));
01034             ia->relocations[0].oldPath = NULL;   /* special case magic */
01035             ia->relocations[0].newPath = ia->prefix;
01036             ia->relocations[1].oldPath = ia->relocations[1].newPath = NULL;
01037         } else if (ia->relocations) {
01038             ia->relocations = xrealloc(ia->relocations, 
01039                         sizeof(*ia->relocations) * (ia->numRelocations + 1));
01040             ia->relocations[ia->numRelocations].oldPath = NULL;
01041             ia->relocations[ia->numRelocations].newPath = NULL;
01042         }
01043 
01044         ec += rpmInstall(rootdir, (const char **)poptGetArgs(optCon), 
01045                         ia->transFlags, ia->installInterfaceFlags, ia->probFilter,
01046                         ia->relocations);
01047         break;
01048 
01049     case MODE_ROLLBACK:
01050         ia->rootdir = rootdir;
01051         ec += rpmRollback(ia, (const char **)poptGetArgs(optCon));
01052         break;
01053 
01054 #endif  /* IAM_RPMEIU */
01055 
01056 #ifdef  IAM_RPMQV
01057     case MODE_QUERY:
01058       { const char * pkg;
01059 
01060         qva->qva_prefix = rootdir;
01061         if (qva->qva_source == RPMQV_ALL) {
01062 #ifdef  DYING
01063             if (poptPeekArg(optCon))
01064                 argerror(_("extra arguments given for query of all packages"));
01065 #else
01066             const char ** av = poptGetArgs(optCon);
01067 #endif
01068             /*@-nullpass@*/     /* FIX: av can be NULL */
01069             ec = rpmQuery(qva, RPMQV_ALL, (const char *) av);
01070             /*@=nullpass@*/
01071         } else {
01072             if (!poptPeekArg(optCon))
01073                 argerror(_("no arguments given for query"));
01074             while ((pkg = poptGetArg(optCon)))
01075                 ec += rpmQuery(qva, qva->qva_source, pkg);
01076         }
01077       } break;
01078 
01079     case MODE_VERIFY:
01080       { const char * pkg;
01081         rpmVerifyFlags verifyFlags = VERIFY_ALL;
01082 
01083         verifyFlags &= ~qva->qva_flags;
01084         qva->qva_flags = (rpmQueryFlags) verifyFlags;
01085         qva->qva_prefix = rootdir;
01086 
01087         if (qva->qva_source == RPMQV_ALL) {
01088             if (poptPeekArg(optCon))
01089                 argerror(_("extra arguments given for verify of all packages"));
01090             ec = rpmVerify(qva, RPMQV_ALL, NULL);
01091         } else {
01092             if (!poptPeekArg(optCon))
01093                 argerror(_("no arguments given for verify"));
01094             while ((pkg = poptGetArg(optCon)))
01095                 ec += rpmVerify(qva, qva->qva_source, pkg);
01096         }
01097       } break;
01098 
01099     case MODE_QUERYTAGS:
01100         if (argc != 2)
01101             argerror(_("unexpected arguments to --querytags "));
01102 
01103         rpmDisplayQueryTags(stdout);
01104         break;
01105 #endif  /* IAM_RPMQV */
01106 
01107 #ifdef IAM_RPMK
01108     case MODE_CHECKSIG:
01109         if (!poptPeekArg(optCon))
01110             argerror(_("no packages given for signature check"));
01111         ec = rpmCheckSig(ka->checksigFlags,
01112                         (const char **)poptGetArgs(optCon));
01113         /* XXX don't overflow single byte exit status */
01114         if (ec > 255) ec = 255;
01115         break;
01116 
01117     case MODE_RESIGN:
01118         if (!poptPeekArg(optCon))
01119             argerror(_("no packages given for signing"));
01120         ec = rpmReSign(ka->addSign, passPhrase,
01121                         (const char **)poptGetArgs(optCon));
01122         /* XXX don't overflow single byte exit status */
01123         if (ec > 255) ec = 255;
01124         break;
01125 #endif  /* IAM_RPMK */
01126         
01127 #if !defined(IAM_RPMQV)
01128     case MODE_QUERY:
01129     case MODE_VERIFY:
01130     case MODE_QUERYTAGS:
01131 #endif
01132 #if !defined(IAM_RPMK)
01133     case MODE_CHECKSIG:
01134     case MODE_RESIGN:
01135 #endif
01136 #if !defined(IAM_RPMDB)
01137     case MODE_INITDB:
01138     case MODE_REBUILDDB:
01139     case MODE_VERIFYDB:
01140 #endif
01141 #if !defined(IAM_RPMBT)
01142     case MODE_BUILD:
01143     case MODE_REBUILD:
01144     case MODE_RECOMPILE:
01145     case MODE_TARBUILD:
01146 #endif
01147 #if !defined(IAM_RPMEIU)
01148     case MODE_INSTALL:
01149     case MODE_ERASE:
01150     case MODE_ROLLBACK:
01151 #endif
01152     case MODE_UNKNOWN:
01153         if (!showVersion && !help && !noUsageMsg) printUsage();
01154         break;
01155     }
01156 
01157 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
01158 exit:
01159 #endif  /* IAM_RPMBT || IAM_RPMK */
01160     optCon = poptFreeContext(optCon);
01161     rpmFreeMacros(NULL);
01162     rpmFreeMacros(&rpmCLIMacroContext);
01163     rpmFreeRpmrc();
01164 
01165     if (pipeChild) {
01166         (void) fclose(stdout);
01167         (void) waitpid(pipeChild, &status, 0);
01168     }
01169 
01170     /* keeps memory leak checkers quiet */
01171     freeNames();
01172     freeFilesystems();
01173     urlFreeCache();
01174     rpmlogClose();
01175     dbiTags = _free(dbiTags);
01176 
01177 #ifdef  IAM_RPMQV
01178     qva->qva_queryFormat = _free(qva->qva_queryFormat);
01179 #endif
01180 
01181 #ifdef  IAM_RPMBT
01182     ba->buildRootOverride = _free(ba->buildRootOverride);
01183     ba->targets = _free(ba->targets);
01184 #endif
01185 
01186 #ifdef  IAM_RPMEIU
01187     ia->relocations = _free(ia->relocations);
01188 #endif
01189 
01190 #if HAVE_MCHECK_H && HAVE_MTRACE
01191     muntrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
01192 #endif
01193     /*@-globstate@*/
01194     return ec;
01195     /*@=globstate@*/
01196 }

Generated at Thu Sep 6 11:32:33 2001 for rpm by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001