X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=ext%2Frepo_releasefile_products.c;h=a40bc984a6faba5ae3fcb82c1bc3844c4af8d4e5;hb=6a68988035ea989055076d81b7ab53c7015c8c32;hp=2703c924f4c4b15c5bfe08dec85db94fa0cec143;hpb=b739fb5bbdf2378b3e8d571df396c665af61a02d;p=platform%2Fupstream%2Flibsolv.git diff --git a/ext/repo_releasefile_products.c b/ext/repo_releasefile_products.c index 2703c92..a40bc98 100644 --- a/ext/repo_releasefile_products.c +++ b/ext/repo_releasefile_products.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "pool.h" #include "repo.h" @@ -29,9 +30,15 @@ #define BUFF_SIZE 8192 +struct parsedata { + Repo *repo; + struct joindata jd; +}; + static void -add_releasefile_product(Repo *repo, FILE *fp) +add_releasefile_product(struct parsedata *pd, FILE *fp) { + Repo *repo = pd->repo; Pool *pool = repo->pool; char buf[BUFF_SIZE]; Id name = 0; @@ -66,7 +73,7 @@ add_releasefile_product(Repo *repo, FILE *fp) && (*ptr1 == ' ' || isdigit(*ptr1) || *ptr1 == '.')) --ptr1; *(++ptr1) = 0; - name = str2id(pool, join2("product", ":", buf), 1); + name = pool_str2id(pool, join2(&pd->jd, "product", ":", buf), 1); if (ptr) { @@ -83,7 +90,7 @@ add_releasefile_product(Repo *repo, FILE *fp) *ptr1 = tolower(*ptr1); ++ptr1; } - arch = str2id(pool, ptr, 1); + arch = pool_str2id(pool, ptr, 1); } } } @@ -105,23 +112,34 @@ add_releasefile_product(Repo *repo, FILE *fp) s->evr = version ? version : ID_EMPTY; s->arch = arch ? arch : ARCH_NOARCH; if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); } } -void +int repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags) { DIR *dir; struct dirent *entry; FILE *fp; char *fullpath; + struct parsedata pd; + if (!dirpath) + dirpath = "/etc"; + if (flags & REPO_USE_ROOTDIR) + dirpath = pool_prepend_rootdir(repo->pool, dirpath); dir = opendir(dirpath); if (!dir) - return; + { + if (flags & REPO_USE_ROOTDIR) + solv_free((char *)dirpath); + return 0; + } + memset(&pd, 0, sizeof(pd)); + pd.repo = repo; while ((entry = readdir(dir))) { int len = strlen(entry->d_name); @@ -130,19 +148,23 @@ repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags) /* skip /etc/lsb-release, thats not a product per-se */ if (strcmp(entry->d_name, "lsb-release") == 0) continue; - fullpath = join2(dirpath, "/", entry->d_name); + fullpath = join2(&pd.jd, dirpath, "/", entry->d_name); if ((fp = fopen(fullpath, "r")) == 0) { - perror(fullpath); + pool_error(repo->pool, 0, "%s: %s", fullpath, strerror(errno)); continue; } - add_releasefile_product(repo, fp); + add_releasefile_product(&pd, fp); + fclose(fp); } } closedir(dir); - join_freemem(); + join_freemem(&pd.jd); + if (flags & REPO_USE_ROOTDIR) + solv_free((char *)dirpath); if (!(flags & REPO_NO_INTERNALIZE) && (flags & REPO_REUSE_REPODATA) != 0) repodata_internalize(repo_last_repodata(repo)); + return 0; }