diff options
-rw-r--r-- | URPM.xs | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -852,15 +852,17 @@ pack_header(URPM__Package pkg) { if (pkg->info == NULL) { 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 *arch = headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? get_name(pkg->h, RPMTAG_ARCH) : "src"; - - p += 1 + snprintf(buff, sizeof(buff), "%s-%s-%s.%s@%d@%d@%s", name, version, release, arch, + const char *group = get_name(pkg->h, RPMTAG_GROUP); + const char *nvra = headerFormat(pkg->h, + "%{NAME}-%{VERSION}-%{RELEASE}%|DISTTAG?{-%{DISTTAG}%|DISTEPOCH?" + "{%{DISTEPOCH}}|}|%|ARCH?{.%|SOURCERPM?{%{ARCH}}:{src}|}:{}|", + NULL + ); + p += 1 + snprintf(buff, sizeof(buff), "%s@%d@%d@%s", nvra, get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), - get_name(pkg->h, RPMTAG_GROUP)); + group); pkg->info = memcpy(malloc(p-buff), buff, p-buff); + _free(nvra); } if (pkg->filesize == 0) pkg->filesize = sigsize_to_filesize(get_int(pkg->h, RPMTAG_SIGSIZE)); if (pkg->requires == NULL && pkg->suggests == NULL) @@ -1788,7 +1790,13 @@ Pkg_fullname(pkg) char *arch = headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? get_name(pkg->h, RPMTAG_ARCH) : "src"; if (gimme == G_SCALAR) { - XPUSHs(sv_2mortal(newSVpvf("%s-%s-%s.%s", name, version, release, arch))); + const char *nvra = headerFormat(pkg->h, + "%{NAME}-%{VERSION}-%{RELEASE}%|DISTTAG?{-%{DISTTAG}%|DISTEPOCH?" + "{%{DISTEPOCH}}|}|%|ARCH?{.%|SOURCERPM?{%{ARCH}}:{src}|}:{}|", + NULL + ); + XPUSHs(sv_2mortal(newSVpvf("%s", nvra))); + _free(nvra); } else if (gimme == G_ARRAY) { EXTEND(SP, 4); PUSHs(sv_2mortal(newSVpv(name, 0))); @@ -2070,12 +2078,14 @@ 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 *arch = headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? get_name(pkg->h, RPMTAG_ARCH) : "src"; + const char *nvra = headerFormat(pkg->h, + "%{NAME}-%{VERSION}-%{RELEASE}%|DISTTAG?{-%{DISTTAG}%|DISTEPOCH?" + "{%{DISTEPOCH}}|}|%|ARCH?{.%|SOURCERPM?{%{ARCH}}:{src}|}:{}|", + NULL + ); - XPUSHs(sv_2mortal(newSVpvf("%s-%s-%s.%s.rpm", name, version, release, arch))); + XPUSHs(sv_2mortal(newSVpvf("%s.rpm", nvra))); + _free(nvra); } # deprecated @@ -2092,13 +2102,17 @@ 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 *arch = headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? get_name(pkg->h, RPMTAG_ARCH) : "src"; - p += snprintf(buff, sizeof(buff), "%s-%s-%s.%s", name, version, release, arch); + const char *nvra = headerFormat(pkg->h, + "%{NAME}-%{VERSION}-%{RELEASE}%|DISTTAG?{-%{DISTTAG}%|DISTEPOCH?" + "{%{DISTEPOCH}}|}|%|ARCH?{.%|SOURCERPM?{%{ARCH}}:{src}|}:{}|", + NULL + ); + + p += snprintf(buff, sizeof(buff), "%s", nvra); XPUSHs(sv_2mortal(newSVpv(buff, p-buff))); + _free(nvra); + } void |