aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-15 17:38:04 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-15 17:38:04 +0000
commit7d4ab1b1f12c436590f878889932ebe45c37aa10 (patch)
tree4d623e7e0dd03824199f709e9c5568a440aca760 /URPM.xs
parent126c3859aded2c842fc00110981f54bc47e34e27 (diff)
downloadperl-URPM-7d4ab1b1f12c436590f878889932ebe45c37aa10.tar
perl-URPM-7d4ab1b1f12c436590f878889932ebe45c37aa10.tar.gz
perl-URPM-7d4ab1b1f12c436590f878889932ebe45c37aa10.tar.bz2
perl-URPM-7d4ab1b1f12c436590f878889932ebe45c37aa10.tar.xz
perl-URPM-7d4ab1b1f12c436590f878889932ebe45c37aa10.zip
simplify using RPMTAG_NVR
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs31
1 files changed, 12 insertions, 19 deletions
diff --git a/URPM.xs b/URPM.xs
index 907620d..a1d29d4 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -837,12 +837,10 @@ pack_header(const URPM__Package pkg) {
if (pkg->info == NULL) {
char buff[1024];
const char *p = buff;
- const char *name = get_name(pkg->h, RPMTAG_NAME);
- const char *version = get_name(pkg->h, RPMTAG_VERSION);
- const char *release = get_name(pkg->h, RPMTAG_RELEASE);
+ const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR);
const char *arch = get_arch(pkg->h);
- p += 1 + snprintf(buff, sizeof(buff), "%s-%s-%s.%s@%d@%d@%s", name, version, release, arch,
+ p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%d@%d@%s", nvr, arch,
get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE),
get_name(pkg->h, RPMTAG_GROUP));
pkg->info = memcpy(malloc(p-buff), buff, p-buff);
@@ -1615,18 +1613,17 @@ Pkg_fullname(pkg)
mPUSHs(newSVpv(arch, eos-arch));
}
} else if (pkg->h) {
- char *name = get_name(pkg->h, RPMTAG_NAME);
- char *version = get_name(pkg->h, RPMTAG_VERSION);
- char *release = get_name(pkg->h, RPMTAG_RELEASE);
char *arch = get_arch(pkg->h);
if (gimme == G_SCALAR) {
- mXPUSHs(newSVpvf("%s-%s-%s.%s", name, version, release, arch));
+ const char *s = headerGetAsString(pkg->h, RPMTAG_NVR);
+ mXPUSHs(newSVpvf("%s.%s", s, arch));
+ free(s);
} else if (gimme == G_ARRAY) {
EXTEND(SP, 4);
- mPUSHs(newSVpv(name, 0));
- mPUSHs(newSVpv(version, 0));
- mPUSHs(newSVpv(release, 0));
+ mPUSHs(newSVpv(get_name(pkg->h, RPMTAG_NAME), 0));
+ mPUSHs(newSVpv(get_name(pkg->h, RPMTAG_VERSION), 0));
+ mPUSHs(newSVpv(get_name(pkg->h, RPMTAG_RELEASE), 0));
mPUSHs(newSVpv(arch, 0));
}
}
@@ -1907,12 +1904,10 @@ Pkg_filename(pkg)
memcpy(eon, savbuf, 4);
}
} else if (pkg->h) {
- char *name = get_name(pkg->h, RPMTAG_NAME);
- char *version = get_name(pkg->h, RPMTAG_VERSION);
- char *release = get_name(pkg->h, RPMTAG_RELEASE);
+ char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR);
char *arch = get_arch(pkg->h);
- mXPUSHs(newSVpvf("%s-%s-%s.%s.rpm", name, version, release, arch));
+ mXPUSHs(newSVpvf("%s.%s.rpm", nvr, arch));
}
# deprecated
@@ -1929,12 +1924,10 @@ Pkg_header_filename(pkg)
} else if (pkg->h) {
char buff[1024];
char *p = buff;
- char *name = get_name(pkg->h, RPMTAG_NAME);
- char *version = get_name(pkg->h, RPMTAG_VERSION);
- char *release = get_name(pkg->h, RPMTAG_RELEASE);
+ char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR);
char *arch = get_arch(pkg->h);
- p += snprintf(buff, sizeof(buff), "%s-%s-%s.%s", name, version, release, arch);
+ p += snprintf(buff, sizeof(buff), "%s.%s", nvr, arch);
mXPUSHs(newSVpv(buff, p-buff));
}