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 */
789 /* Make a first pass through the arguments, looking for --rcfile */
790 /* We need to handle that before dealing with the rest of the arguments. */
791 /*@-nullpass -temptrans@*/
792 optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
793 /*@=nullpass =temptrans@*/
794 (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
795 (void) poptReadDefaultConfig(optCon, 1);
796 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
798 /* reading rcfile early makes it easy to override */
799 /* XXX only --rcfile (and --showrc) need this pre-parse */
801 while ((arg = poptGetNextOpt(optCon)) > 0) {
804 rpmIncreaseVerbosity(); /* XXX silly use by showrc */
811 if (rpmReadConfigFiles(rcfile, NULL))
815 (void) rpmShowRC(stdout);
819 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
821 poptResetContext(optCon);
824 if (qva->qva_queryFormat) free((void *)qva->qva_queryFormat);
825 memset(qva, 0, sizeof(*qva));
826 qva->qva_source = RPMQV_PACKAGE;
832 if (ba->buildRootOverride) free((void *)ba->buildRootOverride);
833 if (ba->targets) free(ba->targets);
834 memset(ba, 0, sizeof(*ba));
840 transFlags = RPMTRANS_FLAG_NONE;
841 probFilter = RPMPROB_FILTER_NONE;
842 installInterfaceFlags = INSTALL_NONE;
843 eraseInterfaceFlags = UNINSTALL_NONE;
846 while ((arg = poptGetNextOpt(optCon)) > 0) {
847 optArg = poptGetOptArg(optCon);
852 rpmIncreaseVerbosity();
855 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
858 if (bigMode == MODE_QUERY) {
860 const char * infoCommand[] = { "--info", NULL };
862 (void) poptStuffArgs(optCon, infoCommand);
866 if (bigMode == MODE_INSTALL)
868 if (bigMode == MODE_UNKNOWN) {
870 const char * installCommand[] = { "--install", NULL };
872 (void) poptStuffArgs(optCon, installCommand);
876 #endif /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */
881 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
882 argerror(_("only one major mode may be specified"));
883 bigMode = MODE_UNINSTALL;
887 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
888 argerror(_("only one major mode may be specified"));
889 bigMode = MODE_INSTALL;
892 #ifdef DYING /* XXX handled by popt */
894 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
895 argerror(_("only one major mode may be specified"));
896 bigMode = MODE_INSTALL;
900 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
901 argerror(_("only one major mode may be specified"));
902 bigMode = MODE_INSTALL;
906 case GETOPT_EXCLUDEPATH:
907 if (optArg == NULL || *optArg != '/')
908 argerror(_("exclude paths must begin with a /"));
910 relocations = xrealloc(relocations,
911 sizeof(*relocations) * (numRelocations + 1));
912 /*@-observertrans -dependenttrans@*/ /* FIX: W2DO? */
913 relocations[numRelocations].oldPath = optArg;
914 relocations[numRelocations++].newPath = NULL;
915 /*@=observertrans =dependenttrans@*/
918 case GETOPT_RELOCATE:
919 { char * newPath = NULL;
920 if (optArg == NULL || *optArg != '/')
921 argerror(_("relocations must begin with a /"));
922 if (!(newPath = strchr(optArg, '=')))
923 argerror(_("relocations must contain a ="));
926 argerror(_("relocations must have a / following the ="));
927 relocations = xrealloc(relocations,
928 sizeof(*relocations) * (numRelocations + 1));
929 /*@-observertrans -kepttrans@*/ /* FIX: W2DO? */
930 relocations[numRelocations].oldPath = optArg;
931 relocations[numRelocations++].newPath = newPath;
932 /*@=observertrans =kepttrans@*/
934 #endif /* IAM_RPMEIU */
937 case GETOPT_REBUILDDB:
938 if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILDDB)
939 argerror(_("only one major mode may be specified"));
940 bigMode = MODE_REBUILDDB;
942 case GETOPT_VERIFYDB:
943 if (bigMode != MODE_UNKNOWN && bigMode != MODE_VERIFYDB)
944 argerror(_("only one major mode may be specified"));
945 bigMode = MODE_VERIFYDB;
951 if (bigMode != MODE_UNKNOWN && bigMode != MODE_CHECKSIG)
952 argerror(_("only one major mode may be specified"));
953 bigMode = MODE_CHECKSIG;
957 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
958 argerror(_("only one major mode may be specified"));
959 bigMode = MODE_RESIGN;
960 addSign = RESIGN_NEW_SIGNATURE;
965 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
966 argerror(_("only one major mode may be specified"));
967 bigMode = MODE_RESIGN;
968 addSign = RESIGN_ADD_SIGNATURE;
971 #endif /* IAM_RPMK */
973 case GETOPT_DEFINEMACRO:
975 (void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
976 (void) rpmDefineMacro(&rpmCLIMacroContext, optArg,RMIL_CMDLINE);
981 case GETOPT_EVALMACRO:
983 const char *val = rpmExpand(optArg, NULL);
984 fprintf(stdout, "%s\n", val);
990 #if defined(GETOPT_RCFILE)
992 fprintf(stderr, _("The --rcfile option has been eliminated.\n"));
993 fprintf(stderr, _("Use \"--macros <file:...>\" instead.\n"));
995 /*@notreached@*/ break;
999 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
1005 rpmSetVerbosity(RPMMESS_QUIET);
1007 if (showVersion) printVersion();
1010 fprintf(stderr, "%s: %s\n",
1011 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
1017 switch (ba->buildMode) {
1018 case 'b': bigMode = MODE_BUILD; break;
1019 case 't': bigMode = MODE_TARBUILD; break;
1020 case 'B': bigMode = MODE_REBUILD; break;
1021 case 'C': bigMode = MODE_RECOMPILE; break;
1024 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
1025 bigMode = MODE_BUILD;
1027 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
1028 bigMode = MODE_BUILD;
1030 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
1031 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
1032 argerror("--buildroot may only be used during package builds");
1034 #endif /* IAM_RPMBT */
1038 if (bigMode != MODE_UNKNOWN)
1039 argerror(_("only one major mode may be specified"));
1041 bigMode = MODE_INITDB;
1043 #endif /* IAM_RPMDB */
1046 switch (qva->qva_mode) {
1047 case 'q': bigMode = MODE_QUERY; break;
1048 case 'V': bigMode = MODE_VERIFY; break;
1049 case 'Q': bigMode = MODE_QUERYTAGS; break;
1052 if (qva->qva_sourceCount) {
1053 if (qva->qva_sourceCount > 2)
1054 argerror(_("one type of query/verify may be performed at a "
1057 if (qva->qva_flags && (bigMode & ~MODES_QV))
1058 argerror(_("unexpected query flags"));
1060 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
1061 argerror(_("unexpected query format"));
1063 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
1064 argerror(_("unexpected query source"));
1067 if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
1068 argerror(_("--dbpath given for operation that does not use a "
1071 #if defined(IAM_RPMEIU)
1073 if (!( bigMode == MODE_INSTALL ) && force)
1074 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
1075 #endif /* IAM_RPMEIU */
1078 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_FORCERELOCATE))
1079 argerror(_("files may only be relocated during package installation"));
1081 if (relocations && prefix)
1082 argerror(_("only one of --prefix or --relocate may be used"));
1084 if (bigMode != MODE_INSTALL && relocations)
1085 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
1087 if (bigMode != MODE_INSTALL && prefix)
1088 argerror(_("--prefix may only be used when installing new packages"));
1090 if (prefix && prefix[0] != '/')
1091 argerror(_("arguments to --prefix must begin with a /"));
1093 if (bigMode != MODE_INSTALL && (installInterfaceFlags & INSTALL_HASH))
1094 argerror(_("--hash (-h) may only be specified during package "
1097 if (bigMode != MODE_INSTALL && (installInterfaceFlags & INSTALL_PERCENT))
1098 argerror(_("--percent may only be specified during package "
1101 if (bigMode != MODE_INSTALL &&
1102 (probFilter & (RPMPROB_FILTER_REPLACEOLDFILES|RPMPROB_FILTER_REPLACENEWFILES)))
1103 argerror(_("--replacefiles may only be specified during package "
1106 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_REPLACEPKG))
1107 argerror(_("--replacepkgs may only be specified during package "
1110 if (bigMode != MODE_INSTALL && (transFlags & RPMTRANS_FLAG_NODOCS))
1111 argerror(_("--excludedocs may only be specified during package "
1114 if (bigMode != MODE_INSTALL && incldocs)
1115 argerror(_("--includedocs may only be specified during package "
1118 if (incldocs && (transFlags & RPMTRANS_FLAG_NODOCS))
1119 argerror(_("only one of --excludedocs and --includedocs may be "
1122 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_IGNOREARCH))
1123 argerror(_("--ignorearch may only be specified during package "
1126 if (bigMode != MODE_INSTALL && (probFilter & RPMPROB_FILTER_IGNOREOS))
1127 argerror(_("--ignoreos may only be specified during package "
1130 if (bigMode != MODE_INSTALL &&
1131 (probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
1132 argerror(_("--ignoresize may only be specified during package "
1135 if ((eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_UNINSTALL)
1136 argerror(_("--allmatches may only be specified during package "
1139 if ((transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
1140 argerror(_("--allfiles may only be specified during package "
1143 if ((transFlags & RPMTRANS_FLAG_JUSTDB) &&
1144 bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL)
1145 argerror(_("--justdb may only be specified during package "
1146 "installation and erasure"));
1147 #endif /* IAM_RPMEIU */
1149 #if defined(IAM_RPMEIU)
1150 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1151 (transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
1152 argerror(_("script disabling options may only be specified during "
1153 "package installation and erasure"));
1155 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1156 (transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
1157 argerror(_("trigger disabling options may only be specified during "
1158 "package installation and erasure"));
1160 if (noDeps & (bigMode & ~MODES_FOR_NODEPS))
1161 argerror(_("--nodeps may only be specified during package "
1162 "building, rebuilding, recompilation, installation,"
1163 "erasure, and verification"));
1165 if ((transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
1166 argerror(_("--test may only be specified during package installation, "
1167 "erasure, and building"));
1168 #endif /* IAM_RPMEIU */
1170 if (rootdir && rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
1171 argerror(_("--root (-r) may only be specified during "
1172 "installation, erasure, querying, and "
1173 "database rebuilds"));
1176 switch (urlIsURL(rootdir)) {
1178 if (bigMode & MODES_FOR_ROOT)
1181 case URL_IS_UNKNOWN:
1182 if (rootdir[0] != '/')
1183 argerror(_("arguments to --root (-r) must begin with a /"));
1189 if (noPgp && bigMode != MODE_CHECKSIG)
1190 argerror(_("--nopgp may only be used during signature checking"));
1192 if (noGpg && bigMode != MODE_CHECKSIG)
1193 argerror(_("--nogpg may only be used during signature checking"));
1196 #if defined(IAM_RPMK) || defined(IAM_RPMQV)
1197 if (noMd5 && bigMode != MODE_CHECKSIG && bigMode != MODE_VERIFY)
1198 argerror(_("--nomd5 may only be used during signature checking and "
1199 "package verification"));
1202 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1203 #if defined(IAM_RPMBT)
1207 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
1208 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
1213 if ((av = poptGetArgs(optCon)) == NULL) {
1214 fprintf(stderr, _("no files to sign\n"));
1218 if (stat(*av, &sb)) {
1219 fprintf(stderr, _("cannot access file %s\n"), *av);
1230 if (poptPeekArg(optCon)) {
1232 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
1236 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
1237 !rpmDetectPGPVersion(NULL)) {
1238 fprintf(stderr, _("pgp not found: "));
1243 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
1244 if (passPhrase == NULL) {
1245 fprintf(stderr, _("Pass phrase check failed\n"));
1249 fprintf(stderr, _("Pass phrase is good.\n"));
1250 passPhrase = xstrdup(passPhrase);
1254 _("Invalid %%_signature spec in macro file.\n"));
1257 /*@notreached@*/ break;
1261 argerror(_("--sign may only be used during package building"));
1264 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
1265 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
1267 #endif /* IAM_RPMBT || IAM_RPMK */
1272 if (!(pipeChild = fork())) {
1274 (void) dup2(p[0], STDIN_FILENO);
1276 (void) execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
1277 fprintf(stderr, _("exec failed\n"));
1281 (void) dup2(p[1], STDOUT_FILENO);
1288 (void) rpmdbInit(rootdir, 0644);
1291 case MODE_REBUILDDB:
1292 ec = rpmdbRebuild(rootdir);
1295 ec = rpmdbVerify(rootdir);
1297 #if !defined(__LCLINT__)
1300 case MODE_QUERYTAGS:
1302 case MODE_UNINSTALL:
1305 case MODE_RECOMPILE:
1309 if (!showVersion && !help && !noUsageMsg) printUsage();
1312 #endif /* IAM_RPMDB */
1316 case MODE_RECOMPILE:
1318 while (!rpmIsVerbose())
1319 rpmIncreaseVerbosity();
1321 if (!poptPeekArg(optCon))
1322 argerror(_("no packages files given for rebuild"));
1324 ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
1325 if (bigMode == MODE_REBUILD) {
1326 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1327 ba->buildAmount |= RPMBUILD_RMSOURCE;
1328 ba->buildAmount |= RPMBUILD_RMSPEC;
1329 ba->buildAmount |= RPMBUILD_CLEAN;
1330 ba->buildAmount |= RPMBUILD_RMBUILD;
1333 while ((pkg = poptGetArg(optCon))) {
1334 const char * specFile = NULL;
1335 char * cookie = NULL;
1337 ec = rpmInstallSource("", pkg, &specFile, &cookie);
1341 ba->rootdir = rootdir;
1342 ec = build(specFile, ba, passPhrase, cookie, rcfile);
1345 free((void *)specFile);
1356 while (!rpmIsVerbose())
1357 rpmIncreaseVerbosity();
1359 switch (ba->buildChar) {
1361 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1364 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1365 ba->buildAmount |= RPMBUILD_CLEAN;
1368 ba->buildAmount |= RPMBUILD_INSTALL;
1369 if ((ba->buildChar == 'i') && ba->shortCircuit)
1373 ba->buildAmount |= RPMBUILD_BUILD;
1374 if ((ba->buildChar == 'c') && ba->shortCircuit)
1378 ba->buildAmount |= RPMBUILD_PREP;
1382 ba->buildAmount |= RPMBUILD_FILECHECK;
1385 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1389 if (!poptPeekArg(optCon)) {
1390 if (bigMode == MODE_BUILD)
1391 argerror(_("no spec files given for build"));
1393 argerror(_("no tar files given for build"));
1396 while ((pkg = poptGetArg(optCon))) {
1397 ba->rootdir = rootdir;
1398 ec = build(pkg, ba, passPhrase, NULL, rcfile);
1401 rpmFreeMacros(NULL);
1402 (void) rpmReadConfigFiles(rcfile, NULL);
1406 #if !defined(__LCLINT__)
1409 case MODE_QUERYTAGS:
1411 case MODE_UNINSTALL:
1415 case MODE_REBUILDDB:
1417 if (!showVersion && !help && !noUsageMsg) printUsage();
1420 #endif /* IAM_RPMBT */
1423 case MODE_UNINSTALL:
1424 if (!poptPeekArg(optCon))
1425 argerror(_("no packages given for uninstall"));
1427 if (noDeps) eraseInterfaceFlags |= UNINSTALL_NODEPS;
1429 ec = rpmErase(rootdir, (const char **)poptGetArgs(optCon),
1430 transFlags, eraseInterfaceFlags);
1435 probFilter |= RPMPROB_FILTER_REPLACEPKG |
1436 RPMPROB_FILTER_REPLACEOLDFILES |
1437 RPMPROB_FILTER_REPLACENEWFILES |
1438 RPMPROB_FILTER_OLDPACKAGE;
1441 /* RPMTRANS_FLAG_BUILD_PROBS */
1442 /* RPMTRANS_FLAG_KEEPOBSOLETE */
1445 if (transFlags & RPMTRANS_FLAG_NODOCS)
1447 else if (rpmExpandNumeric("%{_excludedocs}"))
1448 transFlags |= RPMTRANS_FLAG_NODOCS;
1451 if (noDeps) installInterfaceFlags |= INSTALL_NODEPS;
1453 if (!poptPeekArg(optCon))
1454 argerror(_("no packages given for install"));
1456 /* we've already ensured !(!prefix && !relocations) */
1458 relocations = alloca(2 * sizeof(*relocations));
1459 relocations[0].oldPath = NULL; /* special case magic */
1460 relocations[0].newPath = prefix;
1461 relocations[1].oldPath = relocations[1].newPath = NULL;
1462 } else if (relocations) {
1463 relocations = xrealloc(relocations,
1464 sizeof(*relocations) * (numRelocations + 1));
1465 relocations[numRelocations].oldPath = NULL;
1466 relocations[numRelocations].newPath = NULL;
1469 ec += rpmInstall(rootdir, (const char **)poptGetArgs(optCon),
1470 transFlags, installInterfaceFlags, probFilter,
1473 #if !defined(__LCLINT__)
1476 case MODE_QUERYTAGS:
1479 case MODE_RECOMPILE:
1484 case MODE_REBUILDDB:
1486 if (!showVersion && !help && !noUsageMsg) printUsage();
1489 #endif /* IAM_RPMEIU */
1495 qva->qva_prefix = rootdir;
1496 if (qva->qva_source == RPMQV_ALL) {
1497 if (poptPeekArg(optCon))
1498 argerror(_("extra arguments given for query of all packages"));
1500 ec = rpmQuery(qva, RPMQV_ALL, NULL);
1502 if (!poptPeekArg(optCon))
1503 argerror(_("no arguments given for query"));
1504 while ((pkg = poptGetArg(optCon)))
1505 ec += rpmQuery(qva, qva->qva_source, pkg);
1513 verifyFlags = (VERIFY_FILES|VERIFY_DEPS|VERIFY_SCRIPT|VERIFY_MD5);
1514 verifyFlags &= ~qva->qva_flags;
1516 qva->qva_prefix = rootdir;
1517 qva->qva_flags = verifyFlags;
1518 if (qva->qva_source == RPMQV_ALL) {
1519 if (poptPeekArg(optCon))
1520 argerror(_("extra arguments given for verify of all packages"));
1521 ec = rpmVerify(qva, RPMQV_ALL, NULL);
1523 if (!poptPeekArg(optCon))
1524 argerror(_("no arguments given for verify"));
1525 while ((pkg = poptGetArg(optCon)))
1526 ec += rpmVerify(qva, qva->qva_source, pkg);
1530 case MODE_QUERYTAGS:
1532 argerror(_("unexpected arguments to --querytags "));
1534 rpmDisplayQueryTags(stdout);
1537 #if !defined(__LCLINT__)
1539 case MODE_UNINSTALL:
1542 case MODE_RECOMPILE:
1547 case MODE_REBUILDDB:
1549 if (!showVersion && !help && !noUsageMsg) printUsage();
1552 #endif /* IAM_RPMQV */
1556 if (!poptPeekArg(optCon))
1557 argerror(_("no packages given for signature check"));
1558 if (!noPgp) checksigFlags |= CHECKSIG_PGP;
1559 if (!noGpg) checksigFlags |= CHECKSIG_GPG;
1560 if (!noMd5) checksigFlags |= CHECKSIG_MD5;
1561 ec = rpmCheckSig(checksigFlags, (const char **)poptGetArgs(optCon));
1562 /* XXX don't overflow single byte exit status */
1563 if (ec > 255) ec = 255;
1567 if (!poptPeekArg(optCon))
1568 argerror(_("no packages given for signing"));
1569 ec = rpmReSign(addSign, passPhrase, (const char **)poptGetArgs(optCon));
1570 /* XXX don't overflow single byte exit status */
1571 if (ec > 255) ec = 255;
1573 #if !defined(__LCLINT__)
1576 case MODE_QUERYTAGS:
1578 case MODE_UNINSTALL:
1581 case MODE_RECOMPILE:
1584 case MODE_REBUILDDB:
1586 if (!showVersion && !help && !noUsageMsg) printUsage();
1589 #endif /* IAM_RPMK */
1592 if (!showVersion && !help && !noUsageMsg) printUsage();
1597 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1599 #endif /* IAM_RPMBT || IAM_RPMK */
1600 optCon = poptFreeContext(optCon);
1601 rpmFreeMacros(NULL);
1602 rpmFreeMacros(&rpmCLIMacroContext);
1606 (void) fclose(stdout);
1607 (void) waitpid(pipeChild, &status, 0);
1610 /* keeps memory leak checkers quiet */
1616 qva->qva_queryFormat = _free(qva->qva_queryFormat);
1620 ba->buildRootOverride = _free(ba->buildRootOverride);
1621 ba->targets = _free(ba->targets);
1624 #if HAVE_MCHECK_H && HAVE_MTRACE
1625 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */