+ Repo *repo;
+ Repodata *data;
+ int c, percent = 0;
+ int nopacks = 0;
+ int add_changelog = 0;
+ const char *root = 0;
+ const char *refname = 0;
+#ifdef ENABLE_SUSEREPO
+ char *proddir = 0;
+#endif
+ char *outfile = 0;
+#ifdef ENABLE_PUBKEY
+ int pubkeys = 0;
+#endif
+#ifdef ENABLE_APPDATA
+ int add_appdata = 0;
+#endif
+#ifdef SUSE
+ int add_auto = 0;
+#endif
+
+ /*
+ * parse arguments
+ */
+
+ while ((c = getopt(argc, argv, "ACPhnkxXr:p:o:")) >= 0)
+ switch (c)
+ {
+ case 'h':
+ usage(0);
+ break;
+ case 'r':
+ root = optarg;
+ break;
+ case 'n':
+ nopacks = 1;
+ break;
+ case 'P':
+ percent = 1;
+ break;
+ case 'p':
+#ifdef ENABLE_SUSEREPO
+ proddir = optarg;
+#endif
+ break;
+ case 'x':
+ break; /* extrapool no longer supported */
+ case 'X':
+#ifdef SUSE
+ add_auto = 1;
+#endif
+ break;
+ case 'A':
+#ifdef ENABLE_APPDATA
+ add_appdata = 1;
+#endif
+ break;
+ case 'o':
+ outfile = optarg;
+ break;
+#ifdef ENABLE_PUBKEY
+ case 'k':
+ nopacks = 1;
+ pubkeys = 1;
+ break;
+#endif
+ case 'C':
+ add_changelog = 1;
+ break;
+ 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);
+
+ repo = repo_create(pool, "installed");
+ data = repo_add_repodata(repo, 0);