2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
9 * deb2solv - create a solv file from one or multiple debs
13 #include <sys/types.h>
23 #include "repo_solv.h"
24 #include "common_write.h"
27 fgets0(char *s, int size, FILE *stream)
50 main(int argc, char **argv)
52 const char **debs = 0;
55 int c, i, res, ndebs = 0;
56 Pool *pool = pool_create();
60 const char *basefile = 0;
63 while ((c = getopt(argc, argv, "0b:m:r")) >= 0)
85 if (!strcmp(manifest, "-"))
87 else if ((fp = fopen(manifest, "r")) == 0)
96 if (!fgets0(buf, sizeof(buf), fp))
101 if (!fgets(buf, sizeof(buf), fp))
103 if ((p = strchr(buf, '\n')) != 0)
106 debs = solv_extend(debs, ndebs, 1, sizeof(char *), 15);
107 debs[ndebs++] = strdup(buf);
112 while (optind < argc)
114 debs = solv_extend(debs, ndebs, 1, sizeof(char *), 15);
115 debs[ndebs++] = strdup(argv[optind++]);
117 repo = repo_create(pool, "deb2solv");
118 repo_add_repodata(repo, 0);
120 if (!ndebs && !manifest && is_repo)
122 if (repo_add_debpackages(repo, stdin, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE))
124 fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool));
128 for (i = 0; i < ndebs; i++)
132 if ((fp = fopen(debs[i], "r")) == 0)
138 if (repo_add_debpackages(repo, fp, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE))
140 fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool));
146 if (repo_add_deb(repo, debs[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0)
148 fprintf(stderr, "deb2solv: %s\n", pool_errstr(pool));
152 repo_internalize(repo);
153 tool_write(repo, basefile, 0);
155 for (c = 0; c < ndebs; c++)
156 free((char *)debs[c]);