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-01-29 00:16:27 +08:00
|
|
|
#define POPT_NODEPS 1025
|
|
|
|
#define POPT_FORCE 1026
|
|
|
|
#define POPT_NOMD5 1027
|
|
|
|
#define POPT_NOSCRIPTS 1028
|
2001-07-13 21:44:26 +08:00
|
|
|
|
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"
|
|
|
|
|
2002-01-29 00:16:27 +08:00
|
|
|
#define GETOPT_DBPATH 1010
|
|
|
|
#define GETOPT_SHOWRC 1018
|
|
|
|
#define GETOPT_DEFINEMACRO 1020
|
|
|
|
#define GETOPT_EVALMACRO 1021
|
2001-05-06 03:28:32 +08:00
|
|
|
#ifdef NOTYET
|
2002-01-29 00:16:27 +08:00
|
|
|
#define GETOPT_RCFILE 1022
|
2001-05-06 03:28:32 +08:00
|
|
|
#endif
|
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),
|
2001-07-07 04:37:42 +08:00
|
|
|
MODE_ROLLBACK = (1 << 14),
|
|
|
|
#define MODES_IE (MODE_INSTALL | MODE_ERASE | MODE_ROLLBACK)
|
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)
|
|
|
|
#define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
|
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-exportheadervar@*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
extern int _ftp_debug;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
extern int noLibio;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
extern int _rpmio_debug;
|
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@=exportheadervar@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
/* options for all executables */
|
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
static int help = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
static int noUsageMsg = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@observer@*/ /*@null@*/ static const char * pipeOutput = NULL;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
static int quiet = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@observer@*/ /*@null@*/ static const char * rcfile = NULL;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@observer@*/ /*@null@*/ static char * rootdir = "/";
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
static int showrc = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2000-05-25 01:53:35 +08:00
|
|
|
static int showVersion = 0;
|
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-01-02 07:14:47 +08:00
|
|
|
static struct poptOption rpmAllPoptTable[] = {
|
|
|
|
{ "version", '\0', 0, &showVersion, 0,
|
|
|
|
N_("print the version of rpm being used"),
|
|
|
|
NULL },
|
|
|
|
{ "quiet", '\0', 0, &quiet, 0,
|
|
|
|
N_("provide less detailed output"), NULL},
|
|
|
|
{ "verbose", 'v', 0, 0, 'v',
|
|
|
|
N_("provide more detailed output"), NULL},
|
2001-07-08 03:15:17 +08:00
|
|
|
{ "define", '\0', POPT_ARG_STRING, 0, GETOPT_DEFINEMACRO,
|
2001-01-02 07:14:47 +08:00
|
|
|
N_("define macro <name> with value <body>"),
|
|
|
|
N_("'<name> <body>'") },
|
2001-07-08 03:15:17 +08:00
|
|
|
{ "eval", '\0', POPT_ARG_STRING, 0, GETOPT_EVALMACRO,
|
2001-01-02 07:14:47 +08:00
|
|
|
N_("print macro expansion of <expr>+"),
|
|
|
|
N_("<expr>+") },
|
|
|
|
{ "pipe", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &pipeOutput, 0,
|
|
|
|
N_("send stdout to <cmd>"),
|
|
|
|
N_("<cmd>") },
|
2001-06-17 08:36:01 +08:00
|
|
|
{ "root", 'r', POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT, &rootdir, 0,
|
2001-01-02 07:14:47 +08:00
|
|
|
N_("use <dir> as the top level directory"),
|
|
|
|
N_("<dir>") },
|
2000-09-02 05:15:40 +08:00
|
|
|
{ "macros", '\0', POPT_ARG_STRING, ¯ofiles, 0,
|
|
|
|
N_("read <file:...> instead of default macro file(s)"),
|
|
|
|
N_("<file:...>") },
|
2001-05-06 03:28:32 +08:00
|
|
|
#if !defined(GETOPT_RCFILE)
|
2001-01-02 07:14:47 +08:00
|
|
|
{ "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
|
|
|
|
N_("read <file:...> instead of default rpmrc file(s)"),
|
|
|
|
N_("<file:...>") },
|
2000-09-14 19:42:48 +08:00
|
|
|
#else
|
2001-01-02 07:14:47 +08:00
|
|
|
{ "rcfile", '\0', 0, 0, GETOPT_RCFILE,
|
|
|
|
N_("read <file:...> instead of default rpmrc file(s)"),
|
|
|
|
N_("<file:...>") },
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
2001-01-02 07:14:47 +08:00
|
|
|
{ "showrc", '\0', 0, &showrc, GETOPT_SHOWRC,
|
|
|
|
N_("display final rpmrc and macro configuration"),
|
|
|
|
NULL },
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2001-03-15 02:07:47 +08:00
|
|
|
#if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
|
2001-01-02 07:14:47 +08:00
|
|
|
{ "nolibio", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noLibio, 1,
|
|
|
|
N_("disable use of libio(3) API"), NULL},
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
2001-01-02 07:14:47 +08:00
|
|
|
{ "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
|
|
|
|
N_("debug protocol data stream"), NULL},
|
|
|
|
{ "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
|
|
|
|
N_("debug rpmio I/O"), NULL},
|
|
|
|
{ "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
|
|
|
|
N_("debug URL cache handling"), NULL},
|
|
|
|
|
|
|
|
POPT_TABLEEND
|
|
|
|
};
|
2000-05-25 01:53:35 +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 */
|
|
|
|
#if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
|
|
|
|
{ NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i', NULL, NULL},
|
2001-07-13 21:44:26 +08:00
|
|
|
{ "nodeps", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NODEPS, NULL, NULL},
|
2001-07-28 08:33:07 +08:00
|
|
|
{ "noscripts", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOSCRIPTS, NULL, NULL},
|
2001-07-13 21:44:26 +08:00
|
|
|
{ "nomd5", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOMD5, NULL, NULL},
|
|
|
|
{ "force", 0, POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_FORCE, NULL, NULL},
|
2001-01-02 07:14:47 +08:00
|
|
|
#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 */
|
|
|
|
|
2001-01-02 07:14:47 +08:00
|
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmAllPoptTable, 0,
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2001-06-06 03:26:22 +08:00
|
|
|
static void printVersion(void)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals rpmEVR, fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2000-05-19 05:03:14 +08:00
|
|
|
fprintf(stdout, _("RPM version %s\n"), rpmEVR);
|
|
|
|
}
|
|
|
|
|
2001-06-06 03:26:22 +08:00
|
|
|
static void printBanner(void)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) puts(_("Copyright (C) 1998-2000 - Red Hat, Inc."));
|
|
|
|
(void) puts(_("This program may be freely redistributed under the terms of the GNU GPL"));
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2001-06-06 03:26:22 +08:00
|
|
|
static void printUsage(void)
|
2001-11-03 10:34:15 +08:00
|
|
|
/*@globals __assert_program_name, rpmEVR, fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/
|
|
|
|
{
|
2001-06-12 12:10:21 +08:00
|
|
|
FILE * fp = stdout;
|
2000-05-19 05:03:14 +08:00
|
|
|
printVersion();
|
|
|
|
printBanner();
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) puts("");
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
fprintf(fp, _("Usage: %s {--help}\n"), __progname);
|
2001-09-21 23:07:11 +08:00
|
|
|
fprintf(fp, " %s {--version}\n" , __progname);
|
2000-05-25 01:53:35 +08:00
|
|
|
|
|
|
|
#ifdef IAM_RPMEIU
|
2001-01-21 23:43:32 +08:00
|
|
|
#ifdef DYING
|
|
|
|
--dbpath all
|
|
|
|
--ftpproxy etc all
|
|
|
|
--force alias for --replacepkgs --replacefiles
|
|
|
|
--includedocs handle as option in table
|
|
|
|
--erase forbids many options
|
2001-06-12 12:10:21 +08:00
|
|
|
#endif /* DYING */
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMEIU */
|
|
|
|
|
|
|
|
#ifdef IAM_RPMQV
|
2001-01-21 23:43:32 +08:00
|
|
|
#ifdef DYING /* XXX popt glue needing --help doco. */
|
|
|
|
--dbpath all
|
|
|
|
--ftpproxy etc all
|
|
|
|
-i,--info Q
|
|
|
|
-R,--requires Q
|
|
|
|
-P,--provides Q
|
|
|
|
--scripts Q
|
|
|
|
--triggeredby Q
|
|
|
|
--changelog Q
|
|
|
|
--triggers Q
|
|
|
|
--querytags !V
|
|
|
|
--setperms V
|
|
|
|
--setugids V
|
|
|
|
#endif /* DYING */
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif /* IAM_RPMQV */
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-mods@*/ /* FIX: shrug */
|
2000-05-19 05:03:14 +08:00
|
|
|
int main(int argc, const char ** argv)
|
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
|
|
|
{
|
2001-10-28 06:31:10 +08:00
|
|
|
rpmTransactionSet 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;
|
|
|
|
int gotDbpath = 0;
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
#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 */
|
|
|
|
|
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
|
|
|
/* set the defaults for the various command line options */
|
|
|
|
_ftp_debug = 0;
|
2000-05-25 01:53:35 +08:00
|
|
|
|
2001-03-15 02:07:47 +08:00
|
|
|
#if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
|
2000-05-19 05:03:14 +08:00
|
|
|
noLibio = 0;
|
|
|
|
#else
|
|
|
|
noLibio = 1;
|
|
|
|
#endif
|
|
|
|
_rpmio_debug = 0;
|
|
|
|
|
|
|
|
/* XXX Eliminate query linkage loop */
|
2000-05-25 01:53:35 +08:00
|
|
|
specedit = 0;
|
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);
|
|
|
|
|
|
|
|
/* reading rcfile early makes it easy to override */
|
|
|
|
/* XXX only --rcfile (and --showrc) need this pre-parse */
|
|
|
|
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
switch(arg) {
|
|
|
|
case 'v':
|
|
|
|
rpmIncreaseVerbosity(); /* XXX silly use by showrc */
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
default:
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rpmReadConfigFiles(rcfile, NULL))
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
if (showrc) {
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) rpmShowRC(stdout);
|
2000-05-19 05:03:14 +08:00
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmSetVerbosity(RPMMESS_NORMAL); /* XXX silly use by showrc */
|
|
|
|
|
|
|
|
poptResetContext(optCon);
|
|
|
|
|
2000-05-25 01:53:35 +08:00
|
|
|
#ifdef IAM_RPMQV
|
2001-06-09 04:45:59 +08:00
|
|
|
qva->qva_queryFormat = _free(qva->qva_queryFormat);
|
2000-05-19 05:03:14 +08:00
|
|
|
memset(qva, 0, sizeof(*qva));
|
2000-06-12 03:15:27 +08:00
|
|
|
qva->qva_source = RPMQV_PACKAGE;
|
2001-06-21 05:20:16 +08:00
|
|
|
qva->qva_fflags = RPMFILE_ALL;
|
2000-05-27 02:51:11 +08:00
|
|
|
qva->qva_mode = ' ';
|
|
|
|
qva->qva_char = ' ';
|
2000-05-25 01:53:35 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IAM_RPMBT
|
2001-06-09 04:45:59 +08:00
|
|
|
ba->buildRootOverride = _free(ba->buildRootOverride);
|
|
|
|
ba->targets = _free(ba->targets);
|
2000-05-19 05:03:14 +08:00
|
|
|
memset(ba, 0, sizeof(*ba));
|
2000-05-27 02:51:11 +08:00
|
|
|
ba->buildMode = ' ';
|
2000-05-19 05:03:14 +08:00
|
|
|
ba->buildChar = ' ';
|
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_RPMDB
|
|
|
|
memset(da, 0, sizeof(*da));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef IAM_RPMK
|
2001-10-25 09:36:32 +08:00
|
|
|
ka->qva_queryFormat = _free(ka->qva_queryFormat);
|
2001-06-09 04:45:59 +08:00
|
|
|
memset(ka, 0, sizeof(*ka));
|
2001-10-25 09:36:32 +08:00
|
|
|
ka->qva_source = RPMQV_PACKAGE;
|
|
|
|
ka->qva_fflags = RPMFILE_ALL;
|
|
|
|
ka->qva_mode = ' ';
|
|
|
|
ka->qva_char = ' ';
|
2001-06-09 04:45:59 +08:00
|
|
|
#endif
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
#ifdef IAM_RPMEIU
|
2001-06-09 04:45:59 +08:00
|
|
|
ia->relocations = _free(ia->relocations);
|
|
|
|
memset(ia, 0, sizeof(*ia));
|
|
|
|
ia->transFlags = RPMTRANS_FLAG_NONE;
|
|
|
|
ia->probFilter = RPMPROB_FILTER_NONE;
|
|
|
|
ia->installInterfaceFlags = INSTALL_NONE;
|
|
|
|
ia->eraseInterfaceFlags = UNINSTALL_NONE;
|
2001-01-21 23:43:32 +08:00
|
|
|
#endif
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
optArg = poptGetOptArg(optCon);
|
|
|
|
|
|
|
|
switch (arg) {
|
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case 'v':
|
2000-05-25 01:53:35 +08:00
|
|
|
rpmIncreaseVerbosity();
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-07-13 21:44:26 +08:00
|
|
|
/* XXX options used in multiple rpm modes */
|
|
|
|
#if defined(IAM_RPMQV) || defined(IAM_RPMK)
|
|
|
|
case POPT_NOMD5:
|
|
|
|
#ifdef IAM_RPMQV
|
|
|
|
if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
|
|
|
|
qva->qva_flags |= VERIFY_MD5;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMK
|
|
|
|
if (bigMode & MODES_K)
|
2001-10-25 09:36:32 +08:00
|
|
|
ka->qva_flags |= VERIFY_MD5;
|
2001-07-13 21:44:26 +08:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
/*@-ifempty@*/ ;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-07-13 21:44:26 +08:00
|
|
|
#endif /* IAM_RPMQV || IAM_RPMK */
|
|
|
|
|
2000-05-27 02:51:11 +08:00
|
|
|
#if defined(IAM_RPMQV) || defined(IAM_RPMEIU) || defined(IAM_RPMBT)
|
2001-07-13 21:44:26 +08:00
|
|
|
case POPT_NODEPS:
|
|
|
|
#ifdef IAM_RPMQV
|
|
|
|
if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
|
|
|
|
qva->qva_flags |= VERIFY_DEPS;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMEIU
|
|
|
|
if ((bigMode & MODES_IE) ||
|
|
|
|
(ia->installInterfaceFlags &
|
|
|
|
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
|
|
|
|
ia->noDeps = 1;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMBT
|
|
|
|
if ((bigMode & MODES_BT) || ba->buildMode != ' ')
|
|
|
|
ba->noDeps = 1;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
/*@-ifempty@*/ ;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-07-13 21:44:26 +08:00
|
|
|
|
|
|
|
case POPT_FORCE:
|
|
|
|
#ifdef IAM_RPMEIU
|
|
|
|
if ((bigMode & MODES_IE) ||
|
|
|
|
(ia->installInterfaceFlags &
|
|
|
|
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
|
|
|
|
ia->probFilter |=
|
|
|
|
( RPMPROB_FILTER_REPLACEPKG
|
|
|
|
| RPMPROB_FILTER_REPLACEOLDFILES
|
|
|
|
| RPMPROB_FILTER_REPLACENEWFILES
|
|
|
|
| RPMPROB_FILTER_OLDPACKAGE);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMBT
|
|
|
|
if ((bigMode & MODES_BT) || ba->buildMode != ' ')
|
|
|
|
ba->force = 1;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
/*@-ifempty@*/ ;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-07-13 21:44:26 +08:00
|
|
|
|
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;
|
2001-07-28 08:33:07 +08:00
|
|
|
|
|
|
|
case POPT_NOSCRIPTS:
|
|
|
|
#ifdef IAM_RPMQV
|
|
|
|
if (bigMode == MODE_VERIFY || qva->qva_mode == 'V')
|
|
|
|
qva->qva_flags |= VERIFY_SCRIPT;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#ifdef IAM_RPMEIU
|
|
|
|
if ((bigMode & MODES_IE) ||
|
|
|
|
(ia->installInterfaceFlags &
|
|
|
|
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE)))
|
|
|
|
ia->transFlags |= (_noTransScripts | _noTransTriggers);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
/*@-ifempty@*/ ;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-07-28 08:33:07 +08:00
|
|
|
|
2000-05-27 02:51:11 +08:00
|
|
|
#endif /* IAM_RPMQV || IAM_RPMEIU || IAM_RPMBT */
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case GETOPT_DEFINEMACRO:
|
2001-05-29 23:03:35 +08:00
|
|
|
if (optArg) {
|
|
|
|
(void) rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@i@*/ (void) rpmDefineMacro(rpmCLIMacroContext, optArg,RMIL_CMDLINE);
|
2001-05-29 23:03:35 +08:00
|
|
|
}
|
2000-05-19 05:03:14 +08:00
|
|
|
noUsageMsg = 1;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case GETOPT_EVALMACRO:
|
2001-05-29 23:03:35 +08:00
|
|
|
if (optArg) {
|
|
|
|
const char *val = rpmExpand(optArg, NULL);
|
|
|
|
fprintf(stdout, "%s\n", val);
|
|
|
|
val = _free(val);
|
|
|
|
}
|
2000-05-19 05:03:14 +08:00
|
|
|
noUsageMsg = 1;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-05-06 03:28:32 +08:00
|
|
|
#if defined(GETOPT_RCFILE)
|
2001-06-07 03:57:12 +08:00
|
|
|
case GETOPT_RCFILE:
|
2000-09-02 05:15:40 +08:00
|
|
|
fprintf(stderr, _("The --rcfile option has been eliminated.\n"));
|
2000-12-31 02:26:10 +08:00
|
|
|
fprintf(stderr, _("Use \"--macros <file:...>\" instead.\n"));
|
2000-09-02 05:15:40 +08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
/*@notreached@*/ break;
|
2001-05-06 03:28:32 +08:00
|
|
|
#endif
|
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 (quiet)
|
|
|
|
rpmSetVerbosity(RPMMESS_QUIET);
|
|
|
|
|
|
|
|
if (showVersion) printVersion();
|
|
|
|
|
|
|
|
if (arg < -1) {
|
|
|
|
fprintf(stderr, "%s: %s\n",
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
poptStrerror(arg));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
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-06-12 12:10:21 +08:00
|
|
|
/* XXX TODO: never happens. */
|
2000-06-01 12:47:42 +08:00
|
|
|
if (gotDbpath && (bigMode & ~MODES_FOR_DBPATH))
|
|
|
|
argerror(_("--dbpath given for operation that does not use a "
|
|
|
|
"database"));
|
2000-05-19 05:03:14 +08:00
|
|
|
|
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
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
if (rootdir && rootdir[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"));
|
|
|
|
|
|
|
|
if (rootdir) {
|
|
|
|
switch (urlIsURL(rootdir)) {
|
|
|
|
default:
|
|
|
|
if (bigMode & MODES_FOR_ROOT)
|
|
|
|
break;
|
|
|
|
/*@fallthrough@*/
|
|
|
|
case URL_IS_UNKNOWN:
|
|
|
|
if (rootdir[0] != '/')
|
|
|
|
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
|
|
|
|
|
|
|
if (pipeOutput) {
|
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]);
|
|
|
|
(void) execl("/bin/sh", "/bin/sh", "-c", pipeOutput, 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
|
|
|
}
|
|
|
|
|
2001-10-28 06:31:10 +08:00
|
|
|
ts = rpmtransCreateSet(NULL, rootdir);
|
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:
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) rpmdbInit(rootdir, 0644);
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
|
|
|
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_REBUILDDB:
|
2000-05-19 05:03:14 +08:00
|
|
|
ec = rpmdbRebuild(rootdir);
|
|
|
|
break;
|
2001-06-07 03:57:12 +08:00
|
|
|
case MODE_VERIFYDB:
|
2001-05-26 03:51:53 +08:00
|
|
|
ec = rpmdbVerify(rootdir);
|
|
|
|
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) {
|
|
|
|
ba->rootdir = rootdir;
|
|
|
|
ba->passPhrase = passPhrase;
|
2001-10-28 06:31:10 +08:00
|
|
|
ec = build(ts, specFile, ba, rcfile);
|
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))) {
|
|
|
|
ba->rootdir = rootdir;
|
2001-10-24 00:48:20 +08:00
|
|
|
ba->passPhrase = passPhrase;
|
|
|
|
ba->cookie = NULL;
|
2001-10-28 06:31:10 +08:00
|
|
|
ec = build(ts, pkg, ba, rcfile);
|
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);
|
2001-05-04 05:00:18 +08:00
|
|
|
(void) rpmReadConfigFiles(rcfile, 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:
|
2000-05-19 05:03:14 +08:00
|
|
|
if (!poptPeekArg(optCon))
|
2002-01-28 23:18:18 +08:00
|
|
|
argerror(_("no packages given for erase"));
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS;
|
2000-05-19 05:03:14 +08:00
|
|
|
|
2001-10-28 06:31:10 +08:00
|
|
|
ec = rpmErase(ts, (const char **)poptGetArgs(optCon),
|
2001-06-09 04:45:59 +08:00
|
|
|
ia->transFlags, ia->eraseInterfaceFlags);
|
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
|
|
|
|
2001-07-07 04:37:42 +08:00
|
|
|
if (!poptPeekArg(optCon))
|
|
|
|
argerror(_("no packages given for install"));
|
|
|
|
|
2000-05-19 05:03:14 +08:00
|
|
|
/* RPMTRANS_FLAG_BUILD_PROBS */
|
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
|
|
|
|
2001-09-21 23:07:11 +08:00
|
|
|
/*@-compdef@*/ /* FIX: ia->relocations[0].newPath undefined */
|
2001-10-28 06:31:10 +08:00
|
|
|
ec += rpmInstall(ts, (const char **)poptGetArgs(optCon),
|
2001-06-09 04:45:59 +08:00
|
|
|
ia->transFlags, ia->installInterfaceFlags, ia->probFilter,
|
|
|
|
ia->relocations);
|
2001-09-21 23:07:11 +08:00
|
|
|
/*@=compdef@*/
|
2000-05-19 05:03:14 +08:00
|
|
|
break;
|
2001-07-07 04:37:42 +08:00
|
|
|
|
|
|
|
case MODE_ROLLBACK:
|
2001-10-28 06:31:10 +08:00
|
|
|
ec += rpmRollback(ts, ia, (const char **)poptGetArgs(optCon));
|
2001-07-07 04:37:42 +08:00
|
|
|
break;
|
|
|
|
|
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;
|
2001-10-24 04:52:51 +08:00
|
|
|
ec = rpmcliSign(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-07-07 04:37:42 +08:00
|
|
|
case MODE_ROLLBACK:
|
2001-06-07 03:57:12 +08:00
|
|
|
#endif
|
|
|
|
case MODE_UNKNOWN:
|
2000-05-25 01:53:35 +08:00
|
|
|
if (!showVersion && !help && !noUsageMsg) printUsage();
|
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
|
|
|
|
|
|
|
ts = rpmtransFree(ts);
|
|
|
|
|
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
|
|
|
|
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@*/
|