2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #include <sys/types.h>
21 #include "repo_solv.h"
23 #include "repo_autopattern.h"
25 #include "common_write.h"
30 fprintf(stderr, "\nUsage:\n"
31 "mergesolv [file] [file] [...]\n"
32 " merges multiple solv files into one and writes it to stdout\n"
38 loadcallback (Pool *pool, Repodata *data, void *vdata)
41 const char *location = repodata_lookup_str(data, SOLVID_META, REPOSITORY_LOCATION);
46 fprintf(stderr, "Loading SOLV file %s\n", location);
47 fp = fopen (location, "r");
53 r = repo_add_solv(data->repo, fp, REPO_USE_LOADING|REPO_LOCALPOOL);
59 main(int argc, char **argv)
70 repo = repo_create(pool, "<mergesolv>");
72 while ((c = getopt(argc, argv, "ahX")) >= 0)
93 pool_setloadcallback(pool, loadcallback, 0);
95 for (; optind < argc; optind++)
98 if ((fp = fopen(argv[optind], "r")) == NULL)
100 perror(argv[optind]);
103 if (repo_add_solv(repo, fp, 0))
105 fprintf(stderr, "repo %s: %s\n", argv[optind], pool_errstr(pool));
112 repo_add_autopattern(repo, 0);
114 tool_write(repo, stdout);