18 #define GETOPT_REBUILD 1003
19 #define GETOPT_RECOMPILE 1004
23 #define GETOPT_REBUILDDB 1013
24 static int initdb = 0;
29 #define GETOPT_INSTALL 1014
30 #define GETOPT_RELOCATE 1016
31 #define GETOPT_EXCLUDEPATH 1019
32 static int allFiles = 0;
33 static int allMatches = 0;
34 static int badReloc = 0;
35 static int excldocs = 0;
36 static int ignoreArch = 0;
37 static int ignoreOs = 0;
38 static int ignoreSize = 0;
39 static int incldocs = 0;
40 static int justdb = 0;
41 static int noOrder = 0;
42 static int oldPackage = 0;
43 static char * prefix = NULL;
44 static int replaceFiles = 0;
45 static int replacePackages = 0;
46 static int showHash = 0;
47 static int showPercents = 0;
48 static int noTriggers = 0;
49 #endif /* IAM_RPMEIU */
52 #define GETOPT_ADDSIGN 1005
53 #define GETOPT_RESIGN 1006
58 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
59 #include "signature.h"
64 #define GETOPT_DBPATH 1010
65 #define GETOPT_SHOWRC 1018
66 #define GETOPT_DEFINEMACRO 1020
67 #define GETOPT_EVALMACRO 1021
68 #define GETOPT_RCFILE 1022
72 MODE_QUERY = (1 << 0),
73 MODE_VERIFY = (1 << 3),
74 MODE_QUERYTAGS = (1 << 9),
75 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
77 MODE_INSTALL = (1 << 1),
78 MODE_UNINSTALL = (1 << 2),
79 #define MODES_IE (MODE_INSTALL | MODE_UNINSTALL)
81 MODE_BUILD = (1 << 4),
82 MODE_REBUILD = (1 << 5),
83 MODE_RECOMPILE = (1 << 8),
84 MODE_TARBUILD = (1 << 11),
85 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
87 MODE_CHECKSIG = (1 << 6),
88 MODE_RESIGN = (1 << 7),
89 #define MODES_K (MODE_CHECKSIG | MODES_RESIGN)
91 MODE_INITDB = (1 << 10),
92 MODE_REBUILDDB = (1 << 12),
93 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB)
98 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
99 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
100 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
101 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
103 extern int _ftp_debug;
105 extern int _rpmio_debug;
106 extern int _url_debug;
107 extern int _noDirTokens;
109 extern const char * rpmNAME;
110 extern const char * rpmEVR;
113 extern MacroContext rpmCLIMacroContext;
115 /* options for all executables */
118 static int noUsageMsg = 0;
119 static char * pipeOutput = NULL;
120 static int quiet = 0;
121 static char * rcfile = NULL;
122 static char * rootdir = "/";
123 static int showrc = 0;
124 static int showVersion = 0;
126 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
127 static int signIt = 0;
128 #endif /* IAM_RPMBT || IAM_RPMK */
130 #if defined(IAM_RPMQV) || defined(IAM_RPMK)
131 static int noMd5 = 0;
134 #if defined(IAM_RPMEIU)
135 static int noDeps = 0;
138 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU)
139 static int noScripts = 0;
142 #if defined(IAM_RPMEIU)
143 static int force = 0;
147 static struct poptOption rpmAllPoptTable[] = {
148 { "version", '\0', 0, &showVersion, 0,
149 N_("print the version of rpm being used"),
151 { "quiet", '\0', 0, &quiet, 0,
152 N_("provide less detailed output"), NULL},
153 { "verbose", 'v', 0, 0, 'v',
154 N_("provide more detailed output"), NULL},
155 { "define", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, GETOPT_DEFINEMACRO,
156 N_("define macro <name> with value <body>"),
157 N_("'<name> <body>'") },
158 { "eval", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, GETOPT_EVALMACRO,
159 N_("print macro expansion of <expr>+"),
161 { "pipe", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &pipeOutput, 0,
162 N_("send stdout to <cmd>"),
164 { "root", 'r', POPT_ARG_STRING, &rootdir, 0,
165 N_("use <dir> as the top level directory"),
167 { "macros", '\0', POPT_ARG_STRING, ¯ofiles, 0,
168 N_("read <file:...> instead of default macro file(s)"),
171 { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
172 N_("read <file:...> instead of default rpmrc file(s)"),
175 { "rcfile", '\0', 0, 0, GETOPT_RCFILE,
176 N_("read <file:...> instead of default rpmrc file(s)"),
179 { "showrc", '\0', 0, &showrc, GETOPT_SHOWRC,
180 N_("display final rpmrc and macro configuration"),
183 #if HAVE_LIBIO_H && defined(_IO_BAD_SEEN)
184 { "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1,
185 N_("disable use of libio(3) API"), NULL},
187 { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
188 N_("debug protocol data stream"), NULL},
189 { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
190 N_("debug rpmio I/O"), NULL},
191 { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
192 N_("debug URL cache handling"), NULL},
198 static struct poptOption rpmDatabasePoptTable[] = {
199 { "initdb", '\0', 0, &initdb, 0,
200 N_("initialize database"), NULL},
201 { "rebuilddb", '\0', 0, 0, GETOPT_REBUILDDB,
202 N_("rebuild database inverted lists from installed package headers"),
204 { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1,
205 N_("generate headers compatible with (legacy) rpm[23] packaging"),
207 { "dirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 0,
208 N_("generate headers compatible with rpm4 packaging"),
213 #endif /* IAM_RPMDB */
216 static struct poptOption rpmSignPoptTable[] = {
217 { "addsign", '\0', 0, 0, GETOPT_ADDSIGN,
218 N_("add a signature to a package"),
220 { "resign", '\0', 0, 0, GETOPT_RESIGN,
221 N_("sign a package (discard current signature)"),
223 { "sign", '\0', 0, &signIt, 0,
224 N_("generate PGP/GPG signature"),
226 { "checksig", 'K', 0, 0, 'K',
227 N_("verify package signature"),
229 { "nogpg", '\0', 0, &noGpg, 0,
230 N_("skip any PGP signatures"),
232 { "nopgp", '\0', 0, &noPgp, 0,
233 N_("skip any GPG signatures"),
235 { "nomd5", '\0', 0, &noMd5, 0,
236 N_("do not verify file md5 checksums"),
241 #endif /* IAM_RPMK */
244 static struct poptOption rpmInstallPoptTable[] = {
245 { "allfiles", '\0', 0, &allFiles, 0,
246 N_("install all files, even configurations which might otherwise be skipped"),
248 { "allmatches", '\0', 0, &allMatches, 0,
249 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
251 { "badreloc", '\0', 0, &badReloc, 0,
252 N_("relocate files in non-relocateable package"),
254 { "erase", 'e', 0, 0, 'e',
255 N_("erase (uninstall) package"),
257 { "excludedocs", '\0', 0, &excldocs, 0,
258 N_("do not install documentation"),
260 { "excludepath", '\0', POPT_ARG_STRING, 0, GETOPT_EXCLUDEPATH,
261 N_("skip files with leading component <path> "),
263 { "force", '\0', 0, &force, 0,
264 N_("short hand for --replacepkgs --replacefiles"),
266 { "freshen", 'F', 0, 0, 'F',
267 N_("upgrade package if already installed"),
268 N_("<packagefile>+") },
269 { "hash", 'h', 0, &showHash, 0,
270 N_("print hash marks as package installs (good with -v)"),
272 { "ignorearch", '\0', 0, &ignoreArch, 0,
273 N_("don't verify package architecture"),
275 { "ignoreos", '\0', 0, &ignoreOs, 0,
276 N_("don't verify package operating system"),
278 { "ignoresize", '\0', 0, &ignoreSize, 0,
279 N_("don't check disk space before installing"),
281 { "includedocs", '\0', 0, &incldocs, 0,
282 N_("install documentation"),
284 { "install", '\0', 0, 0, GETOPT_INSTALL,
285 N_("install package"),
286 N_("<packagefile>+") },
287 { "justdb", '\0', 0, &justdb, 0,
288 N_("update the database, but do not modify the filesystem"),
290 { "nodeps", '\0', 0, &noDeps, 0,
291 N_("do not verify package dependencies"),
293 { "noorder", '\0', 0, &noOrder, 0,
294 N_("do not reorder package installation to satisfy dependencies"),
296 { "noscripts", '\0', 0, &noScripts, 0,
297 N_("do not execute scripts (if any)"),
299 { "notriggers", '\0', 0, &noTriggers, 0,
300 N_("don't execute any scriptlets triggered by this package"),
302 { "oldpackage", '\0', 0, &oldPackage, 0,
303 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
305 { "percent", '\0', 0, &showPercents, 0,
306 N_("print percentages as package installs"),
308 { "prefix", '\0', POPT_ARG_STRING, &prefix, 0,
309 N_("relocate the package to <dir>, if relocatable"),
311 { "relocate", '\0', POPT_ARG_STRING, 0, GETOPT_RELOCATE,
312 N_("relocate files from <oldpath> to <newpath>"),
313 N_("<oldpath>=<newpath>") },
314 { "replacefiles", '\0', 0, &replaceFiles, 0,
315 N_("install even if the package replaces installed files"),
317 { "replacepkgs", '\0', 0, &replacePackages, 0,
318 N_("reinstall if the package is already present"),
320 { "test", '\0', 0, &test, 0,
321 N_("don't install, but tell if it would work or not"),
323 { "upgrade", 'U', 0, 0, 'U',
324 N_("upgrade package"),
325 N_("<packagefile>+") },
326 { "uninstall", 'u', POPT_ARGFLAG_DOC_HIDDEN, 0, 'u',
332 #endif /* IAM_RPMEIU */
334 /* the structure describing the options we take and the defaults */
335 static struct poptOption optionsTable[] = {
336 #if !defined(_AUTOHELP)
337 { "help", '\0', 0, &help, 0, NULL, NULL},
340 /* XXX colliding options */
341 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
342 { NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i', NULL, NULL},
346 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
347 N_("Query options (with -q or --query):"),
349 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
350 N_("Verify options (with -V or --verify):"),
352 #endif /* IAM_RPMQV */
355 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
356 N_("Signature options:"),
358 #endif /* IAM_RPMK */
361 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
362 N_("Database options:"),
364 #endif /* IAM_RPMDB */
367 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
368 N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
370 #endif /* IAM_RPMBT */
372 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmAllPoptTable, 0,
373 N_("Common options for all rpm modes:"),
381 /* MiNT cannot dynamically increase the stack. */
382 long _stksize = 64 * 1024L;
385 static void argerror(const char * desc) {
386 fprintf(stderr, _("rpm: %s\n"), desc);
390 static void printHelp(void);
391 static void printVersion(void);
392 static void printBanner(void);
393 static void printUsage(void);
394 static void printHelpLine(char * prefix, char * help);
396 static void printVersion(void) {
397 fprintf(stdout, _("RPM version %s\n"), rpmEVR);
400 static void printBanner(void) {
401 puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
402 puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
405 static void printUsage(void) {
413 fprintf(fp, _("Usage: %s {--help}\n"), __progname);
414 fprintf(fp, (" %s {--version}\n"), __progname);
417 fprintf(fp, _(" %s {--initdb} [--dbpath <dir>]\n"), __progname);
418 fprintf(fp, _(" %s {--rebuilddb} [--macros <file:...>] [--dbpath <dir>]\n"), __progname);
422 fprintf(fp, _(" %s {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]\n"), __progname);
423 puts(_(" [--replacepkgs] [--replacefiles] [--root <dir>]"));
424 puts(_(" [--excludedocs] [--includedocs] [--noscripts]"));
425 puts(_(" [--macros <file:...>] [--ignorearch] [--dbpath <dir>]"));
426 puts(_(" [--prefix <dir>] [--ignoreos] [--nodeps] [--allfiles]"));
427 puts(_(" [--ftpproxy <host>] [--ftpport <port>]"));
428 puts(_(" [--httpproxy <host>] [--httpport <port>]"));
429 puts(_(" [--justdb] [--noorder] [--relocate oldpath=newpath]"));
430 puts(_(" [--badreloc] [--notriggers] [--excludepath <path>]"));
431 puts(_(" [--ignoresize] file1.rpm ... fileN.rpm"));
432 fprintf(fp, (" %s {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]\n"), __progname);
433 puts(_(" [--oldpackage] [--root <dir>] [--noscripts]"));
434 puts(_(" [--excludedocs] [--includedocs] [--macros <file:...>]"));
435 puts(_(" [--ignorearch] [--dbpath <dir>] [--prefix <dir>] "));
436 puts(_(" [--ftpproxy <host>] [--ftpport <port>]"));
437 puts(_(" [--httpproxy <host>] [--httpport <port>]"));
438 puts(_(" [--ignoreos] [--nodeps] [--allfiles] [--justdb]"));
439 puts(_(" [--noorder] [--relocate oldpath=newpath]"));
440 puts(_(" [--badreloc] [--excludepath <path>] [--ignoresize]"));
441 puts(_(" file1.rpm ... fileN.rpm"));
442 fprintf(fp, _(" %s {--erase -e} [--root <dir>] [--noscripts] [--macros <file:...>]\n"), __progname);
443 puts(_(" [--dbpath <dir>] [--nodeps] [--allmatches]"));
444 puts(_(" [--justdb] [--notriggers] package1 ... packageN"));
445 #endif /* IAM_RPMEIU */
448 fprintf(fp, (" %s {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]\n"), __progname);
449 puts(_(" [--scripts] [--root <dir>] [--macros <file:...>]"));
450 puts(_(" [--whatprovides] [--whatrequires] [--requires]"));
451 puts(_(" [--triggeredby]"));
452 puts(_(" [--ftpproxy <host>] [--ftpport <port>]"));
453 puts(_(" [--httpproxy <host>] [--httpport <port>]"));
454 puts(_(" [--provides] [--triggers] [--dump]"));
455 puts(_(" [--changelog] [--dbpath <dir>] [targets]"));
456 fprintf(fp, _(" %s {--verify -V -y} [-afpg] [--root <dir>] [--macros <file:...>]\n"), __progname);
457 puts(_(" [--dbpath <dir>] [--nodeps] [--nofiles] [--noscripts]"));
458 puts(_(" [--nomd5] [targets]"));
459 fprintf(fp, (" %s {--querytags}\n"), __progname);
460 fprintf(fp, _(" %s {--setperms} [-afpg] [target]\n"), __progname);
461 fprintf(fp, _(" %s {--setugids} [-afpg] [target]\n"), __progname);
462 #endif /* IAM_RPMQV */
465 fprintf(fp, _(" %s {--resign} [--macros <file:...>] package1 package2 ... packageN\n"), __progname);
466 fprintf(fp, _(" %s {--addsign} [--macros <file:...>] package1 package2 ... packageN"), __progname);
467 fprintf(fp, _(" %s {--checksig -K} [--nopgp] [--nogpg] [--nomd5] [--macros <file:...>]\n"), __progname);
468 puts(_(" package1 ... packageN"));
469 #endif /* IAM_RPMK */
473 static void printHelpLine(char * prefix, char * help) {
474 int indentLength = strlen(prefix) + 3;
475 int lineLength = 79 - indentLength;
476 int helpLength = strlen(help);
480 fprintf(stdout, "%s - ", prefix);
482 while (helpLength > lineLength) {
483 ch = help + lineLength - 1;
484 while (ch > help && !isspace(*ch)) ch--;
485 if (ch == help) break; /* give up */
486 while (ch > (help + 1) && isspace(*ch)) ch--;
489 sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
490 fprintf(stdout, format, help, " ");
492 while (isspace(*help) && *help) help++;
493 helpLength = strlen(help);
496 if (helpLength) puts(help);
499 static void printHelp(void) {
505 printHelpLine( " --help ",
506 _("print this message"));
507 printHelpLine( " --version ",
508 _("print the version of rpm being used"));
511 puts( _(" All modes support the following options:"));
512 printHelpLine(_(" --define '<name> <body>'"),
513 _("define macro <name> with value <body>"));
514 printHelpLine(_(" --eval '<expr>+' "),
515 _("print the expansion of macro <expr> to stdout"));
516 printHelpLine(_(" --pipe <cmd> "),
517 _("send stdout to <cmd>"));
518 printHelpLine(_(" --macros <file:...> "),
519 _("use <file:...> instead of default list of macro files"));
520 printHelpLine( " --showrc ",
521 _("display final rpmrc and macro configuration"));
522 #if defined(IAM_RPMBT) || defined(IAM_RPMDB) || defined(IAM_RPMEIU) || defined(IAM_RPMQV)
523 printHelpLine(_(" --dbpath <dir> "),
524 _("use <dir> as the directory for the database"));
525 printHelpLine(_(" --root <dir> "),
526 _("use <dir> as the top level directory"));
527 #endif /* IAM_RPMBT || IAM_RPMDB || IAM_RPMEIU || IAM_RPMQV */
528 printHelpLine( " -v ",
529 _("be a little more verbose"));
530 printHelpLine( " -vv ",
531 _("be incredibly verbose (for debugging)"));
533 #if defined(IAM_RPMEIU) || defined(IAM_RPMQV)
535 puts( _(" Install, upgrade and query (with -p) modes allow URL's to be used in place"));
536 puts( _(" of file names as well as the following options:"));
537 printHelpLine(_(" --ftpproxy <host> "),
538 _("hostname or IP of ftp proxy"));
539 printHelpLine(_(" --ftpport <port> "),
540 _("port number of ftp server (or proxy)"));
541 printHelpLine(_(" --httpproxy <host> "),
542 _("hostname or IP of http proxy"));
543 printHelpLine(_(" --httpport <port> "),
544 _("port number of http server (or proxy)"));
545 #endif /* IAM_RPMEIU || IAM_RPMQV */
549 puts( _(" Package specification options:"));
550 printHelpLine( " -a, --all ",
551 _("query/verify all packages"));
552 printHelpLine(_(" -f <file>+ "),
553 _("query/verify package owning <file>"));
554 printHelpLine(_(" -p <packagefile>+ "),
555 _("query/verify (uninstalled) package <packagefile>"));
556 printHelpLine(_(" --triggeredby <pkg> "),
557 _("query/verify packages triggered by <pkg>"));
558 printHelpLine(_(" --whatprovides <cap> "),
559 _("query/verify packages which provide <cap> capability"));
560 printHelpLine(_(" --whatrequires <cap> "),
561 _("query/verify packages which require <cap> capability"));
563 printHelpLine( " -q, --query ",
565 printHelpLine(_(" --queryformat <qfmt> "),
566 _("use <qfmt> as the header format (implies --info)"));
568 puts( _(" Information selection options:"));
569 printHelpLine( " -i, --info ",
570 _("display package information"));
571 printHelpLine( " --changelog ",
572 _("display the package's change log"));
573 printHelpLine( " -l ",
574 _("display package file list"));
575 printHelpLine( " -s ",
576 _("show file states (implies -l)"));
577 printHelpLine( " -d ",
578 _("list only documentation files (implies -l)"));
579 printHelpLine( " -c ",
580 _("list only configuration files (implies -l)"));
581 printHelpLine( " --dump ",
582 _("show all verifiable information for each file (must be used with -l, -c, or -d)"));
583 printHelpLine( " --provides ",
584 _("list capabilities provided by package"));
585 printHelpLine( " -R, --requires ",
586 _("list capabilities required by package"));
587 printHelpLine( " --scripts ",
588 _("print the various [un]install scriptlets"));
589 printHelpLine( " --triggers ",
590 _("show the trigger scriptlets contained in the package"));
592 printHelpLine( " -V, -y, --verify ",
593 _("verify a package installation using the same same package specification options as -q"));
594 printHelpLine( " --nodeps ",
595 _("do not verify package dependencies"));
596 printHelpLine( " --nofiles ",
597 _("do not verify file attributes"));
598 printHelpLine( " --nomd5 ",
599 _("do not verify file md5 checksums"));
600 printHelpLine( " --noscripts ",
601 _("do not execute scripts (if any)"));
603 printHelpLine( " --querytags ",
604 _("list the tags that can be used in a query format"));
605 printHelpLine( " --setperms ",
606 _("set the file permissions to those in the package database"
607 " using the same package specification options as -q"));
608 printHelpLine( " --setugids ",
609 _("set the file owner and group to those in the package "
610 "database using the same package specification options as "
612 #endif /* IAM_RPMQV */
616 puts( _(" --install <packagefile>"));
617 printHelpLine(_(" -i <packagefile> "),
618 _("install package"));
619 printHelpLine( " --allfiles ",
620 _("install all files, even configurations which might "
621 "otherwise be skipped"));
622 printHelpLine( " --badreloc ",
623 _("relocate files in non-relocateable package"));
624 printHelpLine( " --excludedocs ",
625 _("do not install documentation"));
626 printHelpLine(_(" --excludepath <path> "),
627 _("skip files with leading component <path> "));
628 printHelpLine( " --force ",
629 _("short hand for --replacepkgs --replacefiles"));
630 printHelpLine( " -h, --hash ",
631 _("print hash marks as package installs (good with -v)"));
632 printHelpLine( " --ignorearch ",
633 _("don't verify package architecture"));
634 printHelpLine( " --ignoresize ",
635 _("don't check disk space before installing"));
636 printHelpLine( " --ignoreos ",
637 _("don't verify package operating system"));
638 printHelpLine( " --includedocs ",
639 _("install documentation"));
640 printHelpLine( " --justdb ",
641 _("update the database, but do not modify the filesystem"));
642 printHelpLine( " --nodeps ",
643 _("do not verify package dependencies"));
644 printHelpLine( " --noorder ",
645 _("do not reorder package installation to satisfy dependencies"));
646 printHelpLine( " --noscripts ",
647 _("don't execute any installation scriptlets"));
648 printHelpLine( " --notriggers ",
649 _("don't execute any scriptlets triggered by this package"));
650 printHelpLine( " --percent ",
651 _("print percentages as package installs"));
652 printHelpLine(_(" --prefix <dir> "),
653 _("relocate the package to <dir>, if relocatable"));
654 printHelpLine(_(" --relocate <oldpath>=<newpath>"),
655 _("relocate files from <oldpath> to <newpath>"));
656 printHelpLine( " --replacefiles ",
657 _("install even if the package replaces installed files"));
658 printHelpLine( " --replacepkgs ",
659 _("reinstall if the package is already present"));
660 printHelpLine( " --test ",
661 _("don't install, but tell if it would work or not"));
663 puts( _(" --upgrade <packagefile>"));
664 printHelpLine(_(" -U <packagefile> "),
665 _("upgrade package (same options as --install, plus)"));
666 printHelpLine( " --oldpackage ",
667 _("upgrade to an old version of the package (--force on upgrades does this automatically)"));
669 puts( _(" --erase <package>"));
670 printHelpLine( " -e <package> ",
671 _("erase (uninstall) package"));
672 printHelpLine( " --allmatches ",
673 _("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"));
674 printHelpLine( " --justdb ",
675 _("update the database, but do not modify the filesystem"));
676 printHelpLine( " --nodeps ",
677 _("do not verify package dependencies"));
678 printHelpLine( " --noorder ",
679 _("do not reorder package installation to satisfy dependencies"));
680 printHelpLine( " --noscripts ",
681 _("do not execute any package specific scripts"));
682 printHelpLine( " --notriggers ",
683 _("don't execute any scripts triggered by this package"));
684 #endif /* IAM_RPMEIU */
688 printHelpLine(_(" --resign <pkg>+ "),
689 _("sign a package (discard current signature)"));
690 printHelpLine(_(" --addsign <pkg>+ "),
691 _("add a signature to a package"));
693 puts( _(" --checksig <pkg>+"));
694 printHelpLine(_(" -K <pkg>+ "),
695 _("verify package signature"));
696 printHelpLine( " --nopgp ",
697 _("skip any PGP signatures"));
698 printHelpLine( " --nogpg ",
699 _("skip any GPG signatures"));
700 printHelpLine( " --nomd5 ",
701 _("skip any MD5 signatures"));
702 #endif /* IAM_RPMK */
706 printHelpLine( " --initdb ",
707 _("initalize database (unnecessary, legacy use)"));
708 printHelpLine( " --rebuilddb ",
709 _("rebuild database indices from existing database headers"));
714 int main(int argc, const char ** argv)
716 enum modes bigMode = MODE_UNKNOWN;
719 QVA_t *qva = &rpmQVArgs;
723 struct rpmBuildArguments *ba = &rpmBTArgs;
727 rpmRelocation * relocations = NULL;
728 int numRelocations = 0;
729 int installFlags = 0, uninstallFlags = 0, interfaceFlags = 0;
735 #if defined(IAM_RPMK)
736 rpmResignFlags addSign = RESIGN_NEW_SIGNATURE;
737 rpmCheckSigFlags checksigFlags = CHECKSIG_NONE;
740 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
741 char * passPhrase = "";
754 #if HAVE_MCHECK_H && HAVE_MTRACE
755 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
757 setprogname(argv[0]); /* Retrofit glibc __progname */
759 /* XXX glibc churn sanity */
760 if (__progname == NULL) {
761 if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
762 else __progname = argv[0];
765 /* Set the major mode based on argv[0] */
767 if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
768 if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
769 if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
772 if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
773 if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
774 if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
775 if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
778 if (!strcmp(__progname, "rpme")) bigMode = MODE_UNINSTALL;
779 if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
780 if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
783 /* set the defaults for the various command line options */
786 #if HAVE_LIBIO_H && defined(_IO_BAD_SEEN)
794 /* XXX Eliminate query linkage loop */
796 parseSpecVec = parseSpec;
797 freeSpecVec = freeSpec;
799 /* set up the correct locale */
800 setlocale(LC_ALL, "" );
803 #define LOCALEDIR "/usr/share/locale"
805 bindtextdomain(PACKAGE, LOCALEDIR);
808 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
810 /* Make a first pass through the arguments, looking for --rcfile */
811 /* We need to handle that before dealing with the rest of the arguments. */
812 optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
813 poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
814 poptReadDefaultConfig(optCon, 1);
815 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
817 /* reading rcfile early makes it easy to override */
818 /* XXX only --rcfile (and --showrc) need this pre-parse */
820 while ((arg = poptGetNextOpt(optCon)) > 0) {
823 rpmIncreaseVerbosity(); /* XXX silly use by showrc */
830 if (rpmReadConfigFiles(rcfile, NULL))
838 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
840 poptResetContext(optCon);
843 if (qva->qva_queryFormat) free((void *)qva->qva_queryFormat);
844 memset(qva, 0, sizeof(*qva));
845 qva->qva_source = RPMQV_PACKAGE;
851 if (ba->buildRootOverride) free((void *)ba->buildRootOverride);
852 if (ba->targets) free(ba->targets);
853 memset(ba, 0, sizeof(*ba));
858 while ((arg = poptGetNextOpt(optCon)) > 0) {
859 optArg = poptGetOptArg(optCon);
864 rpmIncreaseVerbosity();
867 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
870 if (bigMode == MODE_QUERY) {
871 const char * infoCommand[] = { "--info", NULL };
872 poptStuffArgs(optCon, infoCommand);
876 if (bigMode == MODE_INSTALL)
878 if (bigMode == MODE_UNKNOWN) {
879 const char * installCommand[] = { "--install", NULL };
880 poptStuffArgs(optCon, installCommand);
884 #endif /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */
888 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
889 argerror(_("only one major mode may be specified"));
890 bigMode = MODE_UNINSTALL;
891 rpmMessage(RPMMESS_ERROR, _("-u and --uninstall are deprecated and no"
893 rpmMessage(RPMMESS_ERROR, _("Use -e or --erase instead.\n"));
897 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
898 argerror(_("only one major mode may be specified"));
899 bigMode = MODE_UNINSTALL;
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;
916 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
917 argerror(_("only one major mode may be specified"));
918 bigMode = MODE_INSTALL;
919 upgrade = 1; /* Freshen implies upgrade */
923 case GETOPT_EXCLUDEPATH:
925 argerror(_("exclude paths must begin with a /"));
927 relocations = xrealloc(relocations,
928 sizeof(*relocations) * (numRelocations + 1));
929 relocations[numRelocations].oldPath = optArg;
930 relocations[numRelocations++].newPath = NULL;
933 case GETOPT_RELOCATE:
934 { char * errString = NULL;
936 argerror(_("relocations must begin with a /"));
937 if (!(errString = strchr(optArg, '=')))
938 argerror(_("relocations must contain a ="));
940 if (*errString != '/')
941 argerror(_("relocations must have a / following the ="));
942 relocations = xrealloc(relocations,
943 sizeof(*relocations) * (numRelocations + 1));
944 relocations[numRelocations].oldPath = optArg;
945 relocations[numRelocations++].newPath = errString;
947 #endif /* IAM_RPMEIU */
950 case GETOPT_REBUILDDB:
951 if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILDDB)
952 argerror(_("only one major mode may be specified"));
953 bigMode = MODE_REBUILDDB;
959 if (bigMode != MODE_UNKNOWN && bigMode != MODE_CHECKSIG)
960 argerror(_("only one major mode may be specified"));
961 bigMode = MODE_CHECKSIG;
965 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
966 argerror(_("only one major mode may be specified"));
967 bigMode = MODE_RESIGN;
968 addSign = RESIGN_NEW_SIGNATURE;
973 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
974 argerror(_("only one major mode may be specified"));
975 bigMode = MODE_RESIGN;
976 addSign = RESIGN_ADD_SIGNATURE;
979 #endif /* IAM_RPMK */
981 case GETOPT_DEFINEMACRO:
982 rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
983 rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
987 case GETOPT_EVALMACRO:
988 { const char *val = rpmExpand(optArg, NULL);
989 fprintf(stdout, "%s\n", val);
995 fprintf(stderr, _("The --rcfile option has been eliminated.\n"));
996 fprintf(stderr, _("Use \"--macros <file:...>\" instead.\n"));
998 /*@notreached@*/ break;
1001 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
1007 rpmSetVerbosity(RPMMESS_QUIET);
1009 if (showVersion) printVersion();
1010 if (help) printHelp();
1013 fprintf(stderr, "%s: %s\n",
1014 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
1020 switch (ba->buildMode) {
1021 case 'b': bigMode = MODE_BUILD; break;
1022 case 't': bigMode = MODE_TARBUILD; break;
1023 case 'B': bigMode = MODE_REBUILD; break;
1024 case 'C': bigMode = MODE_RECOMPILE; break;
1027 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
1028 bigMode = MODE_BUILD;
1030 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
1031 bigMode = MODE_BUILD;
1033 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
1034 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
1035 argerror("--buildroot may only be used during package builds");
1037 #endif /* IAM_RPMBT */
1041 if (bigMode != MODE_UNKNOWN)
1042 argerror(_("only one major mode may be specified"));
1044 bigMode = MODE_INITDB;
1046 #endif /* IAM_RPMDB */
1049 switch (qva->qva_mode) {
1050 case 'q': bigMode = MODE_QUERY; break;
1051 case 'V': bigMode = MODE_VERIFY; break;
1052 case 'Q': bigMode = MODE_QUERYTAGS; break;
1055 if (qva->qva_sourceCount) {
1056 if (qva->qva_sourceCount > 2)
1057 argerror(_("one type of query/verify may be performed at a "
1060 if (qva->qva_flags && (bigMode & ~MODES_QV))
1061 argerror(_("unexpected query flags"));
1063 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
1064 argerror(_("unexpected query format"));
1066 if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
1067 argerror(_("unexpected query source"));
1070 if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
1071 argerror(_("--dbpath given for operation that does not use a "
1074 #if defined(IAM_RPMEIU)
1076 if (!( bigMode == MODE_INSTALL ) && force)
1077 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
1078 #endif /* IAM_RPMEIU */
1081 if (bigMode != MODE_INSTALL && badReloc)
1082 argerror(_("files may only be relocated during package installation"));
1084 if (relocations && prefix)
1085 argerror(_("only one of --prefix or --relocate may be used"));
1087 if (bigMode != MODE_INSTALL && relocations)
1088 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
1090 if (bigMode != MODE_INSTALL && prefix)
1091 argerror(_("--prefix may only be used when installing new packages"));
1093 if (prefix && prefix[0] != '/')
1094 argerror(_("arguments to --prefix must begin with a /"));
1096 if (bigMode != MODE_INSTALL && showHash)
1097 argerror(_("--hash (-h) may only be specified during package "
1100 if (bigMode != MODE_INSTALL && showPercents)
1101 argerror(_("--percent may only be specified during package "
1104 if (bigMode != MODE_INSTALL && replaceFiles)
1105 argerror(_("--replacefiles may only be specified during package "
1108 if (bigMode != MODE_INSTALL && replacePackages)
1109 argerror(_("--replacepkgs may only be specified during package "
1112 if (bigMode != MODE_INSTALL && excldocs)
1113 argerror(_("--excludedocs may only be specified during package "
1116 if (bigMode != MODE_INSTALL && incldocs)
1117 argerror(_("--includedocs may only be specified during package "
1120 if (excldocs && incldocs)
1121 argerror(_("only one of --excludedocs and --includedocs may be "
1124 if (bigMode != MODE_INSTALL && ignoreArch)
1125 argerror(_("--ignorearch may only be specified during package "
1128 if (bigMode != MODE_INSTALL && ignoreOs)
1129 argerror(_("--ignoreos may only be specified during package "
1132 if (bigMode != MODE_INSTALL && ignoreSize)
1133 argerror(_("--ignoresize may only be specified during package "
1136 if (allMatches && bigMode != MODE_UNINSTALL)
1137 argerror(_("--allmatches may only be specified during package "
1140 if (allFiles && bigMode != MODE_INSTALL)
1141 argerror(_("--allfiles may only be specified during package "
1144 if (justdb && 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_RPMQV) || defined(IAM_RPMEIU)
1150 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1151 bigMode != MODE_VERIFY && noScripts)
1152 argerror(_("--noscripts may only be specified during package "
1153 "installation, erasure, and verification"));
1154 #endif /* IAM_RPMQV || IAM_RPMEIU */
1156 #if defined(IAM_RPMEIU)
1157 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL && noTriggers)
1158 argerror(_("--notriggers may only be specified during package "
1159 "installation and erasure"));
1161 if (noDeps & (bigMode & ~MODES_FOR_NODEPS))
1162 argerror(_("--nodeps may only be specified during package "
1163 "building, rebuilding, recompilation, installation,"
1164 "erasure, and verification"));
1166 if (test && (bigMode & ~MODES_FOR_TEST))
1167 argerror(_("--test may only be specified during package installation, "
1168 "erasure, and building"));
1169 #endif /* IAM_RPMEIU */
1171 if (rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
1172 argerror(_("--root (-r) may only be specified during "
1173 "installation, erasure, querying, and "
1174 "database rebuilds"));
1177 switch (urlIsURL(rootdir)) {
1179 if (bigMode & MODES_FOR_ROOT)
1182 case URL_IS_UNKNOWN:
1183 if (rootdir[0] != '/')
1184 argerror(_("arguments to --root (-r) must begin with a /"));
1190 if (oldPackage && !upgrade)
1191 argerror(_("--oldpackage may only be used during upgrades"));
1195 if (noPgp && bigMode != MODE_CHECKSIG)
1196 argerror(_("--nopgp may only be used during signature checking"));
1198 if (noGpg && bigMode != MODE_CHECKSIG)
1199 argerror(_("--nogpg may only be used during signature checking"));
1202 #if defined(IAM_RPMK) || defined(IAM_RPMQV)
1203 if (noMd5 && bigMode != MODE_CHECKSIG && bigMode != MODE_VERIFY)
1204 argerror(_("--nomd5 may only be used during signature checking and "
1205 "package verification"));
1208 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1209 #if defined(IAM_RPMBT)
1213 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
1214 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
1219 if ((argv = poptGetArgs(optCon)) == NULL) {
1220 fprintf(stderr, _("no files to sign\n"));
1224 if (stat(*argv, &sb)) {
1225 fprintf(stderr, _("cannot access file %s\n"), *argv);
1231 if (errors) return errors;
1233 if (poptPeekArg(optCon)) {
1235 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
1239 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
1240 !rpmDetectPGPVersion(NULL)) {
1241 fprintf(stderr, _("pgp not found: "));
1245 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
1246 if (passPhrase == NULL) {
1247 fprintf(stderr, _("Pass phrase check failed\n"));
1250 fprintf(stderr, _("Pass phrase is good.\n"));
1251 passPhrase = xstrdup(passPhrase);
1255 _("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 rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
1267 #endif /* IAM_RPMBT || IAM_RPMK */
1272 if (!(pipeChild = fork())) {
1274 dup2(p[0], STDIN_FILENO);
1276 execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
1277 fprintf(stderr, _("exec failed\n"));
1281 dup2(p[1], STDOUT_FILENO);
1288 rpmdbInit(rootdir, 0644);
1291 case MODE_REBUILDDB:
1292 ec = rpmdbRebuild(rootdir);
1296 case MODE_QUERYTAGS:
1298 case MODE_UNINSTALL:
1301 case MODE_RECOMPILE:
1305 if (!showVersion && !help && !noUsageMsg) printUsage();
1307 #endif /* IAM_RPMDB */
1311 case MODE_RECOMPILE:
1314 rpmSetVerbosity(RPMMESS_VERBOSE);
1316 if (!poptPeekArg(optCon))
1317 argerror(_("no packages files given for rebuild"));
1319 ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
1320 if (bigMode == MODE_REBUILD) {
1321 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1322 ba->buildAmount |= RPMBUILD_RMSOURCE;
1323 ba->buildAmount |= RPMBUILD_RMSPEC;
1324 ba->buildAmount |= RPMBUILD_CLEAN;
1325 ba->buildAmount |= RPMBUILD_RMBUILD;
1328 while ((pkg = poptGetArg(optCon))) {
1329 const char * specFile = NULL;
1330 char * cookie = NULL;
1332 ec = rpmInstallSource("", pkg, &specFile, &cookie);
1336 ba->rootdir = rootdir;
1337 ec = build(specFile, ba, passPhrase, cookie, rcfile);
1340 free((void *)specFile);
1352 rpmSetVerbosity(RPMMESS_VERBOSE);
1354 switch (ba->buildChar) {
1356 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1359 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1360 ba->buildAmount |= RPMBUILD_CLEAN;
1363 ba->buildAmount |= RPMBUILD_INSTALL;
1364 if ((ba->buildChar == 'i') && ba->shortCircuit)
1368 ba->buildAmount |= RPMBUILD_BUILD;
1369 if ((ba->buildChar == 'c') && ba->shortCircuit)
1373 ba->buildAmount |= RPMBUILD_PREP;
1377 ba->buildAmount |= RPMBUILD_FILECHECK;
1380 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1384 if (!poptPeekArg(optCon)) {
1385 if (bigMode == MODE_BUILD)
1386 argerror(_("no spec files given for build"));
1388 argerror(_("no tar files given for build"));
1391 while ((pkg = poptGetArg(optCon))) {
1392 ba->rootdir = rootdir;
1393 ec = build(pkg, ba, passPhrase, NULL, rcfile);
1396 rpmFreeMacros(NULL);
1397 rpmReadConfigFiles(rcfile, NULL);
1403 case MODE_QUERYTAGS:
1405 case MODE_UNINSTALL:
1409 case MODE_REBUILDDB:
1410 if (!showVersion && !help && !noUsageMsg) printUsage();
1412 #endif /* IAM_RPMBT */
1415 case MODE_UNINSTALL:
1416 if (!poptPeekArg(optCon))
1417 argerror(_("no packages given for uninstall"));
1419 if (noScripts) uninstallFlags |= RPMTRANS_FLAG_NOSCRIPTS;
1420 if (noTriggers) uninstallFlags |= RPMTRANS_FLAG_NOTRIGGERS;
1421 if (test) uninstallFlags |= RPMTRANS_FLAG_TEST;
1422 if (justdb) uninstallFlags |= RPMTRANS_FLAG_JUSTDB;
1423 if (noDeps) interfaceFlags |= UNINSTALL_NODEPS;
1424 if (allMatches) interfaceFlags |= UNINSTALL_ALLMATCHES;
1426 ec = rpmErase(rootdir, (const char **)poptGetArgs(optCon),
1427 uninstallFlags, interfaceFlags);
1432 probFilter |= RPMPROB_FILTER_REPLACEPKG |
1433 RPMPROB_FILTER_REPLACEOLDFILES |
1434 RPMPROB_FILTER_REPLACENEWFILES |
1435 RPMPROB_FILTER_OLDPACKAGE;
1437 if (replaceFiles) probFilter |= RPMPROB_FILTER_REPLACEOLDFILES |
1438 RPMPROB_FILTER_REPLACENEWFILES;
1439 if (badReloc) probFilter |= RPMPROB_FILTER_FORCERELOCATE;
1440 if (replacePackages) probFilter |= RPMPROB_FILTER_REPLACEPKG;
1441 if (oldPackage) probFilter |= RPMPROB_FILTER_OLDPACKAGE;
1442 if (ignoreArch) probFilter |= RPMPROB_FILTER_IGNOREARCH;
1443 if (ignoreOs) probFilter |= RPMPROB_FILTER_IGNOREOS;
1444 if (ignoreSize) probFilter |= RPMPROB_FILTER_DISKSPACE;
1446 if (test) installFlags |= RPMTRANS_FLAG_TEST;
1447 /* RPMTRANS_FLAG_BUILD_PROBS */
1448 if (noScripts) installFlags |= RPMTRANS_FLAG_NOSCRIPTS;
1449 if (justdb) installFlags |= RPMTRANS_FLAG_JUSTDB;
1450 if (noTriggers) installFlags |= RPMTRANS_FLAG_NOTRIGGERS;
1453 installFlags |= RPMTRANS_FLAG_NODOCS;
1454 else if (rpmExpandNumeric("%{_excludedocs}"))
1455 installFlags |= RPMTRANS_FLAG_NODOCS;
1457 if (allFiles) installFlags |= RPMTRANS_FLAG_ALLFILES;
1458 /* RPMTRANS_FLAG_KEEPOBSOLETE */
1460 if (showPercents) interfaceFlags |= INSTALL_PERCENT;
1461 if (showHash) interfaceFlags |= INSTALL_HASH;
1462 if (noDeps) interfaceFlags |= INSTALL_NODEPS;
1463 if (noOrder) interfaceFlags |= INSTALL_NOORDER;
1464 if (upgrade) interfaceFlags |= INSTALL_UPGRADE;
1465 if (freshen) interfaceFlags |= (INSTALL_UPGRADE|INSTALL_FRESHEN);
1467 if (!poptPeekArg(optCon))
1468 argerror(_("no packages given for install"));
1470 /* we've already ensured !(!prefix && !relocations) */
1472 relocations = alloca(2 * sizeof(*relocations));
1473 relocations[0].oldPath = NULL; /* special case magic */
1474 relocations[0].newPath = prefix;
1475 relocations[1].oldPath = relocations[1].newPath = NULL;
1476 } else if (relocations) {
1477 relocations = xrealloc(relocations,
1478 sizeof(*relocations) * (numRelocations + 1));
1479 relocations[numRelocations].oldPath = NULL;
1480 relocations[numRelocations].newPath = NULL;
1483 ec += rpmInstall(rootdir, (const char **)poptGetArgs(optCon),
1484 installFlags, interfaceFlags, probFilter, relocations);
1488 case MODE_QUERYTAGS:
1491 case MODE_RECOMPILE:
1496 case MODE_REBUILDDB:
1497 if (!showVersion && !help && !noUsageMsg) printUsage();
1499 #endif /* IAM_RPMEIU */
1505 qva->qva_prefix = rootdir;
1506 if (qva->qva_source == RPMQV_ALL) {
1507 if (poptPeekArg(optCon))
1508 argerror(_("extra arguments given for query of all packages"));
1510 ec = rpmQuery(qva, RPMQV_ALL, NULL);
1512 if (!poptPeekArg(optCon))
1513 argerror(_("no arguments given for query"));
1514 while ((pkg = poptGetArg(optCon)))
1515 ec += rpmQuery(qva, qva->qva_source, pkg);
1523 verifyFlags = (VERIFY_FILES|VERIFY_DEPS|VERIFY_SCRIPT|VERIFY_MD5);
1524 verifyFlags &= ~qva->qva_flags;
1526 if (noDeps) verifyFlags &= ~VERIFY_DEPS;
1527 if (noScripts) verifyFlags &= ~VERIFY_SCRIPT;
1528 if (noMd5) verifyFlags &= ~VERIFY_MD5;
1531 qva->qva_prefix = rootdir;
1532 qva->qva_flags = verifyFlags;
1533 if (qva->qva_source == RPMQV_ALL) {
1534 if (poptPeekArg(optCon))
1535 argerror(_("extra arguments given for verify of all packages"));
1536 ec = rpmVerify(qva, RPMQV_ALL, NULL);
1538 if (!poptPeekArg(optCon))
1539 argerror(_("no arguments given for verify"));
1540 while ((pkg = poptGetArg(optCon)))
1541 ec += rpmVerify(qva, qva->qva_source, pkg);
1545 case MODE_QUERYTAGS:
1547 argerror(_("unexpected arguments to --querytags "));
1549 rpmDisplayQueryTags(stdout);
1553 case MODE_UNINSTALL:
1556 case MODE_RECOMPILE:
1561 case MODE_REBUILDDB:
1562 if (!showVersion && !help && !noUsageMsg) printUsage();
1564 #endif /* IAM_RPMQV */
1568 if (!poptPeekArg(optCon))
1569 argerror(_("no packages given for signature check"));
1570 if (!noPgp) checksigFlags |= CHECKSIG_PGP;
1571 if (!noGpg) checksigFlags |= CHECKSIG_GPG;
1572 if (!noMd5) checksigFlags |= CHECKSIG_MD5;
1573 ec = rpmCheckSig(checksigFlags, (const char **)poptGetArgs(optCon));
1574 /* XXX don't overflow single byte exit status */
1575 if (ec > 255) ec = 255;
1579 if (!poptPeekArg(optCon))
1580 argerror(_("no packages given for signing"));
1581 ec = rpmReSign(addSign, passPhrase, (const char **)poptGetArgs(optCon));
1582 /* XXX don't overflow single byte exit status */
1583 if (ec > 255) ec = 255;
1587 case MODE_QUERYTAGS:
1589 case MODE_UNINSTALL:
1592 case MODE_RECOMPILE:
1595 case MODE_REBUILDDB:
1596 if (!showVersion && !help && !noUsageMsg) printUsage();
1598 #endif /* IAM_RPMK */
1601 if (!showVersion && !help && !noUsageMsg) printUsage();
1606 poptFreeContext(optCon);
1607 rpmFreeMacros(NULL);
1608 rpmFreeMacros(&rpmCLIMacroContext);
1613 (void)waitpid(pipeChild, &status, 0);
1616 /* keeps memory leak checkers quiet */
1622 if (qva->qva_queryFormat) free((void *)qva->qva_queryFormat);
1626 if (ba->buildRootOverride) free((void *)ba->buildRootOverride);
1627 if (ba->targets) free(ba->targets);
1630 #if HAVE_MCHECK_H && HAVE_MTRACE
1631 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */