9 #if defined(RPM_VENDOR_WINDRIVER)
13 #if defined(ENABLE_NLS) && !defined(__LCLINT__)
17 #define _RPMIOB_INTERNAL
42 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
44 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
45 #define VSF_SET(_vsflags, _FLAG) \
46 (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
47 #define VSF_CLR(_vsflags, _FLAG) \
48 (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
50 GENfree(
unsigned int *)
54 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
56 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
57 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
58 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
63 extern unsigned int *
keyids;
65 #define POPT_SHOWVERSION -999
66 #define POPT_SHOWRC -998
67 #define POPT_QUERYTAGS -997
68 #define POPT_PREDEFINE -996
69 #define POPT_UNDEFINE -994
200 fprintf(fp,
"rpmlib 0x%08x,0x%08x,0x%08x\n", (
unsigned)
rpmlibVersion(),
211 if (rpmcliInitialized < 0) {
213 if (rpmcliTargets != NULL) {
216 if ((te = strchr(t,
',')) != NULL)
222 if (rpmcliInitialized)
232 const char * pre =
"";
233 const char * post =
"";
235 const char * val = NULL;
239 if (!strcmp(arg,
"-")) {
242 if ((arg[0] ==
'/' || strchr(arg,
' ') == NULL)
244 && S_ISREG(sb.st_mode)) {
250 val =
rpmExpand(pre, iob->b, post, NULL);
258 enum poptCallbackReason reason,
259 const struct poptOption * opt,
const char *
arg,
268 if (opt->arg == NULL)
278 if (*t ==
'-') *t =
'_';
296 if (*t ==
'-') *t =
'_';
312 size_t val_len = fwrite(val, strlen(val), 1, stdout);
313 if (val_len > 0 && val[val_len - 1] !=
'\n')
314 fprintf(stdout,
"\n");
335 #if defined(SUPPORT_NOSIGNATURES)
346 #if defined(SUPPORT_NOSIGNATURES)
357 #if defined(SUPPORT_NOSIGNATURES)
364 if (rpmcliTargets == NULL)
368 char * t = (
char *) rpmcliTargets;
369 size_t nb = strlen(t) + (
sizeof(
",")-1) + strlen(arg) + 1;
385 N_(
"Add packages to resolve dependencies"), NULL },
386 {
"anaconda",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
388 N_(
"Use anaconda \"presentation order\""), NULL},
389 {
"deploops",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
391 N_(
"Print dependency loops as warning"), NULL},
394 N_(
"Do not suggest missing dependency resolution(s)"), NULL},
395 {
"noconflicts",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
397 N_(
"Do not check added package conflicts"), NULL},
400 N_(
"Ignore added package requires on symlink targets"), NULL},
401 {
"noobsoletes",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
403 N_(
"Ignore added package obsoletes"), NULL},
406 N_(
"Ignore added package requires on file parent directory"), NULL},
407 {
"norequires",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
409 N_(
"Do not check added package requires"), NULL},
410 {
"noupgrade",
'\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
412 N_(
"Ignore added package upgrades"), NULL},
420 { NULL,
'\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
424 {
"debug",
'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_debug, -1,
425 N_(
"Debug generic operations"), NULL},
427 {
"predefine",
'\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, NULL,
POPT_PREDEFINE,
428 N_(
"Predefine MACRO with value EXPR"),
429 N_(
"'MACRO EXPR'") },
431 {
"define",
'D', POPT_ARG_STRING, NULL,
'D',
432 N_(
"Define MACRO with value EXPR"),
433 N_(
"'MACRO EXPR'") },
435 N_(
"Undefine MACRO"),
437 {
"eval",
'E', POPT_ARG_STRING, NULL,
'E',
438 N_(
"Print macro expansion of EXPR"),
441 N_(
"Read <FILE:...> instead of default file(s)"),
444 {
"rpmlua",
'\0', POPT_ARG_STRING, &
rpmluaFiles, 0,
445 N_(
"Read <FILE:...> instead of default RPM Lua file(s)"),
448 {
"rpmpopt",
'\0', POPT_ARG_STRING, NULL, 0,
449 N_(
"Read <FILE:...> instead of default POPT file(s)"),
453 N_(
"Specify target platform"),
N_(
"CPU-VENDOR-OS") },
456 N_(
"Don't verify package digest(s)"), NULL },
458 N_(
"Don't verify database header(s) when retrieved"), NULL },
460 N_(
"Don't verify package signature(s)"), NULL },
463 N_(
"Display known query tags"), NULL },
465 N_(
"Display macro and configuration values"), NULL },
467 N_(
"Print the version"), NULL },
469 {
"promoteepoch",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmds_nopromote, 0,
472 {
"fpsdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_fps_debug, -1,
473 N_(
"Debug file FingerPrintS"), NULL},
474 {
"fsmdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_fsm_debug, -1,
475 N_(
"Debug payload File State Machine"), NULL},
476 {
"fsmthreads",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_fsm_threads, -1,
477 N_(
"Use threads for File State Machine"), NULL},
478 {
"hdrdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_hdr_debug, -1,
480 {
"hdrqfdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_hdrqf_debug, -1,
482 {
"macrosused",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmts_macros, -1,
483 N_(
"Display macros used"), NULL},
484 {
"pkgiodebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_pkgio_debug, -1,
486 {
"prtpkts",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_print_pkts, -1,
487 N_(
"Display OpenPGP (RFC 2440/4880) parsing"), NULL},
488 {
"psmdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_psm_debug, -1,
489 N_(
"Debug Package State Machine"), NULL},
490 {
"psmthreads",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_psm_threads, -1,
491 N_(
"Use threads for Package State Machine"), NULL},
492 {
"rpmdsdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmds_debug, -1,
493 N_(
"Debug rpmds Dependency Set"), NULL},
494 {
"rpmfcdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmfc_debug, -1,
495 N_(
"Debug rpmfc File Classifier"), NULL},
496 {
"rpmfidebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmfi_debug, -1,
497 N_(
"Debug rpmfi File Info"), NULL},
498 {
"rpmgidebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmgi_debug, -1,
499 N_(
"Debug rpmgi Generalized Iterator"), NULL},
500 {
"rpmmidebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmmi_debug, -1,
501 N_(
"Debug rpmmi Match Iterator"), NULL},
502 {
"rpmnsdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmns_debug, -1,
503 N_(
"Debug rpmns Name Space"), NULL},
504 {
"rpmpsdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmps_debug, -1,
505 N_(
"Debug rpmps Problem Set"), NULL},
506 {
"rpmtedebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmte_debug, -1,
507 N_(
"Debug rpmte Transaction Element"), NULL},
508 {
"rpmtsdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmts_debug, -1,
509 N_(
"Debug rpmts Transaction Set"), NULL},
510 {
"rpmwfdebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmwf_debug, -1,
511 N_(
"Debug rpmwf Wrapper Format"), NULL},
512 {
"stats",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_rpmts_stats, -1,
513 N_(
"Display operation statistics"), NULL},
534 #if defined(HAVE_SQLITE3_H)
547 evr_tuple_order =
_free(evr_tuple_order);
548 evr_tuple_match =
_free(evr_tuple_match);
549 evr_tuple_mire =
mireFree(evr_tuple_mire);
553 _rpmjniI = rpmjniFree(_rpmjniI);
584 #if defined(HAVE_SQLITE3_H)
600 rpmcliTargets =
_free(rpmcliTargets);
602 keyids =
_free(keyids);
608 optCon = poptFreeContext(optCon);
610 #if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
627 if (fstat(fdno, &sb) == -1 &&
errno == EBADF)
628 ret = (open(devnull, flags) == fdno) ? 1 : 2;
632 #if defined(RPM_VENDOR_WINDRIVER)
633 void setRuntimeRelocPaths(
void)
642 __usrlibrpm =
getenv(
"RPM_USRLIBRPM");
643 __etcrpm =
getenv(
"RPM_ETCRPM");
644 #if defined(ENABLE_NLS) && !defined(__LCLINT__)
645 __localedir =
getenv(
"RPM_LOCALEDIR");
648 if ( __usrlibrpm == NULL ) {
653 if ( __etcrpm == NULL ) {
658 #if defined(ENABLE_NLS) && !defined(__LCLINT__)
659 if ( __localedir == NULL ) {
678 #if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
694 {
static const char _devnull[] =
"/dev/null";
695 #if defined(STDIN_FILENO)
696 (void)
checkfd(_devnull, STDIN_FILENO, O_RDONLY);
698 #if defined(STDOUT_FILENO)
699 (void)
checkfd(_devnull, STDOUT_FILENO, O_WRONLY);
701 #if defined(STDERR_FILENO)
702 (void)
checkfd(_devnull, STDERR_FILENO, O_WRONLY);
706 #if defined(RPM_VENDOR_WINDRIVER)
707 (void) setRuntimeRelocPaths();
710 #if defined(ENABLE_NLS) && !defined(__LCLINT__)
718 if (optionsTable == NULL) {
725 for (i = 1; i < argc; i++) {
726 if (strcmp(argv[i],
"--rpmpopt") == 0 && i+1 < argc) {
727 rpmpoptfiles = argv[i+1];
730 else if (strncmp(argv[i],
"--rpmpopt=", 10) == 0) {
731 rpmpoptfiles = argv[
i]+10;
737 {
static const char lt_[] =
"lt-";
739 if (!strncmp(s, lt_,
sizeof(lt_)-1))
742 optCon = poptGetContext(s, argc, (
const char **)argv, optionsTable, 0);
746 #if defined(RPM_VENDOR_OPENPKG) || \
747 !defined(POPT_ERROR_BADCONFIG)
748 {
char * path_buf =
xstrdup(rpmpoptfiles);
752 for (path = path_buf; path != NULL && *path !=
'\0'; path = path_next) {
757 path_next = strchr(path,
':');
758 if (path_next != NULL && *path_next ==
':')
761 path_next = path + strlen(path);
766 if ((xx =
rpmGlob(path, &ac, &av)) != 0)
770 for (i = 0; i < ac; i++) {
771 const char *fn = av[
i];
775 rpmlog(
RPMLOG_WARNING,
"existing POPT configuration file \"%s\" considered INSECURE -- not loaded\n", fn);
779 (void) poptReadConfigFile(optCon, fn);
784 path_buf =
_free(path_buf);
788 if ((xx = poptReadConfigFiles(optCon, rpmpoptfiles)) != 0)
789 rpmlog(
RPMLOG_WARNING,
"existing POPT configuration file \"%s\" considered INSECURE -- not loaded\n", rpmpoptfiles);
792 #if defined(RPM_VENDOR_WINDRIVER)
793 {
const char * poptAliasFn =
rpmGetPath(__usrlibrpm,
"/rpmpopt", NULL);
794 (void) poptReadConfigFile(optCon, poptAliasFn);
795 poptAliasFn =
_free(poptAliasFn);
801 (void) poptReadDefaultConfig(optCon, 1);
803 #if defined(RPM_VENDOR_WINDRIVER)
804 {
const char * poptExecPath =
rpmGetPath(__usrlibrpm, NULL);
805 poptSetExecPath(optCon, poptExecPath, 1);
806 poptExecPath =
_free(poptExecPath);
813 while ((rc = poptGetNextOpt(optCon)) > 0) {
814 const char * optArg = poptGetOptArg(optCon);
816 optArg =
_free(optArg);
821 fprintf(stderr,
_(
"%s: option table misconfigured (%d)\n"),
833 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
void rpmFreeMacros(MacroContext mc)
Destroy macro context.
enum rpmQueryFlags_e rpmQueryFlags
Bit(s) to control rpmQuery() operation, stored in qva_flags.
#define RPMCLI_POPT_TARGETPLATFORM
rpmQueryFlags rpmcliQueryFlags
Bit(s) from common command line options.
const char * evr_tuple_match
struct poptOption rpmcliDepFlagsPoptTable[]
void rpmioClean(void)
Free all memory allocated by rpmio usage.
void tagClean(headerTagIndices _rpmTags)
Free memory in header tag indices.
char * getenv(const char *name)
#define VSF_SET(_vsflags, _FLAG)
char * xstrdup(const char *str)
rpmruby _rpmrubyI
Current (global) interpreter instance.
rpmjs rpmjsFree(rpmjs js)
Destroy a js interpreter.
rpmmdb rpmmdbFree(rpmmdb mdb)
Destroy a mongodb wrapper.
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
MacroContext rpmCLIMacroContext
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
static struct poptOption optionsTable[]
int setenv(const char *name, const char *value, int replace)
const char * evr_tuple_order
int Stat(const char *path, struct stat *st)
stat(2) clone.
Structure(s) and routine(s) used for classifying and parsing names.
Access mounted file system information.
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
static void rpmlog(int code, const char *fmt,...)
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
poptContext rpmcliInit(int argc, char *const argv[], struct poptOption *optionsTable)
Initialize most everything needed by an rpm CLI executable context.
#define RPMCLI_POPT_NODIGEST
#define bindtextdomain(Domain, Directory)
int rpmiobSlurp(const char *fn, rpmiob *iobp)
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
rpmuint32_t rpmlibVendor(void)
miRE mireFree(miRE mire)
Free pattern container.
pgpVSFlags pgpDigVSFlags
Disabler bits(s) for signature/digest checking.
void rpmnsClean(void)
Clean global name space dependency sets.
#define RPMCLI_POPT_NOHDRCHK
static const char * rpmcliEvalSlurp(const char *arg)
static int checkfd(const char *devnull, int fdno, int flags)
static int rpmcliInitialized
#define VSF_CLR(_vsflags, _FLAG)
const char const bson * data
#define POPT_ARGFLAG_TOGGLE
static int xisspace(int c)
#define setlocale(Category, Locale)
int rpmDefineMacro(MacroContext mc, const char *macro, int level)
Define macro in context.
const char * rpmcliTargets
rpmioPool _rpmrubyPool
The pool of Ruby interpreter instances.
const char * rpmMacrofiles
List of macro files to read when configuring rpm.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
void rpmFreeFilesystems(void)
Release storage used by file system usage cache.
Embedded Ruby interpreter.
#define rpmSetVerbosity(_lvl)
const char const char int arg
rpmuint32_t rpmlibVersion(void)
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
const char const bson int mongo_write_concern int flags
rpmuint32_t rpmlibTimestamp(void)
rpmruby rpmrubyFree(rpmruby ruby)
Destroys a Ruby interpreter instance.
#define RPMCLI_POPT_NOSIGNATURE
char * stpcpy(char *dest, const char *src)
void rpmcliConfigured(void)
Make sure that rpm configuration has been read.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int rpmShowRC(FILE *fp)
Display current rpmrc (and macro) configuration.
int _hdr_stats
Global header stats enabler.
void rpmDisplayQueryTags(FILE *fp, headerTagTableEntry _rpmTagTable, headerSprintfExtension _rpmHeaderFormats)
Display list of tags that can be used in –queryformat.
int rpmSecuritySaneFile(const char *filename)
Check whether configuration file is moderately secure to load.
static const char * rpmpoptfiles
#define textdomain(Domain)
struct poptOption rpmioAllPoptTable[]
Popt option table for options shared by all modes and executables.
static void printVersion(FILE *fp)
Display rpm version.
static void rpmcliAllArgCallback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
poptContext rpmcliFini(poptContext optCon)
Destroy most everything needed by an rpm CLI executable context.
rpmioPool rpmioFreePool(rpmioPool pool)
Reclaim memory pool items.
int rpmUndefineMacro(MacroContext mc, const char *macro)
Undefine macro in context.
#define rpmIncreaseVerbosity()