X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tools%2Fsusetags2solv.c;h=71c65d800d143a391d36dce14693531a18506a4b;hb=c8e2acdc6c28d39193d24c9ca0a934ee43225648;hp=2b926bb33de299cfabce4198bcca95c932f9b234;hpb=7a13cb5917d03d3e49f20752202f96217d493ee4;p=platform%2Fupstream%2Flibsolv.git diff --git a/tools/susetags2solv.c b/tools/susetags2solv.c index 2b926bb..71c65d8 100644 --- a/tools/susetags2solv.c +++ b/tools/susetags2solv.c @@ -19,10 +19,14 @@ #include "pool.h" #include "repo.h" +#include "repo_solv.h" #include "repo_susetags.h" #include "repo_content.h" +#ifdef SUSE +#include "repo_autopattern.h" +#endif #include "common_write.h" -#include "sat_xfopen.h" +#include "solv_xfopen.h" static void usage(int status) @@ -48,7 +52,7 @@ doquery(Pool *pool, Repo *repo, const char *arg) Id id; snprintf(qbuf, sizeof(qbuf), "susetags:%s", arg); - id = str2id(pool, qbuf, 0); + id = pool_str2id(pool, qbuf, 0); if (!id) return; str = repo_lookup_str(repo, SOLVID_META, id); @@ -64,11 +68,17 @@ main(int argc, char **argv) const char *descrdir = 0; const char *basefile = 0; const char *query = 0; + const char *mergefile = 0; Id defvendor = 0; int flags = 0; +#ifdef SUSE + int add_auto = 0; +#endif int c; + Pool *pool; + Repo *repo; - while ((c = getopt(argc, argv, "hn:c:d:b:q:")) >= 0) + while ((c = getopt(argc, argv, "hn:c:d:b:q:M:X")) >= 0) { switch (c) { @@ -90,13 +100,21 @@ main(int argc, char **argv) case 'q': query = optarg; break; + case 'M': + mergefile = optarg; + break; + case 'X': +#ifdef SUSE + add_auto = 1; +#endif + break; default: usage(1); break; } } - Pool *pool = pool_create(); - Repo *repo = repo_create(pool, ""); + pool = pool_create(); + repo = repo_create(pool, ""); repo_add_repodata(repo, 0); @@ -108,7 +126,11 @@ main(int argc, char **argv) perror(contentfile); exit(1); } - repo_add_content(repo, fp, REPO_REUSE_REPODATA); + if (repo_add_content(repo, fp, REPO_REUSE_REPODATA)) + { + fprintf(stderr, "susetags2solv: %s: %s\n", contentfile, pool_errstr(pool)); + exit(1); + } defvendor = repo_lookup_id(repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR); fclose(fp); } @@ -163,46 +185,60 @@ main(int argc, char **argv) files[0] = de; } - fnp = sat_malloc(strlen(descrdir) + 128); + fnp = solv_malloc(strlen(descrdir) + 128); for (i = 0; i < ndirs; i++) { char *fn = files[i]->d_name; if (!strcmp(fn, "packages") || !strcmp(fn, "packages.gz")) { + FILE *fp; sprintf(fnp, "%s/%s", descrdir, fn); - FILE *fp = sat_xfopen(fnp); + fp = solv_xfopen(fnp, 0); if (!fp) { perror(fn); exit(1); } - repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + if (repo_add_susetags(repo, fp, defvendor, 0, flags | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool)); + exit(1); + } fclose(fp); } else if (!strcmp(fn, "packages.DU") || !strcmp(fn, "packages.DU.gz")) { + FILE *fp; sprintf(fnp, "%s/%s", descrdir, fn); - FILE *fp = sat_xfopen(fnp); + fp = solv_xfopen(fnp, 0); if (!fp) { perror(fn); exit(1); } - repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + if (repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool)); + exit(1); + } fclose(fp); } else if (!strcmp(fn, "packages.FL") || !strcmp(fn, "packages.FL.gz")) { #if 0 sprintf(fnp, "%s/%s", descrdir, fn); - FILE *fp = sat_xfopen(fnp); + FILE *fp = solv_xfopen(fnp, 0); if (!fp) { perror(fn); exit(1); } - repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + if (repo_add_susetags(repo, fp, defvendor, 0, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool)); + exit(1); + } fclose(fp); #else /* ignore for now. reactivate when filters work */ @@ -213,6 +249,7 @@ main(int argc, char **argv) { char lang[6]; char *p; + FILE *fp; sprintf(fnp, "%s/%s", descrdir, fn); p = strrchr(fnp, '.'); if (p && !strcmp(p, ".gz")) @@ -224,13 +261,17 @@ main(int argc, char **argv) continue; strcpy(lang, p + 1); sprintf(fnp, "%s/%s", descrdir, fn); - FILE *fp = sat_xfopen(fnp); + fp = solv_xfopen(fnp, 0); if (!fp) { perror(fn); exit(1); } - repo_add_susetags(repo, fp, defvendor, lang, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + if (repo_add_susetags(repo, fp, defvendor, lang, flags | SUSETAGS_EXTEND | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "susetags2solv: %s: %s\n", fnp, pool_errstr(pool)); + exit(1); + } fclose(fp); } } @@ -241,9 +282,34 @@ main(int argc, char **argv) repo_internalize(repo); } else - /* read data from stdin */ - repo_add_susetags(repo, stdin, defvendor, 0, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + { + /* read data from stdin */ + if (repo_add_susetags(repo, stdin, defvendor, 0, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "susetags2solv: %s\n", pool_errstr(pool)); + exit(1); + } + } repo_internalize(repo); + if (mergefile) + { + FILE *fp = fopen(mergefile, "r"); + if (!fp) + { + perror(mergefile); + exit(1); + } + if (repo_add_solv(repo, fp, 0)) + { + fprintf(stderr, "susetags2solv: %s\n", pool_errstr(pool)); + exit(1); + } + fclose(fp); + } +#ifdef SUSE + if (add_auto) + repo_add_autopattern(repo, 0); +#endif if (query) doquery(pool, repo, query);