10 #define GETOPT_REBUILD 1003
11 #define GETOPT_RECOMPILE 1004
12 #define GETOPT_ADDSIGN 1005
13 #define GETOPT_RESIGN 1006
14 #define GETOPT_DBPATH 1010
15 #define GETOPT_TIMECHECK 1012
16 #define GETOPT_REBUILDDB 1013
17 #define GETOPT_INSTALL 1014
18 #define GETOPT_RELOCATE 1016
19 #define GETOPT_SHOWRC 1018
20 #define GETOPT_EXCLUDEPATH 1019
21 #define GETOPT_DEFINEMACRO 1020
22 #define GETOPT_EVALMACRO 1021
26 MODE_QUERY = (1 << 0),
27 MODE_INSTALL = (1 << 1),
28 MODE_UNINSTALL = (1 << 2),
29 MODE_VERIFY = (1 << 3),
30 MODE_BUILD = (1 << 4),
31 MODE_REBUILD = (1 << 5),
32 MODE_CHECKSIG = (1 << 6),
33 MODE_RESIGN = (1 << 7),
34 MODE_RECOMPILE = (1 << 8),
35 MODE_QUERYTAGS = (1 << 9),
36 MODE_INITDB = (1 << 10),
37 MODE_TARBUILD = (1 << 11),
38 MODE_REBUILDDB = (1 << 12)
41 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
42 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
43 #define MODES_IE (MODE_INSTALL | MODE_UNINSTALL)
44 #define MODES_DB (MODE_INITDB | MODE_REBUILDDB)
45 #define MODES_K (MODE_CHECKSIG | MODES_RESIGN)
47 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
48 #define MODES_FOR_TIMECHECK (MODES_BT)
49 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
50 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
51 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
53 /* the flags for the various options */
55 static int allMatches;
59 extern int _ftp_debug;
60 static char * ftpPort;
61 static char * ftpProxy;
62 static char * httpPort;
63 static char * httpProxy;
66 static int ignoreArch;
68 static int ignoreSize;
79 static int noTriggers;
80 static int noUsageMsg;
81 static int oldPackage;
82 static char * pipeOutput;
87 static int replaceFiles;
88 static int replacePackages;
89 static char * rootdir;
90 extern int _rpmio_debug;
91 static int showPercents;
95 extern int _url_debug;
96 extern int _noDirTokens;
98 static int showVersion;
99 extern const char * rpmNAME;
100 extern const char * rpmEVR;
103 extern MacroContext rpmCLIMacroContext;
105 static struct rpmQVArguments rpmQVArgs;
106 static struct rpmBuildArguments rpmBArgs;
108 /* the structure describing the options we take and the defaults */
109 static struct poptOption optionsTable[] = {
110 { "addsign", '\0', 0, 0, GETOPT_ADDSIGN, NULL, NULL},
111 /* all and allmatches both using 'a' is dumb */
112 { "all", 'a', 0, 0, 'a', NULL, NULL},
113 { "allfiles", '\0', 0, &allFiles, 0, NULL, NULL},
114 { "allmatches", '\0', 0, &allMatches, 0, NULL, NULL},
115 { "badreloc", '\0', 0, &badReloc, 0, NULL, NULL},
116 { "build", 'b', POPT_ARG_STRING, 0, 'b', NULL, NULL},
117 { "checksig", 'K', 0, 0, 'K', NULL, NULL},
118 { "dbpath", '\0', POPT_ARG_STRING, 0, GETOPT_DBPATH, NULL, NULL},
119 { "define", '\0', POPT_ARG_STRING, &noUsageMsg, GETOPT_DEFINEMACRO,NULL, NULL},
120 { "dirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 0, NULL, NULL},
121 { "erase", 'e', 0, 0, 'e', NULL, NULL},
122 { "eval", '\0', POPT_ARG_STRING, &noUsageMsg, GETOPT_EVALMACRO, NULL, NULL},
123 { "excludedocs", '\0', 0, &excldocs, 0, NULL, NULL},
124 { "excludepath", '\0', POPT_ARG_STRING, 0, GETOPT_EXCLUDEPATH, NULL, NULL},
125 { "force", '\0', 0, &force, 0, NULL, NULL},
126 { "ftpdebug", '\0', POPT_ARG_VAL, &_ftp_debug, -1, NULL, NULL},
127 { "ftpport", '\0', POPT_ARG_STRING, &ftpPort, 0, NULL, NULL},
128 { "ftpproxy", '\0', POPT_ARG_STRING, &ftpProxy, 0, NULL, NULL},
129 { "hash", 'h', 0, &showHash, 0, NULL, NULL},
130 { "help", '\0', 0, &help, 0, NULL, NULL},
131 { "httpport", '\0', POPT_ARG_STRING, &httpPort, 0, NULL, NULL},
132 { "httpproxy", '\0', POPT_ARG_STRING, &httpProxy, 0, NULL, NULL},
133 { NULL, 'i', 0, 0, 'i', NULL, NULL},
134 { "i18ndomains", '\0', POPT_ARG_STRING, &i18ndomains, 0,
135 N_("i18n catalogue domains to search for package text"),
136 "DOMAIN1[:DOMAIN2...]" },
137 { "ignorearch", '\0', 0, &ignoreArch, 0, NULL, NULL},
138 { "ignoreos", '\0', 0, &ignoreOs, 0, NULL, NULL},
139 { "ignoresize", '\0', 0, &ignoreSize, 0, NULL, NULL},
140 { "includedocs", '\0', 0, &incldocs, 0, NULL, NULL},
141 { "initdb", '\0', 0, &initdb, 0, NULL, NULL},
142 /* info and install both using 'i' is dumb */
143 { "install", '\0', 0, 0, GETOPT_INSTALL, NULL, NULL},
144 { "justdb", '\0', 0, &justdb, 0, NULL, NULL},
145 { "nodeps", '\0', 0, &noDeps, 0, NULL, NULL},
146 { "nodirtokens", '\0', POPT_ARG_VAL, &_noDirTokens, 1, NULL, NULL},
147 { "nogpg", '\0', 0, &noGpg, 0, NULL, NULL},
148 { "nolibio", '\0', 0, &noLibio, 0, NULL, NULL},
149 { "nomd5", '\0', 0, &noMd5, 0, NULL, NULL},
150 { "noorder", '\0', 0, &noOrder, 0, NULL, NULL},
151 { "nopgp", '\0', 0, &noPgp, 0, NULL, NULL},
152 { "noscripts", '\0', 0, &noScripts, 0, NULL, NULL},
153 { "notriggers", '\0', 0, &noTriggers, 0, NULL, NULL},
154 { "oldpackage", '\0', 0, &oldPackage, 0, NULL, NULL},
155 { "percent", '\0', 0, &showPercents, 0, NULL, NULL},
156 { "pipe", '\0', POPT_ARG_STRING, &pipeOutput, 0, NULL, NULL},
157 { "prefix", '\0', POPT_ARG_STRING, &prefix, 0, NULL, NULL},
158 { "query", 'q', 0, NULL, 'q', NULL, NULL},
159 { "querytags", '\0', 0, &queryTags, 0, NULL, NULL},
160 { "quiet", '\0', 0, &quiet, 0, NULL, NULL},
161 { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0, NULL, NULL},
162 { "rebuild", '\0', 0, 0, GETOPT_REBUILD, NULL, NULL},
163 { "rebuilddb", '\0', 0, 0, GETOPT_REBUILDDB, NULL, NULL},
164 { "recompile", '\0', 0, 0, GETOPT_RECOMPILE, NULL, NULL},
165 { "relocate", '\0', POPT_ARG_STRING, 0, GETOPT_RELOCATE, NULL, NULL},
166 { "replacefiles", '\0', 0, &replaceFiles, 0, NULL, NULL},
167 { "replacepkgs", '\0', 0, &replacePackages, 0, NULL, NULL},
168 { "resign", '\0', 0, 0, GETOPT_RESIGN, NULL, NULL},
169 { "root", 'r', POPT_ARG_STRING, &rootdir, 0, NULL, NULL},
170 { "rpmiodebug", '\0', POPT_ARG_VAL, &_rpmio_debug, -1, NULL, NULL},
171 { "showrc", '\0', 0, &showrc, GETOPT_SHOWRC, NULL, NULL},
172 { "sign", '\0', 0, &signIt, 0, NULL, NULL},
173 { "tarbuild", 't', POPT_ARG_STRING, 0, 't', NULL, NULL},
174 { "test", '\0', 0, &test, 0, NULL, NULL},
175 { "timecheck", '\0', POPT_ARG_STRING, 0, GETOPT_TIMECHECK, NULL, NULL},
176 { "upgrade", 'U', 0, 0, 'U', NULL, NULL},
177 { "urldebug", '\0', POPT_ARG_VAL, &_url_debug, -1, NULL, NULL},
178 { "uninstall", 'u', 0, 0, 'u', NULL, NULL},
179 { "verbose", 'v', 0, 0, 'v', NULL, NULL},
180 { "verify", 'V', 0, 0, 'V', NULL, NULL},
181 { NULL, 'y', 0, 0, 'V', NULL, NULL},
182 { "version", '\0', 0, &showVersion, 0, NULL, NULL},
183 { NULL, '\0', POPT_ARG_INCLUDE_TABLE,
184 rpmQVSourcePoptTable, 0, (void *) &rpmQVArgs, NULL },
185 { NULL, '\0', POPT_ARG_INCLUDE_TABLE,
186 rpmQueryPoptTable, 0, (void *) &rpmQVArgs, NULL },
187 { NULL, '\0', POPT_ARG_INCLUDE_TABLE,
188 rpmVerifyPoptTable, 0, (void *) &rpmQVArgs, NULL },
189 { NULL, '\0', POPT_ARG_INCLUDE_TABLE,
190 rpmBuildPoptTable, 0, (void *) &rpmBArgs, NULL },
191 { 0, 0, 0, 0, 0, NULL, NULL }
195 /* MiNT cannot dynamically increase the stack. */
196 long _stksize = 64 * 1024L;
199 static void argerror(char * desc) {
200 fprintf(stderr, _("rpm: %s\n"), desc);
204 static void printHelp(void);
205 static void printVersion(void);
206 static void printBanner(void);
207 static void printUsage(void);
208 static void printHelpLine(char * prefix, char * help);
210 static void printVersion(void) {
211 fprintf(stdout, _("RPM version %s\n"), rpmEVR);
214 static void printBanner(void) {
215 puts(_("Copyright (C) 1998 - Red Hat Software"));
216 puts(_("This may be freely redistributed under the terms of the GNU GPL"));
219 static void printUsage(void) {
224 puts(_("usage: rpm {--help}"));
225 puts(_(" rpm {--version}"));
226 puts(_(" rpm {--initdb} [--dbpath <dir>]"));
227 puts(_(" rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]"));
228 puts(_(" [--replacepkgs] [--replacefiles] [--root <dir>]"));
229 puts(_(" [--excludedocs] [--includedocs] [--noscripts]"));
230 puts(_(" [--rcfile <file>] [--ignorearch] [--dbpath <dir>]"));
231 puts(_(" [--prefix <dir>] [--ignoreos] [--nodeps] [--allfiles]"));
232 puts(_(" [--ftpproxy <host>] [--ftpport <port>] [--justdb]"));
233 puts(_(" [--httpproxy <host>] [--httpport <port>] "));
234 puts(_(" [--noorder] [--relocate oldpath=newpath]"));
235 puts(_(" [--badreloc] [--notriggers] [--excludepath <path>]"));
236 puts(_(" [--ignoresize] file1.rpm ... fileN.rpm"));
237 puts(_(" rpm {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]"));
238 puts(_(" [--oldpackage] [--root <dir>] [--noscripts]"));
239 puts(_(" [--excludedocs] [--includedocs] [--rcfile <file>]"));
240 puts(_(" [--ignorearch] [--dbpath <dir>] [--prefix <dir>] "));
241 puts(_(" [--ftpproxy <host>] [--ftpport <port>]"));
242 puts(_(" [--httpproxy <host>] [--httpport <port>] "));
243 puts(_(" [--ignoreos] [--nodeps] [--allfiles] [--justdb]"));
244 puts(_(" [--noorder] [--relocate oldpath=newpath]"));
245 puts(_(" [--badreloc] [--excludepath <path>] [--ignoresize]"));
246 puts(_(" file1.rpm ... fileN.rpm"));
247 puts(_(" rpm {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]"));
248 puts(_(" [--scripts] [--root <dir>] [--rcfile <file>]"));
249 puts(_(" [--whatprovides] [--whatrequires] [--requires]"));
250 puts(_(" [--triggeredby] [--ftpuseport] [--ftpproxy <host>]"));
251 puts(_(" [--httpproxy <host>] [--httpport <port>] "));
252 puts(_(" [--ftpport <port>] [--provides] [--triggers] [--dump]"));
253 puts(_(" [--changelog] [--dbpath <dir>] [targets]"));
254 puts(_(" rpm {--verify -V -y} [-afpg] [--root <dir>] [--rcfile <file>]"));
255 puts(_(" [--dbpath <dir>] [--nodeps] [--nofiles] [--noscripts]"));
256 puts(_(" [--nomd5] [targets]"));
257 puts(_(" rpm {--setperms} [-afpg] [target]"));
258 puts(_(" rpm {--setugids} [-afpg] [target]"));
259 puts(_(" rpm {--freshen -F} file1.rpm ... fileN.rpm"));
260 puts(_(" rpm {--erase -e} [--root <dir>] [--noscripts] [--rcfile <file>]"));
261 puts(_(" [--dbpath <dir>] [--nodeps] [--allmatches]"));
262 puts(_(" [--justdb] [--notriggers] rpackage1 ... packageN"));
263 puts(_(" rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile <file>]"));
264 puts(_(" [--sign] [--nobuild] [--timecheck <s>] ]"));
265 puts(_(" [--target=platform1[,platform2...]]"));
266 puts(_(" [--rmsource] [--rmspec] specfile"));
267 puts(_(" rpm {--rmsource} [--rcfile <file>] [-v] specfile"));
268 puts(_(" rpm {--rebuild} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"));
269 puts(_(" rpm {--recompile} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm"));
270 puts(_(" rpm {--resign} [--rcfile <file>] package1 package2 ... packageN"));
271 puts(_(" rpm {--addsign} [--rcfile <file>] package1 package2 ... packageN"));
272 puts(_(" rpm {--checksig -K} [--nopgp] [--nogpg] [--nomd5] [--rcfile <file>]"));
273 puts(_(" package1 ... packageN"));
274 puts(_(" rpm {--rebuilddb} [--rcfile <file>] [--dbpath <dir>]"));
275 puts(_(" rpm {--querytags}"));
278 static void printHelpLine(char * prefix, char * help) {
279 int indentLength = strlen(prefix) + 3;
280 int lineLength = 79 - indentLength;
281 int helpLength = strlen(help);
285 fprintf(stdout, "%s - ", prefix);
287 while (helpLength > lineLength) {
288 ch = help + lineLength - 1;
289 while (ch > help && !isspace(*ch)) ch--;
290 if (ch == help) break; /* give up */
291 while (ch > (help + 1) && isspace(*ch)) ch--;
294 sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
295 fprintf(stdout, format, help, " ");
297 while (isspace(*help) && *help) help++;
298 helpLength = strlen(help);
301 if (helpLength) puts(help);
304 static void printHelp(void) {
310 printHelpLine( " --help ",
311 _("print this message"));
312 printHelpLine( " --version ",
313 _("print the version of rpm being used"));
314 puts( _(" all modes support the following arguments:"));
315 printHelpLine(_(" --rcfile <file> "),
316 _("use <file> instead of /etc/rpmrc and $HOME/.rpmrc"));
317 printHelpLine( " -v ",
318 _("be a little more verbose"));
319 printHelpLine( " -vv ",
320 _("be incredibly verbose (for debugging)"));
321 printHelpLine( " -q ",
323 printHelpLine(_(" --root <dir> "),
324 _("use <dir> as the top level directory"));
325 printHelpLine(_(" --dbpath <dir> "),
326 _("use <dir> as the directory for the database"));
327 printHelpLine(_(" --queryformat <qfmt>"),
328 _("use <qfmt> as the header format (implies -i)"));
329 puts( _(" install, upgrade and query (with -p) allow ftp URL's to be used in place"));
330 puts( _(" of file names as well as the following options:"));
331 printHelpLine(_(" --ftpproxy <host> "),
332 _("hostname or IP of ftp proxy"));
333 printHelpLine(_(" --ftpport <port> "),
334 _("port number of ftp server (or proxy)"));
335 printHelpLine(_(" --httpproxy <host> "),
336 _("hostname or IP of http proxy"));
337 printHelpLine(_(" --httpport <port> "),
338 _("port number of http server (or proxy)"));
339 puts( _(" Package specification options:"));
340 printHelpLine( " -a ",
341 _("query all packages"));
342 printHelpLine(_(" -f <file>+ "),
343 _("query package owning <file>"));
344 printHelpLine(_(" -p <packagefile>+ "),
345 _("query (uninstalled) package <packagefile>"));
346 printHelpLine(_(" --triggeredby <pkg>"),
347 _("query packages triggered by <pkg>"));
348 printHelpLine(_(" --whatprovides <cap>"),
349 _("query packages which provide <cap> capability"));
350 printHelpLine(_(" --whatrequires <cap>"),
351 _("query packages which require <cap> capability"));
352 puts( _(" Information selection options:"));
353 printHelpLine( " -i ",
354 _("display package information"));
355 printHelpLine( " --changelog ",
356 _("display the package's change log"));
357 printHelpLine( " -l ",
358 _("display package file list"));
359 printHelpLine( " -s ",
360 _("show file states (implies -l)"));
361 printHelpLine( " -d ",
362 _("list only documentation files (implies -l)"));
363 printHelpLine( " -c ",
364 _("list only configuration files (implies -l)"));
365 printHelpLine( " --dump ",
366 _("show all verifiable information for each file (must be used with -l, -c, or -d)"));
367 printHelpLine( " --provides ",
368 _("list capabilities package provides"));
369 puts( _(" --requires"));
370 printHelpLine( " -R ",
371 _("list package dependencies"));
372 printHelpLine( " --scripts ",
373 _("print the various [un]install scripts"));
374 printHelpLine(" --triggers ",
375 _("show the trigger scripts contained in the package"));
379 printHelpLine(_(" --pipe <cmd> "),
380 _("send stdout to <cmd>"));
381 printHelpLine( " --verify ",
382 _("verify a package installation using the same same package specification options as -q"));
383 printHelpLine(_(" --dbpath <dir> "),
384 _("use <dir> as the directory for the database"));
385 printHelpLine(_(" --root <dir> "),
386 _("use <dir> as the top level directory"));
387 printHelpLine( " --nodeps ",
388 _("do not verify package dependencies"));
389 printHelpLine( " --nomd5 ",
390 _("do not verify file md5 checksums"));
391 printHelpLine( " --nofiles ",
392 _("do not verify file attributes"));
394 printHelpLine( " --setperms ",
395 _("set the file permissions to those in the package database"
396 " using the same package specification options as -q"));
397 printHelpLine( " --setugids ",
398 _("set the file owner and group to those in the package "
399 "database using the same package specification options as "
402 puts( _(" --install <packagefile>"));
403 printHelpLine(_(" -i <packagefile> "),
404 _("install package"));
405 printHelpLine(_(" --excludepath <path>"),
406 _("skip files in path <path>"));
407 printHelpLine(_(" --relocate <oldpath>=<newpath>"),
408 _("relocate files from <oldpath> to <newpath>"));
409 printHelpLine( " --badreloc",
410 _("relocate files even though the package doesn't allow it"));
411 printHelpLine(_(" --prefix <dir> "),
412 _("relocate the package to <dir>, if relocatable"));
413 printHelpLine(_(" --dbpath <dir> "),
414 _("use <dir> as the directory for the database"));
415 printHelpLine( " --excludedocs ",
416 _("do not install documentation"));
417 printHelpLine( " --force ",
418 _("short hand for --replacepkgs --replacefiles"));
420 printHelpLine( " --hash ",
421 _("print hash marks as package installs (good with -v)"));
422 printHelpLine( " --allfiles ",
423 _("install all files, even configurations which might "
424 "otherwise be skipped"));
425 printHelpLine( " --ignorearch ",
426 _("don't verify package architecture"));
427 printHelpLine( " --ignoresize ",
428 _("don't check disk space before installing"));
429 printHelpLine( " --ignoreos ",
430 _("don't verify package operating system"));
431 printHelpLine( " --includedocs ",
432 _("install documentation"));
433 printHelpLine( " --justdb ",
434 _("update the database, but do not modify the filesystem"));
435 printHelpLine( " --nodeps ",
436 _("do not verify package dependencies"));
437 printHelpLine( " --noorder ",
438 _("do not reorder package installation to satisfy dependencies"));
439 printHelpLine( " --noscripts ",
440 _("don't execute any installation scripts"));
441 printHelpLine( " --notriggers ",
442 _("don't execute any scripts triggered by this package"));
443 printHelpLine( " --percent ",
444 _("print percentages as package installs"));
445 printHelpLine( " --replacefiles ",
446 _("install even if the package replaces installed files"));
447 printHelpLine( " --replacepkgs ",
448 _("reinstall if the package is already present"));
449 printHelpLine(_(" --root <dir> "),
450 _("use <dir> as the top level directory"));
451 printHelpLine( " --test ",
452 _("don't install, but tell if it would work or not"));
454 puts( _(" --upgrade <packagefile>"));
455 printHelpLine(_(" -U <packagefile> "),
456 _("upgrade package (same options as --install, plus)"));
457 printHelpLine( " --oldpackage ",
458 _("upgrade to an old version of the package (--force on upgrades does this automatically)"));
460 puts( _(" --erase <package>"));
461 printHelpLine( " -e <package> ",
462 _("erase (uninstall) package"));
463 printHelpLine( " --allmatches ",
464 _("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"));
465 printHelpLine(_(" --dbpath <dir> "),
466 _("use <dir> as the directory for the database"));
467 printHelpLine( " --justdb ",
468 _("update the database, but do not modify the filesystem"));
469 printHelpLine( " --nodeps ",
470 _("do not verify package dependencies"));
471 printHelpLine( " --noorder ",
472 _("do not reorder package installation to satisfy dependencies"));
473 printHelpLine( " --noscripts ",
474 _("do not execute any package specific scripts"));
475 printHelpLine( " --notriggers ",
476 _("don't execute any scripts triggered by this package"));
477 printHelpLine(_(" --root <dir> "),
478 _("use <dir> as the top level directory"));
480 puts( _(" -b<stage> <spec> "));
481 printHelpLine(_(" -t<stage> <tarball> "),
482 _("build package, where <stage> is one of:"));
483 printHelpLine( " p ",
484 _("prep (unpack sources and apply patches)"));
485 printHelpLine( " l ",
486 _("list check (do some cursory checks on %files)"));
487 printHelpLine( " c ",
488 _("compile (prep and compile)"));
489 printHelpLine( " i ",
490 _("install (prep, compile, install)"));
491 printHelpLine( " b ",
492 _("binary package (prep, compile, install, package)"));
493 printHelpLine( " a ",
494 _("bin/src package (prep, compile, install, package)"));
495 printHelpLine( " --short-circuit ",
496 _("skip straight to specified stage (only for c,i)"));
497 printHelpLine( " --clean ",
498 _("remove build tree when done"));
499 printHelpLine( " --rmsource ",
500 _("remove sources and spec file when done"));
501 printHelpLine( " --sign ",
502 _("generate PGP/GPG signature"));
503 printHelpLine(_(" --buildroot <dir> "),
504 _("use <dir> as the build root"));
505 printHelpLine(_(" --target=<platform>+"),
506 _("build the packages for the build targets platform1...platformN."));
507 printHelpLine( " --nobuild ",
508 _("do not execute any stages"));
509 printHelpLine(_(" --timecheck <secs> "),
510 _("set the time check to <secs> seconds (0 disables)"));
512 printHelpLine(_(" --rebuild <src_pkg> "),
513 _("install source package, build binary package and remove spec file, sources, patches, and icons."));
514 printHelpLine(_(" --rmsource <spec> "),
515 _("remove sources and spec file"));
516 printHelpLine(_(" --recompile <src_pkg> "),
517 _("like --rebuild, but don't build any package"));
518 printHelpLine(_(" --resign <pkg>+ "),
519 _("sign a package (discard current signature)"));
520 printHelpLine(_(" --addsign <pkg>+ "),
521 _("add a signature to a package"));
523 printHelpLine(_(" --checksig <pkg>+ "),
524 _("verify package signature"));
525 printHelpLine( " --nopgp ",
526 _("skip any PGP signatures"));
527 printHelpLine( " --nogpg ",
528 _("skip any GPG signatures"));
529 printHelpLine( " --nomd5 ",
530 _("skip any MD5 signatures"));
531 printHelpLine( " --querytags ",
532 _("list the tags that can be used in a query format"));
533 printHelpLine( " --initdb ",
534 _("make sure a valid database exists"));
535 printHelpLine( " --rebuilddb ",
536 _("rebuild database from existing database"));
537 printHelpLine(_(" --dbpath <dir> "),
538 _("use <dir> as the directory for the database"));
539 printHelpLine( " --root <dir> ",
540 _("use <dir> as the top level directory"));
543 int main(int argc, const char ** argv)
545 enum modes bigMode = MODE_UNKNOWN;
546 QVA_t *qva = &rpmQVArgs;
547 struct rpmBuildArguments *ba = &rpmBArgs;
548 enum rpmQVSources QVSource = RPMQV_PACKAGE;
550 int installFlags = 0, uninstallFlags = 0, interfaceFlags = 0;
551 int gotDbpath = 0, verifyFlags;
552 int checksigFlags = 0;
553 unsigned long int timeCheck = 0L;
554 int addSign = NEW_SIGNATURE;
555 const char * specFile;
557 char * passPhrase = "";
558 char * cookie = NULL;
562 char * errString = NULL;
564 const char * infoCommand[] = { "--info", NULL };
565 const char * installCommand[] = { "--install", NULL };
569 rpmRelocation * relocations = NULL;
570 int numRelocations = 0;
575 #if HAVE_MCHECK_H && HAVE_MTRACE
576 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
578 setprogname(argv[0]); /* Retrofit glibc __progname */
580 /* set the defaults for the various command line options */
625 /* XXX Eliminate query linkage loop */
626 parseSpecVec = parseSpec;
627 freeSpecVec = freeSpec;
630 /* set up the correct locale */
631 setlocale(LC_ALL, "" );
634 #define LOCALEDIR "/usr/share/locale"
636 bindtextdomain(PACKAGE, LOCALEDIR);
639 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
641 /* Make a first pass through the arguments, looking for --rcfile */
642 /* We need to handle that before dealing with the rest of the arguments. */
643 optCon = poptGetContext("rpm", argc, argv, optionsTable, 0);
644 poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
645 poptReadDefaultConfig(optCon, 1);
646 poptSetExecPath(optCon, RPMCONFIGDIR, 1);
648 /* reading rcfile early makes it easy to override */
649 /* XXX only --rcfile (and --showrc) need this pre-parse */
651 while ((arg = poptGetNextOpt(optCon)) > 0) {
654 rpmIncreaseVerbosity(); /* XXX silly use by showrc */
661 if (rpmReadConfigFiles(rcfile, NULL))
669 rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
671 poptResetContext(optCon);
673 if (qva->qva_queryFormat) xfree(qva->qva_queryFormat);
674 memset(qva, 0, sizeof(*qva));
675 if (ba->buildRootOverride) xfree(ba->buildRootOverride);
676 if (ba->targets) free(ba->targets);
677 memset(ba, 0, sizeof(*ba));
680 while ((arg = poptGetNextOpt(optCon)) > 0) {
681 optArg = poptGetOptArg(optCon);
685 if (bigMode != MODE_UNKNOWN && bigMode != MODE_CHECKSIG)
686 argerror(_("only one major mode may be specified"));
687 bigMode = MODE_CHECKSIG;
691 if (bigMode != MODE_UNKNOWN && bigMode != MODE_QUERY)
692 argerror(_("only one major mode may be specified"));
693 bigMode = MODE_QUERY;
698 if (bigMode != MODE_UNKNOWN && bigMode != MODE_VERIFY)
699 argerror(_("only one major mode may be specified"));
700 bigMode = MODE_VERIFY;
704 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
705 argerror(_("only one major mode may be specified"));
706 bigMode = MODE_UNINSTALL;
707 rpmMessage(RPMMESS_ERROR, _("-u and --uninstall are deprecated and no"
709 rpmMessage(RPMMESS_ERROR, _("Use -e or --erase instead.\n"));
713 if (bigMode != MODE_UNKNOWN && bigMode != MODE_UNINSTALL)
714 argerror(_("only one major mode may be specified"));
715 bigMode = MODE_UNINSTALL;
720 if (bigMode != MODE_UNKNOWN && bigMode != MODE_BUILD)
721 argerror(_("only one major mode may be specified"));
724 bigMode = MODE_BUILD;
725 errString = _("--build (-b) requires one of a,b,i,c,p,l as "
726 "its sole argument");
728 bigMode = MODE_TARBUILD;
729 errString = _("--tarbuild (-t) requires one of a,b,i,c,p,l as "
730 "its sole argument");
733 if (strlen(optArg) > 1)
736 ba->buildChar = optArg[0];
737 switch (ba->buildChar) {
754 rpmIncreaseVerbosity();
758 if (bigMode == MODE_QUERY)
759 poptStuffArgs(optCon, infoCommand);
760 else if (bigMode == MODE_INSTALL)
762 else if (bigMode == MODE_UNKNOWN)
763 poptStuffArgs(optCon, installCommand);
767 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
768 argerror(_("only one major mode may be specified"));
769 bigMode = MODE_INSTALL;
773 if (bigMode != MODE_UNKNOWN && bigMode != MODE_INSTALL)
774 argerror(_("only one major mode may be specified"));
775 bigMode = MODE_INSTALL;
780 if (QVSource != RPMQV_PACKAGE && QVSource != RPMQV_RPM)
781 argerror(_("one type of query/verify may be performed at a " "time"));
782 QVSource = RPMQV_RPM;
786 if (QVSource != RPMQV_PACKAGE && QVSource != RPMQV_GROUP)
787 argerror(_("one type of query/verify may be performed at a "
789 QVSource = RPMQV_GROUP;
793 if (QVSource != RPMQV_PACKAGE && QVSource != RPMQV_PATH)
794 argerror(_("one type of query/verify may be performed at a "
796 QVSource = RPMQV_PATH;
800 if (QVSource != RPMQV_PACKAGE && QVSource != RPMQV_ALL)
801 argerror(_("one type of query/verify may be performed at a "
803 QVSource = RPMQV_ALL;
807 if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILD)
808 argerror(_("only one major mode may be specified"));
809 bigMode = MODE_REBUILD;
812 case GETOPT_RECOMPILE:
813 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RECOMPILE)
814 argerror(_("only one major mode may be specified"));
815 bigMode = MODE_RECOMPILE;
819 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
820 argerror(_("only one major mode may be specified"));
821 bigMode = MODE_RESIGN;
822 addSign = NEW_SIGNATURE;
827 if (bigMode != MODE_UNKNOWN && bigMode != MODE_RESIGN)
828 argerror(_("only one major mode may be specified"));
829 bigMode = MODE_RESIGN;
830 addSign = ADD_SIGNATURE;
835 switch (urlIsURL(optArg)) {
837 if (optArg[0] != '/')
838 argerror(_("arguments to --dbpath must begin with a /"));
843 addMacro(NULL, "_dbpath", NULL, optArg, RMIL_CMDLINE);
844 addMacro(&rpmCLIMacroContext, "_dbpath", NULL, optArg, RMIL_CMDLINE);
848 case GETOPT_DEFINEMACRO:
849 rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
850 rpmDefineMacro(&rpmCLIMacroContext, optArg, RMIL_CMDLINE);
853 case GETOPT_EVALMACRO:
854 { const char *val = rpmExpand(optArg, NULL);
855 fprintf(stdout, "%s\n", val);
859 case GETOPT_TIMECHECK:
861 timeCheck = strtoul(optArg, &tce, 10);
862 if ((*tce) || (tce == optArg) || (timeCheck == ULONG_MAX)) {
863 argerror("Argument to --timecheck must be integer");
865 addMacro(NULL, "_timecheck", NULL, optArg, RMIL_CMDLINE);
866 addMacro(&rpmCLIMacroContext, "_timecheck", NULL, optArg, RMIL_CMDLINE);
870 case GETOPT_REBUILDDB:
871 if (bigMode != MODE_UNKNOWN && bigMode != MODE_REBUILDDB)
872 argerror(_("only one major mode may be specified"));
873 bigMode = MODE_REBUILDDB;
876 case GETOPT_RELOCATE:
878 argerror(_("relocations must begin with a /"));
879 if (!(errString = strchr(optArg, '=')))
880 argerror(_("relocations must contain a ="));
882 if (*errString != '/')
883 argerror(_("relocations must have a / following the ="));
884 relocations = xrealloc(relocations,
885 sizeof(*relocations) * (numRelocations + 1));
886 relocations[numRelocations].oldPath = optArg;
887 relocations[numRelocations++].newPath = errString;
890 case GETOPT_EXCLUDEPATH:
892 argerror(_("exclude paths must begin with a /"));
894 relocations = xrealloc(relocations,
895 sizeof(*relocations) * (numRelocations + 1));
896 relocations[numRelocations].oldPath = optArg;
897 relocations[numRelocations++].newPath = NULL;
901 fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
907 rpmSetVerbosity(RPMMESS_QUIET);
909 if (showVersion) printVersion();
910 if (help) printHelp();
913 fprintf(stderr, "%s: %s\n",
914 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
919 if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
920 bigMode = MODE_BUILD;
922 if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
923 bigMode = MODE_BUILD;
926 if (bigMode != MODE_UNKNOWN)
927 argerror(_("only one major mode may be specified"));
929 bigMode = MODE_INITDB;
933 if (bigMode != MODE_UNKNOWN)
934 argerror(_("only one major mode may be specified"));
936 bigMode = MODE_QUERYTAGS;
939 if (qva->qva_sourceCount) {
940 if (QVSource != RPMQV_PACKAGE || qva->qva_sourceCount > 1)
941 argerror(_("one type of query/verify may be performed at a "
943 QVSource = qva->qva_source;
946 if (ba->buildRootOverride && bigMode != MODE_BUILD &&
947 bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
948 argerror("--buildroot may only be used during package builds");
951 if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
952 argerror(_("--dbpath given for operation that does not use a "
955 if (timeCheck && (bigMode & ~MODES_FOR_TIMECHECK))
956 argerror(_("--timecheck may only be used during package builds"));
958 if (qva->qva_flags && (bigMode & ~MODES_QV))
959 argerror(_("unexpected query flags"));
961 if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
962 argerror(_("unexpected query format"));
964 if (QVSource != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
965 argerror(_("unexpected query source"));
967 if (!(bigMode == MODE_INSTALL ||
968 (bigMode==MODE_BUILD && (ba->buildAmount & RPMBUILD_RMSOURCE))||
969 (bigMode==MODE_BUILD && (ba->buildAmount & RPMBUILD_RMSPEC)))
971 argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
973 if (bigMode != MODE_INSTALL && badReloc)
974 argerror(_("files may only be relocated during package installation"));
976 if (relocations && prefix)
977 argerror(_("only one of --prefix or --relocate may be used"));
979 if (bigMode != MODE_INSTALL && relocations)
980 argerror(_("--relocate and --excludepath may only be used when installing new packages"));
982 if (bigMode != MODE_INSTALL && prefix)
983 argerror(_("--prefix may only be used when installing new packages"));
985 if (prefix && prefix[0] != '/')
986 argerror(_("arguments to --prefix must begin with a /"));
988 if (bigMode != MODE_INSTALL && showHash)
989 argerror(_("--hash (-h) may only be specified during package "
992 if (bigMode != MODE_INSTALL && showPercents)
993 argerror(_("--percent may only be specified during package "
996 if (bigMode != MODE_INSTALL && replaceFiles)
997 argerror(_("--replacefiles may only be specified during package "
1000 if (bigMode != MODE_INSTALL && replacePackages)
1001 argerror(_("--replacepkgs may only be specified during package "
1004 if (bigMode != MODE_INSTALL && excldocs)
1005 argerror(_("--excludedocs may only be specified during package "
1008 if (bigMode != MODE_INSTALL && incldocs)
1009 argerror(_("--includedocs may only be specified during package "
1012 if (excldocs && incldocs)
1013 argerror(_("only one of --excludedocs and --includedocs may be "
1016 if (bigMode != MODE_INSTALL && ignoreArch)
1017 argerror(_("--ignorearch may only be specified during package "
1020 if (bigMode != MODE_INSTALL && ignoreOs)
1021 argerror(_("--ignoreos may only be specified during package "
1024 if (bigMode != MODE_INSTALL && ignoreSize)
1025 argerror(_("--ignoresize may only be specified during package "
1028 if (allMatches && bigMode != MODE_UNINSTALL)
1029 argerror(_("--allmatches may only be specified during package "
1032 if (allFiles && bigMode != MODE_INSTALL)
1033 argerror(_("--allfiles may only be specified during package "
1036 if (justdb && bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL)
1037 argerror(_("--justdb may only be specified during package "
1038 "installation and erasure"));
1040 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL &&
1041 bigMode != MODE_VERIFY && noScripts)
1042 argerror(_("--noscripts may only be specified during package "
1043 "installation, erasure, and verification"));
1045 if (bigMode != MODE_INSTALL && bigMode != MODE_UNINSTALL && noTriggers)
1046 argerror(_("--notriggers may only be specified during package "
1047 "installation, erasure, and verification"));
1049 if (noDeps & (bigMode & ~MODES_FOR_NODEPS))
1050 argerror(_("--nodeps may only be specified during package "
1051 "building, rebuilding, recompilation, installation,"
1052 "erasure, and verification"));
1054 if (test && (bigMode & ~MODES_FOR_TEST))
1055 argerror(_("--test may only be specified during package installation, "
1056 "erasure, and building"));
1058 if (rootdir[1] && (bigMode & ~MODES_FOR_ROOT))
1059 argerror(_("--root (-r) may only be specified during "
1060 "installation, erasure, querying, and "
1061 "database rebuilds"));
1064 switch (urlIsURL(rootdir)) {
1066 if (bigMode & MODES_FOR_ROOT)
1069 case URL_IS_UNKNOWN:
1070 if (rootdir[0] != '/')
1071 argerror(_("arguments to --root (-r) must begin with a /"));
1076 if (oldPackage && !upgrade)
1077 argerror(_("--oldpackage may only be used during upgrades"));
1079 if ((ftpProxy || ftpPort) && !(bigMode == MODE_INSTALL ||
1080 ((bigMode == MODE_QUERY && QVSource == RPMQV_RPM)) ||
1081 ((bigMode == MODE_VERIFY && QVSource == RPMQV_RPM))))
1082 argerror(_("ftp options can only be used during package queries, "
1083 "installs, and upgrades"));
1085 if ((httpProxy || httpPort) && !(bigMode == MODE_INSTALL ||
1086 ((bigMode == MODE_QUERY && QVSource == RPMQV_RPM)) ||
1087 ((bigMode == MODE_VERIFY && QVSource == RPMQV_RPM))))
1088 argerror(_("http options can only be used during package queries, "
1089 "installs, and upgrades"));
1091 if (noPgp && bigMode != MODE_CHECKSIG)
1092 argerror(_("--nopgp may only be used during signature checking"));
1094 if (noGpg && bigMode != MODE_CHECKSIG)
1095 argerror(_("--nogpg may only be used during signature checking"));
1097 if (noMd5 && bigMode != MODE_CHECKSIG && bigMode != MODE_VERIFY)
1098 argerror(_("--nomd5 may only be used during signature checking and "
1099 "package verification"));
1102 addMacro(NULL, "_ftpproxy", NULL, ftpProxy, RMIL_CMDLINE);
1103 addMacro(&rpmCLIMacroContext, "_ftpproxy", NULL, ftpProxy, RMIL_CMDLINE);
1106 addMacro(NULL, "_ftpport", NULL, ftpPort, RMIL_CMDLINE);
1107 addMacro(&rpmCLIMacroContext, "_ftpport", NULL, ftpPort, RMIL_CMDLINE);
1110 addMacro(NULL, "_httpproxy", NULL, httpProxy, RMIL_CMDLINE);
1111 addMacro(&rpmCLIMacroContext, "_httpproxy", NULL, httpProxy, RMIL_CMDLINE);
1114 addMacro(NULL, "_httpport", NULL, httpPort, RMIL_CMDLINE);
1115 addMacro(&rpmCLIMacroContext, "_httpport", NULL, httpPort, RMIL_CMDLINE);
1119 if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
1120 bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD) {
1125 if ((argv = poptGetArgs(optCon)) == NULL) {
1126 fprintf(stderr, _("no files to sign\n"));
1130 if (stat(*argv, &sb)) {
1131 fprintf(stderr, _("cannot access file %s\n"), *argv);
1137 if (errors) return errors;
1139 if (poptPeekArg(optCon)) {
1140 switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
1144 if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
1145 !rpmDetectPGPVersion(NULL)) {
1146 fprintf(stderr, _("pgp not found: "));
1150 passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
1151 if (passPhrase == NULL) {
1152 fprintf(stderr, _("Pass phrase check failed\n"));
1155 fprintf(stderr, _("Pass phrase is good.\n"));
1156 passPhrase = xstrdup(passPhrase);
1160 _("Invalid %%_signature spec in macro file.\n"));
1162 /*@notreached@*/ break;
1166 argerror(_("--sign may only be used during package building"));
1169 /* Make rpmLookupSignatureType() return 0 ("none") from now on */
1170 rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
1176 if (!(pipeChild = fork())) {
1178 dup2(p[0], STDIN_FILENO);
1180 execl("/bin/sh", "/bin/sh", "-c", pipeOutput, NULL);
1181 fprintf(stderr, _("exec failed\n"));
1185 dup2(p[1], STDOUT_FILENO);
1191 if (!showVersion && !help && !noUsageMsg) printUsage();
1194 case MODE_REBUILDDB:
1195 ec = rpmdbRebuild(rootdir);
1198 case MODE_QUERYTAGS:
1200 argerror(_("unexpected arguments to --querytags "));
1202 rpmDisplayQueryTags(stdout);
1206 rpmdbInit(rootdir, 0644);
1210 if (!poptPeekArg(optCon))
1211 argerror(_("no packages given for signature check"));
1212 if (!noPgp) checksigFlags |= CHECKSIG_PGP;
1213 if (!noGpg) checksigFlags |= CHECKSIG_GPG;
1214 if (!noMd5) checksigFlags |= CHECKSIG_MD5;
1215 ec = rpmCheckSig(checksigFlags, (const char **)poptGetArgs(optCon));
1216 /* XXX don't overflow single byte exit status */
1217 if (ec > 255) ec = 255;
1221 if (!poptPeekArg(optCon))
1222 argerror(_("no packages given for signing"));
1223 ec = rpmReSign(addSign, passPhrase, (const char **)poptGetArgs(optCon));
1224 /* XXX don't overflow single byte exit status */
1225 if (ec > 255) ec = 255;
1229 case MODE_RECOMPILE:
1230 if (rpmGetVerbosity() == RPMMESS_NORMAL)
1231 rpmSetVerbosity(RPMMESS_VERBOSE);
1233 if (!poptPeekArg(optCon))
1234 argerror(_("no packages files given for rebuild"));
1236 ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
1237 if (bigMode == MODE_REBUILD) {
1238 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1239 ba->buildAmount |= RPMBUILD_RMSOURCE;
1240 ba->buildAmount |= RPMBUILD_RMSPEC;
1241 ba->buildAmount |= RPMBUILD_CLEAN;
1242 ba->buildAmount |= RPMBUILD_RMBUILD;
1245 while ((pkg = poptGetArg(optCon))) {
1246 ec = rpmInstallSource("", pkg, &specFile, &cookie);
1250 ba->rootdir = rootdir;
1251 ec = build(specFile, ba, passPhrase, 0, cookie, rcfile, force, noDeps);
1261 if (rpmGetVerbosity() == RPMMESS_NORMAL)
1262 rpmSetVerbosity(RPMMESS_VERBOSE);
1264 switch (ba->buildChar) {
1265 /* these fallthroughs are intentional */
1267 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1270 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
1271 ba->buildAmount |= RPMBUILD_CLEAN;
1274 ba->buildAmount |= RPMBUILD_INSTALL;
1275 if ((ba->buildChar == 'i') && ba->shortCircuit)
1279 ba->buildAmount |= RPMBUILD_BUILD;
1280 if ((ba->buildChar == 'c') && ba->shortCircuit)
1284 ba->buildAmount |= RPMBUILD_PREP;
1288 ba->buildAmount |= RPMBUILD_FILECHECK;
1291 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
1295 if (!poptPeekArg(optCon)) {
1296 if (bigMode == MODE_BUILD)
1297 argerror(_("no spec files given for build"));
1299 argerror(_("no tar files given for build"));
1302 while ((pkg = poptGetArg(optCon))) {
1303 ba->rootdir = rootdir;
1304 ec = build(pkg, ba, passPhrase, bigMode == MODE_TARBUILD,
1305 NULL, rcfile, force, noDeps);
1308 rpmFreeMacros(NULL);
1309 rpmReadConfigFiles(rcfile, NULL);
1313 case MODE_UNINSTALL:
1314 if (!poptPeekArg(optCon))
1315 argerror(_("no packages given for uninstall"));
1317 if (noScripts) uninstallFlags |= RPMTRANS_FLAG_NOSCRIPTS;
1318 if (noTriggers) uninstallFlags |= RPMTRANS_FLAG_NOTRIGGERS;
1319 if (test) uninstallFlags |= RPMTRANS_FLAG_TEST;
1320 if (justdb) uninstallFlags |= RPMTRANS_FLAG_JUSTDB;
1321 if (noDeps) interfaceFlags |= UNINSTALL_NODEPS;
1322 if (allMatches) interfaceFlags |= UNINSTALL_ALLMATCHES;
1324 ec = rpmErase(rootdir, (const char **)poptGetArgs(optCon),
1325 uninstallFlags, interfaceFlags);
1330 probFilter |= RPMPROB_FILTER_REPLACEPKG |
1331 RPMPROB_FILTER_REPLACEOLDFILES |
1332 RPMPROB_FILTER_REPLACENEWFILES |
1333 RPMPROB_FILTER_OLDPACKAGE;
1335 if (replaceFiles) probFilter |= RPMPROB_FILTER_REPLACEOLDFILES |
1336 RPMPROB_FILTER_REPLACENEWFILES;
1337 if (badReloc) probFilter |= RPMPROB_FILTER_FORCERELOCATE;
1338 if (replacePackages) probFilter |= RPMPROB_FILTER_REPLACEPKG;
1339 if (oldPackage) probFilter |= RPMPROB_FILTER_OLDPACKAGE;
1340 if (ignoreArch) probFilter |= RPMPROB_FILTER_IGNOREARCH;
1341 if (ignoreOs) probFilter |= RPMPROB_FILTER_IGNOREOS;
1342 if (ignoreSize) probFilter |= RPMPROB_FILTER_DISKSPACE;
1344 if (test) installFlags |= RPMTRANS_FLAG_TEST;
1345 /* RPMTRANS_FLAG_BUILD_PROBS */
1346 if (noScripts) installFlags |= RPMTRANS_FLAG_NOSCRIPTS;
1347 if (justdb) installFlags |= RPMTRANS_FLAG_JUSTDB;
1348 if (noTriggers) installFlags |= RPMTRANS_FLAG_NOTRIGGERS;
1351 installFlags |= RPMTRANS_FLAG_NODOCS;
1352 else if (rpmExpandNumeric("%{_excludedocs}"))
1353 installFlags |= RPMTRANS_FLAG_NODOCS;
1355 if (allFiles) installFlags |= RPMTRANS_FLAG_ALLFILES;
1356 /* RPMTRANS_FLAG_KEEPOBSOLETE */
1358 if (showPercents) interfaceFlags |= INSTALL_PERCENT;
1359 if (showHash) interfaceFlags |= INSTALL_HASH;
1360 if (noDeps) interfaceFlags |= INSTALL_NODEPS;
1361 if (noOrder) interfaceFlags |= INSTALL_NOORDER;
1362 if (upgrade) interfaceFlags |= INSTALL_UPGRADE;
1364 if (!poptPeekArg(optCon))
1365 argerror(_("no packages given for install"));
1367 /* we've already ensured !(!prefix && !relocations) */
1369 relocations = alloca(2 * sizeof(*relocations));
1370 relocations[0].oldPath = NULL; /* special case magic */
1371 relocations[0].newPath = prefix;
1372 relocations[1].oldPath = relocations[1].newPath = NULL;
1373 } else if (relocations) {
1374 relocations = xrealloc(relocations,
1375 sizeof(*relocations) * (numRelocations + 1));
1376 relocations[numRelocations].oldPath = NULL;
1377 relocations[numRelocations].newPath = NULL;
1380 ec += rpmInstall(rootdir, (const char **)poptGetArgs(optCon),
1381 installFlags, interfaceFlags, probFilter, relocations);
1385 qva->qva_prefix = rootdir;
1386 if (QVSource == RPMQV_ALL) {
1387 if (poptPeekArg(optCon))
1388 argerror(_("extra arguments given for query of all packages"));
1390 ec = rpmQuery(qva, RPMQV_ALL, NULL);
1392 if (!poptPeekArg(optCon))
1393 argerror(_("no arguments given for query"));
1394 while ((pkg = poptGetArg(optCon)))
1395 ec += rpmQuery(qva, QVSource, pkg);
1400 verifyFlags = (VERIFY_FILES|VERIFY_DEPS|VERIFY_SCRIPT|VERIFY_MD5);
1401 verifyFlags &= ~qva->qva_flags;
1402 if (noDeps) verifyFlags &= ~VERIFY_DEPS;
1403 if (noScripts) verifyFlags &= ~VERIFY_SCRIPT;
1404 if (noMd5) verifyFlags &= ~VERIFY_MD5;
1406 qva->qva_prefix = rootdir;
1407 qva->qva_flags = verifyFlags;
1408 if (QVSource == RPMQV_ALL) {
1409 if (poptPeekArg(optCon))
1410 argerror(_("extra arguments given for verify of all packages"));
1411 ec = rpmVerify(qva, RPMQV_ALL, NULL);
1413 if (!poptPeekArg(optCon))
1414 argerror(_("no arguments given for verify"));
1415 while ((pkg = poptGetArg(optCon)))
1416 ec += rpmVerify(qva, QVSource, pkg);
1421 poptFreeContext(optCon);
1422 rpmFreeMacros(NULL);
1423 rpmFreeMacros(&rpmCLIMacroContext);
1428 (void)waitpid(pipeChild, &status, 0);
1431 /* keeps memory leak checkers quiet */
1435 if (qva->qva_queryFormat) xfree(qva->qva_queryFormat);
1436 if (ba->buildRootOverride) xfree(ba->buildRootOverride);
1437 if (ba->targets) free(ba->targets);
1439 #if HAVE_MCHECK_H && HAVE_MTRACE
1440 muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */