2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
9 * rpms2solv - create a solv file from multiple rpms
13 #include <sys/types.h>
22 #include "repo_rpmdb.h"
24 #include "repo_pubkey.h"
25 #include "solv_xfopen.h"
27 #include "repo_solv.h"
29 #include "repo_autopattern.h"
31 #include "common_write.h"
34 fgets0(char *s, int size, FILE *stream)
57 main(int argc, char **argv)
59 const char **rpms = 0;
62 int c, i, res, nrpms = 0;
63 Pool *pool = pool_create();
67 const char *basefile = 0;
75 while ((c = getopt(argc, argv, "0XkKb:m:")) >= 0)
107 if (!strcmp(manifest, "-"))
109 else if ((fp = fopen(manifest, "r")) == 0)
118 if (!fgets0(buf, sizeof(buf), fp))
123 if (!fgets(buf, sizeof(buf), fp))
125 if ((p = strchr(buf, '\n')) != 0)
128 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
129 rpms[nrpms++] = strdup(buf);
134 while (optind < argc)
136 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
137 rpms[nrpms++] = strdup(argv[optind++]);
139 repo = repo_create(pool, "rpms2solv");
140 repo_add_repodata(repo, 0);
142 for (i = 0; i < nrpms; i++)
147 FILE *fp = solv_xfopen(rpms[i], "r");
154 if (repo_add_keyring(repo, fp, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|ADD_WITH_KEYSIGNATURES))
156 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
164 if (repo_add_pubkey(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|ADD_WITH_KEYSIGNATURES) == 0)
166 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
172 if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
174 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
178 repo_internalize(repo);
181 repo_add_autopattern(repo, 0);
183 tool_write(repo, basefile, 0);
185 for (c = 0; c < nrpms; c++)
186 free((char *)rpms[c]);