2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
10 #include <sys/types.h>
21 #include "repo_rpmmd.h"
22 #include "common_write.h"
23 #include "solv_xfopen.h"
29 fprintf(stderr, "\nUsage:\n"
30 "rpmmd2solv [-a][-h][-n <attrname>][-l <locale>]\n"
31 " reads 'primary' from a 'rpmmd' repository from <stdin> and writes a .solv file to <stdout>\n"
32 " -h : print help & exit\n"
33 " -n <name>: save attributes as <name>.attr\n"
34 " -l <locale>: parse localization data for <locale>\n"
40 main(int argc, char **argv)
43 const char *attrname = 0;
44 const char *basefile = 0;
46 const char *locale = 0;
48 Pool *pool = pool_create();
49 Repo *repo = repo_create(pool, "<stdin>");
51 while ((c = getopt (argc, argv, "hn:b:d:l:")) >= 0)
80 l = strlen(dir) + 128;
81 fnp = solv_malloc(l+1);
82 snprintf(fnp, l, "%s/primary.xml.gz", dir);
83 if (!(fp = solv_xfopen(fnp, 0)))
88 if (repo_add_rpmmd(repo, fp, 0, flags))
90 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
94 snprintf(fnp, l, "%s/diskusagedata.xml.gz", dir);
95 if ((fp = solv_xfopen(fnp, 0)))
97 if (repo_add_rpmmd(repo, fp, 0, flags))
99 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
106 if (snprintf(fnp, l, "%s/translation-%s.xml.gz", dir, locale) >= l)
108 fprintf(stderr, "-l parameter too long\n");
111 while (!(fp = solv_xfopen(fnp, 0)))
113 fprintf(stderr, "not opened %s\n", fnp);
114 if (strlen(locale) > 2)
116 if (snprintf(fnp, l, "%s/translation-%.2s.xml.gz", dir, locale) >= l)
118 fprintf(stderr, "-l parameter too long\n");
121 if ((fp = solv_xfopen(fnp, 0)))
127 fprintf(stderr, "opened %s\n", fnp);
128 if (repo_add_rpmmd(repo, fp, 0, flags))
130 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
139 if (repo_add_rpmmd(repo, stdin, 0, flags))
141 fprintf(stderr, "rpmmd2solv: %s\n", pool_errstr(pool));
145 tool_write(repo, basefile, attrname);