Add getter to return system set for a razor_root.
authorKristian Høgsberg <krh@redhat.com>
Fri, 20 Jun 2008 22:26:46 +0000 (18:26 -0400)
committerKristian Høgsberg <krh@redhat.com>
Fri, 20 Jun 2008 22:26:46 +0000 (18:26 -0400)
librazor/razor.h
librazor/root.c
src/main.c

index b9ecb0e..8e69f1d 100644 (file)
@@ -176,22 +176,17 @@ int razor_rpm_install(struct razor_rpm *rpm, const char *root);
 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_ */
index 8c032ef..9e0ae26 100644 (file)
@@ -68,7 +68,7 @@ razor_root_create(const char *root)
 }
 
 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 @@ razor_root_open_read_only(const char *root)
        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 @@ razor_root_update(struct razor_root *root, struct razor_set *next)
 }
 
 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);
-}
index 7dd4bb7..96b2517 100644 (file)
@@ -644,7 +644,7 @@ static int
 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 @@ command_install(int argc, const char *argv[])
                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 @@ command_install(int argc, const char *argv[])
        }
 
        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 @@ command_install(int argc, const char *argv[])
 
        /* 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);