+ Repo *repo;
+ Repodata *data;
+ int c, percent = 0;
+ int nopacks = 0;
+ const char *root = 0;
+ const char *basefile = 0;
+ const char *refname = 0;
+#ifdef ENABLE_SUSEREPO
+ char *proddir = 0;
+#endif
+ char *outfile = 0;
+#ifdef ENABLE_RPMDB_PUBKEY
+ int pubkeys = 0;
+#endif
+
+ /*
+ * parse arguments
+ */
+
+ while ((c = getopt(argc, argv, "Phnkxb:r:p:o:")) >= 0)
+ switch (c)
+ {
+ case 'h':
+ usage(0);
+ break;
+ case 'r':
+ root = optarg;
+ break;
+ case 'b':
+ basefile = optarg;
+ break;
+ case 'n':
+ nopacks = 1;
+ break;
+ case 'P':
+ percent = 1;
+ break;
+ case 'p':
+#ifdef ENABLE_SUSEREPO
+ proddir = optarg;
+#endif
+ break;
+ case 'x':
+ break;
+ case 'o':
+ outfile = optarg;
+ break;
+#ifdef ENABLE_RPMDB_PUBKEY
+ case 'k':
+ nopacks = 1;
+ pubkeys = 1;
+ break;
+#endif
+ default:
+ usage(1);
+ }
+
+ if (outfile && !freopen(outfile, "w", stdout))
+ {
+ perror(outfile);
+ exit(1);
+ }
+
+ /*
+ * optional arg is old version of rpmdb solv file
+ * should make this a real option instead
+ */
+
+ if (optind < argc)
+ refname = argv[optind];
+
+ if (refname && !nopacks)
+ {
+ if ((reffp = fopen(refname, "r")) == NULL)
+ perror(refname);
+ }
+
+ /*
+ * create 'installed' repository
+ * add products
+ * add rpmdb
+ * write .solv
+ */
+
+ if (root && *root)
+ pool_set_rootdir(pool, root);