main.c
changeset 172 852e66234cf6
parent 155 068f443e00cc
child 175 d453ed5bfcfe
     1.1 --- a/main.c	Fri Mar 07 13:44:22 2008 -0500
     1.2 +++ b/main.c	Wed Mar 12 16:26:26 2008 -0400
     1.3 @@ -12,6 +12,7 @@
     1.4  #include "razor-internal.h"
     1.5  
     1.6  static const char system_repo_filename[] = "system.repo";
     1.7 +static const char next_repo_filename[] = "system-next.repo";
     1.8  static const char rawhide_repo_filename[] = "rawhide.repo";
     1.9  static const char updated_repo_filename[] = "system-updated.repo";
    1.10  static const char razor_root_path[] = "/var/lib/razor";
    1.11 @@ -502,11 +503,11 @@
    1.12  static int
    1.13  command_install(int argc, const char *argv[])
    1.14  {
    1.15 -	struct razor_set *system, *upstream, *new;
    1.16 +	struct razor_set *system, *upstream, *next;
    1.17  	struct razor_transaction *trans;
    1.18  	struct razor_rpm *rpm;
    1.19  	const char *filename;
    1.20 -	char path[PATH_MAX], **packages;
    1.21 +	char path[PATH_MAX], new_path[PATH_MAX], **packages;
    1.22  	int i;
    1.23  
    1.24  	upstream = create_set_from_rpms(argc, argv);
    1.25 @@ -532,9 +533,21 @@
    1.26  	 * destroying the transaction.  Nice for transient objects
    1.27  	 * such as the merger and the importer.  Should we do that for
    1.28  	 * transactions too, that is, razor_transaction_finish()? */
    1.29 -	new = razor_transaction_run(trans);
    1.30 +	next = razor_transaction_run(trans);
    1.31  	razor_transaction_destroy(trans);
    1.32  
    1.33 +	/* FIXME: Need razor_set_write_to_fd() so we can open it excl
    1.34 +	 * up front here or fail if it already exists. */
    1.35 +	snprintf(new_path, sizeof new_path,
    1.36 +		 "%s%s/%s", root, razor_root_path, next_repo_filename);
    1.37 +	razor_set_write(next, path);
    1.38 +
    1.39 +	razor_set_destroy(next);
    1.40 +	razor_set_destroy(system);
    1.41 +	razor_set_destroy(upstream);
    1.42 +
    1.43 +	printf("wrote %s\n", new_path);
    1.44 +
    1.45  	for (i = 0; i < argc; i++) {
    1.46  		filename = argv[i];
    1.47  		rpm = razor_rpm_open(argv[i]);
    1.48 @@ -550,6 +563,10 @@
    1.49  		razor_rpm_close(rpm);
    1.50  	}	
    1.51  
    1.52 +	/* Make it so. */
    1.53 +	rename(new_path, path);
    1.54 +	printf("renamed %s to %s\n", new_path, path);
    1.55 +
    1.56  	return 0;
    1.57  }
    1.58