Add getter to return system set for a razor_root.
authorKristian H?gsberg <krh@redhat.com>
Fri Jun 20 18:26:46 2008 -0400 (2008-06-20)
changeset 250ce5402017488
parent 249 061a5b815727
child 251 d8b3c713aa42
Add getter to return system set for a razor_root.
librazor/razor.h
librazor/root.c
src/main.c
     1.1 --- a/librazor/razor.h	Fri Jun 20 16:48:44 2008 -0400
     1.2 +++ b/librazor/razor.h	Fri Jun 20 18:26:46 2008 -0400
     1.3 @@ -176,22 +176,17 @@
     1.4  int razor_rpm_close(struct razor_rpm *rpm);
     1.5  
     1.6  
     1.7 -/* Razor root functions. The root data struct encapsulates filesystem
     1.8 - * conventions and the locking protocol. */
     1.9 +/* Razor root functions. The root data structure encapsulates
    1.10 + * filesystem conventions and the locking protocol. */
    1.11  
    1.12  struct razor_root;
    1.13 -#define RAZOR_ROOT_OPEN_WRITE 0x01
    1.14  
    1.15  int razor_root_create(const char *root);
    1.16 -struct razor_root *razor_root_open(const char *root, int flags);
    1.17 +struct razor_root *razor_root_open(const char *root);
    1.18  struct razor_set *razor_root_open_read_only(const char *root);
    1.19 -struct razor_transaction *
    1.20 -razor_root_create_transaction(struct razor_root *image,
    1.21 -			      struct razor_set *upstream);
    1.22 -int razor_root_close(struct razor_root *image);
    1.23 -void razor_root_update(struct razor_root *image, struct razor_set *next);
    1.24 -int razor_root_commit(struct razor_root *image);
    1.25 -void razor_root_diff(struct razor_root *root,
    1.26 -		     razor_package_callback_t callback, void *data);
    1.27 +struct razor_set *razor_root_get_system_set(struct razor_root *root);
    1.28 +int razor_root_close(struct razor_root *root);
    1.29 +void razor_root_update(struct razor_root *root, struct razor_set *next);
    1.30 +int razor_root_commit(struct razor_root *root);
    1.31  
    1.32  #endif /* _RAZOR_H_ */
     2.1 --- a/librazor/root.c	Fri Jun 20 16:48:44 2008 -0400
     2.2 +++ b/librazor/root.c	Fri Jun 20 18:26:46 2008 -0400
     2.3 @@ -68,7 +68,7 @@
     2.4  }
     2.5  
     2.6  struct razor_root *
     2.7 -razor_root_open(const char *root, int flags)
     2.8 +razor_root_open(const char *root)
     2.9  {
    2.10  	struct razor_root *image;
    2.11  
    2.12 @@ -118,20 +118,19 @@
    2.13  	return razor_set_open(path);
    2.14  }
    2.15  
    2.16 -struct razor_transaction *
    2.17 -razor_root_create_transaction(struct razor_root *image,
    2.18 -			      struct razor_set *upstream)
    2.19 +struct razor_set *
    2.20 +razor_root_get_system_set(struct razor_root *root)
    2.21  {
    2.22 -	/* FIXME: This should take a number of upstream repos. */
    2.23 -	return razor_transaction_create(image->system, upstream);
    2.24 +	return root->system;
    2.25  }
    2.26  
    2.27  int
    2.28 -razor_root_close(struct razor_root *image)
    2.29 +razor_root_close(struct razor_root *root)
    2.30  {
    2.31 -	unlink(image->new_path);
    2.32 -	close(image->fd);
    2.33 -	free(image);
    2.34 +	razor_set_destroy(root->system);
    2.35 +	unlink(root->new_path);
    2.36 +	close(root->fd);
    2.37 +	free(root);
    2.38  
    2.39  	return 0;
    2.40  }
    2.41 @@ -149,20 +148,14 @@
    2.42  }
    2.43  
    2.44  int
    2.45 -razor_root_commit(struct razor_root *image)
    2.46 +razor_root_commit(struct razor_root *root)
    2.47  {
    2.48  	/* Make it so. */
    2.49 -	rename(image->new_path, image->path);
    2.50 -	printf("renamed %s to %s\n", image->new_path, image->path);
    2.51 -	close(image->fd);
    2.52 -	free(image);
    2.53 +	rename(root->new_path, root->path);
    2.54 +	printf("renamed %s to %s\n", root->new_path, root->path);
    2.55 +	razor_set_destroy(root->system);
    2.56 +	close(root->fd);
    2.57 +	free(root);
    2.58  
    2.59  	return 0;
    2.60  }
    2.61 -
    2.62 -void
    2.63 -razor_root_diff(struct razor_root *root,
    2.64 -		razor_package_callback_t callback, void *data)
    2.65 -{
    2.66 -	return razor_set_diff(root->system, root->next, callback, data);
    2.67 -}
     3.1 --- a/src/main.c	Fri Jun 20 16:48:44 2008 -0400
     3.2 +++ b/src/main.c	Fri Jun 20 18:26:46 2008 -0400
     3.3 @@ -644,7 +644,7 @@
     3.4  command_install(int argc, const char *argv[])
     3.5  {
     3.6  	struct razor_root *root;
     3.7 -	struct razor_set *upstream, *next;
     3.8 +	struct razor_set *system, *upstream, *next;
     3.9  	struct razor_transaction *trans;
    3.10  	int i = 0, errors, dependencies = 1;
    3.11  
    3.12 @@ -653,9 +653,10 @@
    3.13  		i++;
    3.14  	}
    3.15  
    3.16 -	root = razor_root_open(install_root, RAZOR_ROOT_OPEN_WRITE);
    3.17 +	root = razor_root_open(install_root);
    3.18 +	system = razor_root_get_system_set(root);
    3.19  	upstream = razor_set_open(rawhide_repo_filename);
    3.20 -	trans = razor_root_create_transaction(root, upstream);
    3.21 +	trans = razor_transaction_create(system, upstream);
    3.22  
    3.23  	for (; i < argc; i++) {
    3.24  		if (mark_packages_for_update(trans, upstream, argv[i]) == 0) {
    3.25 @@ -684,7 +685,7 @@
    3.26  	}
    3.27  
    3.28  	errors = 0;
    3.29 -	razor_root_diff(root, download_package, &errors);
    3.30 +	razor_set_diff(system, next, download_package, &errors);
    3.31  	if (errors > 0) {
    3.32  		fprintf(stderr, "failed to download %d packages\n", errors);
    3.33  		razor_root_close(root);
    3.34 @@ -693,7 +694,7 @@
    3.35  
    3.36  	/* FIXME: We need to figure out the right install order here,
    3.37  	 * so the post and pre scripts can run. */
    3.38 -	razor_root_diff(root, install_package, (void *) install_root);
    3.39 +	razor_set_diff(system, next, install_package, (void *) install_root);
    3.40  
    3.41  	razor_set_destroy(next);
    3.42  	razor_set_destroy(upstream);