6 #if defined(IAM_RPM) || defined(__LCLINT__)
27 #define GETOPT_REBUILD 1003
28 #define GETOPT_RECOMPILE 1004
31 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
41 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
45 #define MODES_IE (MODE_INSTALL | MODE_ERASE)
51 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
55 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
66 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
67 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
68 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
69 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
79 N_(
"Query options (with -q or --query):"),
82 N_(
"Verify options (with -V or --verify):"),
85 { NULL,
'\0', POPT_ARG_INCLUDE_TABLE, rpmcliQVSourcePoptTable, 0,
86 N_(
"Source options (with --query or --verify):"),
91 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU)
93 N_(
"Dependency check/order options:"),
99 N_(
"File tree walk options (with --ftswalk):"),
105 N_(
"Signature options:"),
111 N_(
"Database options:"),
117 N_(
"Build options with [ <specfile> | <tarball> | <source package> ]:"),
123 N_(
"Install/Upgrade/Erase options:"),
127 {
"quiet",
'\0', 0, &
quiet, 0, NULL, NULL},
130 N_(
"Common options for all rpm modes and executables:"),
140 long _stksize = 64 * 1024L;
155 fprintf(fp,
_(
"RPM version %s\n"),
rpmEVR);
162 fprintf(fp,
_(
"Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
163 fprintf(fp,
_(
"This program may be freely redistributed under the terms of the GNU GPL\n"));
166 static void printUsage(poptContext con, FILE * fp,
int flags)
175 poptPrintHelp(con, fp, flags);
177 poptPrintUsage(con, fp, flags);
182 #if !defined(__GLIBC__) && !defined(__LCLINT__)
183 int main(
int argc,
const char ** argv,
char ** envp)
185 int main(
int argc,
const char ** argv)
192 poptContext optCon =
rpmcliInit(argc, (
char *
const *)argv, optionsTable);
197 #if defined(IAM_RPMQV)
209 #if defined(IAM_RPMDB)
213 #if defined(IAM_RPMK)
217 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
218 char * passPhrase =
"";
229 #if !defined(__GLIBC__) && !defined(__LCLINT__)
256 #if defined(IAM_RPMQV)
299 argerror(
_(
"only one major mode may be specified"));
305 argerror(
_(
"only one major mode may be specified"));
311 argerror(
_(
"only one major mode may be specified"));
327 argerror(
_(
"one type of query/verify may be performed at a "
330 if (qva->
qva_flags && (bigMode & ~MODES_QV))
348 argerror(
_(
"only one major mode may be specified"));
377 #if defined(IAM_RPMEIU)
380 argerror(
_(
"only installation, upgrading, rmsource and rmspec may be forced"));
382 argerror(
_(
"files may only be relocated during package installation"));
385 argerror(
_(
"cannot use --prefix with --relocate or --excludepath"));
388 argerror(
_(
"--relocate and --excludepath may only be used when installing new packages"));
391 argerror(
_(
"--prefix may only be used when installing new packages"));
394 argerror(
_(
"arguments to --prefix must begin with a /"));
397 argerror(
_(
"--hash (-h) may only be specified during package "
401 argerror(
_(
"--percent may only be specified during package "
405 argerror(
_(
"--replacepkgs may only be specified during package "
409 argerror(
_(
"--excludedocs may only be specified during package "
413 argerror(
_(
"--includedocs may only be specified during package "
417 argerror(
_(
"only one of --excludedocs and --includedocs may be "
421 argerror(
_(
"--ignorearch may only be specified during package "
425 argerror(
_(
"--ignoreos may only be specified during package "
430 argerror(
_(
"--ignoresize may only be specified during package "
434 argerror(
_(
"--allmatches may only be specified during package "
438 argerror(
_(
"--allfiles may only be specified during package "
443 argerror(
_(
"--justdb may only be specified during package "
444 "installation and erasure"));
448 argerror(
_(
"script disabling options may only be specified during "
449 "package installation and erasure"));
453 argerror(
_(
"trigger disabling options may only be specified during "
454 "package installation and erasure"));
457 argerror(
_(
"--nodeps may only be specified during package "
458 "building, rebuilding, recompilation, installation,"
459 "erasure, and verification"));
462 argerror(
_(
"--test may only be specified during package installation, "
463 "erasure, and building"));
467 argerror(
_(
"--root (-r) may only be specified during "
468 "installation, erasure, querying, and "
469 "database rebuilds"));
479 argerror(
_(
"arguments to --root (-r) must begin with a /"));
487 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
489 #
if defined(IAM_RPMBT)
492 #
if defined(IAM_RPMK)
505 if ((av = poptGetArgs(optCon)) == NULL) {
506 fprintf(stderr,
_(
"no files to sign\n"));
510 if (stat(*av, &sb)) {
511 fprintf(stderr,
_(
"cannot access file %s\n"), *av);
522 if (poptPeekArg(optCon)) {
531 fprintf(stderr,
_(
"pgp not found: "));
540 if (passPhrase == NULL) {
541 fprintf(stderr,
_(
"Pass phrase check failed\n"));
545 fprintf(stderr,
_(
"Pass phrase is good.\n"));
546 passPhrase =
xstrdup(passPhrase);
550 _(
"Invalid %%_signature spec in macro file.\n"));
557 argerror(
_(
"--sign may only be used during package building"));
569 if (!(pipeChild = fork())) {
571 (void) dup2(p[0], STDIN_FILENO);
574 fprintf(stderr,
_(
"exec failed\n"));
578 (void) dup2(p[1], STDOUT_FILENO);
610 if (!poptPeekArg(optCon))
611 argerror(
_(
"no packages files given for rebuild"));
623 while ((pkg = poptGetArg(optCon))) {
624 const char * specFile = NULL;
639 specFile =
_free(specFile);
663 #
if !defined(RPM_VENDOR_MANDRIVA)
673 #
if !defined(RPM_VENDOR_MANDRIVA)
682 #
if !defined(RPM_VENDOR_MANDRIVA)
700 if (!poptPeekArg(optCon)) {
702 argerror(
_(
"no spec files given for build"));
704 argerror(
_(
"no tar files given for build"));
707 while ((pkg = poptGetArg(optCon))) {
728 if (!poptPeekArg(optCon)) {
730 argerror(
_(
"no packages given for erase"));
738 ec +=
rpmErase(ts, ia, (
const char **) poptGetArgs(optCon));
772 if (!poptPeekArg(optCon)) {
774 argerror(
_(
"no packages given for install"));
783 ec +=
rpmInstall(ts, ia, (
const char **)poptGetArgs(optCon));
792 if (!poptPeekArg(optCon)
794 argerror(
_(
"no arguments given for query"));
798 ec =
rpmcliQuery(ts, qva, (
const char **) poptGetArgs(optCon));
809 if (!poptPeekArg(optCon)
811 argerror(
_(
"no arguments given for verify"));
812 ec =
rpmcliVerify(ts, qva, (
const char **) poptGetArgs(optCon));
825 if (!poptPeekArg(optCon))
828 ec =
rpmcliSign(ts, ka, (
const char **)poptGetArgs(optCon));
832 #if !defined(IAM_RPMQV)
836 #if !defined(IAM_RPMK)
840 #if !defined(IAM_RPMDB)
845 #if !defined(IAM_RPMBT)
851 #if !defined(IAM_RPMEIU)
856 if (poptPeekArg(optCon) != NULL || argc <= 1 ||
rpmIsVerbose()) {
863 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
870 (void) fclose(stdout);
871 (void) waitpid(pipeChild, &status, 0);
892 if (ec > 255) ec = 255;