summaryrefslogtreecommitdiff
path: root/tools/rpms2solv.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/rpms2solv.c')
-rw-r--r--tools/rpms2solv.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/tools/rpms2solv.c b/tools/rpms2solv.c
index d4a228e..76a659a 100644
--- a/tools/rpms2solv.c
+++ b/tools/rpms2solv.c
@@ -23,20 +23,43 @@
#include "repo_solv.h"
#include "common_write.h"
+static char *
+fgets0(char *s, int size, FILE *stream)
+{
+ char *p = s;
+ int c;
+
+ while (--size > 0)
+ {
+ c = getc(stream);
+ if (c == EOF)
+ {
+ if (p == s)
+ return 0;
+ c = 0;
+ }
+ *p++ = c;
+ if (!c)
+ return s;
+ }
+ *p = 0;
+ return s;
+}
+
int
main(int argc, char **argv)
{
const char **rpms = 0;
char *manifest = 0;
+ int manifest0 = 0;
int c, nrpms = 0;
Pool *pool = pool_create();
Repo *repo;
- Repodata *repodata;
FILE *fp;
char buf[4096], *p;
const char *basefile = 0;
- while ((c = getopt(argc, argv, "b:m:")) >= 0)
+ while ((c = getopt(argc, argv, "0b:m:")) >= 0)
{
switch(c)
{
@@ -46,6 +69,9 @@ main(int argc, char **argv)
case 'm':
manifest = optarg;
break;
+ case '0':
+ manifest0 = 1;
+ break;
default:
exit(1);
}
@@ -59,10 +85,20 @@ main(int argc, char **argv)
perror(manifest);
exit(1);
}
- while(fgets(buf, sizeof(buf), fp))
+ for (;;)
{
- if ((p = strchr(buf, '\n')) != 0)
- *p = 0;
+ if (manifest0)
+ {
+ if (!fgets0(buf, sizeof(buf), fp))
+ break;
+ }
+ else
+ {
+ if (!fgets(buf, sizeof(buf), fp))
+ break;
+ if ((p = strchr(buf, '\n')) != 0)
+ *p = 0;
+ }
rpms = sat_extend(rpms, nrpms, 1, sizeof(char *), 15);
rpms[nrpms++] = strdup(buf);
}
@@ -75,10 +111,7 @@ main(int argc, char **argv)
rpms[nrpms++] = strdup(argv[optind++]);
}
repo = repo_create(pool, "rpms2solv");
- repodata = repo_add_repodata(repo, 0);
- repo_add_rpms(repo, repodata, rpms, nrpms);
- if (repodata)
- repodata_internalize(repodata);
+ repo_add_rpms(repo, rpms, nrpms, 0);
tool_write(repo, basefile, 0);
pool_free(pool);
for (c = 0; c < nrpms; c++)