From: Michael Schroeder Date: Wed, 20 Apr 2016 11:15:50 +0000 (+0200) Subject: Add -r option to deb2solv to make it read repo metadata instead of deb packages X-Git-Tag: 0.6.21~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b19115fc03cbbd99c4d24ca591ee48561c6a0891;p=thirdparty%2Flibsolv.git Add -r option to deb2solv to make it read repo metadata instead of deb packages --- diff --git a/tools/deb2solv.c b/tools/deb2solv.c index 0d22f244..63b6839b 100644 --- a/tools/deb2solv.c +++ b/tools/deb2solv.c @@ -58,8 +58,9 @@ main(int argc, char **argv) FILE *fp; char buf[4096], *p; const char *basefile = 0; + int is_repo = 0; - while ((c = getopt(argc, argv, "0b:m:")) >= 0) + while ((c = getopt(argc, argv, "0b:m:r")) >= 0) { switch(c) { @@ -69,6 +70,9 @@ main(int argc, char **argv) case 'm': manifest = optarg; break; + case 'r': + is_repo = 1; + break; case '0': manifest0 = 1; break; @@ -113,8 +117,32 @@ main(int argc, char **argv) repo = repo_create(pool, "deb2solv"); repo_add_repodata(repo, 0); res = 0; + if (!ndebs && !manifest && is_repo) + { + if (repo_add_debpackages(repo, stdin, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool)); + res = 1; + } + } for (i = 0; i < ndebs; i++) { + if (is_repo) + { + if ((fp = fopen(debs[i], "r")) == 0) + { + perror(debs[i]); + res = 1; + continue; + } + if (repo_add_debpackages(repo, fp, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE)) + { + fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool)); + res = 1; + } + fclose(fp); + continue; + } if (repo_add_deb(repo, debs[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0) { fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool));