1.1 --- a/librazor/root.c Mon Jan 12 18:53:02 2009 +0000
1.2 +++ b/librazor/root.c Thu Aug 13 07:14:51 2009 +0100
1.3 @@ -42,9 +42,6 @@
1.4 #endif
1.5
1.6 static const char system_repo_filename[] = "system.rzdb";
1.7 -static const char system_repo_details_filename[] = "system-details.rzdb";
1.8 -static const char system_repo_files_filename[] = "system-files.rzdb";
1.9 -
1.10 static const char next_repo_filename[] = "system-next.rzdb";
1.11 #ifdef MSWIN_API
1.12 #define RAZOR_ROOT_PATH NULL
1.13 @@ -57,7 +54,6 @@
1.14 struct razor_set *system;
1.15 struct razor_set *next;
1.16 int fd;
1.17 - char root[PATH_MAX];
1.18 char path[PATH_MAX];
1.19 char new_path[PATH_MAX];
1.20 };
1.21 @@ -82,7 +78,7 @@
1.22 {
1.23 struct stat buf;
1.24 struct razor_set *set;
1.25 - char path[PATH_MAX], details_path[PATH_MAX], files_path[PATH_MAX];
1.26 + char path[PATH_MAX];
1.27
1.28 assert (root != NULL);
1.29
1.30 @@ -115,18 +111,12 @@
1.31 set = razor_set_create();
1.32 snprintf(path, sizeof path, "%s%s/%s",
1.33 root, razor_root_path, system_repo_filename);
1.34 - snprintf(details_path, sizeof details_path, "%s%s/%s",
1.35 - root, razor_root_path, system_repo_details_filename);
1.36 - snprintf(files_path, sizeof files_path, "%s%s/%s",
1.37 - root, razor_root_path, system_repo_files_filename);
1.38 if (stat(path, &buf) == 0) {
1.39 fprintf(stderr,
1.40 "a razor install root is already initialized\n");
1.41 return -1;
1.42 }
1.43 - if (razor_set_write(set, path, RAZOR_REPO_FILE_MAIN) < 0 ||
1.44 - razor_set_write(set, details_path, RAZOR_REPO_FILE_DETAILS) < 0 ||
1.45 - razor_set_write(set, files_path, RAZOR_REPO_FILE_FILES) < 0 ) {
1.46 + if (razor_set_write(set, path, RAZOR_SECTION_ALL) < 0) {
1.47 fprintf(stderr, "could not write initial package set\n");
1.48 return -1;
1.49 }
1.50 @@ -139,7 +129,6 @@
1.51 razor_root_open(const char *root)
1.52 {
1.53 struct razor_root *image;
1.54 - char details_path[PATH_MAX], files_path[PATH_MAX];
1.55
1.56 assert (root != NULL);
1.57
1.58 @@ -169,19 +158,9 @@
1.59
1.60 snprintf(image->path, sizeof image->path,
1.61 "%s%s/%s", root, razor_root_path, system_repo_filename);
1.62 - snprintf(details_path, sizeof details_path,
1.63 - "%s%s/%s", root, razor_root_path, system_repo_details_filename);
1.64 - snprintf(files_path, sizeof files_path,
1.65 - "%s%s/%s", root, razor_root_path, system_repo_files_filename);
1.66 -
1.67 - /* FIXME: We store the root path to make the hack in
1.68 - * razor_root_update() work. Need to get rid of this. */
1.69 - strcpy(image->root, root);
1.70
1.71 image->system = razor_set_open(image->path);
1.72 - if (image->system == NULL ||
1.73 - razor_set_open_details(image->system, details_path) ||
1.74 - razor_set_open_files(image->system, files_path)) {
1.75 + if (image->system == NULL) {
1.76 unlink(image->new_path);
1.77 close(image->fd);
1.78 free(image);
1.79 @@ -194,31 +173,15 @@
1.80 RAZOR_EXPORT struct razor_set *
1.81 razor_root_open_read_only(const char *root)
1.82 {
1.83 - char path[PATH_MAX], details_path[PATH_MAX], files_path[PATH_MAX];
1.84 - struct razor_set *set;
1.85 + char path[PATH_MAX];
1.86
1.87 assert (root != NULL);
1.88
1.89 razor_root_init();
1.90 snprintf(path, sizeof path, "%s%s/%s",
1.91 root, razor_root_path, system_repo_filename);
1.92 - snprintf(details_path, sizeof details_path,
1.93 - "%s%s/%s", root, razor_root_path, system_repo_details_filename);
1.94 - snprintf(files_path, sizeof files_path,
1.95 - "%s%s/%s", root, razor_root_path, system_repo_files_filename);
1.96
1.97 -
1.98 - set = razor_set_open(path);
1.99 - if (set == NULL)
1.100 - return NULL;
1.101 -
1.102 - if (razor_set_open_details(set, details_path) ||
1.103 - razor_set_open_files(set, files_path)) {
1.104 - razor_set_destroy(set);
1.105 - return NULL;
1.106 - }
1.107 -
1.108 - return set;
1.109 + return razor_set_open(path);
1.110 }
1.111
1.112 RAZOR_EXPORT struct razor_set *
1.113 @@ -245,27 +208,13 @@
1.114 RAZOR_EXPORT void
1.115 razor_root_update(struct razor_root *root, struct razor_set *next)
1.116 {
1.117 - char path[PATH_MAX];
1.118 -
1.119 assert (root != NULL);
1.120 assert (next != NULL);
1.121
1.122 razor_root_init();
1.123 - razor_set_write_to_fd(next, root->fd, RAZOR_REPO_FILE_MAIN);
1.124 + razor_set_write_to_fd(next, root->fd, RAZOR_SECTION_ALL);
1.125 root->next = next;
1.126
1.127 - /* FIXME: This is a pretty bad hack that just overwrites the
1.128 - * system details and files rzdb files before the transaction
1.129 - * succeeds. We need to fix this by merging the separate
1.130 - * details and files rzdb files back into the main rzdb
1.131 - * file. */
1.132 - snprintf(path, sizeof path,
1.133 - "%s%s/%s", root->root, razor_root_path, system_repo_details_filename);
1.134 - razor_set_write(next, path, RAZOR_REPO_FILE_DETAILS);
1.135 - snprintf(path, sizeof path,
1.136 - "%s%s/%s", root->root, razor_root_path, system_repo_files_filename);
1.137 - razor_set_write(next, path, RAZOR_REPO_FILE_FILES);
1.138 -
1.139 /* Sync the new repo file so the new package set is on disk
1.140 * before we start upgrading. */
1.141 fsync(root->fd);