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;
74 int filtered_filelist = 0;
76 while ((c = getopt(argc, argv, "0XkKb:m:F")) >= 0)
90 filtered_filelist = 1;
111 if (!strcmp(manifest, "-"))
113 else if ((fp = fopen(manifest, "r")) == 0)
122 if (!fgets0(buf, sizeof(buf), fp))
127 if (!fgets(buf, sizeof(buf), fp))
129 if ((p = strchr(buf, '\n')) != 0)
132 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
133 rpms[nrpms++] = strdup(buf);
138 while (optind < argc)
140 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
141 rpms[nrpms++] = strdup(argv[optind++]);
143 repo = repo_create(pool, "rpms2solv");
144 repo_add_repodata(repo, 0);
146 for (i = 0; i < nrpms; i++)
151 FILE *fp = solv_xfopen(rpms[i], "r");
158 if (repo_add_keyring(repo, fp, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|ADD_WITH_KEYSIGNATURES))
160 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
168 if (repo_add_pubkey(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|ADD_WITH_KEYSIGNATURES) == 0)
170 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
176 if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|(filtered_filelist ? RPM_ADD_FILTERED_FILELIST : 0)) == 0)
178 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
182 repo_internalize(repo);
185 repo_add_autopattern(repo, 0);
187 tool_write(repo, basefile, 0);
189 for (c = 0; c < nrpms; c++)
190 free((char *)rpms[c]);