From cf697b9faf3ed57ef592d761b008afb32101ec3e Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 21 Sep 2012 11:30:58 +0000 Subject: add EVR method for rpmdrake --- NEWS | 2 ++ URPM.pm | 2 ++ URPM.xs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/NEWS b/NEWS index 072c547..0dc3634 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- API: add EVR method + Version 4.14 - 21 September 2012 - API: add resolve_requested_suggests() diff --git a/URPM.pm b/URPM.pm index 890cdcb..8abeae4 100644 --- a/URPM.pm +++ b/URPM.pm @@ -532,6 +532,8 @@ This is only used when faking a URPM::DB: $urpm can be used as-a $db =item $package->epoch() +=item $package->EVR() + =item $package->excludearchs() =item $package->exclusivearchs() diff --git a/URPM.xs b/URPM.xs index fccb009..997580d 100644 --- a/URPM.xs +++ b/URPM.xs @@ -1436,6 +1436,36 @@ Pkg_release(pkg) mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_RELEASE), 0)); } +void +Pkg_EVR(pkg) + URPM::Package pkg + PPCODE: + if (pkg->info) { + char *s, *eos; + char *version, *arch; + int epoch; + + if ((s = strchr(pkg->info, '@')) != NULL) { + if ((eos = strchr(s+1, '@')) != NULL) + *eos = 0; /* mark end of string to enable searching backwards */ + epoch = atoi(s+1); + if (eos != NULL) *eos = '@'; + } else + epoch = 0; + get_fullname_parts(pkg, NULL, &version, NULL, &arch, &eos); + if (epoch == 0) + mXPUSHs(newSVpv(version, arch-version-1)); + else { + char *res; + arch--; + *arch = '\0'; + asprintf(&res, "%d:%s", epoch, version); + mXPUSHs(newSVpv(res, 0)); + *arch = '.'; /* restore info string modified */ + } + } else if (pkg->h) + mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_EVR), 0)); + void Pkg_arch(pkg) URPM::Package pkg -- cgit v1.2.1