2000-05-19 05:03:14 +08:00
|
|
|
#include "system.h"
|
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
#define _AUTOHELP
|
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
#if defined(IAM_RPM) || defined(__LCLINT__)
|
2000-05-25 01:53:35 +08:00
|
|
|
#define IAM_RPMBT
|
2000-05-27 02:51:11 +08:00
|
|
|
#define IAM_RPMDB
|
|
|
|
#define IAM_RPMEIU
|
|
|
|
#define IAM_RPMQV
|
|
|
|
#define IAM_RPMK
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
#include <rpmcli.h>
|
2000-05-19 05:03:14 +08:00
|
|
|
#include <rpmbuild.h>
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
#include "rpmdb.h"
|
2002-05-20 02:42:25 +08:00
|
|
|
#include "rpmps.h"
|
2002-05-17 00:55:21 +08:00
|
|
|
#include "rpmts.h"
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMBT
|
2000-05-19 05:03:14 +08:00
|
|
|
#include "build.h"
|
2002-01-29 00:16:27 +08:00
|
|
|
#define GETOPT_REBUILD 1003
|
|
|
|
#define GETOPT_RECOMPILE 1004
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(IAM_RPMBT) || defined(IAM_RPMK)
|
|
|
|
#include "signature.h"
|
|
|
|
#endif
|
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
enum modes {
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
MODE_QUERY = (1 << 0),
|
2000-05-25 01:53:35 +08:00
|
|
|
MODE_VERIFY = (1 << 3),
|
|
|
|
MODE_QUERYTAGS = (1 << 9),
|
|
|
|
#define MODES_QV (MODE_QUERY | MODE_VERIFY)
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
MODE_INSTALL = (1 << 1),
|
2001-06-09 04:45:59 +08:00
|
|
|
MODE_ERASE = (1 << 2),
|
2002-02-03 06:45:41 +08:00
|
|
|
#define MODES_IE (MODE_INSTALL | MODE_ERASE)
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
MODE_BUILD = (1 << 4),
|
|
|
|
MODE_REBUILD = (1 << 5),
|
|
|
|
MODE_RECOMPILE = (1 << 8),
|
|
|
|
MODE_TARBUILD = (1 << 11),
|
|
|
|
#define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
MODE_CHECKSIG = (1 << 6),
|
|
|
|
MODE_RESIGN = (1 << 7),
|
2001-07-13 21:44:26 +08:00
|
|
|
#define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
MODE_INITDB = (1 << 10),
|
|
|
|
MODE_REBUILDDB = (1 << 12),
|
2001-05-26 03:51:53 +08:00
|
|
|
MODE_VERIFYDB = (1 << 13),
|
|
|
|
#define MODES_DB (MODE_INITDB | MODE_REBUILDDB | MODE_VERIFYDB)
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2001-07-07 04:37:42 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
MODE_UNKNOWN = 0
|
|
|
|
};
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
#define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
|
|
|
|
#define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
|
|
|
|
#define MODES_FOR_TEST (MODES_BT | MODES_IE)
|
2002-03-13 04:28:30 +08:00
|
|
|
#define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
/* the structure describing the options we take and the defaults */
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-01-02 07:14:47 +08:00
|
|
|
static struct poptOption optionsTable[] = {
|
|
|
|
|
|
|
|
/* XXX colliding options */
|
2002-07-28 08:41:15 +08:00
|
|
|
#if defined(IAM_RPMQV) || defined(IAM_RPMEIU)
|
2001-01-02 07:14:47 +08:00
|
|
|
{ NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i', NULL, NULL},
|
|
|
|
#endif
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMQV
|
2001-01-02 07:14:47 +08:00
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
|
|
|
|
N_("Query options (with -q or --query):"),
|
|
|
|
NULL },
|
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
|
|
|
|
N_("Verify options (with -V or --verify):"),
|
|
|
|
NULL },
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMQV */
|
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
#ifdef IAM_RPMK
|
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
|
|
|
|
N_("Signature options:"),
|
|
|
|
NULL },
|
|
|
|
#endif /* IAM_RPMK */
|
|
|
|
|
|
|
|
#ifdef IAM_RPMDB
|
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
|
|
|
|
N_("Database options:"),
|
|
|
|
NULL },
|
|
|
|
#endif /* IAM_RPMDB */
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMBT
|
2001-01-02 07:14:47 +08:00
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
|
|
|
|
N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
|
|
|
|
NULL },
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMBT */
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
#ifdef IAM_RPMEIU
|
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
|
|
|
|
N_("Install/Upgrade/Erase options:"),
|
|
|
|
NULL },
|
|
|
|
#endif /* IAM_RPMEIU */
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
|
2001-01-02 07:14:47 +08:00
|
|
|
N_("Common options for all rpm modes:"),
|
|
|
|
NULL },
|
|
|
|
|
2001-07-08 03:15:17 +08:00
|
|
|
POPT_AUTOALIAS
|
2001-01-02 07:14:47 +08:00
|
|
|
POPT_AUTOHELP
|
|
|
|
POPT_TABLEEND
|
2000-05-19 05:03:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __MINT__
|
|
|
|
/* MiNT cannot dynamically increase the stack. */
|
|
|
|
long _stksize = 64 * 1024L;
|
|
|
|
#endif
|
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
/*@exits@*/ static void argerror(const char * desc)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals __assert_program_name, fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
2001-04-29 09:05:43 +08:00
|
|
|
{
|
2001-06-09 04:45:59 +08:00
|
|
|
fprintf(stderr, _("%s: %s\n"), __progname, desc);
|
2000-05-19 05:03:14 +08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
static void printVersion(FILE * fp)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals rpmEVR, fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2002-07-28 08:41:15 +08:00
|
|
|
fprintf(fp, _("RPM version %s\n"), rpmEVR);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
static void printBanner(FILE * fp)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2002-07-28 08:41:15 +08:00
|
|
|
fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
|
|
|
|
fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
static void printUsage(poptContext con, FILE * fp, int flags)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals __assert_program_name, rpmEVR, fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2002-07-28 08:41:15 +08:00
|
|
|
printVersion(fp);
|
|
|
|
printBanner(fp);
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
|
|
|
if (rpmIsVerbose())
|
|
|
|
poptPrintHelp(con, fp, flags);
|
|
|
|
else
|
|
|
|
poptPrintUsage(con, fp, flags);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-bounds@*/ /* LCL: segfault */
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-mods@*/ /* FIX: shrug */
|
2002-04-13 09:28:20 +08:00
|
|
|
#if !defined(__GLIBC__) && !defined(__LCLINT__)
|
2002-04-12 00:55:19 +08:00
|
|
|
int main(int argc, const char ** argv, /*@unused@*/ char ** envp)
|
2002-04-13 09:28:20 +08:00
|
|
|
#else
|
|
|
|
int main(int argc, const char ** argv)
|
2002-04-12 00:55:19 +08:00
|
|
|
#endif
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals __assert_program_name, rpmEVR, RPMVERSION,
|
2001-10-15 11:22:10 +08:00
|
|
|
rpmGlobalMacroContext, rpmCLIMacroContext,
|
|
|
|
fileSystem, internalState@*/
|
|
|
|
/*@modifies __assert_program_name,
|
|
|
|
fileSystem, internalState@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmts ts = NULL;
|
2000-05-19 05:03:14 +08:00
|
|
|
enum modes bigMode = MODE_UNKNOWN;
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
#ifdef IAM_RPMQV
|
2001-10-25 09:36:32 +08:00
|
|
|
QVA_t qva = &rpmQVKArgs;
|
2000-06-12 03:15:27 +08:00
|
|
|
#endif
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
#ifdef IAM_RPMBT
|
2001-05-04 05:00:18 +08:00
|
|
|
BTA_t ba = &rpmBTArgs;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IAM_RPMEIU
|
2001-06-09 04:45:59 +08:00
|
|
|
struct rpmInstallArguments_s * ia = &rpmIArgs;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(IAM_RPMDB)
|
|
|
|
struct rpmDatabaseArguments_s * da = &rpmDBArgs;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(IAM_RPMK)
|
2001-10-25 09:36:32 +08:00
|
|
|
QVA_t ka = &rpmQVKArgs;
|
2001-06-09 04:45:59 +08:00
|
|
|
#endif
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
#if defined(IAM_RPMBT) || defined(IAM_RPMK)
|
2000-05-19 05:03:14 +08:00
|
|
|
char * passPhrase = "";
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int arg;
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
const char * optArg;
|
|
|
|
pid_t pipeChild = 0;
|
|
|
|
poptContext optCon;
|
|
|
|
int ec = 0;
|
|
|
|
int status;
|
|
|
|
int p[2];
|
2002-06-28 21:04:38 +08:00
|
|
|
#ifdef IAM_RPMEIU
|
|
|
|
int i;
|
|
|
|
#endif
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
#if HAVE_MCHECK_H && HAVE_MTRACE
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-noeffect@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=noeffect@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
#endif
|
|
|
|
setprogname(argv[0]); /* Retrofit glibc __progname */
|
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
#if !defined(__GLIBC__) && !defined(__LCLINT__)
|
2002-04-09 06:52:45 +08:00
|
|
|
environ = envp;
|
|
|
|
#endif
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
/* XXX glibc churn sanity */
|
|
|
|
if (__progname == NULL) {
|
|
|
|
if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
|
|
|
|
else __progname = argv[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the major mode based on argv[0] */
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@-nullpass@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMBT
|
|
|
|
if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
|
|
|
|
if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
|
2000-07-26 02:37:21 +08:00
|
|
|
if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMQV
|
|
|
|
if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
|
|
|
|
if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
|
2000-07-26 02:37:21 +08:00
|
|
|
if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
|
|
|
|
if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
#ifdef RPMEIU
|
2001-06-09 04:45:59 +08:00
|
|
|
if (!strcmp(__progname, "rpme")) bigMode = MODE_ERASE;
|
2000-05-25 01:53:35 +08:00
|
|
|
if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
|
|
|
|
if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
|
|
|
|
#endif
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullpass@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
/* XXX Eliminate query linkage loop */
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@-type@*/ /* FIX: casts? */
|
2000-05-19 05:03:14 +08:00
|
|
|
parseSpecVec = parseSpec;
|
|
|
|
freeSpecVec = freeSpec;
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@=type@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
/* set up the correct locale */
|
2001-04-29 09:05:43 +08:00
|
|
|
(void) setlocale(LC_ALL, "" );
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
#ifdef __LCLINT__
|
|
|
|
#define LOCALEDIR "/usr/share/locale"
|
|
|
|
#endif
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
|
|
|
|
rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
|
|
|
|
|
|
|
|
/* Make a first pass through the arguments, looking for --rcfile */
|
|
|
|
/* We need to handle that before dealing with the rest of the arguments. */
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@-nullpass -temptrans@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
optCon = poptGetContext(__progname, argc, argv, optionsTable, 0);
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullpass =temptrans@*/
|
|
|
|
(void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
|
|
|
|
(void) poptReadDefaultConfig(optCon, 1);
|
2000-05-19 05:03:14 +08:00
|
|
|
poptSetExecPath(optCon, RPMCONFIGDIR, 1);
|
|
|
|
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
optArg = poptGetOptArg(optCon);
|
|
|
|
|
|
|
|
switch (arg) {
|
|
|
|
|
2001-07-13 21:44:26 +08:00
|
|
|
/* XXX options used in multiple rpm modes */
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
#if defined(IAM_RPMQV) || defined(IAM_RPMEIU)
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'i':
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMQV
|
2001-07-11 01:59:11 +08:00
|
|
|
if (bigMode == MODE_QUERY || qva->qva_mode == 'q') {
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@-nullassign -readonlytrans@*/
|
2000-05-27 02:51:11 +08:00
|
|
|
const char * infoCommand[] = { "--info", NULL };
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=nullassign =readonlytrans@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) poptStuffArgs(optCon, infoCommand);
|
2001-07-11 01:59:11 +08:00
|
|
|
} else
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMEIU
|
2001-07-11 01:59:11 +08:00
|
|
|
if (bigMode == MODE_INSTALL ||
|
|
|
|
(ia->installInterfaceFlags &
|
|
|
|
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL)))
|
2000-05-25 01:53:35 +08:00
|
|
|
/*@-ifempty@*/ ;
|
2001-07-11 01:59:11 +08:00
|
|
|
else if (bigMode == MODE_UNKNOWN) {
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@-nullassign -readonlytrans@*/
|
2000-05-27 02:51:11 +08:00
|
|
|
const char * installCommand[] = { "--install", NULL };
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=nullassign =readonlytrans@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) poptStuffArgs(optCon, installCommand);
|
2001-07-11 01:59:11 +08:00
|
|
|
} else
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
2001-07-11 01:59:11 +08:00
|
|
|
/*@-ifempty@*/ ;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2002-07-28 08:41:15 +08:00
|
|
|
#endif /* IAM_RPMQV || IAM_RPMEIU */
|
2000-09-02 05:15:40 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
default:
|
2000-05-19 05:03:14 +08:00
|
|
|
fprintf(stderr, _("Internal error in argument processing (%d) :-(\n"), arg);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg < -1) {
|
|
|
|
fprintf(stderr, "%s: %s\n",
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
poptStrerror(arg));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
rpmcliConfigured();
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMBT
|
2000-05-27 02:51:11 +08:00
|
|
|
switch (ba->buildMode) {
|
|
|
|
case 'b': bigMode = MODE_BUILD; break;
|
|
|
|
case 't': bigMode = MODE_TARBUILD; break;
|
|
|
|
case 'B': bigMode = MODE_REBUILD; break;
|
|
|
|
case 'C': bigMode = MODE_RECOMPILE; break;
|
|
|
|
}
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
|
|
|
|
bigMode = MODE_BUILD;
|
|
|
|
|
|
|
|
if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
|
|
|
|
bigMode = MODE_BUILD;
|
2000-05-27 02:51:11 +08:00
|
|
|
|
2000-06-01 12:47:42 +08:00
|
|
|
if (ba->buildRootOverride && bigMode != MODE_BUILD &&
|
|
|
|
bigMode != MODE_REBUILD && bigMode != MODE_TARBUILD) {
|
|
|
|
argerror("--buildroot may only be used during package builds");
|
|
|
|
}
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMBT */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMDB
|
2001-07-17 11:03:14 +08:00
|
|
|
if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
|
2001-06-09 04:45:59 +08:00
|
|
|
if (da->init) {
|
2000-05-19 05:03:14 +08:00
|
|
|
if (bigMode != MODE_UNKNOWN)
|
|
|
|
argerror(_("only one major mode may be specified"));
|
|
|
|
else
|
|
|
|
bigMode = MODE_INITDB;
|
2001-06-09 04:45:59 +08:00
|
|
|
} else
|
|
|
|
if (da->rebuild) {
|
|
|
|
if (bigMode != MODE_UNKNOWN)
|
|
|
|
argerror(_("only one major mode may be specified"));
|
|
|
|
else
|
|
|
|
bigMode = MODE_REBUILDDB;
|
|
|
|
} else
|
|
|
|
if (da->verify) {
|
|
|
|
if (bigMode != MODE_UNKNOWN)
|
|
|
|
argerror(_("only one major mode may be specified"));
|
|
|
|
else
|
|
|
|
bigMode = MODE_VERIFYDB;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-07-11 01:59:11 +08:00
|
|
|
}
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMDB */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMQV
|
2001-07-17 11:03:14 +08:00
|
|
|
if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
|
2000-05-27 02:51:11 +08:00
|
|
|
switch (qva->qva_mode) {
|
|
|
|
case 'q': bigMode = MODE_QUERY; break;
|
|
|
|
case 'V': bigMode = MODE_VERIFY; break;
|
|
|
|
case 'Q': bigMode = MODE_QUERYTAGS; break;
|
|
|
|
}
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
if (qva->qva_sourceCount) {
|
2001-01-02 08:10:45 +08:00
|
|
|
if (qva->qva_sourceCount > 2)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("one type of query/verify may be performed at a "
|
|
|
|
"time"));
|
|
|
|
}
|
|
|
|
if (qva->qva_flags && (bigMode & ~MODES_QV))
|
|
|
|
argerror(_("unexpected query flags"));
|
|
|
|
|
|
|
|
if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
|
|
|
|
argerror(_("unexpected query format"));
|
|
|
|
|
2000-06-12 03:15:27 +08:00
|
|
|
if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("unexpected query source"));
|
2001-07-11 01:59:11 +08:00
|
|
|
}
|
2001-06-09 04:45:59 +08:00
|
|
|
#endif /* IAM_RPMQV */
|
|
|
|
|
|
|
|
#ifdef IAM_RPMEIU
|
2001-07-17 11:03:14 +08:00
|
|
|
if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
|
2001-06-09 04:45:59 +08:00
|
|
|
{ int iflags = (ia->installInterfaceFlags &
|
2001-07-11 01:59:11 +08:00
|
|
|
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL));
|
|
|
|
int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
|
2001-06-09 04:45:59 +08:00
|
|
|
|
|
|
|
if (iflags & eflags)
|
|
|
|
argerror(_("only one major mode may be specified"));
|
|
|
|
else if (iflags)
|
|
|
|
bigMode = MODE_INSTALL;
|
|
|
|
else if (eflags)
|
|
|
|
bigMode = MODE_ERASE;
|
|
|
|
}
|
|
|
|
#endif /* IAM_RPMQV */
|
2000-06-01 12:47:42 +08:00
|
|
|
|
2001-06-26 04:01:42 +08:00
|
|
|
#ifdef IAM_RPMK
|
2001-07-17 11:03:14 +08:00
|
|
|
if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
|
2001-10-25 09:36:32 +08:00
|
|
|
switch (ka->qva_mode) {
|
2001-10-24 00:48:20 +08:00
|
|
|
case RPMSIGN_NONE:
|
|
|
|
ka->sign = 0;
|
2001-07-08 03:15:17 +08:00
|
|
|
break;
|
2001-10-24 00:48:20 +08:00
|
|
|
case RPMSIGN_IMPORT_PUBKEY:
|
|
|
|
case RPMSIGN_CHK_SIGNATURE:
|
2001-06-26 04:01:42 +08:00
|
|
|
bigMode = MODE_CHECKSIG;
|
2001-10-24 00:48:20 +08:00
|
|
|
ka->sign = 0;
|
2001-06-26 04:01:42 +08:00
|
|
|
break;
|
2001-10-24 00:48:20 +08:00
|
|
|
case RPMSIGN_ADD_SIGNATURE:
|
|
|
|
case RPMSIGN_NEW_SIGNATURE:
|
2001-06-26 04:01:42 +08:00
|
|
|
bigMode = MODE_RESIGN;
|
2001-10-24 00:48:20 +08:00
|
|
|
ka->sign = 1;
|
2001-06-26 04:01:42 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-07-11 01:59:11 +08:00
|
|
|
}
|
2001-06-26 04:01:42 +08:00
|
|
|
#endif /* IAM_RPMK */
|
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
#if defined(IAM_RPMEIU)
|
2001-06-09 04:45:59 +08:00
|
|
|
if (!( bigMode == MODE_INSTALL ) &&
|
|
|
|
(ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE)))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("files may only be relocated during package installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->relocations && ia->prefix)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("only one of --prefix or --relocate may be used"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && ia->relocations)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--relocate and --excludepath may only be used when installing new packages"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && ia->prefix)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--prefix may only be used when installing new packages"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->prefix && ia->prefix[0] != '/')
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("arguments to --prefix must begin with a /"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--hash (-h) may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--percent may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
if (bigMode != MODE_INSTALL &&
|
2001-06-09 04:45:59 +08:00
|
|
|
(ia->probFilter & (RPMPROB_FILTER_REPLACEOLDFILES|RPMPROB_FILTER_REPLACENEWFILES)))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--replacefiles may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--replacepkgs may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--excludedocs may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && ia->incldocs)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--includedocs may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("only one of --excludedocs and --includedocs may be "
|
|
|
|
"specified"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--ignorearch may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--ignoreos may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
if (bigMode != MODE_INSTALL &&
|
2001-06-09 04:45:59 +08:00
|
|
|
(ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES)))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--ignoresize may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if ((ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--allmatches may only be specified during package "
|
|
|
|
"erasure"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--allfiles may only be specified during package "
|
|
|
|
"installation"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
|
|
|
|
bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--justdb may only be specified during package "
|
|
|
|
"installation and erasure"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
|
|
|
|
(ia->transFlags & (RPMTRANS_FLAG_NOSCRIPTS | _noTransScripts | _noTransTriggers)))
|
2001-03-04 23:34:53 +08:00
|
|
|
argerror(_("script disabling options may only be specified during "
|
|
|
|
"package installation and erasure"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
|
|
|
|
(ia->transFlags & (RPMTRANS_FLAG_NOTRIGGERS | _noTransTriggers)))
|
2001-03-04 23:34:53 +08:00
|
|
|
argerror(_("trigger disabling options may only be specified during "
|
|
|
|
"package installation and erasure"));
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--nodeps may only be specified during package "
|
|
|
|
"building, rebuilding, recompilation, installation,"
|
|
|
|
"erasure, and verification"));
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--test may only be specified during package installation, "
|
|
|
|
"erasure, and building"));
|
2001-01-02 07:14:47 +08:00
|
|
|
#endif /* IAM_RPMEIU */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmcliRootDir && rpmcliRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("--root (-r) may only be specified during "
|
|
|
|
"installation, erasure, querying, and "
|
|
|
|
"database rebuilds"));
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmcliRootDir) {
|
|
|
|
switch (urlIsURL(rpmcliRootDir)) {
|
2000-05-19 05:03:14 +08:00
|
|
|
default:
|
|
|
|
if (bigMode & MODES_FOR_ROOT)
|
|
|
|
break;
|
|
|
|
/*@fallthrough@*/
|
|
|
|
case URL_IS_UNKNOWN:
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmcliRootDir[0] != '/')
|
2000-05-19 05:03:14 +08:00
|
|
|
argerror(_("arguments to --root (-r) must begin with a /"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#if defined(IAM_RPMBT) || defined(IAM_RPMK)
|
2001-06-09 04:45:59 +08:00
|
|
|
if (0
|
2001-01-02 07:14:47 +08:00
|
|
|
#if defined(IAM_RPMBT)
|
2001-06-09 04:45:59 +08:00
|
|
|
|| ba->sign
|
|
|
|
#endif
|
|
|
|
#if defined(IAM_RPMK)
|
|
|
|
|| ka->sign
|
2001-01-02 07:14:47 +08:00
|
|
|
#endif
|
2001-10-16 01:53:34 +08:00
|
|
|
)
|
|
|
|
/*@-branchstate@*/
|
|
|
|
{
|
2000-05-19 05:03:14 +08:00
|
|
|
if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
|
2001-10-24 00:48:20 +08:00
|
|
|
bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD)
|
|
|
|
{
|
2001-04-29 09:05:43 +08:00
|
|
|
const char ** av;
|
2000-05-19 05:03:14 +08:00
|
|
|
struct stat sb;
|
|
|
|
int errors = 0;
|
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
if ((av = poptGetArgs(optCon)) == NULL) {
|
2000-05-19 05:03:14 +08:00
|
|
|
fprintf(stderr, _("no files to sign\n"));
|
|
|
|
errors++;
|
|
|
|
} else
|
2001-04-29 09:05:43 +08:00
|
|
|
while (*av) {
|
|
|
|
if (stat(*av, &sb)) {
|
|
|
|
fprintf(stderr, _("cannot access file %s\n"), *av);
|
2000-05-19 05:03:14 +08:00
|
|
|
errors++;
|
|
|
|
}
|
2001-04-29 09:05:43 +08:00
|
|
|
av++;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
if (errors) {
|
|
|
|
ec = errors;
|
|
|
|
goto exit;
|
|
|
|
}
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
if (poptPeekArg(optCon)) {
|
2000-05-25 01:53:35 +08:00
|
|
|
int sigTag;
|
2000-05-19 05:03:14 +08:00
|
|
|
switch (sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY)) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case RPMSIGTAG_PGP:
|
|
|
|
if ((sigTag == RPMSIGTAG_PGP || sigTag == RPMSIGTAG_PGP5) &&
|
|
|
|
!rpmDetectPGPVersion(NULL)) {
|
|
|
|
fprintf(stderr, _("pgp not found: "));
|
2001-04-29 09:05:43 +08:00
|
|
|
ec = EXIT_FAILURE;
|
|
|
|
goto exit;
|
2000-05-19 05:03:14 +08:00
|
|
|
} /*@fallthrough@*/
|
|
|
|
case RPMSIGTAG_GPG:
|
|
|
|
passPhrase = rpmGetPassPhrase(_("Enter pass phrase: "), sigTag);
|
|
|
|
if (passPhrase == NULL) {
|
|
|
|
fprintf(stderr, _("Pass phrase check failed\n"));
|
2001-04-29 09:05:43 +08:00
|
|
|
ec = EXIT_FAILURE;
|
|
|
|
goto exit;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
fprintf(stderr, _("Pass phrase is good.\n"));
|
|
|
|
passPhrase = xstrdup(passPhrase);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr,
|
|
|
|
_("Invalid %%_signature spec in macro file.\n"));
|
2001-04-29 09:05:43 +08:00
|
|
|
ec = EXIT_FAILURE;
|
|
|
|
goto exit;
|
2000-05-19 05:03:14 +08:00
|
|
|
/*@notreached@*/ break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
argerror(_("--sign may only be used during package building"));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Make rpmLookupSignatureType() return 0 ("none") from now on */
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMBT || IAM_RPMK */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmcliPipeOutput) {
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) pipe(p);
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
if (!(pipeChild = fork())) {
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) close(p[1]);
|
|
|
|
(void) dup2(p[0], STDIN_FILENO);
|
|
|
|
(void) close(p[0]);
|
2002-07-28 08:41:15 +08:00
|
|
|
(void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
|
2000-05-19 05:03:14 +08:00
|
|
|
fprintf(stderr, _("exec failed\n"));
|
|
|
|
}
|
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) close(p[0]);
|
|
|
|
(void) dup2(p[1], STDOUT_FILENO);
|
|
|
|
(void) close(p[1]);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
ts = rpmtsCreate();
|
2002-07-28 08:41:15 +08:00
|
|
|
(void) rpmtsSetRootDir(ts, rpmcliRootDir);
|
2000-05-19 05:03:14 +08:00
|
|
|
switch (bigMode) {
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMDB
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_INITDB:
|
2002-07-25 00:21:23 +08:00
|
|
|
(void) rpmtsInitDB(ts, 0644);
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_REBUILDDB:
|
2002-07-25 00:21:23 +08:00
|
|
|
{ int vsflags = rpmExpandNumeric("%{_vsflags_rebuilddb}");
|
|
|
|
(void)rpmtsSetVerifySigFlags(ts, (vsflags & ~_RPMTS_VSF_VERIFY_LEGACY));
|
|
|
|
ec = rpmtsRebuildDB(ts);
|
|
|
|
} break;
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_VERIFYDB:
|
2002-07-25 00:21:23 +08:00
|
|
|
ec = rpmtsVerifyDB(ts);
|
2001-05-26 03:51:53 +08:00
|
|
|
break;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMDB */
|
|
|
|
|
|
|
|
#ifdef IAM_RPMBT
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_REBUILD:
|
|
|
|
case MODE_RECOMPILE:
|
2001-10-26 12:16:19 +08:00
|
|
|
{ const char * pkg;
|
|
|
|
|
2001-02-10 04:58:37 +08:00
|
|
|
while (!rpmIsVerbose())
|
|
|
|
rpmIncreaseVerbosity();
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
if (!poptPeekArg(optCon))
|
|
|
|
argerror(_("no packages files given for rebuild"));
|
|
|
|
|
|
|
|
ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL;
|
|
|
|
if (bigMode == MODE_REBUILD) {
|
|
|
|
ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
|
|
|
|
ba->buildAmount |= RPMBUILD_RMSOURCE;
|
|
|
|
ba->buildAmount |= RPMBUILD_RMSPEC;
|
|
|
|
ba->buildAmount |= RPMBUILD_CLEAN;
|
|
|
|
ba->buildAmount |= RPMBUILD_RMBUILD;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((pkg = poptGetArg(optCon))) {
|
2000-05-25 01:53:35 +08:00
|
|
|
const char * specFile = NULL;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-10-24 00:48:20 +08:00
|
|
|
ba->cookie = NULL;
|
2001-10-26 12:16:19 +08:00
|
|
|
ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
|
2001-10-24 00:48:20 +08:00
|
|
|
if (ec == 0) {
|
2002-07-28 08:41:15 +08:00
|
|
|
ba->rootdir = rpmcliRootDir;
|
2001-10-24 00:48:20 +08:00
|
|
|
ba->passPhrase = passPhrase;
|
2002-07-28 08:41:15 +08:00
|
|
|
ec = build(ts, specFile, ba, rpmcliRcfile);
|
2001-10-24 00:48:20 +08:00
|
|
|
}
|
|
|
|
ba->cookie = _free(ba->cookie);
|
|
|
|
specFile = _free(specFile);
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
if (ec)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@loopbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-10-26 12:16:19 +08:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case MODE_BUILD:
|
|
|
|
case MODE_TARBUILD:
|
|
|
|
{ const char * pkg;
|
2001-02-10 04:58:37 +08:00
|
|
|
while (!rpmIsVerbose())
|
|
|
|
rpmIncreaseVerbosity();
|
2000-05-19 05:03:14 +08:00
|
|
|
|
|
|
|
switch (ba->buildChar) {
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'a':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
|
|
|
|
/*@fallthrough@*/
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'b':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
|
|
|
|
ba->buildAmount |= RPMBUILD_CLEAN;
|
|
|
|
/*@fallthrough@*/
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'i':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_INSTALL;
|
|
|
|
if ((ba->buildChar == 'i') && ba->shortCircuit)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
/*@fallthrough@*/
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'c':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_BUILD;
|
|
|
|
if ((ba->buildChar == 'c') && ba->shortCircuit)
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
/*@fallthrough@*/
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'p':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_PREP;
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'l':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_FILECHECK;
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2001-06-07 03:57:12 +08:00
|
|
|
case 's':
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!poptPeekArg(optCon)) {
|
|
|
|
if (bigMode == MODE_BUILD)
|
|
|
|
argerror(_("no spec files given for build"));
|
|
|
|
else
|
|
|
|
argerror(_("no tar files given for build"));
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((pkg = poptGetArg(optCon))) {
|
2002-07-28 08:41:15 +08:00
|
|
|
ba->rootdir = rpmcliRootDir;
|
2001-10-24 00:48:20 +08:00
|
|
|
ba->passPhrase = passPhrase;
|
|
|
|
ba->cookie = NULL;
|
2002-07-28 08:41:15 +08:00
|
|
|
ec = build(ts, pkg, ba, rpmcliRcfile);
|
2000-05-19 05:03:14 +08:00
|
|
|
if (ec)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@loopbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
rpmFreeMacros(NULL);
|
2002-07-28 08:41:15 +08:00
|
|
|
(void) rpmReadConfigFiles(rpmcliRcfile, NULL);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-10-26 12:16:19 +08:00
|
|
|
} break;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMBT */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMEIU
|
2001-06-09 04:45:59 +08:00
|
|
|
case MODE_ERASE:
|
|
|
|
if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2002-02-03 06:45:41 +08:00
|
|
|
if (!poptPeekArg(optCon)) {
|
|
|
|
if (ia->rbtid == 0)
|
|
|
|
argerror(_("no packages given for erase"));
|
2002-02-05 00:53:51 +08:00
|
|
|
ia->transFlags |= RPMTRANS_FLAG_NOMD5;
|
|
|
|
ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
|
2002-02-03 06:45:41 +08:00
|
|
|
ec += rpmRollback(ts, ia, NULL);
|
|
|
|
} else {
|
2002-03-13 23:06:07 +08:00
|
|
|
ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
|
2002-02-03 06:45:41 +08:00
|
|
|
}
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_INSTALL:
|
2001-01-21 23:43:32 +08:00
|
|
|
|
|
|
|
/* RPMTRANS_FLAG_KEEPOBSOLETE */
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (!ia->incldocs) {
|
|
|
|
if (ia->transFlags & RPMTRANS_FLAG_NODOCS)
|
2001-01-21 23:43:32 +08:00
|
|
|
;
|
2000-05-19 05:03:14 +08:00
|
|
|
else if (rpmExpandNumeric("%{_excludedocs}"))
|
2001-06-09 04:45:59 +08:00
|
|
|
ia->transFlags |= RPMTRANS_FLAG_NODOCS;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->noDeps) ia->installInterfaceFlags |= INSTALL_NODEPS;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
/* we've already ensured !(!ia->prefix && !ia->relocations) */
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->prefix) {
|
|
|
|
ia->relocations = xmalloc(2 * sizeof(*ia->relocations));
|
|
|
|
ia->relocations[0].oldPath = NULL; /* special case magic */
|
|
|
|
ia->relocations[0].newPath = ia->prefix;
|
2001-09-25 05:53:14 +08:00
|
|
|
ia->relocations[1].oldPath = NULL;
|
|
|
|
ia->relocations[1].newPath = NULL;
|
2001-06-09 04:45:59 +08:00
|
|
|
} else if (ia->relocations) {
|
|
|
|
ia->relocations = xrealloc(ia->relocations,
|
|
|
|
sizeof(*ia->relocations) * (ia->numRelocations + 1));
|
|
|
|
ia->relocations[ia->numRelocations].oldPath = NULL;
|
|
|
|
ia->relocations[ia->numRelocations].newPath = NULL;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2002-02-03 06:45:41 +08:00
|
|
|
if (!poptPeekArg(optCon)) {
|
|
|
|
if (ia->rbtid == 0)
|
|
|
|
argerror(_("no packages given for install"));
|
2002-02-05 00:53:51 +08:00
|
|
|
ia->transFlags |= RPMTRANS_FLAG_NOMD5;
|
|
|
|
ia->probFilter |= RPMPROB_FILTER_OLDPACKAGE;
|
2002-02-10 06:39:29 +08:00
|
|
|
/*@i@*/ ec += rpmRollback(ts, ia, NULL);
|
2002-02-03 06:45:41 +08:00
|
|
|
} else {
|
2002-03-13 23:06:07 +08:00
|
|
|
/*@-compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */
|
|
|
|
ec += rpmInstall(ts, ia, (const char **)poptGetArgs(optCon));
|
|
|
|
/*@=compmempass@*/
|
2002-02-03 06:45:41 +08:00
|
|
|
}
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
2001-07-07 04:37:42 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMEIU */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMQV
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_QUERY:
|
2001-10-24 21:48:55 +08:00
|
|
|
if (qva->qva_source != RPMQV_ALL && !poptPeekArg(optCon))
|
|
|
|
argerror(_("no arguments given for query"));
|
2001-10-28 06:31:10 +08:00
|
|
|
ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
|
2001-10-24 21:48:55 +08:00
|
|
|
/* XXX don't overflow single byte exit status */
|
|
|
|
if (ec > 255) ec = 255;
|
|
|
|
break;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_VERIFY:
|
2001-10-24 21:48:55 +08:00
|
|
|
{ rpmVerifyFlags verifyFlags = VERIFY_ALL;
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
verifyFlags &= ~qva->qva_flags;
|
2001-06-12 12:10:21 +08:00
|
|
|
qva->qva_flags = (rpmQueryFlags) verifyFlags;
|
|
|
|
|
2001-10-24 21:48:55 +08:00
|
|
|
if (qva->qva_source != RPMQV_ALL && !poptPeekArg(optCon))
|
|
|
|
argerror(_("no arguments given for verify"));
|
2001-10-28 06:31:10 +08:00
|
|
|
ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
|
2001-10-24 21:48:55 +08:00
|
|
|
/* XXX don't overflow single byte exit status */
|
|
|
|
if (ec > 255) ec = 255;
|
|
|
|
} break;
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_QUERYTAGS:
|
2000-05-25 01:53:35 +08:00
|
|
|
if (argc != 2)
|
|
|
|
argerror(_("unexpected arguments to --querytags "));
|
|
|
|
|
|
|
|
rpmDisplayQueryTags(stdout);
|
|
|
|
break;
|
|
|
|
#endif /* IAM_RPMQV */
|
|
|
|
|
|
|
|
#ifdef IAM_RPMK
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_CHECKSIG:
|
2001-10-25 09:36:32 +08:00
|
|
|
{ rpmVerifyFlags verifyFlags =
|
|
|
|
(VERIFY_MD5|VERIFY_DIGEST|VERIFY_SIGNATURE);
|
|
|
|
|
|
|
|
verifyFlags &= ~ka->qva_flags;
|
|
|
|
ka->qva_flags = (rpmQueryFlags) verifyFlags;
|
|
|
|
} /*@fallthrough@*/
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_RESIGN:
|
2000-05-25 01:53:35 +08:00
|
|
|
if (!poptPeekArg(optCon))
|
2001-10-24 04:52:51 +08:00
|
|
|
argerror(_("no arguments given"));
|
2001-10-24 00:48:20 +08:00
|
|
|
ka->passPhrase = passPhrase;
|
2002-03-13 04:28:30 +08:00
|
|
|
ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
|
2000-05-25 01:53:35 +08:00
|
|
|
/* XXX don't overflow single byte exit status */
|
|
|
|
if (ec > 255) ec = 255;
|
2001-10-25 09:36:32 +08:00
|
|
|
break;
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMK */
|
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
#if !defined(IAM_RPMQV)
|
|
|
|
case MODE_QUERY:
|
|
|
|
case MODE_VERIFY:
|
|
|
|
case MODE_QUERYTAGS:
|
|
|
|
#endif
|
|
|
|
#if !defined(IAM_RPMK)
|
|
|
|
case MODE_CHECKSIG:
|
|
|
|
case MODE_RESIGN:
|
|
|
|
#endif
|
|
|
|
#if !defined(IAM_RPMDB)
|
|
|
|
case MODE_INITDB:
|
|
|
|
case MODE_REBUILDDB:
|
|
|
|
case MODE_VERIFYDB:
|
|
|
|
#endif
|
|
|
|
#if !defined(IAM_RPMBT)
|
|
|
|
case MODE_BUILD:
|
|
|
|
case MODE_REBUILD:
|
|
|
|
case MODE_RECOMPILE:
|
|
|
|
case MODE_TARBUILD:
|
|
|
|
#endif
|
|
|
|
#if !defined(IAM_RPMEIU)
|
|
|
|
case MODE_INSTALL:
|
2001-06-09 04:45:59 +08:00
|
|
|
case MODE_ERASE:
|
2001-06-07 03:57:12 +08:00
|
|
|
#endif
|
|
|
|
case MODE_UNKNOWN:
|
2002-07-28 08:41:15 +08:00
|
|
|
if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose())
|
|
|
|
printUsage(optCon, stdout, 0);
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-01 06:32:22 +08:00
|
|
|
#if defined(IAM_RPMBT) || defined(IAM_RPMK)
|
2001-04-29 09:05:43 +08:00
|
|
|
exit:
|
2001-05-01 06:32:22 +08:00
|
|
|
#endif /* IAM_RPMBT || IAM_RPMK */
|
2001-10-28 06:31:10 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
ts = rpmtsFree(ts);
|
2001-10-28 06:31:10 +08:00
|
|
|
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
2000-05-19 05:03:14 +08:00
|
|
|
rpmFreeMacros(NULL);
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@i@*/ rpmFreeMacros(rpmCLIMacroContext);
|
2000-05-19 05:03:14 +08:00
|
|
|
rpmFreeRpmrc();
|
|
|
|
|
|
|
|
if (pipeChild) {
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) fclose(stdout);
|
|
|
|
(void) waitpid(pipeChild, &status, 0);
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* keeps memory leak checkers quiet */
|
|
|
|
freeNames();
|
|
|
|
freeFilesystems();
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@i@*/ urlFreeCache();
|
2001-07-20 05:14:05 +08:00
|
|
|
rpmlogClose();
|
|
|
|
dbiTags = _free(dbiTags);
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
#ifdef IAM_RPMQV
|
2001-04-29 09:05:43 +08:00
|
|
|
qva->qva_queryFormat = _free(qva->qva_queryFormat);
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IAM_RPMBT
|
2001-04-29 09:05:43 +08:00
|
|
|
ba->buildRootOverride = _free(ba->buildRootOverride);
|
|
|
|
ba->targets = _free(ba->targets);
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
#ifdef IAM_RPMEIU
|
2002-07-02 21:16:50 +08:00
|
|
|
if (ia->relocations != NULL)
|
2002-06-28 21:04:38 +08:00
|
|
|
for (i = 0; i < ia->numRelocations; i++)
|
|
|
|
ia->relocations[i].oldPath = _free(ia->relocations[i].oldPath);
|
2001-06-09 04:45:59 +08:00
|
|
|
ia->relocations = _free(ia->relocations);
|
|
|
|
#endif
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
#if HAVE_MCHECK_H && HAVE_MTRACE
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-noeffect@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
muntrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=noeffect@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
#endif
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@-globstate@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
return ec;
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=globstate@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=mods@*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=bounds@*/
|