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

Generated on Thu Apr 18 17:34:49 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002