diff options
author | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2011-01-31 19:57:12 +0000 |
---|---|---|
committer | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2011-01-31 19:57:12 +0000 |
commit | 3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2 (patch) | |
tree | 5ed1cc1d0562775d357b117ec142892375c80897 | |
parent | b31a304909fdb5cb2bb595f9f95d758098ee72a7 (diff) | |
download | perl-URPM-3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2.tar perl-URPM-3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2.tar.gz perl-URPM-3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2.tar.bz2 perl-URPM-3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2.tar.xz perl-URPM-3b4048d6bfdf1922f7132e3ff4539ebbd4f7c3a2.zip |
get nvra with disttag/distepoch for scalars returned by URPM::Package->fullname(), URPM::Package->filename() & URPM::Package->header_filename()
-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 |