5 #if defined(IAM_RPM) || defined(__LCLINT__)
18 #define GETOPT_REBUILD 1003
19 #define GETOPT_RECOMPILE 1004
23 #define GETOPT_REBUILDDB 1013
24 #define GETOPT_VERIFYDB 1023
25 static int initdb = 0;
29 #define GETOPT_INSTALL 1014
30 #define GETOPT_RELOCATE 1016
31 #define GETOPT_EXCLUDEPATH 1019
32 static int incldocs = 0;
33 /*@null@*/ static const char * prefix = NULL;
34 #endif /* IAM_RPMEIU */
37 #define GETOPT_ADDSIGN 1005
38 #define GETOPT_RESIGN 1006
43 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
44 #include "signature.h"
49 #define GETOPT_DBPATH 1010
50 #define GETOPT_SHOWRC 1018
51 #define GETOPT_DEFINEMACRO 1020
52 #define GETOPT_EVALMACRO 1021
54 #define GETOPT_RCFILE 1022
59 MODE_QUERY = (1 << 0),
60 MODE_VERIFY = (1 << 3),
61 MODE_QUERYTAGS = (1 << 9),
62 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
64 MODE_INSTALL = (1 << 1),
65 MODE_UNINSTALL = (1 << 2),
66 #define MODES_IE (MODE_INSTALL | MODE_UNINSTALL)
68 MODE_BUILD = (1 << 4),
69 MODE_REBUILD = (1 << 5),
70 MODE_RECOMPILE = (1 << 8),
71 MODE_TARBUILD = (1 << 11),
72 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
74 MODE_CHECKSIG = (1 << 6),
75 MODE_RESIGN = (1 << 7),
76 #define MODES_K (MODE_CHECKSIG | MODES_RESIGN)
78 MODE_INITDB = (1 << 10),
79 MODE_REBUILDDB = (1 << 12),
80 MODE_VERIFYDB = (1 << 13),
81 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
86 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
87 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
88 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
89 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
91 extern int _ftp_debug;
93 extern int _rpmio_debug;
94 extern int _url_debug;
95 extern int _noDirTokens;
97 extern const char * rpmNAME;
98 extern const char * rpmEVR;
101 extern struct MacroContext_s rpmCLIMacroContext;
103 /* options for all executables */
106 static int noUsageMsg = 0;
107 /*@null@*/ static const char * pipeOutput = NULL;
108 static int quiet = 0;
109 /*@null@*/ static const char * rcfile = NULL;
110 /*@null@*/ static char * rootdir = "/";
111 static int showrc = 0;
112 static int showVersion = 0;
114 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
115 static int signIt = 0;
116 #endif /* IAM_RPMBT || IAM_RPMK */
118 #if defined(IAM_RPMQV) || defined(IAM_RPMK)
119 static int noMd5 = 0;
122 #if defined(IAM_RPMEIU)
123 static int noDeps = 0;
126 #if defined(IAM_RPMEIU)
127 static int force = 0;
130 static struct poptOption rpmAllPoptTable[] = {
131 { "version", '\0', 0, &showVersion, 0,
132 N_("print the version of rpm being used"),
134 { "quiet", '\0', 0, &quiet, 0,
135 N_("provide less detailed output"), NULL},
136 { "verbose", 'v', 0, 0, 'v',
137 N_("provide more detailed output"), NULL},
138 { "define", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, GETOPT_DEFINEMACRO,
139 N_("define macro <name> with value <body>"),
140 N_("'<name> <body>'") },
141 { "eval", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, GETOPT_EVALMACRO,
142 N_("print macro expansion of <expr>+"),
144 { "pipe", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &pipeOutput, 0,
145 N_("send stdout to <cmd>"),
147 { "root", 'r', POPT_ARG_STRING, &rootdir, 0,
148 N_("use <dir> as the top level directory"),
150 { "macros", '\0', POPT_ARG_STRING, ¯ofiles, 0,
151 N_("read <file:...> instead of default macro file(s)"),
153 #if !defined(GETOPT_RCFILE)
154 { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
155 N_("read <file:...> instead of default rpmrc file(s)"),
158 { "rcfile", '\0', 0, 0, GETOPT_RCFILE,
159 N_("read <file:...> instead of default rpmrc file(s)"),
162 { "showrc", '\0', 0, &showrc, GETOPT_SHOWRC,
163 N_("display final rpmrc and macro configuration"),
166 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
167 { "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1,
168 N_("disable use of libio(3) API"), NULL},
170 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
171 N_("debug protocol data stream"), NULL},
172 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
173 N_("debug rpmio I/O"), NULL},
174 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
175 N_("debug URL cache handling"), NULL},
181 static struct poptOption rpmDatabasePoptTable[] = {
182 { "initdb", '\0', 0, &initdb, 0,
183 N_("initialize database"), NULL},
184 { "rebuilddb", '\0', 0, 0, GETOPT_REBUILDDB,
185 N_("rebuild database inverted lists from installed package headers"),
187 { "verifydb", '\0', 0, 0, GETOPT_VERIFYDB,
188 N_("verify database files"),
190 { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1,
191 N_("generate headers compatible with (legacy) rpm[23] packaging"),
193 { "dirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 0,
194 N_("generate headers compatible with rpm4 packaging"), NULL},
198 #endif /* IAM_RPMDB */
201 static struct poptOption rpmSignPoptTable[] = {
202 { "addsign", '\0', 0, 0, GETOPT_ADDSIGN,
203 N_("add a signature to a package"), NULL },
204 { "resign", '\0', 0, 0, GETOPT_RESIGN,
205 N_("sign a package (discard current signature)"), NULL },
206 { "sign", '\0', 0, &signIt, 0,
207 N_("generate PGP/GPG signature"), NULL },
208 { "checksig", 'K', 0, 0, 'K',
209 N_("verify package signature"), NULL },
210 { "nogpg", '\0', 0, &noGpg, 0,
211 N_("skip any PGP signatures"), NULL },
212 { "nopgp", '\0', 0, &noPgp, 0,
213 N_("skip any GPG signatures"), NULL },
214 { "nomd5", '\0', 0, &noMd5, 0,
215 N_("do not verify file md5 checksums"), NULL },
219 #endif /* IAM_RPMK */
222 static rpmtransFlags transFlags = RPMTRANS_FLAG_NONE;
223 static rpmprobFilterFlags probFilter = RPMPROB_FILTER_NONE;
224 static rpmInstallInterfaceFlags installInterfaceFlags = INSTALL_NONE;
225 static rpmEraseInterfaceFlags eraseInterfaceFlags = UNINSTALL_NONE;
227 #define _POPT_SET_BIT (POPT_ARG_VAL|POPT_ARGFLAG_OR)
229 static struct poptOption rpmInstallPoptTable[] = {
230 { "allfiles", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_ALLFILES,
231 N_("install all files, even configurations which might otherwise be skipped"),
233 { "allmatches", '\0', _POPT_SET_BIT, &eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
234 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
237 { "apply", '\0', _POPT_SET_BIT, &transFlags,
238 (_noTransScripts|_noTransTriggers|
239 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
240 N_("do not execute package scriptlet(s)"), NULL },
242 { "badreloc", '\0', _POPT_SET_BIT, &probFilter, RPMPROB_FILTER_FORCERELOCATE,
243 N_("relocate files in non-relocateable package"), NULL},
244 { "dirstash", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_DIRSTASH,
245 N_("save erased package files by renaming into sub-directory"), NULL},
246 { "erase", 'e', 0, 0, 'e',
247 N_("erase (uninstall) package"), N_("<package>+") },
248 { "excludedocs", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_NODOCS,
249 N_("do not install documentation"), NULL},
250 { "excludepath", '\0', POPT_ARG_STRING, 0, GETOPT_EXCLUDEPATH,
251 N_("skip files with leading component <path> "),
253 { "force", '\0', 0, &force, 0,
254 N_("short hand for --replacepkgs --replacefiles"), NULL},
255 { "freshen", 'F', _POPT_SET_BIT, &installInterfaceFlags,
256 (INSTALL_UPGRADE|INSTALL_FRESHEN),
257 N_("upgrade package(s) if already installed"),
258 N_("<packagefile>+") },
259 { "hash", 'h', _POPT_SET_BIT, &installInterfaceFlags, INSTALL_HASH,
260 N_("print hash marks as package installs (good with -v)"), NULL},
261 { "ignorearch", '\0', _POPT_SET_BIT, &probFilter, RPMPROB_FILTER_IGNOREARCH,
262 N_("don't verify package architecture"), NULL},
263 { "ignoreos", '\0', _POPT_SET_BIT, &probFilter, RPMPROB_FILTER_IGNOREOS,
264 N_("don't verify package operating system"), NULL},
265 { "ignoresize", '\0', _POPT_SET_BIT, &probFilter,
266 (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
267 N_("don't check disk space before installing"), NULL},
268 { "includedocs", '\0', 0, &incldocs, 0,
269 N_("install documentation"), NULL},
270 { "install", '\0', 0, 0, GETOPT_INSTALL,
271 N_("install package"), N_("<packagefile>+") },
272 { "justdb", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_JUSTDB,
273 N_("update the database, but do not modify the filesystem"), NULL},
274 { "nodeps", '\0', 0, &noDeps, 0,
275 N_("do not verify package dependencies"), NULL },
276 { "noorder", '\0', _POPT_SET_BIT, &installInterfaceFlags, INSTALL_NOORDER,
277 N_("do not reorder package installation to satisfy dependencies"),
280 { "noscripts", '\0', _POPT_SET_BIT, &transFlags,
281 (_noTransScripts|_noTransTriggers),
282 N_("do not execute package scriptlet(s)"), NULL },
283 { "nopre", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
285 N_("do not execute %%pre scriptlet (if any)"), NULL },
286 { "nopost", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
287 RPMTRANS_FLAG_NOPOST,
288 N_("do not execute %%post scriptlet (if any)"), NULL },
289 { "nopreun", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
290 RPMTRANS_FLAG_NOPREUN,
291 N_("do not execute %%preun scriptlet (if any)"), NULL },
292 { "nopostun", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
293 RPMTRANS_FLAG_NOPOSTUN,
294 N_("do not execute %%postun scriptlet (if any)"), NULL },
296 { "notriggers", '\0', _POPT_SET_BIT, &transFlags,
298 N_("do not execute any scriptlet(s) triggered by this package"), NULL},
299 { "notriggerprein", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
300 RPMTRANS_FLAG_NOTRIGGERPREIN,
301 N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
302 { "notriggerin", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
303 RPMTRANS_FLAG_NOTRIGGERIN,
304 N_("do not execute any %%triggerin scriptlet(s)"), NULL},
305 { "notriggerun", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
306 RPMTRANS_FLAG_NOTRIGGERUN,
307 N_("do not execute any %%triggerun scriptlet(s)"), NULL},
308 { "notriggerpostun", '\0', _POPT_SET_BIT|POPT_ARGFLAG_DOC_HIDDEN, &transFlags,
309 RPMTRANS_FLAG_NOTRIGGERPOSTUN,
310 N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
312 { "oldpackage", '\0', _POPT_SET_BIT, &probFilter, RPMPROB_FILTER_OLDPACKAGE,
313 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
315 { "percent", '\0', _POPT_SET_BIT, &installInterfaceFlags, INSTALL_PERCENT,
316 N_("print percentages as package installs"), NULL},
317 { "prefix", '\0', POPT_ARG_STRING, &prefix, 0,
318 N_("relocate the package to <dir>, if relocatable"),
320 { "relocate", '\0', POPT_ARG_STRING, 0, GETOPT_RELOCATE,
321 N_("relocate files from path <old> to <new>"),
323 { "repackage", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_REPACKAGE,
324 N_("save erased package files by repackaging"), NULL},
325 { "replacefiles", '\0', _POPT_SET_BIT, &probFilter,
326 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
327 N_("install even if the package replaces installed files"), NULL},
328 { "replacepkgs", '\0', _POPT_SET_BIT, &probFilter, RPMPROB_FILTER_REPLACEPKG,
329 N_("reinstall if the package is already present"), NULL},
330 { "test", '\0', _POPT_SET_BIT, &transFlags, RPMTRANS_FLAG_TEST,
331 N_("don't install, but tell if it would work or not"), NULL},
332 { "upgrade", 'U', _POPT_SET_BIT, &installInterfaceFlags, INSTALL_UPGRADE,
333 N_("upgrade package(s)"),
334 N_("<packagefile>+") },
338 #endif /* IAM_RPMEIU */
340 /* the structure describing the options we take and the defaults */
341 static struct poptOption optionsTable[] = {
342 #if !defined(_AUTOHELP)
343 { "help", '\0', 0, &help, 0, NULL, NULL},
346 /* XXX colliding options */
347 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
348 { NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i', NULL, NULL},
352 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
353 N_("Query options (with -q or --query):"),
355 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
356 N_("Verify options (with -V or --verify):"),
358 #endif /* IAM_RPMQV */
361 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
362 N_("Signature options:"),
364 #endif /* IAM_RPMK */
367 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
368 N_("Database options:"),
370 #endif /* IAM_RPMDB */
373 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
374 N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
376 #endif /* IAM_RPMBT */
379 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
380 N_("Install/Upgrade/Erase options:"),
382 #endif /* IAM_RPMEIU */
384 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmAllPoptTable, 0,
385 N_("Common options for all rpm modes:"),
393 /* MiNT cannot dynamically increase the stack. */
394 long _stksize = 64 * 1024L;
397 /*@exits@*/ static void argerror(const char * desc)
399 fprintf(stderr, _("rpm: %s\n"), desc);
403 static void printVersion(void) {
404 fprintf(stdout, _("RPM version %s\n"), rpmEVR);
407 static void printBanner(void) {
408 (void) puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
409 (void) puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
412 static void printUsage(void) {
420 fprintf(fp, _("Usage: %s {--help}\n"), __progname);
421 fprintf(fp, (" %s {--version}\n"), __progname);
427 --force alias for --replacepkgs --replacefiles
428 --includedocs handle as option in table
429 --erase forbids many options
431 #endif /* IAM_RPMEIU */
434 #ifdef DYING /* XXX popt glue needing --help doco. */
448 #endif /* IAM_RPMQV */
453 static void printHelpLine(char * prefix, char * help) {
454 int indentLength = strlen(prefix) + 3;
455 int lineLength = 79 - indentLength;
456 int helpLength = strlen(help);
460 fprintf(stdout, "%s - ", prefix);
462 while (helpLength > lineLength) {
463 ch = help + lineLength - 1;
464 while (ch > help && !isspace(*ch)) ch--;
465 if (ch == help) break; /* give up */
466 while (ch > (help + 1) && isspace(*ch)) ch--;
469 sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
470 fprintf(stdout, format, help, " ");
472 while (isspace(*help) && *help) help++;
473 helpLength = strlen(help);
476 if (helpLength) puts(help);
479 static void printHelp(void) {
485 printHelpLine( " --help ",
486 _("print this message"));
487 printHelpLine( " --version ",
488 _("print the version of rpm being used"));
491 puts( _(" All modes support the following options:"));
492 printHelpLine(_(" --define '<name> <body>'"),
493 _("define macro <name> with value <body>"));
494 printHelpLine(_(" --eval '<expr>+' "),
495 _("print the expansion of macro <expr> to stdout"));
496 printHelpLine(_(" --pipe <cmd> "),
497 _("send stdout to <cmd>"));
498 printHelpLine(_(" --rcfile <file:...> "),
499 _("use <file:...> instead of default list of macro files"));
500 printHelpLine( " --showrc ",
501 _("display final rpmrc and macro configuration"));
502 #if defined(IAM_RPMBT) || defined(IAM_RPMDB) || defined(IAM_RPMEIU) || defined(IAM_RPMQV)
503 printHelpLine(_(" --dbpath <dir> "),
504 _("use <dir> as the directory for the database"));
505 printHelpLine(_(" --root <dir> "),
506 _("use <dir> as the top level directory"));
507 #endif /* IAM_RPMBT || IAM_RPMDB || IAM_RPMEIU || IAM_RPMQV */
508 printHelpLine( " -v ",
509 _("be a little more verbose"));
510 printHelpLine( " -vv ",
511 _("be incredibly verbose (for debugging)"));
513 #if defined(IAM_RPMEIU) || defined(IAM_RPMQV)
515 puts( _(" Install, upgrade and query (with -p) modes allow URL's to be used in place"));
516 puts( _(" of file names as well as the following options:"));
517 printHelpLine(_(" --ftpproxy <host> "),
518 _("hostname or IP of ftp proxy"));
519 printHelpLine(_(" --ftpport <port> "),
520 _("port number of ftp server (or proxy)"));
521 printHelpLine(_(" --httpproxy <host> "),
522 _("hostname or IP of http proxy"));
523 printHelpLine(_(" --httpport <port> "),
524 _("port number of http server (or proxy)"));
525 #endif /* IAM_RPMEIU || IAM_RPMQV */
529 puts( _(" Package specification options:"));
530 printHelpLine( " -a, --all ",
531 _("query/verify all packages"));
532 printHelpLine(_(" -f <file>+ "),
533 _("query/verify package owning <file>"));
534 printHelpLine(_(" -p <packagefile>+ "),
535 _("query/verify (uninstalled) package <packagefile>"));
536 printHelpLine(_(" --triggeredby <pkg> "),
537 _("query/verify packages triggered by <pkg>"));
538 printHelpLine(_(" --whatprovides <cap> "),
539 _("query/verify packages which provide <cap> capability"));
540 printHelpLine(_(" --whatrequires <cap> "),
541 _("query/verify packages which require <cap> capability"));
543 printHelpLine( " -q, --query ",
545 printHelpLine(_(" --queryformat <qfmt> "),
546 _("use <qfmt> as the header format (implies --info)"));
548 puts( _(" Information selection options:"));
549 printHelpLine( " -i, --info ",
550 _("display package information"));
551 printHelpLine( " --changelog ",
552 _("display the package's change log"));
553 printHelpLine( " -l ",
554 _("display package file list"));
555 printHelpLine( " -s ",
556 _("show file states (implies -l)"));
557 printHelpLine( " -d ",
558 _("list only documentation files (implies -l)"));
559 printHelpLine( " -c ",
560 _("list only configuration files (implies -l)"));
561 printHelpLine( " --dump ",
562 _("show all verifiable information for each file (must be used with -l, -c, or -d)"));
563 printHelpLine( " --provides ",
564 _("list capabilities provided by package"));
565 printHelpLine( " -R, --requires ",
566 _("list capabilities required by package"));
567 printHelpLine( " --scripts ",
568 _("print the various [un]install scriptlets"));
569 printHelpLine( " --triggers ",
570 _("show the trigger scriptlets contained in the package"));
572 printHelpLine( " -V, -y, --verify ",
573 _("verify a package installation using the same same package specification options as -q"));
574 printHelpLine( " --nodeps ",
575 _("do not verify package dependencies"));
576 printHelpLine( " --nofiles ",
577 _("do not verify file attributes"));
578 printHelpLine( " --nomd5 ",
579 _("do not verify file md5 checksums"));
580 printHelpLine( " --noscripts ",
581 _("do not execute scripts (if any)"));
583 printHelpLine( " --querytags ",
584 _("list the tags that can be used in a query format"));
585 printHelpLine( " --setperms ",
586 _("set the file permissions to those in the package database"
587 " using the same package specification options as -q"));
588 printHelpLine( " --setugids ",
589 _("set the file owner and group to those in the package "
590 "database using the same package specification options as "
592 #endif /* IAM_RPMQV */
596 puts( _(" --install <packagefile>"));
597 printHelpLine(_(" -i <packagefile> "),
598 _("install package"));
599 printHelpLine( " --allfiles ",
600 _("install all files, even configurations which might "
601 "otherwise be skipped"));
602 printHelpLine( " --badreloc ",
603 _("relocate files in non-relocateable package"));
604 printHelpLine( " --excludedocs ",
605 _("do not install documentation"));
606 printHelpLine(_(" --excludepath <path> "),
607 _("skip files with leading component <path> "));
608 printHelpLine( " --force ",
609 _("short hand for --replacepkgs --replacefiles"));
610 printHelpLine( " -h, --hash ",
611 _("print hash marks as package installs (good with -v)"));
612 printHelpLine( " --ignorearch ",
613 _("don't verify package architecture"));
614 printHelpLine( " --ignoresize ",
615 _("don't check disk space before installing"));
616 printHelpLine( " --ignoreos ",
617 _("don't verify package operating system"));
618 printHelpLine( " --includedocs ",
619 _("install documentation"));
620 printHelpLine( " --justdb ",
621 _("update the database, but do not modify the filesystem"));
622 printHelpLine( " --nodeps ",
623 _("do not verify package dependencies"));
624 printHelpLine( " --noorder ",
625 _("do not reorder package installation to satisfy dependencies"));
626 printHelpLine( " --noscripts ",
627 _("don't execute any installation scriptlets"));
628 printHelpLine( " --notriggers ",
629 _("don't execute any scriptlets triggered by this package"));
630 printHelpLine( " --percent ",
631 _("print percentages as package installs"));
632 printHelpLine(_(" --prefix <dir> "),
633 _("relocate the package to <dir>, if relocatable"));
634 printHelpLine(_(" --relocate <oldpath>=<newpath>"),
635 _("relocate files from <oldpath> to <newpath>"));
636 printHelpLine( " --replacefiles ",
637 _("install even if the package replaces installed files"));
638 printHelpLine( " --replacepkgs ",
639 _("reinstall if the package is already present"));
640 printHelpLine( " --test ",
641 _("don't install, but tell if it would work or not"));
643 puts( _(" --upgrade <packagefile>"));
644 printHelpLine(_(" -U <packagefile> "),
645 _("upgrade package (same options as --install, plus)"));
646 printHelpLine( " --oldpackage ",
647 _("upgrade to an old version of the package (--force on upgrades does this automatically)"));
649 puts( _(" --erase <package>"));
650 printHelpLine(_(" -e <package> "),
651 _("erase (uninstall) package"));
652 printHelpLine( " --allmatches ",
653 _("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"));
654 printHelpLine( " --justdb ",
655 _("update the database, but do not modify the filesystem"));
656 printHelpLine( " --nodeps ",
657 _("do not verify package dependencies"));
658 printHelpLine( " --noorder ",
659 _("do not reorder package installation to satisfy dependencies"));
660 printHelpLine( " --noscripts ",
661 _("do not execute any package specific scripts"));
662 printHelpLine( " --notriggers ",
663 _("don't execute any scripts triggered by this package"));
664 #endif /* IAM_RPMEIU */
668 printHelpLine(_(" --resign <pkg>+ "),
669 _("sign a package (discard current signature)"));
670 printHelpLine(_(" --addsign <pkg>+ "),
671 _("add a signature to a package"));
673 puts( _(" --checksig <pkg>+"));
674 printHelpLine(_(" -K <pkg>+ "),
675 _("verify package signature"));
676 printHelpLine( " --nopgp ",
677 _("skip any PGP signatures"));
678 printHelpLine( " --nogpg ",
679 _("skip any GPG signatures"));
680 printHelpLine( " --nomd5 ",
681 _("skip any MD5 signatures"));
682 #endif /* IAM_RPMK */
686 printHelpLine( " --initdb ",
687 _("initalize database (unnecessary, legacy use)"));
688 printHelpLine( " --rebuilddb ",
689 _("rebuild database indices from existing database headers"));
695 int main(int argc, const char ** argv)
697 enum modes bigMode = MODE_UNKNOWN;
700 QVA_t qva = &rpmQVArgs;
704 BTA_t ba = &rpmBTArgs;
708 /*@only@*/ rpmRelocation * relocations = NULL;
709 int numRelocations = 0;
712 #if defined(IAM_RPMK)
713 rpmResignFlags addSign = RESIGN_NEW_SIGNATURE;
714 rpmCheckSigFlags checksigFlags = CHECKSIG_NONE;
717 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
718 char * passPhrase = "";
731 #if HAVE_MCHECK_H && HAVE_MTRACE
732 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
734 setprogname(argv[0]); /* Retrofit glibc __progname */
736 /* XXX glibc churn sanity */
737 if (__progname == NULL) {
738 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
739 else __progname = argv[0];
742 /* Set the major mode based on argv[0] */
745 if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
746 if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
747 if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
750 if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
751 if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
752 if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
753 if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
756 if (!strcmp(__progname, "rpme")) bigMode = MODE_UNINSTALL;
757 if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
758 if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
762 /* set the defaults for the various command line options */
765 #if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
773 /* XXX Eliminate query linkage loop */
775 parseSpecVec = parseSpec;
776 freeSpecVec = freeSpec;
778 /* set up the correct locale */
779 (void) setlocale(LC_ALL, "" );
782 #define LOCALEDIR "/usr/share/locale"
784 bindtextdomain(PACKAGE, LOCALEDIR);
787 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
791 fprintf(stderr, "==> argv[%d]:", argc);
792 for (avp = argv; *avp; avp++)
793 fprintf(stderr, " '%s'", *avp);
794 fprintf(stderr, "\n");
798 /* Make a first pass through the arguments, looking for --rcfile */
799 /* We need to handle that before dealing with the rest of the arguments. */
800 /*@-nullpass -temptrans@*/
801 optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
802 /*@=nullpass =temptrans@*/
803 (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
804 (void) poptReadDefaultConfig(optCon, 1);
805 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
807 /* reading rcfile early makes it easy to override */
808 /* XXX only --rcfile (and --showrc) need this pre-parse */
810 while ((arg = poptGetNextOpt(optCon)) > 0) {
813 rpmIncreaseVerbosity(); /* XXX silly use by showrc */
820 if (rpmReadConfigFiles(rcfile, NULL))
824 (void) rpmShowRC(stdout);
828 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
830 poptResetContext(optCon);
833 if (qva->qva_queryFormat) free((void *)qva->qva_queryFormat);
834 memset(qva, 0, sizeof(*qva));
835 qva->qva_source = RPMQV_PACKAGE;
841 if (ba->buildRootOverride) free((void *)ba->buildRootOverride);
842 if (ba->targets) free(ba->targets);
843 memset(ba, 0, sizeof(*ba));
849 transFlags = RPMTRANS_FLAG_NONE;
850 probFilter = RPMPROB_FILTER_NONE;
851 installInterfaceFlags = INSTALL_NONE;
852 eraseInterfaceFlags = UNINSTALL_NONE;
855 while ((arg = poptGetNextOpt(optCon)) > 0) {
856 optArg = poptGetOptArg(optCon);
861 rpmIncreaseVerbosity();
864 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
867 if (bigMode == MODE_QUERY) {
869 const char * infoCommand[] = { "--info", NULL };
871 (void) poptStuffArgs(optCon, infoCommand);
875 if (bigMode == MODE_INSTALL)
877 if (bigMode == MODE_UNKNOWN) {
879 const char * installCommand[] = { "--install", NULL };
881 (void) poptStuffArgs(optCon, installCommand);
885 #endif /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */
890 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
891 argerror(_("only one major mode may be specified"));
892 bigMode = MODE_UNINSTALL;
896 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
897 argerror(_("only one major mode may be specified"));
898 bigMode = MODE_INSTALL;
901 #ifdef DYING /* XXX handled by popt */
903 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
904 argerror(_("only one major mode may be specified"));
905 bigMode = MODE_INSTALL;
909 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
910 argerror(_("only one major mode may be specified"));
911 bigMode = MODE_INSTALL;
915 case GETOPT_EXCLUDEPATH:
916 if (optArg == NULL || *optArg != '/')
917 argerror(_("exclude paths must begin with a /"));
919 relocations = xrealloc(relocations,
920 sizeof(*relocations) * (numRelocations + 1));
921 /*@-observertrans -dependenttrans@*/ /* FIX: W2DO? */
922 relocations[numRelocations].oldPath = optArg;
923 relocations[numRelocations++].newPath = NULL;
924 /*@=observertrans =dependenttrans@*/
927 case GETOPT_RELOCATE:
928 { char * newPath = NULL;
929 if (optArg == NULL || *optArg != '/')
930 argerror(_("relocations must begin with a /"));
931 if (!(newPath = strchr(optArg, '=')))
932 argerror(_("relocations must contain a ="));
935 argerror(_("relocations must have a / following the ="));
936 relocations = xrealloc(relocations,
937 sizeof(*relocations) * (numRelocations + 1));
938 /*@-observertrans -kepttrans@*/ /* FIX: W2DO? */
939 relocations[numRelocations].oldPath = optArg;
940 relocations[numRelocations++].newPath = newPath;
941 /*@=observertrans =kepttrans@*/
943 #endif /* IAM_RPMEIU */
946 case GETOPT_REBUILDDB:
947 if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILDDB)
948 argerror(_("only one major mode may be specified"));
949 bigMode = MODE_REBUILDDB;
951 case GETOPT_VERIFYDB:
952 if (bigMode != MODE_UNKNOWN && bigMode != MODE_VERIFYDB)
953 argerror(_("only one major mode may be specified"));
954 bigMode = MODE_VERIFYDB;
960 if (bigMode != MODE_UNKNOWN && bigMode != MODE_CHECKSIG)
961 argerror(_("only one major mode may be specified"));
962 bigMode = MODE_CHECKSIG;
966 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
967 argerror(_("only one major mode may be specified"));
968 bigMode = MODE_RESIGN;
969 addSign = RESIGN_NEW_SIGNATURE;
974 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
975 argerror(_("only one major mode may be specified"));
976 bigMode = MODE_RESIGN;
977 addSign = RESIGN_ADD_SIGNATURE;
980 #endif /* IAM_RPMK */
982 case GETOPT_DEFINEMACRO:
984 (void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
985 (void) rpmDefineMacro(&rpmCLIMacroContext, optArg,RMIL_CMDLINE);
990 case GETOPT_EVALMACRO:
992 const char *val = rpmExpand(optArg, NULL);
993 fprintf(stdout, "%s\n", val);
999 #if defined(GETOPT_RCFILE)
1001 fprintf(stderr, _("The --rcfile option has been eliminated.\n"));
1002 fprintf(stderr, _("Use \"--macros <file:...>\" instead.\n"));
1004 /*@notreached@*/ break;
1008 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
1014 rpmSetVerbosity(RPMMESS_QUIET);
1016 if (showVersion) printVersion();
1019 fprintf(stderr, "%s: %s\n",
1020 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
1026 switch (ba->buildMode) {
1027 case 'b': bigMode = MODE_BUILD; break;
1028 case 't': bigMode = MODE_TARBUILD; break;
1029 case 'B': bigMode = MODE_REBUILD; break;
1030 case 'C': bigMode = MODE_RECOMPILE; break;
1033 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
1034 bigMode = MODE_BUILD;
1036 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
1037 bigMode = MODE_BUILD;
1039 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
1040 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
1041 argerror("--buildroot may only be used during package builds");
1043 #endif /* IAM_RPMBT */
1047 if (bigMode != MODE_UNKNOWN)
1048 argerror(_("only one major mode may be specified"));
1050 bigMode = MODE_INITDB;
1052 #endif /* IAM_RPMDB */
1055 switch (qva->qva_mode) {
1056 case 'q': bigMode = MODE_QUERY; break;
1057 case 'V': bigMode = MODE_VERIFY; break;
1058 case 'Q': bigMode = MODE_QUERYTAGS; break;
1061 if (qva->qva_sourceCount) {
1062 if (qva->qva_sourceCount > 2)
1063 argerror(_("one type of query/verify may be performed at a "
1066 if (qva->qva_flags && (bigMode & ~MODES_QV))
1067 argerror(_("unexpected query flags"));
1069 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
1070 argerror(_("unexpected query format"));
1072 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
1073 argerror(_("unexpected query source"));
1076 if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
1077 argerror(_("--dbpath given for operation that does not use a "
1080 #if defined(IAM_RPMEIU)
1082 if (!( bigMode == MODE_INSTALL ) && force)
1083 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
1084 #endif /* IAM_RPMEIU */
1087 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_FORCERELOCATE))
1088 argerror(_("files may only be relocated during package installation"));
1090 if (relocations && prefix)
1091 argerror(_("only one of --prefix or --relocate may be used"));
1093 if (bigMode != MODE_INSTALL && relocations)
1094 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
1096 if (bigMode != MODE_INSTALL && prefix)
1097 argerror(_("--prefix may only be used when installing new packages"));
1099 if (prefix && prefix[0] != '/')
1100 argerror(_("arguments to --prefix must begin with a /"));
1102 if (bigMode != MODE_INSTALL && (installInterfaceFlags & INSTALL_HASH))
1103 argerror(_("--hash (-h) may only be specified during package "
1106 if (bigMode != MODE_INSTALL && (installInterfaceFlags & INSTALL_PERCENT))
1107 argerror(_("--percent may only be specified during package "
1110 if (bigMode != MODE_INSTALL &&
1111 (probFilter & (RPMPROB_FILTER_REPLACEOLDFILES|RPMPROB_FILTER_REPLACENEWFILES)))
1112 argerror(_("--replacefiles may only be specified during package "
1115 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_REPLACEPKG))
1116 argerror(_("--replacepkgs may only be specified during package "
1119 if (bigMode != MODE_INSTALL && (transFlags & RPMTRANS_FLAG_NODOCS))
1120 argerror(_("--excludedocs may only be specified during package "
1123 if (bigMode != MODE_INSTALL && incldocs)
1124 argerror(_("--includedocs may only be specified during package "
1127 if (incldocs && (transFlags & RPMTRANS_FLAG_NODOCS))
1128 argerror(_("only one of --excludedocs and --includedocs may be "
1131 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_IGNOREARCH))
1132 argerror(_("--ignorearch may only be specified during package "
1135 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_IGNOREOS))
1136 argerror(_("--ignoreos may only be specified during package "
1139 if (bigMode != MODE_INSTALL &&
1140 (probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
1141 argerror(_("--ignoresize may only be specified during package "
1144 if ((eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_UNINSTALL)
1145 argerror(_("--allmatches may only be specified during package "
1148 if ((transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
1149 argerror(_("--allfiles may only be specified during package "
1152 if ((transFlags & RPMTRANS_FLAG_JUSTDB) &&
1153 bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL)
1154 argerror(_("--justdb may only be specified during package "
1155 "installation and erasure"));
1156 #endif /* IAM_RPMEIU */
1158 #if defined(IAM_RPMEIU)
1159 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1160 (transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
1161 argerror(_("script disabling options may only be specified during "
1162 "package installation and erasure"));
1164 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1165 (transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
1166 argerror(_("trigger disabling options may only be specified during "
1167 "package installation and erasure"));
1169 if (noDeps & (bigMode & ~MODES_FOR_NODEPS))
1170 argerror(_("--nodeps may only be specified during package "
1171 "building, rebuilding, recompilation, installation,"
1172 "erasure, and verification"));
1174 if ((transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
1175 argerror(_("--test may only be specified during package installation, "
1176 "erasure, and building"));
1177 #endif /* IAM_RPMEIU */
1179 if (rootdir && rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
1180 argerror(_("--root (-r) may only be specified during "
1181 "installation, erasure, querying, and "
1182 "database rebuilds"));
1185 switch (urlIsURL(rootdir)) {
1187 if (bigMode & MODES_FOR_ROOT)
1190 case URL_IS_UNKNOWN:
1191 if (rootdir[0] != '/')
1192 argerror(_("arguments to --root (-r) must begin with a /"));
1198 if (noPgp && bigMode != MODE_CHECKSIG)
1199 argerror(_("--nopgp may only be used during signature checking"));
1201 if (noGpg && bigMode != MODE_CHECKSIG)
1202 argerror(_("--nogpg may only be used during signature checking"));
1205 #if defined(IAM_RPMK) || defined(IAM_RPMQV)
1206 if (noMd5 && bigMode != MODE_CHECKSIG && bigMode != MODE_VERIFY)
1207 argerror(_("--nomd5 may only be used during signature checking and "
1208 "package verification"));
1211 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1212 #if defined(IAM_RPMBT)
1216 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
1217 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
1222 if ((av = poptGetArgs(optCon)) == NULL) {
1223 fprintf(stderr, _("no files to sign\n"));
1227 if (stat(*av, &sb)) {
1228 fprintf(stderr, _("cannot access file %s\n"), *av);
1239 if (poptPeekArg(optCon)) {
1241 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
1245 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
1246 !rpmDetectPGPVersion(NULL)) {
1247 fprintf(stderr, _("pgp not found: "));
1252 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
1253 if (passPhrase == NULL) {
1254 fprintf(stderr, _("Pass phrase check failed\n"));
1258 fprintf(stderr, _("Pass phrase is good.\n"));
1259 passPhrase = xstrdup(passPhrase);
1263 _("Invalid %%_signature spec in macro file.\n"));
1266 /*@notreached@*/ break;
1270 argerror(_("--sign may only be used during package building"));
1273 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
1274 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
1276 #endif /* IAM_RPMBT || IAM_RPMK */
1281 if (!(pipeChild = fork())) {
1283 (void) dup2(p[0], STDIN_FILENO);
1285 (void) execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
1286 fprintf(stderr, _("exec failed\n"));
1290 (void) dup2(p[1], STDOUT_FILENO);
1297 (void) rpmdbInit(rootdir, 0644);
1300 case MODE_REBUILDDB:
1301 ec = rpmdbRebuild(rootdir);
1304 ec = rpmdbVerify(rootdir);
1306 #if !defined(__LCLINT__)
1309 case MODE_QUERYTAGS:
1311 case MODE_UNINSTALL:
1314 case MODE_RECOMPILE:
1318 if (!showVersion && !help && !noUsageMsg) printUsage();
1321 #endif /* IAM_RPMDB */
1325 case MODE_RECOMPILE:
1327 while (!rpmIsVerbose())
1328 rpmIncreaseVerbosity();
1330 if (!poptPeekArg(optCon))
1331 argerror(_("no packages files given for rebuild"));
1333 ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
1334 if (bigMode == MODE_REBUILD) {
1335 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1336 ba->buildAmount |= RPMBUILD_RMSOURCE;
1337 ba->buildAmount |= RPMBUILD_RMSPEC;
1338 ba->buildAmount |= RPMBUILD_CLEAN;
1339 ba->buildAmount |= RPMBUILD_RMBUILD;
1342 while ((pkg = poptGetArg(optCon))) {
1343 const char * specFile = NULL;
1344 char * cookie = NULL;
1346 ec = rpmInstallSource("", pkg, &specFile, &cookie);
1350 ba->rootdir = rootdir;
1351 ec = build(specFile, ba, passPhrase, cookie, rcfile);
1354 free((void *)specFile);
1365 while (!rpmIsVerbose())
1366 rpmIncreaseVerbosity();
1368 switch (ba->buildChar) {
1370 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1373 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1374 ba->buildAmount |= RPMBUILD_CLEAN;
1377 ba->buildAmount |= RPMBUILD_INSTALL;
1378 if ((ba->buildChar == 'i') && ba->shortCircuit)
1382 ba->buildAmount |= RPMBUILD_BUILD;
1383 if ((ba->buildChar == 'c') && ba->shortCircuit)
1387 ba->buildAmount |= RPMBUILD_PREP;
1391 ba->buildAmount |= RPMBUILD_FILECHECK;
1394 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1398 if (!poptPeekArg(optCon)) {
1399 if (bigMode == MODE_BUILD)
1400 argerror(_("no spec files given for build"));
1402 argerror(_("no tar files given for build"));
1405 while ((pkg = poptGetArg(optCon))) {
1406 ba->rootdir = rootdir;
1407 ec = build(pkg, ba, passPhrase, NULL, rcfile);
1410 rpmFreeMacros(NULL);
1411 (void) rpmReadConfigFiles(rcfile, NULL);
1415 #if !defined(__LCLINT__)
1418 case MODE_QUERYTAGS:
1420 case MODE_UNINSTALL:
1424 case MODE_REBUILDDB:
1426 if (!showVersion && !help && !noUsageMsg) printUsage();
1429 #endif /* IAM_RPMBT */
1432 case MODE_UNINSTALL:
1433 if (!poptPeekArg(optCon))
1434 argerror(_("no packages given for uninstall"));
1436 if (noDeps) eraseInterfaceFlags |= UNINSTALL_NODEPS;
1438 ec = rpmErase(rootdir, (const char **)poptGetArgs(optCon),
1439 transFlags, eraseInterfaceFlags);
1444 probFilter |= RPMPROB_FILTER_REPLACEPKG |
1445 RPMPROB_FILTER_REPLACEOLDFILES |
1446 RPMPROB_FILTER_REPLACENEWFILES |
1447 RPMPROB_FILTER_OLDPACKAGE;
1450 /* RPMTRANS_FLAG_BUILD_PROBS */
1451 /* RPMTRANS_FLAG_KEEPOBSOLETE */
1454 if (transFlags & RPMTRANS_FLAG_NODOCS)
1456 else if (rpmExpandNumeric("%{_excludedocs}"))
1457 transFlags |= RPMTRANS_FLAG_NODOCS;
1460 if (noDeps) installInterfaceFlags |= INSTALL_NODEPS;
1462 if (!poptPeekArg(optCon))
1463 argerror(_("no packages given for install"));
1465 /* we've already ensured !(!prefix && !relocations) */
1467 relocations = alloca(2 * sizeof(*relocations));
1468 relocations[0].oldPath = NULL; /* special case magic */
1469 relocations[0].newPath = prefix;
1470 relocations[1].oldPath = relocations[1].newPath = NULL;
1471 } else if (relocations) {
1472 relocations = xrealloc(relocations,
1473 sizeof(*relocations) * (numRelocations + 1));
1474 relocations[numRelocations].oldPath = NULL;
1475 relocations[numRelocations].newPath = NULL;
1478 ec += rpmInstall(rootdir, (const char **)poptGetArgs(optCon),
1479 transFlags, installInterfaceFlags, probFilter,
1482 #if !defined(__LCLINT__)
1485 case MODE_QUERYTAGS:
1488 case MODE_RECOMPILE:
1493 case MODE_REBUILDDB:
1495 if (!showVersion && !help && !noUsageMsg) printUsage();
1498 #endif /* IAM_RPMEIU */
1504 qva->qva_prefix = rootdir;
1505 if (qva->qva_source == RPMQV_ALL) {
1506 if (poptPeekArg(optCon))
1507 argerror(_("extra arguments given for query of all packages"));
1509 ec = rpmQuery(qva, RPMQV_ALL, NULL);
1511 if (!poptPeekArg(optCon))
1512 argerror(_("no arguments given for query"));
1513 while ((pkg = poptGetArg(optCon)))
1514 ec += rpmQuery(qva, qva->qva_source, pkg);
1522 verifyFlags = (VERIFY_FILES|VERIFY_DEPS|VERIFY_SCRIPT|VERIFY_MD5);
1523 verifyFlags &= ~qva->qva_flags;
1525 qva->qva_prefix = rootdir;
1526 qva->qva_flags = verifyFlags;
1527 if (qva->qva_source == RPMQV_ALL) {
1528 if (poptPeekArg(optCon))
1529 argerror(_("extra arguments given for verify of all packages"));
1530 ec = rpmVerify(qva, RPMQV_ALL, NULL);
1532 if (!poptPeekArg(optCon))
1533 argerror(_("no arguments given for verify"));
1534 while ((pkg = poptGetArg(optCon)))
1535 ec += rpmVerify(qva, qva->qva_source, pkg);
1539 case MODE_QUERYTAGS:
1541 argerror(_("unexpected arguments to --querytags "));
1543 rpmDisplayQueryTags(stdout);
1546 #if !defined(__LCLINT__)
1548 case MODE_UNINSTALL:
1551 case MODE_RECOMPILE:
1556 case MODE_REBUILDDB:
1558 if (!showVersion && !help && !noUsageMsg) printUsage();
1561 #endif /* IAM_RPMQV */
1565 if (!poptPeekArg(optCon))
1566 argerror(_("no packages given for signature check"));
1567 if (!noPgp) checksigFlags |= CHECKSIG_PGP;
1568 if (!noGpg) checksigFlags |= CHECKSIG_GPG;
1569 if (!noMd5) checksigFlags |= CHECKSIG_MD5;
1570 ec = rpmCheckSig(checksigFlags, (const char **)poptGetArgs(optCon));
1571 /* XXX don't overflow single byte exit status */
1572 if (ec > 255) ec = 255;
1576 if (!poptPeekArg(optCon))
1577 argerror(_("no packages given for signing"));
1578 ec = rpmReSign(addSign, passPhrase, (const char **)poptGetArgs(optCon));
1579 /* XXX don't overflow single byte exit status */
1580 if (ec > 255) ec = 255;
1582 #if !defined(__LCLINT__)
1585 case MODE_QUERYTAGS:
1587 case MODE_UNINSTALL:
1590 case MODE_RECOMPILE:
1593 case MODE_REBUILDDB:
1595 if (!showVersion && !help && !noUsageMsg) printUsage();
1598 #endif /* IAM_RPMK */
1601 if (!showVersion && !help && !noUsageMsg) printUsage();
1606 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1608 #endif /* IAM_RPMBT || IAM_RPMK */
1609 optCon = poptFreeContext(optCon);
1610 rpmFreeMacros(NULL);
1611 rpmFreeMacros(&rpmCLIMacroContext);
1615 (void) fclose(stdout);
1616 (void) waitpid(pipeChild, &status, 0);
1619 /* keeps memory leak checkers quiet */
1625 qva->qva_queryFormat = _free(qva->qva_queryFormat);
1629 ba->buildRootOverride = _free(ba->buildRootOverride);
1630 ba->targets = _free(ba->targets);
1633 #if HAVE_MCHECK_H && HAVE_MTRACE
1634 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */