# HG changeset patch # User Kristian H?gsberg # Date 1213065697 14400 # Node ID e4900c8df46155307f25e07a9d3804d5b8d6f366 # Parent 060d83d8eca9aadf42409a178e4663d32abdddec Add read-only open function for razor_root and support --root in rpm wrapper. diff -r 060d83d8eca9 -r e4900c8df461 razor-root.c --- a/razor-root.c Mon Jun 09 16:38:58 2008 -0400 +++ b/razor-root.c Mon Jun 09 22:41:37 2008 -0400 @@ -107,6 +107,17 @@ return image; } +struct razor_set * +razor_root_open_read_only(const char *root) +{ + char path[PATH_MAX]; + + snprintf(path, sizeof path, "%s%s/%s", + root, razor_root_path, system_repo_filename); + + return razor_set_open(path); +} + struct razor_transaction * razor_root_create_transaction(struct razor_root *image, struct razor_set *upstream) diff -r 060d83d8eca9 -r e4900c8df461 razor.h --- a/razor.h Mon Jun 09 16:38:58 2008 -0400 +++ b/razor.h Mon Jun 09 22:41:37 2008 -0400 @@ -118,6 +118,7 @@ struct razor_package *package); void razor_transaction_update_all(struct razor_transaction *transaction); int razor_transaction_resolve(struct razor_transaction *trans); +void razor_transaction_describe(struct razor_transaction *trans); struct razor_set *razor_transaction_finish(struct razor_transaction *trans); void razor_transaction_destroy(struct razor_transaction *trans); @@ -175,6 +176,7 @@ int razor_root_create(const char *root); struct razor_root *razor_root_open(const char *root, int flags); +struct razor_set *razor_root_open_read_only(const char *root); struct razor_transaction * razor_root_create_transaction(struct razor_root *image, struct razor_set *upstream); diff -r 060d83d8eca9 -r e4900c8df461 rpm-razor.c --- a/rpm-razor.c Mon Jun 09 16:38:58 2008 -0400 +++ b/rpm-razor.c Mon Jun 09 22:41:37 2008 -0400 @@ -20,6 +20,7 @@ #include #include #include +#include #include "razor.h" enum option_type { @@ -163,6 +164,7 @@ }; static int option_version; +static const char *option_root = "install"; static const struct option common_options[] = { { OPTION_STRING, "define", 'D', "MACRO EXPR", "define MACRO with value EXPR", NULL, }, @@ -171,7 +173,7 @@ { OPTION_BOOL, "nodigest", 0, NULL, "don't verify package digest(s)", NULL, }, { OPTION_BOOL, "nosignature", 0, NULL, "don't verify package signature(s)", NULL, }, { OPTION_STRING, "rcfile", 0, "", "read instead of default file(s)", NULL }, - { OPTION_STRING, "root", 'r', "ROOT", "use ROOT as top level directory (default: \"/\")", NULL }, + { OPTION_STRING, "root", 'r', "ROOT", "use ROOT as top level directory (default: \"/\")", &option_root }, { OPTION_BOOL, "querytags", 0, NULL, "display known query tags", NULL, }, { OPTION_BOOL, "showrc", 0, NULL, "display final rpmrc and macro configuration", NULL, }, { OPTION_BOOL, "quiet", 0, NULL, "provide less detailed output", NULL }, @@ -240,12 +242,11 @@ 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); + razor_root_create(option_root); } static struct razor_property * @@ -434,7 +435,7 @@ argc = 0; option_all = 1; } else { - set = razor_set_open(repo_filename); + set = razor_root_open_read_only(option_root); } pi = get_query_packages(set, argc, argv); @@ -484,7 +485,7 @@ argc = 0; option_all = 1; } else { - set = razor_set_open(repo_filename); + set = razor_root_open_read_only(option_root); } pi = get_query_packages(set, argc, argv);