本文整理汇总了C++中rpmExpand函数的典型用法代码示例。如果您正苦于以下问题:C++ rpmExpand函数的具体用法?C++ rpmExpand怎么用?C++ rpmExpand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpmExpand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:maxamillion,项目名称:rpm,代码行数:25,代码来源:rpmgensig.c
示例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;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:30,代码来源:parsePreamble.c
示例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);
}
开发者ID:tomhughes,项目名称:rpm,代码行数:29,代码来源:parseSpec.c
示例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;
}
开发者ID:OlegGirko,项目名称:rpm,代码行数:10,代码来源:rpmfc.c
示例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;
}
开发者ID:crossbuild,项目名称:rpm,代码行数:55,代码来源:rpmsign.c
示例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;
}
开发者ID:davidlt,项目名称:rpm-4.13.0-rc1-cms,代码行数:30,代码来源:transaction.c
示例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);
}
开发者ID:xrg,项目名称:RPM,代码行数:35,代码来源:pack.c
示例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;
}
开发者ID:nforro,项目名称:rpm,代码行数:29,代码来源:pack.c
示例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);
}
开发者ID:nforro,项目名称:rpm,代码行数:27,代码来源:pack.c
示例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;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:32,代码来源:rpmns.c
示例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;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:26,代码来源:poptALL.c
示例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;
}
开发者ID:pombredanne,项目名称:rpm-4,代码行数:26,代码来源:rpmscript.c
示例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;
}
开发者ID:xrg,项目名称:RPM,代码行数:26,代码来源:macro.c
示例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;
}
开发者ID:Tojaj,项目名称:rpm,代码行数:33,代码来源:rpmplugins.c
示例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);
}
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:34,代码来源:parsePreamble.c
示例16: urlGetFile
int urlGetFile(const char * url, const char * dest)
{
char *cmd = NULL;
const char *target = NULL;
char *urlhelper = NULL;
int rc;
pid_t pid, wait;
urlhelper = rpmExpand("%{?_urlhelper}", NULL);
if (dest == NULL) {
urlPath(url, &target);
} else {
target = dest;
}
/* XXX TODO: sanity checks like target == dest... */
rasprintf(&cmd, "%s %s %s", urlhelper, target, url);
urlhelper = _free(urlhelper);
if ((pid = fork()) == 0) {
ARGV_t argv = NULL;
argvSplit(&argv, cmd, " ");
execvp(argv[0], argv);
exit(127); /* exit with 127 for compatibility with bash(1) */
}
wait = waitpid(pid, &rc, 0);
cmd = _free(cmd);
return rc;
}
开发者ID:kaltsi,项目名称:rpm,代码行数:33,代码来源:url.c
示例17: tagValidate
static rpmRC tagValidate(Spec spec, rpmTag tag, const char * value)
/*@*/
{
const char * tagN = tagName(tag);
const char * pattern = rpmExpand("%{?pattern_", tagN, "}", NULL);
rpmRC ec = RPMRC_OK;
if (pattern && *pattern) {
miRE mire;
int xx;
mire = mireNew(RPMMIRE_REGEX, tag);
xx = mireSetCOptions(mire, RPMMIRE_REGEX, 0, 0, NULL);
if (!xx)
xx = mireRegcomp(mire, pattern);
if (!xx)
xx = mireRegexec(mire, value, strlen(value));
if (!xx)
ec = RPMRC_OK;
else {
rpmlog(RPMLOG_ERR, _("line %d: invalid tag value(\"%s\") %s: %s\n"),
spec->lineNum, pattern, tagN, spec->line);
ec = RPMRC_FAIL;
}
mire = mireFree(mire);
}
pattern = _free(pattern);
return ec;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:32,代码来源:parsePreamble.c
示例18: rpmgiOpen
/*@[email protected]*/
static FD_t rpmgiOpen(const char * path, const char * fmode)
/*@globals rpmGlobalMacroContext, h_errno, errno, internalState @*/
/*@modifies rpmGlobalMacroContext, h_errno, errno, internalState @*/
{
const char * fn = rpmExpand(path, NULL);
FD_t fd;
/* FIXME (see http://rpm5.org/community/rpm-devel/0523.html) */
errno = 0;
fd = Fopen(fn, fmode);
if (fd == NULL || Ferror(fd)) {
rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), fn, Fstrerror(fd));
if (fd != NULL) (void) Fclose(fd);
fd = NULL;
}
fn = _free(fn);
#if defined(POSIX_FADV_WILLNEED)
if(fd != NULL)
(void) Fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
#endif
return fd;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:26,代码来源:rpmgi.c
示例19: _GetPass
/*@-globs -internalglobs -mods @*/
char * _GetPass(const char * prompt)
{
char * pw;
/*@[email protected]*/
pw = getpass( prompt ? prompt : "" );
/*@[email protected]*/
#if defined(HAVE_KEYUTILS_H)
if (_kuKeyring == 0) {
const char * _keyutils_keyring
= rpmExpand("%{?_keyutils_keyring}", NULL);
_kuKeyring = (rpmuint32_t) kuValue(_keyutils_keyring);
if (_kuKeyring == 0)
_kuKeyring = KEY_SPEC_PROCESS_KEYRING;
_keyutils_keyring = _free(_keyutils_keyring);
}
if (pw && *pw) {
key_serial_t keyring = (key_serial_t) _kuKeyring;
size_t npw = strlen(pw);
(void) add_key("user", "rpm:passwd", pw, npw, keyring);
(void) memset(pw, 0, npw); /* burn the password */
pw = (char *) "@u user rpm:passwd";
}
#endif /* HAVE_KEYUTILS_H */
assert(pw != NULL);
/*@-observertrans [email protected]*/
return pw;
/*@=observertrans [email protected]*/
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:33,代码来源:rpmku.c
示例20: rpmErase
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_const_t argv)
{
char * const * arg;
char *qfmt = NULL;
int numFailed = 0;
int numPackages = 0;
rpmVSFlags vsflags, ovsflags;
if (argv == NULL) return 0;
vsflags = setvsFlags(ia);
ovsflags = rpmtsSetVSFlags(ts, vsflags);
(void) rpmtsSetFlags(ts, ia->transFlags);
setNotifyFlag(ia, ts);
qfmt = rpmExpand("%{?_query_all_fmt}\n", NULL);
for (arg = argv; *arg; arg++) {
rpmdbMatchIterator mi = rpmtsInitIterator(ts, RPMDBI_LABEL, *arg, 0);
int matches = rpmdbGetIteratorCount(mi);
int erasing = 1;
if (! matches) {
rpmlog(RPMLOG_ERR, _("package %s is not installed\n"), *arg);
numFailed++;
} else {
Header h; /* XXX iterator owns the reference */
if (matches > 1 &&
!(ia->installInterfaceFlags & UNINSTALL_ALLMATCHES)) {
rpmlog(RPMLOG_ERR, _("\"%s\" specifies multiple packages:\n"),
*arg);
numFailed++;
erasing = 0;
}
while ((h = rpmdbNextIterator(mi)) != NULL) {
if (erasing) {
(void) rpmtsAddEraseElement(ts, h, -1);
numPackages++;
} else {
char *nevra = headerFormat(h, qfmt, NULL);
rpmlog(RPMLOG_NOTICE, " %s", nevra);
free(nevra);
}
}
}
rpmdbFreeIterator(mi);
}
free(qfmt);
if (numFailed) goto exit;
numFailed = rpmcliTransaction(ts, ia, numPackages);
exit:
rpmtsEmpty(ts);
rpmtsSetVSFlags(ts, ovsflags);
return numFailed;
}
开发者ID:rpm5,项目名称:rpm,代码行数:60,代码来源:rpminstall.c
注:本文中的rpmExpand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论