From: Michael Schroeder Date: Wed, 24 Jun 2009 12:06:31 +0000 (+0200) Subject: - fetch primary location from repomd.xml X-Git-Tag: BASE-SuSE-Code-12_1-Branch~212 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=249fb14b5c2a82d54d9732ed9e600df1c54ed304;p=platform%2Fupstream%2Flibsolv.git - fetch primary location from repomd.xml --- diff --git a/examples/solv.c b/examples/solv.c index d15a22c..26120f5 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -198,7 +198,7 @@ myfopen(const char *fn) } FILE * -curlfopen(char *baseurl, char *file, int uncompress) +curlfopen(const char *baseurl, const char *file, int uncompress) { pid_t pid; int fd, l; @@ -269,6 +269,7 @@ setarch(Pool *pool) pool_setarch(pool, un.machine); } + void read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos) { @@ -276,6 +277,8 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos) struct repoinfo *cinfo; int i; FILE *fp; + Dataiterator di; + const char *primaryfile; printf("reading rpm database\n"); repo = repo_create(pool, "@System"); @@ -297,7 +300,18 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos) repo->appdata = cinfo; repo_add_repomdxml(repo, fp, 0); fclose(fp); - if ((fp = curlfopen(cinfo->baseurl, "repodata/primary.xml.gz", 1)) == 0) + primaryfile = 0; + dataiterator_init(&di, pool, repo, SOLVID_META, REPOSITORY_REPOMD_TYPE, "primary", SEARCH_STRING); + dataiterator_prepend_keyname(&di, REPOSITORY_REPOMD); + if (dataiterator_step(&di)) + { + dataiterator_setpos_parent(&di); + primaryfile = pool_lookup_str(pool, SOLVID_POS, REPOSITORY_REPOMD_LOCATION); + } + dataiterator_free(&di); + if (!primaryfile) + primaryfile = "repodata/primary.xml.gz"; + if ((fp = curlfopen(cinfo->baseurl, primaryfile, 1)) == 0) continue; repo_add_rpmmd(repo, fp, 0, 0); fclose(fp);