Add read-only open function for razor_root and support --root in rpm wrapper.
1.1 --- a/razor-root.c Mon Jun 09 16:38:58 2008 -0400
1.2 +++ b/razor-root.c Mon Jun 09 22:41:37 2008 -0400
1.3 @@ -107,6 +107,17 @@
1.4 return image;
1.5 }
1.6
1.7 +struct razor_set *
1.8 +razor_root_open_read_only(const char *root)
1.9 +{
1.10 + char path[PATH_MAX];
1.11 +
1.12 + snprintf(path, sizeof path, "%s%s/%s",
1.13 + root, razor_root_path, system_repo_filename);
1.14 +
1.15 + return razor_set_open(path);
1.16 +}
1.17 +
1.18 struct razor_transaction *
1.19 razor_root_create_transaction(struct razor_root *image,
1.20 struct razor_set *upstream)
2.1 --- a/razor.h Mon Jun 09 16:38:58 2008 -0400
2.2 +++ b/razor.h Mon Jun 09 22:41:37 2008 -0400
2.3 @@ -118,6 +118,7 @@
2.4 struct razor_package *package);
2.5 void razor_transaction_update_all(struct razor_transaction *transaction);
2.6 int razor_transaction_resolve(struct razor_transaction *trans);
2.7 +void razor_transaction_describe(struct razor_transaction *trans);
2.8 struct razor_set *razor_transaction_finish(struct razor_transaction *trans);
2.9 void razor_transaction_destroy(struct razor_transaction *trans);
2.10
2.11 @@ -175,6 +176,7 @@
2.12
2.13 int razor_root_create(const char *root);
2.14 struct razor_root *razor_root_open(const char *root, int flags);
2.15 +struct razor_set *razor_root_open_read_only(const char *root);
2.16 struct razor_transaction *
2.17 razor_root_create_transaction(struct razor_root *image,
2.18 struct razor_set *upstream);
3.1 --- a/rpm-razor.c Mon Jun 09 16:38:58 2008 -0400
3.2 +++ b/rpm-razor.c Mon Jun 09 22:41:37 2008 -0400
3.3 @@ -20,6 +20,7 @@
3.4 #include <stdlib.h>
3.5 #include <string.h>
3.6 #include <stdio.h>
3.7 +#include <dirent.h>
3.8 #include "razor.h"
3.9
3.10 enum option_type {
3.11 @@ -163,6 +164,7 @@
3.12 };
3.13
3.14 static int option_version;
3.15 +static const char *option_root = "install";
3.16
3.17 static const struct option common_options[] = {
3.18 { OPTION_STRING, "define", 'D', "MACRO EXPR", "define MACRO with value EXPR", NULL, },
3.19 @@ -171,7 +173,7 @@
3.20 { OPTION_BOOL, "nodigest", 0, NULL, "don't verify package digest(s)", NULL, },
3.21 { OPTION_BOOL, "nosignature", 0, NULL, "don't verify package signature(s)", NULL, },
3.22 { OPTION_STRING, "rcfile", 0, "<FILE:...>", "read <FILE:...> instead of default file(s)", NULL },
3.23 - { OPTION_STRING, "root", 'r', "ROOT", "use ROOT as top level directory (default: \"/\")", NULL },
3.24 + { OPTION_STRING, "root", 'r', "ROOT", "use ROOT as top level directory (default: \"/\")", &option_root },
3.25 { OPTION_BOOL, "querytags", 0, NULL, "display known query tags", NULL, },
3.26 { OPTION_BOOL, "showrc", 0, NULL, "display final rpmrc and macro configuration", NULL, },
3.27 { OPTION_BOOL, "quiet", 0, NULL, "provide less detailed output", NULL },
3.28 @@ -240,12 +242,11 @@
3.29
3.30 static const char system_repo_filename[] = "system.repo";
3.31 static const char *repo_filename = system_repo_filename;
3.32 -static const char install_root[] = "install";
3.33
3.34 static void
3.35 command_initdb(int argc, const char *argv[])
3.36 {
3.37 - razor_root_create(install_root);
3.38 + razor_root_create(option_root);
3.39 }
3.40
3.41 static struct razor_property *
3.42 @@ -434,7 +435,7 @@
3.43 argc = 0;
3.44 option_all = 1;
3.45 } else {
3.46 - set = razor_set_open(repo_filename);
3.47 + set = razor_root_open_read_only(option_root);
3.48 }
3.49
3.50 pi = get_query_packages(set, argc, argv);
3.51 @@ -484,7 +485,7 @@
3.52 argc = 0;
3.53 option_all = 1;
3.54 } else {
3.55 - set = razor_set_open(repo_filename);
3.56 + set = razor_root_open_read_only(option_root);
3.57 }
3.58
3.59 pi = get_query_packages(set, argc, argv);