diff options
author | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2010-12-14 03:45:07 +0000 |
---|---|---|
committer | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2010-12-14 03:45:07 +0000 |
commit | e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3 (patch) | |
tree | 276c3173846382b67bb514496b4a4af083051784 | |
parent | 9bd8db7bb032930a96e9cfdf37b3fb71c619fb93 (diff) | |
download | perl-URPM-e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3.tar perl-URPM-e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3.tar.gz perl-URPM-e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3.tar.bz2 perl-URPM-e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3.tar.xz perl-URPM-e584dda49e2bbf6c9f8ff506ca4bbc019b1876f3.zip |
make URPM::Package::get_tag() & URPM::Package::get_tag_modifiers() accept string name of tags
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | URPM.pm | 11 | ||||
-rw-r--r-- | URPM.xs | 58 |
3 files changed, 46 insertions, 33 deletions
@@ -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 @@ -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() @@ -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"); |