14 #include <rpm/rpmcli.h> 15 #include <rpm/rpmlib.h> 16 #include <rpm/rpmbuild.h> 17 #include <rpm/rpmlog.h> 18 #include <rpm/rpmfileutil.h> 20 #include <rpm/rpmdb.h> 21 #include <rpm/rpmps.h> 22 #include <rpm/rpmts.h> 26 #define GETOPT_REBUILD 1003 27 #define GETOPT_RECOMPILE 1004 30 #if defined(IAM_RPMBT) || defined(IAM_RPMK) 31 #include "lib/signature.h" 40 #define MODES_QV (MODE_QUERY | MODE_VERIFY) 44 #define MODES_IE (MODE_INSTALL | MODE_ERASE) 50 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE) 54 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN) 65 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB) 66 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY) 67 #define MODES_FOR_TEST (MODES_BT | MODES_IE) 68 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K) 77 N_(
"Query/Verify package selection options:"),
80 N_(
"Query options (with -q or --query):"),
83 N_(
"Verify options (with -V or --verify):"),
86 N_(
"File tree walk options (with --ftswalk):"),
92 N_(
"Signature options:"),
98 N_(
"Database options:"),
104 N_(
"Build options with [ <specfile> | <tarball> | <source package> ]:"),
110 N_(
"Install/Upgrade/Erase options:"),
114 {
"quiet",
'\0', 0, &
quiet, 0, NULL, NULL},
117 N_(
"Common options for all rpm modes and executables:"),
127 long _stksize = 64 * 1024L;
139 fprintf(fp,
_(
"RPM version %s\n"),
rpmEVR);
144 fprintf(fp,
_(
"Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
145 fprintf(fp,
_(
"This program may be freely redistributed under the terms of the GNU GPL\n"));
148 static void printUsage(poptContext con, FILE * fp,
int flags)
155 poptPrintHelp(con, fp, flags);
157 poptPrintUsage(con, fp, flags);
160 int main(
int argc,
char *argv[])
165 #if defined(IAM_RPMQV) 177 #if defined(IAM_RPMDB) 181 #if defined(IAM_RPMK) 185 #if defined(IAM_RPMBT) || defined(IAM_RPMK) 186 char * passPhrase =
"";
191 const char *optArg, *poptCtx;
201 #if HAVE_MCHECK_H && HAVE_MTRACE 221 #if defined(IAM_RPMQV) 243 #if defined(ENABLE_NLS) 255 poptCtx =
"rpmbuild";
263 optCon = poptGetContext(poptCtx, argc, (
const char **)argv, optionsTable, 0);
266 (void) poptReadConfigFile(optCon, poptfile);
269 (void) poptReadDefaultConfig(optCon, 1);
272 while ((arg = poptGetNextOpt(optCon)) > 0) {
273 optArg = poptGetOptArg(optCon);
277 fprintf(stderr,
_(
"Internal error in argument processing (%d) :-(\n"), arg);
283 fprintf(stderr,
"%s: %s\n",
284 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
307 argerror(
"--buildroot may only be used during package builds");
315 argerror(
_(
"only one major mode may be specified"));
321 argerror(
_(
"only one major mode may be specified"));
327 argerror(
_(
"only one major mode may be specified"));
343 argerror(
_(
"one type of query/verify may be performed at a " 346 if (qva->
qva_flags && (bigMode & ~MODES_QV))
364 argerror(
_(
"only one major mode may be specified"));
393 #if defined(IAM_RPMEIU) 396 argerror(
_(
"only installation, upgrading, rmsource and rmspec may be forced"));
398 argerror(
_(
"files may only be relocated during package installation"));
401 argerror(
_(
"cannot use --prefix with --relocate or --excludepath"));
404 argerror(
_(
"--relocate and --excludepath may only be used when installing new packages"));
407 argerror(
_(
"--prefix may only be used when installing new packages"));
410 argerror(
_(
"arguments to --prefix must begin with a /"));
413 argerror(
_(
"--hash (-h) may only be specified during package " 417 argerror(
_(
"--percent may only be specified during package " 421 argerror(
_(
"--replacepkgs may only be specified during package " 425 argerror(
_(
"--excludedocs may only be specified during package " 429 argerror(
_(
"--includedocs may only be specified during package " 433 argerror(
_(
"only one of --excludedocs and --includedocs may be " 437 argerror(
_(
"--ignorearch may only be specified during package " 441 argerror(
_(
"--ignoreos may only be specified during package " 446 argerror(
_(
"--ignoresize may only be specified during package " 450 argerror(
_(
"--allmatches may only be specified during package " 454 argerror(
_(
"--allfiles may only be specified during package " 459 argerror(
_(
"--justdb may only be specified during package " 460 "installation and erasure"));
464 argerror(
_(
"script disabling options may only be specified during " 465 "package installation and erasure"));
469 argerror(
_(
"trigger disabling options may only be specified during " 470 "package installation and erasure"));
473 argerror(
_(
"--nodeps may only be specified during package " 474 "building, rebuilding, recompilation, installation," 475 "erasure, and verification"));
478 argerror(
_(
"--test may only be specified during package installation, " 479 "erasure, and building"));
483 argerror(
_(
"--root (-r) may only be specified during " 484 "installation, erasure, querying, and " 485 "database rebuilds"));
494 argerror(
_(
"arguments to --root (-r) must begin with a /"));
502 #if defined(IAM_RPMBT) || defined(IAM_RPMK) 504 #
if defined(IAM_RPMBT)
507 #
if defined(IAM_RPMK)
519 if ((av = poptGetArgs(optCon)) == NULL) {
520 fprintf(stderr,
_(
"no files to sign\n"));
524 if (stat(*av, &sb)) {
525 fprintf(stderr,
_(
"cannot access file %s\n"), *av);
536 if (poptPeekArg(optCon)) {
537 int sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY);
545 passPhrase = rpmGetPassPhrase(
_(
"Enter pass phrase: "), sigTag);
546 if (passPhrase == NULL) {
547 fprintf(stderr,
_(
"Pass phrase check failed\n"));
551 fprintf(stderr,
_(
"Pass phrase is good.\n"));
552 passPhrase =
xstrdup(passPhrase);
556 _(
"Invalid %%_signature spec in macro file.\n"));
563 argerror(
_(
"--sign may only be used during package building"));
567 (void) rpmLookupSignatureType(RPMLOOKUPSIG_DISABLE);
573 fprintf(stderr,
_(
"creating a pipe for --pipe failed: %m\n"));
577 if (!(pipeChild = fork())) {
578 (void) signal(SIGPIPE, SIG_DFL);
580 (void) dup2(p[0], STDIN_FILENO);
583 fprintf(stderr,
_(
"exec failed\n"));
587 (void) dup2(p[1], STDOUT_FILENO);
618 if (!poptPeekArg(optCon))
619 argerror(
_(
"no packages files given for rebuild"));
631 while ((pkg = poptGetArg(optCon))) {
632 char * specFile = NULL;
642 specFile =
_free(specFile);
683 if (!poptPeekArg(optCon)) {
685 argerror(
_(
"no spec files given for build"));
687 argerror(
_(
"no tar files given for build"));
690 while ((pkg = poptGetArg(optCon))) {
707 if (!poptPeekArg(optCon)) {
708 argerror(
_(
"no packages given for erase"));
741 if (!poptPeekArg(optCon)) {
742 argerror(
_(
"no packages given for install"));
753 if (!poptPeekArg(optCon)
755 argerror(
_(
"no arguments given for query"));
768 if (!poptPeekArg(optCon)
770 argerror(
_(
"no arguments given for verify"));
784 if (!poptPeekArg(optCon))
791 #if !defined(IAM_RPMQV) 795 #if !defined(IAM_RPMK) 799 #if !defined(IAM_RPMDB) 804 #if !defined(IAM_RPMBT) 810 #if !defined(IAM_RPMEIU) 815 if (poptPeekArg(optCon) != NULL || argc <= 1 ||
rpmIsVerbose()) {
826 optCon = poptFreeContext(optCon);
832 (void) fclose(stdout);
833 (void) waitpid(pipeChild, &status, 0);
857 #if HAVE_MCHECK_H && HAVE_MTRACE 862 if (ec > 254) ec = 254;
static void printBanner(FILE *fp)
const char * rpmcliRcfile
int rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
int rpmInstall(rpmts ts, struct rpmInstallArguments_s *ia, ARGV_t fileArgv)
Install/upgrade/freshen binary rpm package.
struct poptOption rpmcliFtsPoptTable[]
enum rpmQueryFlags_e rpmQueryFlags
Bit(s) to control rpmQuery() operation, stored in qva_flags.
int rpmtsInitDB(rpmts ts, int dbmode)
Initialize the database used by the transaction.
struct poptOption rpmDatabasePoptTable[]
struct rpmDatabaseArguments_s rpmDBArgs
void freeNames(void)
Destroy uid/gid caches.
int build(rpmts ts, const char *arg, BTA_t ba, const char *rcfile)
int main(int argc, char *argv[])
rpmprobFilterFlags probFilter
struct rpmBuildArguments_s rpmBTArgs
void rpmlogClose(void)
Close desriptor used to write to system logger.
int rpmcliQuery(rpmts ts, QVA_t qva, ARGV_const_t argv)
Display package information.
static struct poptOption optionsTable[]
urltype urlIsURL(const char *url)
Return type of URL.
struct poptOption rpmInstallPoptTable[]
rpmRelocation * relocations
struct rpmQVKArguments_s rpmQVKArgs
Describe database command line requests.
#define rpmIncreaseVerbosity()
struct poptOption rpmVerifyPoptTable[]
int rpmcliVerify(rpmts ts, QVA_t qva, ARGV_const_t argv)
Verify package install.
#define setlocale(Category, Locale)
Describe query/verify/signature command line operation.
struct poptOption rpmQueryPoptTable[]
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target.
static void printVersion(FILE *fp)
int rpmErase(rpmts ts, struct rpmInstallArguments_s *ia, ARGV_const_t argv)
Erase binary rpm package.
int rpmcliSign(rpmts ts, QVA_t qva, ARGV_const_t argv)
Create/Modify/Check elements from signature header.
void rpmcliConfigured(void)
Make sure that rpm configuration has been read.
#define RPM_GNUC_NORETURN
const char * rpmcliPipeOutput
int rpmtsVerifyDB(rpmts ts)
Verify the database used by the transaction.
enum rpmVSFlags_e rpmVSFlags
Bit(s) to control digest and signature verification.
static int rstreq(const char *s1, const char *s2)
Test for string equality.
struct poptOption rpmBuildPoptTable[]
static void argerror(const char *desc)
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
int rpmInstallSource(rpmts ts, const char *arg, char **specFilePtr, char **cookie)
Install source rpm package.
rpmInstallFlags installInterfaceFlags
#define UNINSTALL_ALLMATCHES
void rpmFreeFilesystems(void)
Release storage used by file system usage cache.
const char * rpmcliRootDir
enum rpmVerifyFlags_e rpmVerifyFlags
Bit(s) to control rpmVerify() operation.
char *const * ARGV_const_t
const char * rpmConfigDir(void)
Return rpm configuration base directory.
rpmMacroContext rpmCLIMacroContext
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
int rpmspecQuery(rpmts ts, QVA_t qva, const char *arg)
Function to query spec file(s).
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
struct rpmts_s * rpmts
The main types involved in transaction manipulation.
Describe database command line requests.
#define textdomain(Domain)
void rpmFreeRpmrc(void)
Destroy rpmrc arch/os compatibility tables.
struct rpmInstallArguments_s rpmIArgs
int rpmtsRebuildDB(rpmts ts)
Rebuild the database used by the transaction.
struct poptOption rpmQVSourcePoptTable[]
#define rpmSetVerbosity(_lvl)
#define bindtextdomain(Domain, Directory)
rpmts rpmtsCreate(void)
Create an empty transaction set.
char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
#define xrealloc(_ptr, _size)
Describe build command line request.
struct poptOption rpmSignPoptTable[]
static void printUsage(poptContext con, FILE *fp, int flags)
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.