aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2010-12-05 07:33:34 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2010-12-05 07:33:34 +0000
commit6b4f0fe67d3380741c09b119887dcd7faa85734e (patch)
tree0bdeafd3ada77614db23ad18992df5dbc077486a
parent7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71 (diff)
downloadperl-URPM-6b4f0fe67d3380741c09b119887dcd7faa85734e.tar
perl-URPM-6b4f0fe67d3380741c09b119887dcd7faa85734e.tar.gz
perl-URPM-6b4f0fe67d3380741c09b119887dcd7faa85734e.tar.bz2
perl-URPM-6b4f0fe67d3380741c09b119887dcd7faa85734e.tar.xz
perl-URPM-6b4f0fe67d3380741c09b119887dcd7faa85734e.zip
just fetch RPMTAG_NVRA rather than messing with headerSprintf for get_nvra()
-rw-r--r--URPM.xs51
1 files changed, 6 insertions, 45 deletions
diff --git a/URPM.xs b/URPM.xs
index e1e2e9f..32cbefd 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -140,53 +140,14 @@ newSVpv_utf8(const char *s, STRLEN len)
return sv;
}
-/* Since the NVRA format won't change, we'll store it in a global variable so
- * that we only have to expand the macro once.
- */
-static const char *nvra_fmt = NULL;
-
static const char *
-get_nvra_fmt() {
- if(!nvra_fmt) {
- char *qfmt = rpmExpand("%{?___NVRA:%___NVRA}%{?!___NVRA:/%_build_name_fmt}", NULL);
- /* On older rpm versions '%___NVRA' isn't defined, so then we'll have to create
- * it from the '%_build_name_fmt'
- */
- if(qfmt[0] == '/') {
- char *tmp;
- const char macroName[] = "___NVRA";
- if(strcasecmp(tmp = qfmt+strlen(qfmt)-4, ".rpm") == 0)
- *tmp = '\0';
- tmp = qfmt;
- /* As %{ARCH} will be incorrect with source rpms, we replace it with a
- * conditional expression so that we get '.src.rpm' for source rpms.
- * This we'll do in a uhm.. "creative" way replacing '%{ARCH}' with '%{XXXX}',
- * which is a macro we'll define for the conditional expression,
- * when expanded it will return the format macro with the conditional
- * expression.
- */
- while((size_t)(tmp = strcasestr(tmp, "%{ARCH}")+2) != 2)while(*tmp != '}')
- *tmp++ = 'X';
-
- rpmDefineMacro(NULL, "XXXX %%|ARCH?{%%|SOURCERPM?{%%{ARCH}}:{src}|}:{}|", RMIL_DEFAULT);
- tmp = rpmExpand((tmp = strrchr(qfmt, '/')) ? tmp+1 : qfmt, NULL);
-
- qfmt = realloc(qfmt, strlen(tmp) + sizeof(macroName)+1);
- sprintf(qfmt, "%s %s", macroName, tmp);
- rpmDefineMacro(NULL, qfmt, RMIL_DEFAULT);
- sprintf(qfmt, "%s", qfmt+sizeof(macroName));
- _free(tmp);
- }
- nvra_fmt = qfmt;
- }
- return nvra_fmt;
-}
+get_nvra(Header header) {
+ HE_t val = (HE_t)memset(alloca(sizeof(*val)), 0, sizeof(*val));
-static const char *
-get_nvra(Header h) {
- const char *qfmt = get_nvra_fmt();
- const char *NVRA = headerSprintf(h, qfmt, NULL, NULL, NULL);
- return NVRA;
+ val->tag = RPMTAG_NVRA;
+ if(headerGet(header, val, 0))
+ return val->p.str;
+ return "";
}
static int