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"
26 #include "repo_solv.h"
27 #include "common_write.h"
30 fgets0(char *s, int size, FILE *stream)
53 main(int argc, char **argv)
55 const char **rpms = 0;
58 int c, i, res, nrpms = 0;
59 Pool *pool = pool_create();
63 const char *basefile = 0;
68 while ((c = getopt(argc, argv, "0kb:m:")) >= 0)
92 if (!strcmp(manifest, "-"))
94 else if ((fp = fopen(manifest, "r")) == 0)
103 if (!fgets0(buf, sizeof(buf), fp))
108 if (!fgets(buf, sizeof(buf), fp))
110 if ((p = strchr(buf, '\n')) != 0)
113 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
114 rpms[nrpms++] = strdup(buf);
119 while (optind < argc)
121 rpms = solv_extend(rpms, nrpms, 1, sizeof(char *), 15);
122 rpms[nrpms++] = strdup(argv[optind++]);
124 repo = repo_create(pool, "rpms2solv");
125 repo_add_repodata(repo, 0);
127 for (i = 0; i < nrpms; i++)
132 if (repo_add_pubkey(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
134 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
140 if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
142 fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool));
146 repo_internalize(repo);
147 tool_write(repo, basefile, 0);
149 for (c = 0; c < nrpms; c++)
150 free((char *)rpms[c]);