# HG changeset patch # User Kristian H?gsberg # Date 1205350736 14400 # Node ID cca0174a756ef43427ee821f3f8fadb71de9b00a # Parent 44d7bec477d53c635a7eda26c14cea4682d6cac9 Write out the new repo on install. We write the repo to a lock file repo, and once the RPMs are installed we rename() the lock repo back in place. diff -r 44d7bec477d5 -r cca0174a756e main.c --- a/main.c Wed Mar 12 13:27:26 2008 -0400 +++ b/main.c Wed Mar 12 15:38:56 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; }