diff -r 068f443e00cc -r 41e125a91a03 main.c --- a/main.c Fri Mar 07 13:44:22 2008 -0500 +++ b/main.c Wed Mar 12 16:40:50 2008 -0400 @@ -12,6 +12,7 @@ #include "razor-internal.h" static const char system_repo_filename[] = "system.repo"; +static const char next_repo_filename[] = "system-next.repo"; static const char rawhide_repo_filename[] = "rawhide.repo"; static const char updated_repo_filename[] = "system-updated.repo"; static const char razor_root_path[] = "/var/lib/razor"; @@ -502,11 +503,11 @@ static int command_install(int argc, const char *argv[]) { - struct razor_set *system, *upstream, *new; + struct razor_set *system, *upstream, *next; struct razor_transaction *trans; struct razor_rpm *rpm; const char *filename; - char path[PATH_MAX], **packages; + char path[PATH_MAX], new_path[PATH_MAX], **packages; int i; upstream = create_set_from_rpms(argc, argv); @@ -532,9 +533,21 @@ * destroying the transaction. Nice for transient objects * such as the merger and the importer. Should we do that for * transactions too, that is, razor_transaction_finish()? */ - new = razor_transaction_run(trans); + next = razor_transaction_run(trans); razor_transaction_destroy(trans); + /* FIXME: Need razor_set_write_to_fd() so we can open it excl + * up front here or fail if it already exists. */ + snprintf(new_path, sizeof new_path, + "%s%s/%s", root, razor_root_path, next_repo_filename); + razor_set_write(next, path); + + razor_set_destroy(next); + razor_set_destroy(system); + razor_set_destroy(upstream); + + printf("wrote %s\n", new_path); + for (i = 0; i < argc; i++) { filename = argv[i]; rpm = razor_rpm_open(argv[i]); @@ -550,6 +563,10 @@ razor_rpm_close(rpm); } + /* Make it so. */ + rename(new_path, path); + printf("renamed %s to %s\n", new_path, path); + return 0; }