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"
23 #include "repo_autopattern.h"
25 #include "common_write.h"
26 #include "solv_xfopen.h"
32 fprintf(stderr, "\nUsage:\n"
33 "rpmmd2solv [-a][-h][-n <attrname>][-l <locale>]\n"
34 " reads 'primary' from a 'rpmmd' repository from <stdin> and writes a .solv file to <stdout>\n"
35 " -h : print help & exit\n"
36 " -n <name>: save attributes as <name>.attr\n"
37 " -l <locale>: parse localization data for <locale>\n"
43 main(int argc, char **argv)
46 const char *attrname = 0;
47 const char *basefile = 0;
49 const char *locale = 0;
54 Pool *pool = pool_create();
55 Repo *repo = repo_create(pool, "<stdin>");
57 while ((c = getopt (argc, argv, "hn:b:d:l:X")) >= 0)
91 l = strlen(dir) + 128;
92 fnp = solv_malloc(l+1);
93 snprintf(fnp, l, "%s/primary.xml.gz", dir);
94 if (!(fp = solv_xfopen(fnp, 0)))
99 if (repo_add_rpmmd(repo, fp, 0, flags))
101 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
105 snprintf(fnp, l, "%s/diskusagedata.xml.gz", dir);
106 if ((fp = solv_xfopen(fnp, 0)))
108 if (repo_add_rpmmd(repo, fp, 0, flags))
110 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
117 if (snprintf(fnp, l, "%s/translation-%s.xml.gz", dir, locale) >= l)
119 fprintf(stderr, "-l parameter too long\n");
122 while (!(fp = solv_xfopen(fnp, 0)))
124 fprintf(stderr, "not opened %s\n", fnp);
125 if (strlen(locale) > 2)
127 if (snprintf(fnp, l, "%s/translation-%.2s.xml.gz", dir, locale) >= l)
129 fprintf(stderr, "-l parameter too long\n");
132 if ((fp = solv_xfopen(fnp, 0)))
138 fprintf(stderr, "opened %s\n", fnp);
139 if (repo_add_rpmmd(repo, fp, 0, flags))
141 fprintf(stderr, "rpmmd2solv: %s: %s\n", fnp, pool_errstr(pool));
150 if (repo_add_rpmmd(repo, stdin, 0, flags))
152 fprintf(stderr, "rpmmd2solv: %s\n", pool_errstr(pool));
158 repo_add_autopattern(repo, 0);
160 tool_write(repo, basefile, attrname);