rpm
4.5
|
00001 00006 #include "system.h" 00007 const char *__progname; 00008 00009 #include <rpmcli.h> 00010 #include <rpmlua.h> /* XXX rpmluaFree() */ 00011 #include <fs.h> /* XXX rpmFreeFilesystems() */ 00012 #include <fts.h> 00013 #include <mire.h> 00014 00015 #include "debug.h" 00016 00017 #define POPT_SHOWVERSION -999 00018 #define POPT_SHOWRC -998 00019 #define POPT_QUERYTAGS -997 00020 #define POPT_PREDEFINE -996 00021 #ifdef NOTYET 00022 #define POPT_RCFILE -995 00023 #endif 00024 00025 /*@access headerTagIndices @*/ /* XXX rpmcliFini */ 00026 /*@access headerTagTableEntry @*/ /* XXX rpmcliFini */ 00027 00028 /*@unchecked@*/ 00029 extern int _tagcache; 00030 00031 /*@unchecked@*/ 00032 static int _debug = 0; 00033 00034 /*@-exportheadervar@*/ 00035 /*@unchecked@*/ 00036 extern int _rpmds_nopromote; 00037 00038 /*@unchecked@*/ 00039 extern int _cpio_debug; 00040 00041 /*@unchecked@*/ 00042 extern int _fps_debug; 00043 00044 /*@unchecked@*/ 00045 extern int _fsm_debug; 00046 00047 /*@unchecked@*/ 00048 extern int _fsm_threads; 00049 00050 /*@unchecked@*/ 00051 extern int _hdr_debug; 00052 00053 /*@unchecked@*/ 00054 extern int _mire_debug; 00055 00056 /*@unchecked@*/ 00057 extern int _print_pkts; 00058 00059 /*@unchecked@*/ 00060 extern int _psm_debug; 00061 00062 /*@unchecked@*/ 00063 extern int _psm_threads; 00064 00065 /*@unchecked@*/ 00066 extern int _rpmal_debug; 00067 00068 /*@unchecked@*/ 00069 extern int _rpmdb_debug; 00070 00071 /*@unchecked@*/ 00072 extern int _rpmds_debug; 00073 00074 /* XXX avoid -lrpmbuild linkage. */ 00075 /*@unchecked@*/ 00076 int _rpmfc_debug; 00077 00078 /*@unchecked@*/ 00079 extern int _rpmfi_debug; 00080 00081 /*@unchecked@*/ 00082 extern int _rpmgi_debug; 00083 00084 /*@unchecked@*/ 00085 extern int _rpmps_debug; 00086 00087 /*@unchecked@*/ 00088 extern int _rpmsq_debug; 00089 00090 /*@unchecked@*/ 00091 extern int _rpmsx_debug; 00092 00093 /*@unchecked@*/ 00094 extern int _rpmte_debug; 00095 00096 /*@unchecked@*/ 00097 extern int _rpmts_debug; 00098 00099 /*@unchecked@*/ 00100 extern int _rpmts_stats; 00101 00102 /*@unchecked@*/ 00103 extern int _tar_debug; 00104 00105 /*@unchecked@*/ 00106 extern int noLibio; 00107 /*@=exportheadervar@*/ 00108 00109 /*@unchecked@*/ /*@null@*/ 00110 const char * rpmcliPipeOutput = NULL; 00111 00112 /*@unchecked@*/ /*@null@*/ 00113 const char * rpmcliRcfile = NULL; 00114 00115 /*@unchecked@*/ 00116 const char * rpmcliRootDir = "/"; 00117 00118 /*@unchecked@*/ 00119 rpmQueryFlags rpmcliQueryFlags; 00120 00121 /*@unchecked@*/ /*@null@*/ 00122 const char * rpmcliTargets = NULL; 00123 00124 /*@-exportheadervar@*/ 00125 /*@unchecked@*/ 00126 extern int _ftp_debug; 00127 /*@unchecked@*/ 00128 extern int _av_debug; 00129 00130 /*@unchecked@*/ 00131 extern int noLibio; 00132 00133 /*@unchecked@*/ 00134 extern int _rpmio_debug; 00135 /*@=exportheadervar@*/ 00136 00137 /*@unchecked@*/ 00138 static int rpmcliInitialized = -1; 00139 00143 static void printVersion(FILE * fp) 00144 /*@globals rpmEVR, fileSystem @*/ 00145 /*@modifies *fp, fileSystem @*/ 00146 { 00147 fprintf(fp, _("RPM version %s\n"), rpmEVR); 00148 } 00149 00150 void rpmcliConfigured(void) 00151 /*@globals rpmcliInitialized, rpmCLIMacroContext, rpmGlobalMacroContext, 00152 h_errno, fileSystem, internalState @*/ 00153 /*@modifies rpmcliInitialized, rpmCLIMacroContext, rpmGlobalMacroContext, 00154 fileSystem, internalState @*/ 00155 { 00156 00157 if (rpmcliInitialized < 0) { 00158 char * t = NULL; 00159 if (rpmcliTargets != NULL) { 00160 char *te; 00161 t = xstrdup(rpmcliTargets); 00162 if ((te = strchr(t, ',')) != NULL) 00163 *te = '\0'; 00164 } 00165 rpmcliInitialized = rpmReadConfigFiles(rpmcliRcfile, t); 00166 t = _free(t); 00167 } 00168 if (rpmcliInitialized) 00169 exit(EXIT_FAILURE); 00170 } 00171 00174 /*@-bounds@*/ 00175 static void rpmcliAllArgCallback(poptContext con, 00176 /*@unused@*/ enum poptCallbackReason reason, 00177 const struct poptOption * opt, const char * arg, 00178 /*@unused@*/ const void * data) 00179 /*@globals rpmRcfiles, rpmcliTargets, rpmcliQueryFlags, rpmCLIMacroContext, 00180 rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ 00181 /*@modifies con, rpmcliTargets, rpmcliQueryFlags, rpmCLIMacroContext, 00182 rpmGlobalMacroContext, fileSystem, internalState @*/ 00183 { 00184 00185 /* XXX avoid accidental collisions with POPT_BIT_SET for flags */ 00186 /*@-branchstate@*/ 00187 if (opt->arg == NULL) 00188 switch (opt->val) { 00189 case 'q': 00190 rpmSetVerbosity(RPMMESS_QUIET); 00191 break; 00192 case 'v': 00193 rpmIncreaseVerbosity(); 00194 break; 00195 case POPT_PREDEFINE: 00196 (void) rpmDefineMacro(NULL, arg, RMIL_CMDLINE); 00197 break; 00198 case 'D': 00199 { char *s, *t; 00200 /* XXX Convert '-' in macro name to underscore, skip leading %. */ 00201 s = t = xstrdup(arg); 00202 while (*t && !xisspace(*t)) { 00203 if (*t == '-') *t = '_'; 00204 t++; 00205 } 00206 t = s; 00207 if (*t == '%') t++; 00208 /* XXX Predefine macro if not initialized yet. */ 00209 if (rpmcliInitialized < 0) 00210 (void) rpmDefineMacro(NULL, t, RMIL_CMDLINE); 00211 rpmcliConfigured(); 00212 /*@-type@*/ 00213 (void) rpmDefineMacro(NULL, t, RMIL_CMDLINE); 00214 (void) rpmDefineMacro(rpmCLIMacroContext, t, RMIL_CMDLINE); 00215 /*@=type@*/ 00216 s = _free(s); 00217 } break; 00218 case 'E': 00219 rpmcliConfigured(); 00220 { const char *val = rpmExpand(arg, NULL); 00221 fprintf(stdout, "%s\n", val); 00222 val = _free(val); 00223 } 00224 break; 00225 case POPT_SHOWVERSION: 00226 printVersion(stdout); 00227 /*@i@*/ con = rpmcliFini(con); 00228 exit(EXIT_SUCCESS); 00229 /*@notreached@*/ break; 00230 case POPT_SHOWRC: 00231 rpmcliConfigured(); 00232 (void) rpmShowRC(stdout); 00233 /*@i@*/ con = rpmcliFini(con); 00234 exit(EXIT_SUCCESS); 00235 /*@notreached@*/ break; 00236 case POPT_QUERYTAGS: 00237 rpmDisplayQueryTags(stdout); 00238 /*@i@*/ con = rpmcliFini(con); 00239 exit(EXIT_SUCCESS); 00240 /*@notreached@*/ break; 00241 #if defined(POPT_RCFILE) 00242 case POPT_RCFILE: /* XXX FIXME: noop for now */ 00243 break; 00244 #endif 00245 case RPMCLI_POPT_NODIGEST: 00246 rpmcliQueryFlags |= VERIFY_DIGEST; 00247 break; 00248 00249 case RPMCLI_POPT_NOSIGNATURE: 00250 rpmcliQueryFlags |= VERIFY_SIGNATURE; 00251 break; 00252 00253 case RPMCLI_POPT_NOHDRCHK: 00254 rpmcliQueryFlags |= VERIFY_HDRCHK; 00255 break; 00256 00257 case RPMCLI_POPT_TARGETPLATFORM: 00258 if (rpmcliTargets == NULL) 00259 rpmcliTargets = xstrdup(arg); 00260 else { 00261 /*@-modobserver @*/ 00262 char * t = (char *) rpmcliTargets; 00263 size_t nb = strlen(t) + (sizeof(",")-1) + strlen(arg) + 1; 00264 /*@i@*/ t = xrealloc(t, nb); 00265 (void) stpcpy( stpcpy(t, ","), arg); 00266 rpmcliTargets = t; 00267 /*@=modobserver @*/ 00268 } 00269 break; 00270 } 00271 /*@=branchstate@*/ 00272 } 00273 00274 /*@unchecked@*/ 00275 int ftsOpts = 0; 00276 00277 /*@unchecked@*/ 00278 struct poptOption rpmcliFtsPoptTable[] = { 00279 { "comfollow", '\0', POPT_BIT_SET, &ftsOpts, FTS_COMFOLLOW, 00280 N_("FTS_COMFOLLOW: follow command line symlinks"), NULL }, 00281 { "logical", '\0', POPT_BIT_SET, &ftsOpts, FTS_LOGICAL, 00282 N_("FTS_LOGICAL: logical walk"), NULL }, 00283 { "nochdir", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOCHDIR, 00284 N_("FTS_NOCHDIR: don't change directories"), NULL }, 00285 { "nostat", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOSTAT, 00286 N_("FTS_NOSTAT: don't get stat info"), NULL }, 00287 { "physical", '\0', POPT_BIT_SET, &ftsOpts, FTS_PHYSICAL, 00288 N_("FTS_PHYSICAL: physical walk"), NULL }, 00289 { "seedot", '\0', POPT_BIT_SET, &ftsOpts, FTS_SEEDOT, 00290 N_("FTS_SEEDOT: return dot and dot-dot"), NULL }, 00291 { "xdev", '\0', POPT_BIT_SET, &ftsOpts, FTS_XDEV, 00292 N_("FTS_XDEV: don't cross devices"), NULL }, 00293 { "whiteout", '\0', POPT_BIT_SET, &ftsOpts, FTS_WHITEOUT, 00294 N_("FTS_WHITEOUT: return whiteout information"), NULL }, 00295 POPT_TABLEEND 00296 }; 00297 00298 /*@unchecked@*/ 00299 int global_depFlags = (RPMDEPS_FLAG_NOLINKTOS|RPMDEPS_FLAG_NOPARENTDIRS); 00300 00301 /*@unchecked@*/ 00302 struct poptOption rpmcliDepFlagsPoptTable[] = { 00303 { "aid", '\0', POPT_BIT_SET, &global_depFlags, RPMDEPS_FLAG_ADDINDEPS, 00304 N_("add suggested packages to transaction"), NULL }, 00305 { "anaconda", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00306 &global_depFlags, RPMDEPS_FLAG_ANACONDA|RPMDEPS_FLAG_DEPLOOPS, 00307 N_("use anaconda \"presentation order\""), NULL}, 00308 { "deploops", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00309 &global_depFlags, RPMDEPS_FLAG_DEPLOOPS, 00310 N_("print dependency loops as warning"), NULL}, 00311 { "nosuggest", '\0', POPT_BIT_SET, 00312 &global_depFlags, RPMDEPS_FLAG_NOSUGGEST, 00313 N_("do not suggest missing dependency resolution(s)"), NULL}, 00314 { "noconflicts", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00315 &global_depFlags, RPMDEPS_FLAG_NOCONFLICTS, 00316 N_("do not check added package conflicts"), NULL}, 00317 { "linktos", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, 00318 &global_depFlags, RPMDEPS_FLAG_NOLINKTOS, 00319 N_("use added package requires on symlink targets"), NULL}, 00320 { "nolinktos", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00321 &global_depFlags, RPMDEPS_FLAG_NOLINKTOS, 00322 N_("ignore added package requires on symlink targets"), NULL}, 00323 { "noobsoletes", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00324 &global_depFlags, RPMDEPS_FLAG_NOOBSOLETES, 00325 N_("ignore added package obsoletes"), NULL}, 00326 { "parentdirs", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN, 00327 &global_depFlags, RPMDEPS_FLAG_NOPARENTDIRS, 00328 N_("use added package requires on file parent directory"), NULL}, 00329 { "noparentdirs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00330 &global_depFlags, RPMDEPS_FLAG_NOPARENTDIRS, 00331 N_("ignore added package requires on file parent directory"), NULL}, 00332 { "norequires", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00333 &global_depFlags, RPMDEPS_FLAG_NOREQUIRES, 00334 N_("do not check added package requires"), NULL}, 00335 { "noupgrade", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, 00336 &global_depFlags, RPMDEPS_FLAG_NOUPGRADE, 00337 N_("ignore added package upgrades"), NULL}, 00338 POPT_TABLEEND 00339 }; 00340 00341 /*@-bitwisesigned -compmempass @*/ 00342 /*@unchecked@*/ 00343 struct poptOption rpmcliAllPoptTable[] = { 00344 /*@-type@*/ /* FIX: cast? */ 00345 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE, 00346 rpmcliAllArgCallback, 0, NULL, NULL }, 00347 /*@=type@*/ 00348 00349 { "debug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_debug, -1, 00350 NULL, NULL }, 00351 00352 { "predefine", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_PREDEFINE, 00353 N_("predefine MACRO with value EXPR"), 00354 N_("'MACRO EXPR'") }, 00355 { "define", 'D', POPT_ARG_STRING, 0, 'D', 00356 N_("define MACRO with value EXPR"), 00357 N_("'MACRO EXPR'") }, 00358 { "eval", 'E', POPT_ARG_STRING, 0, 'E', 00359 N_("print macro expansion of EXPR"), 00360 N_("'EXPR'") }, 00361 { "macros", '\0', POPT_ARG_STRING, &rpmMacrofiles, 0, 00362 N_("read <FILE:...> instead of default file(s)"), 00363 N_("<FILE:...>") }, 00364 { "target", '\0', POPT_ARG_STRING, 0, RPMCLI_POPT_TARGETPLATFORM, 00365 N_("specify target platform"), N_("CPU-VENDOR-OS") }, 00366 00367 { "nodigest", '\0', 0, 0, RPMCLI_POPT_NODIGEST, 00368 N_("don't verify package digest(s)"), NULL }, 00369 { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK, 00370 N_("don't verify database header(s) when retrieved"), NULL }, 00371 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION) 00372 { "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1, 00373 N_("disable use of libio(3) API"), NULL}, 00374 #endif 00375 { "nosignature", '\0', 0, 0, RPMCLI_POPT_NOSIGNATURE, 00376 N_("don't verify package signature(s)"), NULL }, 00377 00378 { "pipe", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &rpmcliPipeOutput, 0, 00379 N_("send stdout to CMD"), 00380 N_("CMD") }, 00381 #if !defined(POPT_RCFILE) 00382 { "rcfile", '\0', POPT_ARG_STRING, &rpmcliRcfile, 0, 00383 N_("read <FILE:...> instead of default file(s)"), 00384 N_("<FILE:...>") }, 00385 #else 00386 { "rcfile", '\0', 0, NULL, POPT_RCFILE, 00387 N_("read <FILE:...> instead of default file(s)"), 00388 N_("<FILE:...>") }, 00389 #endif 00390 { "root", 'r', POPT_ARG_STRING|POPT_ARGFLAG_SHOW_DEFAULT, &rpmcliRootDir, 0, 00391 N_("use ROOT as top level directory"), 00392 N_("ROOT") }, 00393 00394 { "querytags", '\0', 0, 0, POPT_QUERYTAGS, 00395 N_("display known query tags"), NULL }, 00396 { "showrc", '\0', 0, NULL, POPT_SHOWRC, 00397 N_("display final rpmrc and macro configuration"), NULL }, 00398 { "quiet", '\0', 0, NULL, 'q', 00399 N_("provide less detailed output"), NULL}, 00400 { "verbose", 'v', 0, NULL, 'v', 00401 N_("provide more detailed output"), NULL}, 00402 { "version", '\0', 0, NULL, POPT_SHOWVERSION, 00403 N_("print the version of rpm being used"), NULL }, 00404 00405 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION) 00406 { "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1, 00407 N_("disable use of libio(3) API"), NULL}, 00408 #endif 00409 00410 { "promoteepoch", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmds_nopromote, 0, 00411 NULL, NULL}, 00412 00413 { "cpiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_cpio_debug, -1, 00414 N_("debug cpio payloads"), NULL}, 00415 { "fpsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fps_debug, -1, 00416 NULL, NULL}, 00417 { "fsmdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fsm_debug, -1, 00418 N_("debug payload file state machine"), NULL}, 00419 { "fsmthreads", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fsm_threads, -1, 00420 N_("use threads for file state machine"), NULL}, 00421 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1, 00422 N_("debug FTP/HTTP data stream"), NULL}, 00423 { "avdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_av_debug, -1, 00424 N_("debug argv collections"), NULL}, 00425 { "hdrdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_hdr_debug, -1, 00426 NULL, NULL}, 00427 { "miredebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_mire_debug, -1, 00428 NULL, NULL}, 00429 #ifdef DYING 00430 { "poptdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_popt_debug, -1, 00431 N_("debug option/argument processing"), NULL}, 00432 #endif 00433 { "prtpkts", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_print_pkts, -1, 00434 NULL, NULL}, 00435 { "psmdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_psm_debug, -1, 00436 N_("debug package state machine"), NULL}, 00437 { "psmthreads", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_psm_threads, -1, 00438 N_("use threads for package state machine"), NULL}, 00439 { "rpmaldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmal_debug, -1, 00440 NULL, NULL}, 00441 { "rpmdbdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmdb_debug, -1, 00442 NULL, NULL}, 00443 { "rpmdsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmds_debug, -1, 00444 NULL, NULL}, 00445 { "rpmfcdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmfc_debug, -1, 00446 NULL, NULL}, 00447 { "rpmfidebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmfi_debug, -1, 00448 NULL, NULL}, 00449 { "rpmgidebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmgi_debug, -1, 00450 NULL, NULL}, 00451 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, 00452 N_("debug rpmio I/O"), NULL}, 00453 { "rpmpsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmps_debug, -1, 00454 NULL, NULL}, 00455 { "rpmsqdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmsq_debug, -1, 00456 NULL, NULL}, 00457 { "rpmsxdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmsx_debug, -1, 00458 NULL, NULL}, 00459 { "rpmtedebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmte_debug, -1, 00460 NULL, NULL}, 00461 { "rpmtsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmts_debug, -1, 00462 NULL, NULL}, 00463 { "tardebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_tar_debug, -1, 00464 N_("debug tar payloads"), NULL}, 00465 { "stats", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmts_stats, -1, 00466 NULL, NULL}, 00467 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, 00468 N_("debug URL cache handling"), NULL}, 00469 00470 { "notagcache", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_tagcache, 0, 00471 N_("disable tag data caching"), NULL}, 00472 { "tagcache", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_tagcache, 1, 00473 N_("enable tag data caching"), NULL}, 00474 00475 POPT_TABLEEND 00476 }; 00477 /*@=bitwisesigned =compmempass @*/ 00478 00479 poptContext 00480 rpmcliFini(poptContext optCon) 00481 { 00482 /* keeps memory leak checkers quiet */ 00483 rpmFreeMacros(NULL); 00484 /*@i@*/ rpmFreeMacros(rpmCLIMacroContext); 00485 rpmFreeRpmrc(); 00486 #ifdef WITH_LUA 00487 (void) rpmluaFree(NULL); 00488 #endif 00489 rpmFreeFilesystems(); 00490 /*@i@*/ urlFreeCache(); 00491 rpmlogClose(); 00492 /*@i@*/ rpmcliTargets = _free(rpmcliTargets); 00493 00494 rpmTags->byName = _free(rpmTags->byName); 00495 rpmTags->byValue = _free(rpmTags->byValue); 00496 00497 optCon = poptFreeContext(optCon); 00498 00499 #if HAVE_MCHECK_H && HAVE_MTRACE 00500 /*@-noeffect@*/ 00501 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ 00502 /*@=noeffect@*/ 00503 #endif 00504 00505 return NULL; 00506 } 00507 00508 /*@-globstate@*/ 00509 poptContext 00510 rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable) 00511 { 00512 const char * optArg; 00513 poptContext optCon; 00514 int rc; 00515 00516 #if HAVE_MCHECK_H && HAVE_MTRACE 00517 /*@-noeffect@*/ 00518 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ 00519 /*@=noeffect@*/ 00520 #endif 00521 /*@-globs -mods@*/ 00522 setprogname(argv[0]); /* Retrofit glibc __progname */ 00523 00524 /* XXX glibc churn sanity */ 00525 if (__progname == NULL) { 00526 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++; 00527 else __progname = argv[0]; 00528 } 00529 /*@=globs =mods@*/ 00530 00531 #if defined(ENABLE_NLS) && !defined(__LCLINT__) 00532 (void) setlocale(LC_ALL, "" ); 00533 (void) bindtextdomain(PACKAGE, LOCALEDIR); 00534 (void) textdomain(PACKAGE); 00535 #endif 00536 00537 rpmSetVerbosity(RPMMESS_NORMAL); 00538 00539 if (optionsTable == NULL) { 00540 /* Read rpm configuration (if not already read). */ 00541 rpmcliConfigured(); 00542 return NULL; 00543 } 00544 00545 /*@-nullpass -temptrans@*/ 00546 optCon = poptGetContext(__progname, argc, (const char **)argv, optionsTable, 0); 00547 /*@=nullpass =temptrans@*/ 00548 (void) poptReadConfigFile(optCon, RPMPOPTFILE); 00549 (void) poptReadDefaultConfig(optCon, 1); 00550 poptSetExecPath(optCon, USRLIBRPM, 1); 00551 00552 /* Process all options, whine if unknown. */ 00553 while ((rc = poptGetNextOpt(optCon)) > 0) { 00554 optArg = poptGetOptArg(optCon); 00555 switch (rc) { 00556 default: 00557 /*@-nullpass@*/ 00558 fprintf(stderr, _("%s: option table misconfigured (%d)\n"), 00559 __progname, rc); 00560 /*@=nullpass@*/ 00561 exit(EXIT_FAILURE); 00562 00563 /*@notreached@*/ /*@switchbreak@*/ break; 00564 } 00565 } 00566 00567 if (rc < -1) { 00568 /*@-nullpass@*/ 00569 fprintf(stderr, "%s: %s: %s\n", __progname, 00570 poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 00571 poptStrerror(rc)); 00572 /*@=nullpass@*/ 00573 exit(EXIT_FAILURE); 00574 } 00575 00576 /* Read rpm configuration (if not already read). */ 00577 rpmcliConfigured(); 00578 00579 if (_debug) { 00580 rpmIncreaseVerbosity(); 00581 rpmIncreaseVerbosity(); 00582 } 00583 00584 return optCon; 00585 } 00586 /*@=globstate@*/