From: Michael Schroeder Date: Tue, 13 May 2008 12:41:33 +0000 (+0000) Subject: - expand mergesolv a bit X-Git-Tag: BASE-SuSE-Code-12_1-Branch~652 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a043c8cab4bf32d7519a07e37347e7cd18c02e2c;p=platform%2Fupstream%2Flibsolv.git - expand mergesolv a bit - fix tiny bug in cookie detection --- diff --git a/tools/common_write.c b/tools/common_write.c index 884b417..e12e82f 100644 --- a/tools/common_write.c +++ b/tools/common_write.c @@ -169,7 +169,10 @@ tool_write(Repo *repo, const char *basename, const char *attrname) fileinfos = sat_zextend(fileinfos, nfileinfos, 1, sizeof(Repodatafile), REPODATAFILE_BLOCK); pool_addfileprovides_ids(repo->pool, 0, &fileinfos[nfileinfos].addedfileprovides); - if (repo->rpmdbcookie) + for (i = 0; i < 32; i++) + if (repo->rpmdbcookie[i]) + break; + if (i < 32) fileinfos[nfileinfos].rpmdbcookie = repo->rpmdbcookie; if (fileinfos[nfileinfos].addedfileprovides || fileinfos[nfileinfos].rpmdbcookie) nfileinfos++; diff --git a/tools/mergesolv.c b/tools/mergesolv.c index f770fbd..5b86161 100644 --- a/tools/mergesolv.c +++ b/tools/mergesolv.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -32,31 +33,64 @@ usage() exit(0); } +static FILE * +loadcallback (Pool *pool, Repodata *data, void *vdata) +{ + FILE *fp = 0; + if (data->location) + { + fprintf(stderr, "Loading SOLV file %s\n", data->location); + fp = fopen (data->location, "r"); + if (!fp) + perror(data->location); + } + return fp; +} int main(int argc, char **argv) { - Pool *pool = pool_create(); + Pool *pool; Repo *repo; + const char *basefile = 0; + int with_attr = 0; + int c; - repo = repo_create(pool, ""); - while (argc-- > 1) + pool = pool_create(); + repo = repo_create(pool, ""); + + while ((c = getopt(argc, argv, "ahb:")) >= 0) + { + switch (c) + { + case 'h': + usage(); + break; + case 'a': + with_attr = 1; + break; + case 'b': + basefile = optarg; + break; + default: + exit(1); + } + } + if (with_attr) + pool_setloadcallback(pool, loadcallback, 0); + + for (; optind < argc; optind++) { FILE *fp; - argv++; - if (!strcmp(*argv,"-h")) - usage(); - if ((fp = fopen(*argv, "r")) == NULL) + if ((fp = fopen(argv[optind], "r")) == NULL) { - perror(argv[1]); + perror(argv[optind]); exit(0); } repo_add_solv(repo, fp); fclose(fp); } - - tool_write(repo, 0, 0); + tool_write(repo, basefile, 0); pool_free(pool); - return 0; }