Add --initdb support for rpm wrapper.
authorKristian Høgsberg <krh@redhat.com>
Mon, 9 Jun 2008 20:38:58 +0000 (16:38 -0400)
committerKristian Høgsberg <krh@redhat.com>
Mon, 9 Jun 2008 20:38:58 +0000 (16:38 -0400)
razor-root.c
rpm-razor.c

index 5330868..cfbf59b 100644 (file)
@@ -53,7 +53,7 @@ razor_root_create(const char *root)
        set = razor_set_create();
        snprintf(path, sizeof path, "%s%s/%s",
                 root, razor_root_path, system_repo_filename);
-       if (stat(root, &buf) == 0) {
+       if (stat(path, &buf) == 0) {
                fprintf(stderr,
                        "a razor install root is already initialized\n");
                return -1;
index 5012a5a..6b1e81b 100644 (file)
@@ -116,8 +116,10 @@ static const struct option signature_options[] = {
        { }
 };
 
+static int option_initdb;
+
 static const struct option database_options[] = {
-       { OPTION_BOOL, "initdb", 0, NULL, "initialize database", NULL },
+       { OPTION_BOOL, "initdb", 0, NULL, "initialize database", &option_initdb },
        { OPTION_BOOL, "rebuilddb", 0, NULL, "rebuild database inverted lists from installed package headers", NULL },
        { }
 };
@@ -238,6 +240,13 @@ static const struct option rpm_options[] = {
 
 static const char system_repo_filename[] = "system.repo";
 static const char *repo_filename = system_repo_filename;
+static const char install_root[] = "install";
+
+static void
+command_initdb(int argc, const char *argv[])
+{
+       razor_root_create(install_root);
+}
 
 static struct razor_property *
 add_property_packages(struct razor_set *set, 
@@ -768,7 +777,9 @@ main(int argc, const char *argv[])
                exit(0);
        }
 
-       if (option_verify) {
+       if (option_initdb) {
+               command_initdb(argc, argv);
+       } else if (option_verify) {
                command_verify(argc, argv);
        } else if (option_query) {
                command_query(argc, argv);