From: Klaus Kämpf Date: Sat, 13 Mar 2010 11:59:07 +0000 (+0100) Subject: Merge branch 'master' of gitorious.org:opensuse/sat-solver X-Git-Tag: BASE-SuSE-Code-12_1-Branch~159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7bdc9f122740d6e22056ffebcc00cb40190ff503;hp=1693adbd18248a5af685a2627b36bfbe2499183b;p=platform%2Fupstream%2Flibsolv.git Merge branch 'master' of gitorious.org:opensuse/sat-solver --- diff --git a/VERSION.cmake b/VERSION.cmake index e113b5b..9e997af 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -46,6 +46,6 @@ SET(LIBSATSOLVER_MAJOR "0") SET(LIBSATSOLVER_MINOR "14") -SET(LIBSATSOLVER_PATCH "15") +SET(LIBSATSOLVER_PATCH "16") -# last released 0.14.15 +# last released 0.14.16 diff --git a/examples/solv.c b/examples/solv.c index d0bced4..46aea12 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -2269,6 +2269,14 @@ main(int argc, char **argv) usage(1); pool = pool_create(); + +#if 0 + { + const char *langs[] = {"de_DE", "de", "en"}; + pool_set_languages(pool, langs, sizeof(langs)/sizeof(*langs)); + } +#endif + #ifdef FEDORA pool->obsoleteusescolors = 1; #endif @@ -2449,7 +2457,11 @@ main(int argc, char **argv) } else { - const char *sum = solvable_lookup_str_lang(s, SOLVABLE_SUMMARY, "de"); +#if 1 + const char *sum = solvable_lookup_str_lang(s, SOLVABLE_SUMMARY, "de", 1); +#else + const char *sum = solvable_lookup_str_poollang(s, SOLVABLE_SUMMARY); +#endif printf(" - %s [%s]\n", solvable2str(pool, s), s->repo->name); if (sum) printf(" %s\n", sum); diff --git a/ext/repo_content.c b/ext/repo_content.c index 5fe8b9b..e35bf6b 100644 --- a/ext/repo_content.c +++ b/ext/repo_content.c @@ -280,6 +280,12 @@ repo_add_content(Repo *repo, FILE *fp, int flags) /* we also replicate some of them into the product solvables * to be backward compatible */ + if (istag ("REPOID")) + { + repodata_add_poolstr_array(data, SOLVID_META, REPOSITORY_REPOID, value); + continue; + } + if (istag ("DESCRDIR")) { if (descrdir) diff --git a/ext/repo_repomdxml.c b/ext/repo_repomdxml.c index 915bf1e..193953d 100644 --- a/ext/repo_repomdxml.c +++ b/ext/repo_repomdxml.c @@ -98,6 +98,7 @@ enum state { STATE_REPOMD, STATE_REVISION, STATE_TAGS, + STATE_REPO, STATE_CONTENT, STATE_DISTRO, STATE_UPDATES, @@ -123,25 +124,26 @@ static struct stateswitch stateswitches[] = { { STATE_START, "suseinfo", STATE_SUSEINFO, 0 }, /* we support the tags element in suseinfo in case createrepo version does not support it yet */ - { STATE_SUSEINFO, "tags", STATE_TAGS, 0 }, - { STATE_SUSEINFO, "expire", STATE_EXPIRE, 1 }, - { STATE_SUSEINFO, "keywords", STATE_KEYWORDS, 0 }, + { STATE_SUSEINFO, "tags", STATE_TAGS, 0 }, + { STATE_SUSEINFO, "expire", STATE_EXPIRE, 1 }, + { STATE_SUSEINFO, "keywords", STATE_KEYWORDS, 0 }, /* keywords is the suse extension equivalent of tags/content when this one was not yet available. - therefore we parse both */ - { STATE_KEYWORDS, "k", STATE_KEYWORD, 1 }, + therefore we parse both */ + { STATE_KEYWORDS, "k", STATE_KEYWORD, 1 }, /* standard tags */ { STATE_REPOMD, "revision", STATE_REVISION, 1 }, { STATE_REPOMD, "tags", STATE_TAGS, 0 }, { STATE_REPOMD, "data", STATE_DATA, 0 }, - - { STATE_TAGS, "content", STATE_CONTENT, 1 }, + + { STATE_TAGS, "repo", STATE_REPO, 1 }, + { STATE_TAGS, "content", STATE_CONTENT, 1 }, { STATE_TAGS, "distro", STATE_DISTRO, 1 }, /* this tag is only valid in suseinfo.xml for now */ { STATE_TAGS, "updates", STATE_UPDATES, 1 }, { STATE_DATA, "location", STATE_LOCATION, 0 }, - { STATE_DATA, "checksum", STATE_CHECKSUM, 1 }, + { STATE_DATA, "checksum", STATE_CHECKSUM, 1 }, { STATE_DATA, "timestamp", STATE_TIMESTAMP, 1 }, { STATE_DATA, "open-checksum", STATE_OPENCHECKSUM, 1 }, { NUMSTATES } @@ -159,7 +161,7 @@ struct parsedata { Pool *pool; Repo *repo; Repodata *data; - + XML_Parser *parser; struct stateswitch *swtab[NUMSTATES]; enum state sbtab[NUMSTATES]; @@ -214,7 +216,7 @@ startElement(void *userData, const char *name, const char **atts) for (sw = pd->swtab[pd->state]; sw->from == pd->state; sw++) /* find name in statetable */ if (!strcmp(sw->ename, name)) break; - + if (sw->from != pd->state) { #if 0 @@ -266,7 +268,7 @@ startElement(void *userData, const char *name, const char **atts) was designed for */ const char *cpeid = find_attr("cpeid", atts); pd->rphandle = repodata_new_handle(pd->data); - /* set the cpeid for the product + /* set the cpeid for the product the label is set in the content of the tag */ if (cpeid) repodata_set_poolstr(pd->data, pd->rphandle, REPOSITORY_PRODUCT_CPEID, cpeid); @@ -278,7 +280,7 @@ startElement(void *userData, const char *name, const char **atts) was designed for */ const char *cpeid = find_attr("cpeid", atts); pd->ruhandle = repodata_new_handle(pd->data); - /* set the cpeid for the product + /* set the cpeid for the product the label is set in the content of the tag */ if (cpeid) repodata_set_poolstr(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_CPEID, cpeid); @@ -331,7 +333,7 @@ endElement(void *userData, const char *name) switch (pd->state) { case STATE_START: break; - case STATE_REPOMD: + case STATE_REPOMD: if (pd->timestamp > 0) repodata_set_num(pd->data, SOLVID_META, REPOSITORY_TIMESTAMP, pd->timestamp); break; @@ -412,16 +414,20 @@ endElement(void *userData, const char *name) repodata_set_str(pd->data, pd->ruhandle, REPOSITORY_PRODUCT_LABEL, pd->content); repodata_add_flexarray(pd->data, SOLVID_META, REPOSITORY_UPDATES, pd->ruhandle); break; + case STATE_REPO: + if (pd->content) + repodata_add_poolstr_array(pd->data, SOLVID_META, REPOSITORY_REPOID, pd->content); + break; case STATE_SUSEINFO: break; case STATE_KEYWORDS: break; - case NUMSTATES: break; + case NUMSTATES: break; default: break; } pd->state = pd->sbtab[pd->state]; pd->docontent = 0; - + return; } diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c index f6e9604..cd71fad 100644 --- a/ext/repo_rpmmd.c +++ b/ext/repo_rpmmd.c @@ -66,6 +66,11 @@ enum state { // pattern attributes STATE_CATEGORY, /* pattern and patches */ + STATE_ORDER, + STATE_INCLUDES, + STATE_INCLUDESENTRY, + STATE_EXTENDS, + STATE_EXTENDSENTRY, STATE_SCRIPT, STATE_ICON, STATE_USERVISIBLE, @@ -170,6 +175,9 @@ static struct stateswitch stateswitches[] = { { STATE_SOLVABLE, "icon", STATE_ICON, 1 }, { STATE_SOLVABLE, "uservisible", STATE_USERVISIBLE, 1 }, { STATE_SOLVABLE, "category", STATE_CATEGORY, 1 }, + { STATE_SOLVABLE, "order", STATE_ORDER, 1 }, + { STATE_SOLVABLE, "includes", STATE_INCLUDES, 0 }, + { STATE_SOLVABLE, "extends", STATE_EXTENDS, 0 }, { STATE_SOLVABLE, "default", STATE_DEFAULT, 1 }, { STATE_SOLVABLE, "install-time", STATE_INSTALL_TIME, 1 }, @@ -212,6 +220,9 @@ static struct stateswitch stateswitches[] = { { STATE_ENHANCES, "rpm:entry", STATE_ENHANCESENTRY, 0 }, { STATE_FRESHENS, "rpm:entry", STATE_FRESHENSENTRY, 0 }, + { STATE_INCLUDES, "item", STATE_INCLUDESENTRY, 0 }, + { STATE_EXTENDS, "item", STATE_EXTENDSENTRY, 0 }, + { NUMSTATES} }; @@ -264,7 +275,9 @@ struct parsedata { static Id langtag(struct parsedata *pd, Id tag, const char *language) { - if (language && !language[0]) + if (!language) /* fall back to default if not specified */ + language = pd->language; + if (language && (!language[0] || !strcmp(language, "en"))) language = 0; if (!language || tag >= ID_NUM_INTERNAL) return pool_id2langid(pd->common.repo->pool, tag, language, 1); @@ -512,12 +525,11 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts /* - * set_desciption_author + * set_description_author * */ - static void -set_desciption_author(Repodata *data, Id handle, char *str) +set_description_author(Repodata *data, Id handle, char *str, struct parsedata *pd) { char *aut, *p; @@ -534,7 +546,7 @@ set_desciption_author(Repodata *data, Id handle, char *str) while (l > 0 && str[l - 1] == '\n') str[--l] = 0; if (l) - repodata_set_str(data, handle, SOLVABLE_DESCRIPTION, str); + repodata_set_str(data, handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), str); p = aut + 19; aut = str; /* copy over */ while (*p == ' ' || *p == '\n') @@ -557,7 +569,7 @@ set_desciption_author(Repodata *data, Id handle, char *str) repodata_set_str(data, handle, SOLVABLE_AUTHORS, str); } else if (*str) - repodata_set_str(data, handle, SOLVABLE_DESCRIPTION, str); + repodata_set_str(data, handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), str); } @@ -773,13 +785,29 @@ startElement(void *userData, const char *name, const char **atts) case STATE_FRESHENSENTRY: pd->freshens = adddep(pool, pd, pd->freshens, atts, 0); break; + case STATE_EULA: case STATE_SUMMARY: + case STATE_CATEGORY: case STATE_DESCRIPTION: pd->tmplang = find_attr("lang", atts); break; case STATE_USERVISIBLE: repodata_set_void(pd->data, handle, SOLVABLE_ISVISIBLE ); break; + case STATE_INCLUDESENTRY: + { + const char *tmp = find_attr("pattern", atts); + if (tmp) + repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_INCLUDES, join2("pattern", ":", tmp)); + } + break; + case STATE_EXTENDSENTRY: + { + const char *tmp = find_attr("pattern", atts); + if (tmp) + repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_EXTENDS, join2("pattern", ":", tmp)); + } + break; case STATE_LOCATION: str = find_attr("href", atts); if (str) @@ -1003,12 +1031,13 @@ endElement(void *userData, const char *name) repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, id, p); break; case STATE_SUMMARY: - pd->tmplang = 0; - repodata_set_str(pd->data, handle, SOLVABLE_SUMMARY, pd->content); + repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content); break; case STATE_DESCRIPTION: - pd->tmplang = 0; - set_desciption_author(pd->data, handle, pd->content); + set_description_author(pd->data, handle, pd->content, pd); + break; + case STATE_CATEGORY: + repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_CATEGORY, pd->tmplang), pd->content); break; case STATE_DISTRIBUTION: repodata_set_poolstr(pd->data, handle, SOLVABLE_DISTRIBUTION, pd->content); @@ -1051,7 +1080,7 @@ endElement(void *userData, const char *name) break; case STATE_EULA: if (pd->content[0]) - repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_EULA, pd->language), pd->content); + repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_EULA, pd->tmplang), pd->content); break; case STATE_KEYWORD: if (pd->content[0]) @@ -1061,6 +1090,9 @@ endElement(void *userData, const char *name) if (pd->ndirs) commit_diskusage(pd, pd->handle); break; + case STATE_ORDER: + if (pd->content[0]) + repodata_set_str(pd->data, pd->handle, SOLVABLE_ORDER, pd->content); default: break; } @@ -1157,7 +1189,7 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags) { const char *str; int index; - + if (!sat_chksum_len(di.key->type)) continue; str = repodata_chk2str(di.data, di.key->type, (const unsigned char *)di.kv.str); @@ -1194,7 +1226,7 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags) join_freemem(); stringpool_free(&pd.cspool); sat_free(pd.cscache); - + if (!(flags & REPO_NO_INTERNALIZE)) repodata_internalize(data); POOL_DEBUG(SAT_DEBUG_STATS, "repo_add_rpmmd took %d ms\n", sat_timems(now)); diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes index d33ba03..0f63986 100644 --- a/package/libsatsolver.changes +++ b/package/libsatsolver.changes @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Thu Mar 11 22:13:26 CET 2010 - ma@suse.de + +- parse global repository ids. [bnc#377568] +- fix pattern parsing in repomd format. [bnc#585000] +- 0.14.16 + +------------------------------------------------------------------- +Thu Mar 11 12:18:23 CET 2010 - mls@suse.de + +- fix language code lookup for fallback languages [bnc#584644] +- change solvable_lookup_str_lang interface a bit for libzypp + +------------------------------------------------------------------- Fri Feb 19 17:31:51 CET 2010 - mls@suse.de - make dup rules work when system repo is not first [bnc#581276] diff --git a/src/knownid.h b/src/knownid.h index a84c893..1c322b7 100644 --- a/src/knownid.h +++ b/src/knownid.h @@ -234,6 +234,7 @@ KNOWNID(PUBKEY_EXPIRES, "pubkey:expires"), KNOWNID(PUBKEY_SIGNATURES, "pubkey:signatures"), KNOWNID(REPOSITORY_TOOLVERSION, "repository:toolversion"), +KNOWNID(REPOSITORY_REPOID, "repository:repoid"), KNOWNID(ID_NUM_INTERNAL, 0) diff --git a/src/pool.h b/src/pool.h index d82a0d1..7459143 100644 --- a/src/pool.h +++ b/src/pool.h @@ -222,7 +222,7 @@ Id solvable_lookup_id(Solvable *s, Id keyname); unsigned int solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound); const char *solvable_lookup_str(Solvable *s, Id keyname); const char *solvable_lookup_str_poollang(Solvable *s, Id keyname); -const char *solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang); +const char *solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang, int usebase); int solvable_lookup_bool(Solvable *s, Id keyname); int solvable_lookup_void(Solvable *s, Id keyname); char * solvable_get_location(Solvable *s, unsigned int *medianrp); diff --git a/src/solvable.c b/src/solvable.c index c7f71d8..441af97 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -74,7 +74,7 @@ solvable_lookup_str(Solvable *s, Id keyname) } static const char * -solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname) +solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname, int usebase) { Pool *pool; const char *str, *basestr; @@ -94,7 +94,7 @@ solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname) /* search for a solvable with same name and same base that has the * translation */ if (!pool->whatprovides) - return basestr; + return usebase ? basestr : 0; /* we do this in two passes, first same vendor, then all other vendors */ for (pass = 0; pass < 2; pass++) { @@ -113,7 +113,7 @@ solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname) return str; } } - return basestr; + return usebase ? basestr : 0; } const char * @@ -154,17 +154,8 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname) for (i = 0; i < pool->nlanguages; i++, row++) { if (!*row) - { - char *p; - const char *kn; - - kn = id2str(pool, keyname); - p = sat_malloc(strlen(kn) + strlen(pool->languages[i]) + 2); - sprintf(p, "%s:%s", kn, pool->languages[i]); - *row = str2id(pool, p, 1); - sat_free(p); - } - str = solvable_lookup_str_base(s, *row, keyname); + *row = pool_id2langid(pool, keyname, pool->languages[i], 1); + str = solvable_lookup_str_base(s, *row, keyname, 0); if (str) return str; } @@ -172,14 +163,15 @@ solvable_lookup_str_poollang(Solvable *s, Id keyname) } const char * -solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang) +solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang, int usebase) { if (s->repo) { - const char *str; Id id = pool_id2langid(s->repo->pool, keyname, lang, 0); - if (id && (str = solvable_lookup_str_base(s, id, keyname)) != 0) - return str; + if (id) + return solvable_lookup_str_base(s, id, keyname, usebase); + if (!usebase) + return 0; } return solvable_lookup_str(s, keyname); } diff --git a/src/util.c b/src/util.c index 7dea6aa..0538432 100644 --- a/src/util.c +++ b/src/util.c @@ -106,7 +106,16 @@ sat_timems(unsigned int subtract) void sat_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard) { +#if defined(__GLIBC__) +# if __GLIBC_PREREQ(2, 8) qsort_r(base, nmemb, size, compar, compard); +# else + /* backported for SLE10-SP2 */ + __qsort_r(base, nmemb, size, compar, compard); +# endif +#else +# error please add qsort_r call here +#endif } char * diff --git a/tools/repo2solv.sh b/tools/repo2solv.sh index 512a6aa..4af01e8 100755 --- a/tools/repo2solv.sh +++ b/tools/repo2solv.sh @@ -116,9 +116,9 @@ if test "$repotype" = rpmmd ; then fi prodfile= - prodxml=`repomd_findfile product product.xml` + prodxml=`repomd_findfile products products.xml` if test -z "$prodxml" ; then - prodxml=`repomd_findfile products products.xml` + prodxml=`repomd_findfile product product.xml` fi if test -n "$prodxml" -a -s "$prodxml" ; then prodfile=`mktemp` || exit 3 @@ -130,7 +130,7 @@ if test "$repotype" = rpmmd ; then fi patternfile= - patternxml=`repomd_findfile '' patterns.xml` + patternxml=`repomd_findfile 'patterns' patterns.xml` if test -n "$patternxml" -a -s "$patternxml" ; then patternfile=`mktemp` || exit 3 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4 @@ -148,7 +148,7 @@ if test "$repotype" = rpmmd ; then # This contains suseinfo.xml, which is an extension to repomd.xml # for now we only read some keys like expiration and products suseinfofile= - suseinfoxml=`repomd_findfile '' suseinfo.xml` + suseinfoxml=`repomd_findfile suseinfo suseinfo.xml` if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then suseinfofile=`mktemp` || exit 3 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4 @@ -165,6 +165,9 @@ if test "$repotype" = rpmmd ; then # This contains a deltainfo.xml* deltainfofile= deltainfoxml=`repomd_findfile deltainfo deltainfo.xml` + if test -z "$deltainfoxml"; then + deltainfoxml=`repomd_findfile prestodelta prestodelta.xml` + fi if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then deltainfofile=`mktemp` || exit 3 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4