diff options
author | Michael Schroeder <mls@suse.de> | 2012-04-13 19:23:33 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-04-13 19:23:33 +0200 |
commit | 5702cc433a97b2365801855bdc5572f940d8bc9a (patch) | |
tree | 68a62cbfd9cdfa8f2fd755b2a39b71773bb30afe /tools/rpmdb2solv.c | |
parent | ca1d509d28858cd9d74a4ee7724e774b58ec459c (diff) | |
download | libsolv-5702cc433a97b2365801855bdc5572f940d8bc9a.tar.gz libsolv-5702cc433a97b2365801855bdc5572f940d8bc9a.tar.bz2 libsolv-5702cc433a97b2365801855bdc5572f940d8bc9a.zip |
- add pool_error and pool_errstr. get rid of lots of exit() calls.
Diffstat (limited to 'tools/rpmdb2solv.c')
-rw-r--r-- | tools/rpmdb2solv.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tools/rpmdb2solv.c b/tools/rpmdb2solv.c index 33796ff..e187b13 100644 --- a/tools/rpmdb2solv.c +++ b/tools/rpmdb2solv.c @@ -51,7 +51,6 @@ main(int argc, char **argv) Pool *pool = pool_create(); Repo *repo, *ref = 0; Repodata *data; - Pool *refpool; int c, percent = 0; int extrapool = 0; int nopacks = 0; @@ -123,13 +122,19 @@ main(int argc, char **argv) } else { - if (extrapool) - refpool = pool_create(); + Pool *refpool = extrapool ? pool_create() : 0; + ref = repo_create(refpool ? refpool : pool, "ref"); + if (repo_add_solv(ref, fp, 0) != 0) + { + fprintf(stderr, "%s: %s\n", refname, pool_errstr(ref->pool)); + if (ref->pool != pool) + pool_free(ref->pool); + else + repo_free(ref, 1); + ref = 0; + } else - refpool = pool; - ref = repo_create(refpool, "ref"); - repo_add_solv(ref, fp, 0); - repo_disable_paging(ref); + repo_disable_paging(ref); fclose(fp); } } @@ -145,7 +150,13 @@ main(int argc, char **argv) data = repo_add_repodata(repo, 0); if (!nopacks) - repo_add_rpmdb(repo, ref, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | (percent ? RPMDB_REPORT_PROGRESS : 0)); + { + if (repo_add_rpmdb(repo, ref, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | (percent ? RPMDB_REPORT_PROGRESS : 0))) + { + fprintf(stderr, "rpmdb2solv: %s\n", pool_errstr(pool)); + exit(1); + } + } #ifdef ENABLE_SUSEREPO if (proddir && *proddir) @@ -164,7 +175,11 @@ main(int argc, char **argv) strcpy(buf + rootlen, proddir); } } - repo_add_products(repo, buf, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE); + if (repo_add_products(repo, buf, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "rpmdb2solv: %s\n", pool_errstr(pool)); + exit(1); + } if (buf != proddir) solv_free(buf); } |