usage(int status)
{
fprintf(stderr, "\nUsage:\n"
- "rpmmd2solv [-a][-h][-k][-n <attrname>]\n"
- " reads a 'rpmmd' repository from <stdin> and writes a .solv file to <stdout>\n"
+ "rpmmd2solv [-a][-h][-k][-n <attrname>][-l <locale>]\n"
+ " reads 'primary' from a 'rpmmd' repository from <stdin> and writes a .solv file to <stdout>\n"
" -h : print help & exit\n"
" -k : don't mix kinds (experimental!)\n"
" -n <name>: save attributes as <name>.attr\n"
+ " -l <locale>: parse localization data for <locale>\n"
);
exit(status);
}
const char *attrname = 0;
const char *basefile = 0;
const char *dir = 0;
-
+ const char *locale = 0;
Pool *pool = pool_create();
Repo *repo = repo_create(pool, "<stdin>");
- while ((c = getopt (argc, argv, "hkn:b:d:")) >= 0)
+ while ((c = getopt (argc, argv, "hkn:b:d:l:")) >= 0)
{
switch(c)
{
case 'd':
dir = optarg;
break;
+ case 'l':
+ locale = optarg;
+ break;
default:
usage(1);
break;
FILE *fp;
int l;
char *fnp;
- l = strlen(dir);
- fnp = sat_malloc(l + 20);
- sprintf(fnp, "%s/primary.xml.gz", dir);
+ l = strlen(dir) + 128;
+ fnp = sat_malloc(l+1);
+ snprintf(fnp, l, "%s/primary.xml.gz", dir);
if (!(fp = myfopen(fnp)))
{
perror(fnp);
}
repo_add_rpmmd(repo, fp, flags);
fclose(fp);
+ snprintf(fnp, l, "%s/diskusage.xml.gz", dir);
+ if ((fp = myfopen(fnp)))
+ {
+ repo_add_rpmmd(repo, fp, flags);
+ fclose(fp);
+ }
+ if (locale)
+ {
+ if (snprintf(fnp, l, "%s/translation-%s.xml.gz", dir, locale) >= l)
+ {
+ fprintf(stderr, "-l parameter too long\n");
+ exit(1);
+ }
+ while (!(fp = myfopen(fnp)))
+ {
+ fprintf(stderr, "not opened %s\n", fnp);
+ if (strlen(locale) > 2)
+ {
+ if (snprintf(fnp, l, "%s/translation-%.2s.xml.gz", dir, locale) >= l)
+ {
+ fprintf(stderr, "-l parameter too long\n");
+ exit(1);
+ }
+ if ((fp = myfopen(fnp)))
+ break;
+ }
+ perror(fnp);
+ exit(1);
+ }
+ fprintf(stderr, "opened %s\n", fnp);
+ repo_add_rpmmd(repo, fp, flags);
+ fclose(fp);
+ }
sat_free(fnp);
}
else