aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS10
-rw-r--r--URPM.pm11
-rw-r--r--URPM.xs58
3 files changed, 46 insertions, 33 deletions
diff --git a/NEWS b/NEWS
index 45ea9a4..9ab4835 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,14 @@
+Version 4.4 - Dec 2010, by
+
+- make URPM::Package::get_tag() & URPM::Package::get_tag_modifiers() accept
+ string name of tags
+- URPM::DB::traverse_tag() & URPM::DB::traverse_tag_find() will now accept
+ all available rpm tags
+
Version 4.3 - 11 Dec 2010, by Per Øyvind Karlsen
+
- fix issue with packages added to synthesis having disttag/disttag, but without
- those added to NVRA, leading to segfault.
+ those added to NVRA, leading to segfault
- fix broken support for parsing hdlists, use rpmgi iterator from rpmlib to
simplify code and get packages ordered as an extra benefit in the process.
- URPM::Package::fullname will now always return six items for array in stead
diff --git a/URPM.pm b/URPM.pm
index eadeb02..542b6bd 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -11,7 +11,7 @@ use URPM::Resolve;
use URPM::Signature;
our @ISA = qw(DynaLoader);
-our $VERSION = '4.3';
+our $VERSION = '4.4';
URPM->bootstrap($VERSION);
@@ -576,10 +576,9 @@ Returns a 6 element list: name, version, release, disttag, distepoch and archite
in an array context. Returns a string NAME-VERSION-RELEASE[-DISTTAGDISTEPOCH].ARCH
in scalar context.
-=item $package->get_tag($tagid)
+=item $package->get_tag($tagname)
-Returns an array containing values of $tagid. $tagid is the numerical value of
-rpm tags. See rpmlib.h.
+Returns an array containing values of $tagname. $tagname is the name of a valid rpm tag.
=item $package->queryformat($format)
@@ -588,9 +587,9 @@ Querying the package like rpm --queryformat do.
The function calls directly the rpmlib, then use header informations, so it
silently failed if you use synthesis instead of hdlist/rpm/header files or rpmdb.
-=item $package->get_tag_modifiers($tagid)
+=item $package->get_tag_modifiers($tagname)
-Return an array of human readable view of tag values. $tagid is the numerical value of rpm tags.
+Return an array of human readable view of tag values. $tagname is the name of a valid rpm tag.
=item $package->group()
diff --git a/URPM.xs b/URPM.xs
index 55c3fb3..ac23b98 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -211,6 +211,7 @@ get_nvra(Header h) {
static int
do_rpmEVRcompare(const char *a, const char *b) {
int compare;
+
EVR_t lEVR = rpmEVRnew(RPMSENSE_EQUAL, 0),
rEVR = rpmEVRnew(RPMSENSE_EQUAL, 0);
rpmEVRparse(a, lEVR);
@@ -221,6 +222,22 @@ do_rpmEVRcompare(const char *a, const char *b) {
return compare;
}
+static rpmTag
+rpmtag_from_string(const char *tag)
+{
+ static rpmconst c = NULL;
+ static const char context[] = "rpmtag";
+
+ if(c == NULL) {
+ c = rpmconstNew();
+ if(!rpmconstInitToContext(c, context))
+ croak("unknown context [%s]", context);
+ }
+ if(rpmconstFindName(c, tag, 0))
+ return rpmconstValue(c);
+ else croak("unknown tag [%s]", tag);
+}
+
static const char *
get_name(Header header, rpmTag tag) {
HE_t val = (HE_t)memset(alloca(sizeof(*val)), 0, sizeof(*val));
@@ -641,18 +658,19 @@ return_list_uint_16(Header header, rpmTag tag_name) {
}
void
-return_list_tag_modifier(Header header, rpmTag tag_name) {
+return_list_tag_modifier(Header header, const char *tag_name) {
dSP;
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ rpmTag tag = isdigit(*tag_name) ? (rpmTag)atoi(tag_name) : rpmtag_from_string(tag_name);
- he->tag = tag_name;
+ he->tag = tag;
if (!headerGet(header, he, 0)) return;
for (he->ix = 0; he->ix < (int)he->c; he->ix++) {
char buff[15];
char *s = buff;
rpmTagType tags = he->p.ui32p[he->ix];
- switch (tag_name) {
+ switch (tag) {
case RPMTAG_FILEFLAGS:
if (tags & RPMFILE_CONFIG) *s++ = 'c';
if (tags & RPMFILE_DOC) *s++ = 'd';
@@ -679,15 +697,17 @@ return_list_tag_modifier(Header header, rpmTag tag_name) {
}
void
-return_list_tag(URPM__Package pkg, rpmTag tag_name) {
+return_list_tag(URPM__Package pkg, const char *tag_name) {
dSP;
+ rpmTag tag = isdigit(*tag_name) ? (rpmTag)atoi(tag_name) : rpmtag_from_string(tag_name);
+
if (pkg->h != NULL) {
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
- he->tag = tag_name;
+ he->tag = tag;
if (headerGet(pkg->h, he, 0)) {
void *list = he->p.ptr;
- if (tag_name == RPMTAG_ARCH) {
+ if (tag == RPMTAG_ARCH) {
XPUSHs(sv_2mortal(newSVpv(headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? (char *) list : "src", 0)));
} else
switch (he->t) {
@@ -731,7 +751,7 @@ return_list_tag(URPM__Package pkg, rpmTag tag_name) {
char *arch;
char *eos;
- switch (tag_name) {
+ switch (tag) {
case RPMTAG_NAME:
{
if(get_fullname_parts(pkg, &name, &epoch, &version, &release, &arch, &disttag, &distepoch, &eos))
@@ -1531,21 +1551,6 @@ static void *rpmRunTransactions_callback(__attribute__((unused)) const void *h,
return callback == td->callback_open ? fd : NULL;
}
-static rpmTag rpmtag_from_string(const char *tag)
-{
- static rpmconst c = NULL;
- static const char context[] = "rpmtag";
-
- if(c == NULL) {
- c = rpmconstNew();
- if(!rpmconstInitToContext(c, context))
- croak("unknown context [%s]", context);
- }
- if(rpmconstFindName(c, tag, 0))
- return rpmconstValue(c);
- else croak("unknown tag [%s]", tag);
-}
-
MODULE = URPM PACKAGE = URPM::Package PREFIX = Pkg_
void
@@ -2374,7 +2379,7 @@ Pkg_queryformat(pkg, fmt)
void
Pkg_get_tag(pkg, tagname)
URPM::Package pkg
- int tagname;
+ char *tagname
PPCODE:
PUTBACK;
return_list_tag(pkg, tagname);
@@ -2383,7 +2388,7 @@ Pkg_get_tag(pkg, tagname)
void
Pkg_get_tag_modifiers(pkg, tagname)
URPM::Package pkg
- int tagname;
+ char *tagname
PPCODE:
PUTBACK;
return_list_tag_modifier(pkg->h, tagname);
@@ -2884,7 +2889,8 @@ Db_traverse_tag(db,tag,names,callback)
if (SvROK(names) && SvTYPE(SvRV(names)) == SVt_PVAV) {
AV* names_av = (AV*)SvRV(names);
int len = av_len(names_av);
- int i, rpmtag;
+ int i;
+ rpmTag rpmtag;
rpmtag = rpmtag_from_string(tag);
@@ -2932,7 +2938,7 @@ Db_traverse_tag_find(db,tag,name,callback)
Header header;
rpmmi mi;
CODE:
- int rpmtag = rpmtag_from_string(tag);
+ rpmTag rpmtag = rpmtag_from_string(tag);
int found = 0;
db->ts = rpmtsLink(db->ts, "URPM::DB::traverse_tag");