# HG changeset patch # User Kristian H?gsberg # Date 1214000806 14400 # Node ID ce54020174880b715a96f6d12dc06c231606f6da # Parent 061a5b8157271d1669007b16faeddf5f59949e68 Add getter to return system set for a razor_root. diff -r 061a5b815727 -r ce5402017488 librazor/razor.h --- a/librazor/razor.h Fri Jun 20 16:48:44 2008 -0400 +++ b/librazor/razor.h Fri Jun 20 18:26:46 2008 -0400 @@ -176,22 +176,17 @@ int razor_rpm_close(struct razor_rpm *rpm); -/* Razor root functions. The root data struct encapsulates filesystem - * conventions and the locking protocol. */ +/* Razor root functions. The root data structure encapsulates + * filesystem conventions and the locking protocol. */ struct razor_root; -#define RAZOR_ROOT_OPEN_WRITE 0x01 int razor_root_create(const char *root); -struct razor_root *razor_root_open(const char *root, int flags); +struct razor_root *razor_root_open(const char *root); 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); -int razor_root_close(struct razor_root *image); -void razor_root_update(struct razor_root *image, struct razor_set *next); -int razor_root_commit(struct razor_root *image); -void razor_root_diff(struct razor_root *root, - razor_package_callback_t callback, void *data); +struct razor_set *razor_root_get_system_set(struct razor_root *root); +int razor_root_close(struct razor_root *root); +void razor_root_update(struct razor_root *root, struct razor_set *next); +int razor_root_commit(struct razor_root *root); #endif /* _RAZOR_H_ */ diff -r 061a5b815727 -r ce5402017488 librazor/root.c --- a/librazor/root.c Fri Jun 20 16:48:44 2008 -0400 +++ b/librazor/root.c Fri Jun 20 18:26:46 2008 -0400 @@ -68,7 +68,7 @@ } struct razor_root * -razor_root_open(const char *root, int flags) +razor_root_open(const char *root) { struct razor_root *image; @@ -118,20 +118,19 @@ return razor_set_open(path); } -struct razor_transaction * -razor_root_create_transaction(struct razor_root *image, - struct razor_set *upstream) +struct razor_set * +razor_root_get_system_set(struct razor_root *root) { - /* FIXME: This should take a number of upstream repos. */ - return razor_transaction_create(image->system, upstream); + return root->system; } int -razor_root_close(struct razor_root *image) +razor_root_close(struct razor_root *root) { - unlink(image->new_path); - close(image->fd); - free(image); + razor_set_destroy(root->system); + unlink(root->new_path); + close(root->fd); + free(root); return 0; } @@ -149,20 +148,14 @@ } int -razor_root_commit(struct razor_root *image) +razor_root_commit(struct razor_root *root) { /* Make it so. */ - rename(image->new_path, image->path); - printf("renamed %s to %s\n", image->new_path, image->path); - close(image->fd); - free(image); + rename(root->new_path, root->path); + printf("renamed %s to %s\n", root->new_path, root->path); + razor_set_destroy(root->system); + close(root->fd); + free(root); return 0; } - -void -razor_root_diff(struct razor_root *root, - razor_package_callback_t callback, void *data) -{ - return razor_set_diff(root->system, root->next, callback, data); -} diff -r 061a5b815727 -r ce5402017488 src/main.c --- a/src/main.c Fri Jun 20 16:48:44 2008 -0400 +++ b/src/main.c Fri Jun 20 18:26:46 2008 -0400 @@ -644,7 +644,7 @@ command_install(int argc, const char *argv[]) { struct razor_root *root; - struct razor_set *upstream, *next; + struct razor_set *system, *upstream, *next; struct razor_transaction *trans; int i = 0, errors, dependencies = 1; @@ -653,9 +653,10 @@ i++; } - root = razor_root_open(install_root, RAZOR_ROOT_OPEN_WRITE); + root = razor_root_open(install_root); + system = razor_root_get_system_set(root); upstream = razor_set_open(rawhide_repo_filename); - trans = razor_root_create_transaction(root, upstream); + trans = razor_transaction_create(system, upstream); for (; i < argc; i++) { if (mark_packages_for_update(trans, upstream, argv[i]) == 0) { @@ -684,7 +685,7 @@ } errors = 0; - razor_root_diff(root, download_package, &errors); + razor_set_diff(system, next, download_package, &errors); if (errors > 0) { fprintf(stderr, "failed to download %d packages\n", errors); razor_root_close(root); @@ -693,7 +694,7 @@ /* FIXME: We need to figure out the right install order here, * so the post and pre scripts can run. */ - razor_root_diff(root, install_package, (void *) install_root); + razor_set_diff(system, next, install_package, (void *) install_root); razor_set_destroy(next); razor_set_destroy(upstream);