本文整理汇总了C++中rpmExpand函数的典型用法代码示例。如果您正苦于以下问题:C++ rpmExpand函数的具体用法?C++ rpmExpand怎么用?C++ rpmExpand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpmExpand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: includeFileSignatures
static rpmRC includeFileSignatures(Header *sigp, Header *hdrp)
{
#ifdef WITH_IMAEVM
rpmRC rc;
char *key;
char *keypass;
key = rpmExpand("%{?_file_signing_key}", NULL);
keypass = rpmExpand("%{?_file_signing_key_password}", NULL);
if (rstreq(keypass, "")) {
free(keypass);
keypass = NULL;
}
rc = rpmSignFiles(*sigp, *hdrp, key, keypass);
free(keypass);
free(key);
return rc;
#else
rpmlog(RPMLOG_ERR, _("file signing support not built in\n"));
return RPMRC_FAIL;
#endif
}
示例2: checkForValidArchitectures
static int checkForValidArchitectures(Spec spec)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies rpmGlobalMacroContext, internalState @*/
{
const char *arch = rpmExpand("%{_target_cpu}", NULL);
const char *os = rpmExpand("%{_target_os}", NULL);
int rc = RPMRC_FAIL; /* assume failure. */
if (isMemberInEntry(spec->sourceHeader, arch, RPMTAG_EXCLUDEARCH) == 1) {
rpmlog(RPMLOG_ERR, _("Architecture is excluded: %s\n"), arch);
goto exit;
}
if (isMemberInEntry(spec->sourceHeader, arch, RPMTAG_EXCLUSIVEARCH) == 0) {
rpmlog(RPMLOG_ERR, _("Architecture is not included: %s\n"), arch);
goto exit;
}
if (isMemberInEntry(spec->sourceHeader, os, RPMTAG_EXCLUDEOS) == 1) {
rpmlog(RPMLOG_ERR, _("OS is excluded: %s\n"), os);
goto exit;
}
if (isMemberInEntry(spec->sourceHeader, os, RPMTAG_EXCLUSIVEOS) == 0) {
rpmlog(RPMLOG_ERR, _("OS is not included: %s\n"), os);
goto exit;
}
rc = 0;
exit:
arch = _free(arch);
os = _free(os);
return rc;
}
示例3: addTargets
static void addTargets(Package Pkgs)
{
char *platform = rpmExpand("%{_target_platform}", NULL);
char *arch = rpmExpand("%{_target_cpu}", NULL);
char *os = rpmExpand("%{_target_os}", NULL);
char *optflags = rpmExpand("%{optflags}", NULL);
for (Package pkg = Pkgs; pkg != NULL; pkg = pkg->next) {
headerPutString(pkg->header, RPMTAG_OS, os);
/* noarch subpackages already have arch set here, leave it alone */
if (!headerIsEntry(pkg->header, RPMTAG_ARCH)) {
headerPutString(pkg->header, RPMTAG_ARCH, arch);
}
headerPutString(pkg->header, RPMTAG_PLATFORM, platform);
headerPutString(pkg->header, RPMTAG_OPTFLAGS, optflags);
/* Add manual dependencies early for rpmspec etc to look at */
addPackageProvides(pkg);
for (int i=0; i<PACKAGE_NUM_DEPS; i++) {
rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
}
pkg->ds = rpmdsThis(pkg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
}
free(platform);
free(arch);
free(os);
free(optflags);
}
示例4: rpmExpand
static char *rpmfcAttrMacro(const char *name,
const char *attr_prefix, const char *attr)
{
char *ret;
if (attr_prefix && attr_prefix[0] != '\0')
ret = rpmExpand("%{?__", name, "_", attr_prefix, "_", attr, "}", NULL);
else
ret = rpmExpand("%{?__", name, "_", attr, "}", NULL);
return rstreq(ret, "") ? _free(ret) : ret;
}
示例5: doSign
/* TODO: permit overriding macro setup on the command line */
static int doSign(poptContext optCon)
{
int rc = EXIT_FAILURE;
char * passPhrase = NULL;
char * name = rpmExpand("%{?_gpg_name}", NULL);
struct rpmSignArgs sig = {NULL, 0, 0};
char *key = NULL;
if (rstreq(name, "")) {
fprintf(stderr, _("You must set \"%%_gpg_name\" in your macro file\n"));
goto exit;
}
if (fileSigningKey) {
addMacro(NULL, "_file_signing_key", NULL, fileSigningKey, RMIL_GLOBAL);
}
if (signfiles) {
key = rpmExpand("%{?_file_signing_key}", NULL);
if (rstreq(key, "")) {
fprintf(stderr, _("You must set \"$$_file_signing_key\" in your macro file or on the command line with --fskpath\n"));
goto exit;
}
if (fskpass) {
#ifndef WITH_IMAEVM
argerror(_("--fskpass may only be specified when signing files"));
#else
fileSigningKeyPassword = get_fskpass();
#endif
}
addMacro(NULL, "_file_signing_key_password", NULL,
fileSigningKeyPassword, RMIL_CMDLINE);
if (fileSigningKeyPassword) {
memset(fileSigningKeyPassword, 0, strlen(fileSigningKeyPassword));
free(fileSigningKeyPassword);
}
sig.signfiles = 1;
}
const char *arg;
rc = 0;
while ((arg = poptGetArg(optCon)) != NULL) {
rc += rpmPkgSign(arg, &sig);
}
exit:
free(key);
free(passPhrase);
free(name);
return rc;
}
示例6: rpmtsSetupTransactionPlugins
rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
{
rpmRC rc = RPMRC_OK;
ARGV_t files = NULL;
int nfiles = 0;
char *dsoPath = NULL;
/*
* Assume allocated equals initialized. There are some oddball cases
* (verification of non-installed package) where this is not true
* currently but that's not a new issue.
*/
if ((rpmtsFlags(ts) & RPMTRANS_FLAG_NOPLUGINS) || ts->plugins != NULL)
return RPMRC_OK;
dsoPath = rpmExpand("%{__plugindir}/*.so", NULL);
if (rpmGlob(dsoPath, &nfiles, &files) == 0) {
rpmPlugins tsplugins = rpmtsPlugins(ts);
for (int i = 0; i < nfiles; i++) {
char *bn = basename(files[i]);
bn[strlen(bn)-strlen(".so")] = '\0';
if (rpmpluginsAddPlugin(tsplugins, "transaction", bn) == RPMRC_FAIL)
rc = RPMRC_FAIL;
}
files = argvFree(files);
}
free(dsoPath);
return rc;
}
示例7: addPackageProvides
/*
* Add extra provides to package.
*/
static void addPackageProvides(Header h)
{
const char *name = NULL, *arch = NULL;
char *evr, *isaprov;
rpmsenseFlags pflags = RPMSENSE_EQUAL;
int noarch = 0;
struct rpmtd_s archtd;
/* <name> = <evr> provide */
evr = headerGetEVR(h, &name);
headerPutString(h, RPMTAG_PROVIDENAME, name);
headerPutString(h, RPMTAG_PROVIDEVERSION, evr);
headerPutUint32(h, RPMTAG_PROVIDEFLAGS, &pflags, 1);
/*
* <name>(<isa>) = <evr> provide
* FIXME: noarch needs special casing for now as BuildArch: noarch doesn't
* cause reading in the noarch macros :-/
*/
isaprov = rpmExpand(name, "%{?_isa}", NULL);
headerGet(h, RPMTAG_ARCH, &archtd, HEADERGET_MINMEM);
arch = rpmtdGetString(&archtd);
noarch = (strcmp(arch, "noarch") == 0);
if (!noarch && strcmp(name, isaprov)) {
headerPutString(h, RPMTAG_PROVIDENAME, isaprov);
headerPutString(h, RPMTAG_PROVIDEVERSION, evr);
headerPutUint32(h, RPMTAG_PROVIDEFLAGS, &pflags, 1);
}
free(isaprov);
free(evr);
}
示例8: packageSources
rpmRC packageSources(rpmSpec spec, char **cookie)
{
Package sourcePkg = spec->sourcePackage;
rpmRC rc;
uint32_t one = 1;
/* Add some cruft */
headerPutString(sourcePkg->header, RPMTAG_RPMVERSION, VERSION);
headerPutString(sourcePkg->header, RPMTAG_BUILDHOST, buildHost());
headerPutUint32(sourcePkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
headerPutUint32(sourcePkg->header, RPMTAG_SOURCEPACKAGE, &one, 1);
/* XXX this should be %_srpmdir */
{ char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL);
char *pkgcheck = rpmExpand("%{?_build_pkgcheck_srpm} ", fn, NULL);
spec->sourcePkgId = NULL;
rc = writeRPM(sourcePkg, &spec->sourcePkgId, fn, cookie);
/* Do check SRPM package if enabled */
if (rc == RPMRC_OK && pkgcheck[0] != ' ') {
rc = checkPackages(pkgcheck);
}
free(pkgcheck);
free(fn);
}
return rc;
}
示例9: buildHost
static const char * buildHost(void)
{
static char hostname[1024];
static int oneshot = 0;
struct hostent *hbn;
char *bhMacro;
if (! oneshot) {
bhMacro = rpmExpand("%{?_buildhost}", NULL);
if (strcmp(bhMacro, "") != 0 && strlen(bhMacro) < 1024) {
strcpy(hostname, bhMacro);
} else {
if (strcmp(bhMacro, "") != 0)
rpmlog(RPMLOG_WARNING, _("The _buildhost macro is too long\n"));
(void) gethostname(hostname, sizeof(hostname));
hbn = gethostbyname(hostname);
if (hbn)
strcpy(hostname, hbn->h_name);
else
rpmlog(RPMLOG_WARNING,
_("Could not canonicalize hostname: %s\n"), hostname);
}
free(bhMacro);
oneshot = 1;
}
return(hostname);
}
示例10: rpmnsArch
nsType rpmnsArch(const char * str)
{
nsType rc = RPMNS_TYPE_UNKNOWN;
const char ** av;
#if defined(RPM_VENDOR_WINDRIVER)
const char * known_arch = rpmExpand("%{?_known_arch}", NULL);
const char *p, *pe, *t;
for (p = pe = known_arch ; rc == RPMNS_TYPE_UNKNOWN && pe && *pe ; ) {
while (*p && xisspace(*p)) p++;
pe = p ; while (*pe && !xisspace(*pe)) pe++;
if (p == pe)
break;
t = strndup(p, (pe - p));
p = pe;
if (!strcmp(str, t))
rc = RPMNS_TYPE_ARCH;
t = _free(t);
}
known_arch = _free(known_arch);
#endif
if (rc == RPMNS_TYPE_UNKNOWN)
for (av = rpmnsArches; *av != NULL; av++) {
if (strcmp(str, *av))
continue;
rc = RPMNS_TYPE_ARCH;
break;
}
return rc;
}
示例11: rpmcliEvalSlurp
static const char * rpmcliEvalSlurp(const char * arg)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/
{
const char * pre = "";
const char * post = "";
rpmiob iob = NULL;
const char * val = NULL;
struct stat sb;
int xx;
if (!strcmp(arg, "-")) { /* Macros from stdin arg. */
xx = rpmiobSlurp(arg, &iob);
} else
if ((arg[0] == '/' || strchr(arg, ' ') == NULL)
&& !Stat(arg, &sb)
&& S_ISREG(sb.st_mode)) { /* Macros from a file arg. */
xx = rpmiobSlurp(arg, &iob);
} else { /* Macros from string arg. */
iob = rpmiobAppend(rpmiobNew(strlen(arg)+1), arg, 0);
}
val = rpmExpand(pre, iob->b, post, NULL);
iob = rpmiobFree(iob);
return val;
}
示例12: rpmScriptNew
static rpmScript rpmScriptNew(Header h, rpmTagVal tag, const char *body,
rpmscriptFlags flags)
{
char *nevra = headerGetAsString(h, RPMTAG_NEVRA);
rpmScript script = xcalloc(1, sizeof(*script));
script->tag = tag;
script->flags = flags;
script->body = (body != NULL) ? xstrdup(body) : NULL;
rasprintf(&script->descr, "%s(%s)", tag2sln(tag), nevra);
/* macros need to be expanded before possible queryformat */
if (script->body && (script->flags & RPMSCRIPT_FLAG_EXPAND)) {
char *body = rpmExpand(script->body, NULL);
free(script->body);
script->body = body;
}
if (script->body && (script->flags & RPMSCRIPT_FLAG_QFORMAT)) {
/* XXX TODO: handle queryformat errors */
char *body = headerFormat(h, script->body, NULL);
free(script->body);
script->body = body;
}
free(nevra);
return script;
}
示例13: rpmExpandNumeric
int
rpmExpandNumeric(const char *arg)
{
char *val;
int rc;
if (arg == NULL)
return 0;
val = rpmExpand(arg, NULL);
if (!(val && *val != '%'))
rc = 0;
else if (*val == 'Y' || *val == 'y')
rc = 1;
else if (*val == 'N' || *val == 'n')
rc = 0;
else {
char *end;
rc = strtol(val, &end, 0);
if (!(end && *end == '\0'))
rc = 0;
}
val = _free(val);
return rc;
}
示例14: rpmpluginsAddPlugin
rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name)
{
char *path;
char *options;
rpmRC rc = RPMRC_FAIL;
path = rpmExpand("%{?__", type, "_", name, "}", NULL);
if (!path || rstreq(path, "")) {
rpmlog(RPMLOG_ERR, _("Failed to expand %%__%s_%s macro\n"),
type, name);
goto exit;
}
/* split the options from the path */
#define SKIPSPACE(s) { while (*(s) && risspace(*(s))) (s)++; }
#define SKIPNONSPACE(s) { while (*(s) && !risspace(*(s))) (s)++; }
options = path;
SKIPNONSPACE(options);
if (risspace(*options)) {
*options = '\0';
options++;
SKIPSPACE(options);
}
if (*options == '\0') {
options = NULL;
}
rc = rpmpluginsAdd(plugins, name, path, options);
exit:
_free(path);
return rc;
}
示例15: fillOutMainPackage
static void fillOutMainPackage(Header h)
/*@globals rpmGlobalMacroContext, h_errno, internalState @*/
/*@modifies h, rpmGlobalMacroContext, internalState @*/
{
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
struct optionalTag *ot;
int xx;
for (ot = optionalTags; ot->ot_mac != NULL; ot++) {
const char * val;
rpmTag tag;
tag = ot->ot_tag;
/* Generate arbitrary tag (if necessary). */
if (tag == 0xffffffff) {
val = tagCanonicalize(ot->ot_mac + (sizeof("%{")-1));
tag = tagGenerate(val);
val = _free(val);
}
if (headerIsEntry(h, tag))
continue;
val = rpmExpand(ot->ot_mac, NULL);
if (val && *val != '%') {
he->tag = tag;
he->t = RPM_STRING_TYPE;
he->p.str = val;
he->c = 1;
xx = headerPut(h, he, 0);
}
val = _free(val);
}
}