diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-01-14 11:16:17 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-01-14 11:16:17 +0100 |
commit | f3bf30334c483c11679c5465cf869f38cab70126 (patch) | |
tree | 91b85dcb29fffcda38b6f0ae0c226627fbf786c3 /builder | |
parent | 7fb1309488656721fff47c2e57ae5e79a47c307b (diff) | |
download | xdg-app-f3bf30334c483c11679c5465cf869f38cab70126.tar.gz |
builder: Also apply cleanup to changes in usr
Diffstat (limited to 'builder')
-rw-r--r-- | builder/builder-cache.c | 11 | ||||
-rw-r--r-- | builder/builder-manifest.c | 2 | ||||
-rw-r--r-- | builder/builder-module.c | 30 | ||||
-rw-r--r-- | builder/builder-utils.c | 5 | ||||
-rw-r--r-- | builder/builder-utils.h | 1 |
5 files changed, 28 insertions, 21 deletions
diff --git a/builder/builder-cache.c b/builder/builder-cache.c index f919e42..877a33a 100644 --- a/builder/builder-cache.c +++ b/builder/builder-cache.c @@ -496,9 +496,7 @@ builder_cache_get_changes (BuilderCache *self, g_autoptr(GPtrArray) removed = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) added_paths = g_ptr_array_new_with_free_func (g_free); g_autoptr(GFile) current_root = NULL; - g_autoptr(GFile) current_files = NULL; g_autoptr(GFile) parent_root = NULL; - g_autoptr(GFile) parent_files = NULL; g_autoptr(GVariant) variant = NULL; g_autofree char *parent_commit = NULL; int i; @@ -506,8 +504,6 @@ builder_cache_get_changes (BuilderCache *self, if (!ostree_repo_read_commit (self->repo, self->last_parent, ¤t_root, NULL, NULL, error)) return NULL; - current_files = g_file_get_child (current_root, "files"); - if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_COMMIT, self->last_parent, &variant, NULL)) return NULL; @@ -517,12 +513,11 @@ builder_cache_get_changes (BuilderCache *self, { if (!ostree_repo_read_commit (self->repo, parent_commit, &parent_root, NULL, NULL, error)) return FALSE; - parent_files = g_file_get_child (parent_root, "files"); } if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_NONE, - parent_files, - current_files, + parent_root, + current_root, modified, removed, added, @@ -531,7 +526,7 @@ builder_cache_get_changes (BuilderCache *self, for (i = 0; i < added->len; i++) { - char *path = g_file_get_relative_path (current_files, g_ptr_array_index (added, i)); + char *path = g_file_get_relative_path (current_root, g_ptr_array_index (added, i)); g_ptr_array_add (added_paths, path); } diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index e4f46c4..ec207f5 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -962,7 +962,7 @@ builder_manifest_cleanup (BuilderManifest *self, for (i = n_keys - 1; i >= 0; i--) { g_autoptr(GError) my_error = NULL; - g_autoptr(GFile) f = g_file_resolve_relative_path (app_root, keys[i]); + g_autoptr(GFile) f = g_file_resolve_relative_path (app_dir, keys[i]); g_print ("Removing %s\n", keys[i]); if (!g_file_delete (f, NULL, &my_error)) { diff --git a/builder/builder-module.c b/builder/builder-module.c index 73998ec..d15ec5d 100644 --- a/builder/builder-module.c +++ b/builder/builder-module.c @@ -1056,6 +1056,7 @@ builder_module_set_changes (BuilderModule *self, static void collect_cleanup_for_path (const char **patterns, const char *path, + const char *add_prefix, GHashTable *to_remove_ht) { int i; @@ -1064,7 +1065,7 @@ collect_cleanup_for_path (const char **patterns, return; for (i = 0; patterns[i] != NULL; i++) - xdg_app_collect_matches_for_path_pattern (path, patterns[i], to_remove_ht); + xdg_app_collect_matches_for_path_pattern (path, patterns[i], add_prefix, to_remove_ht); } static gboolean @@ -1098,28 +1099,37 @@ builder_module_cleanup_collect (BuilderModule *self, for (i = 0; i < changed_files->len; i++) { const char *path = g_ptr_array_index (changed_files, i); + const char *unprefixed_path; + const char *prefix; - collect_cleanup_for_path (global_patterns, path, to_remove_ht); - collect_cleanup_for_path ((const char **)self->cleanup, path, to_remove_ht); + if (g_str_has_prefix (path, "files/")) + prefix = "files/"; + else if (g_str_has_prefix (path, "usr/")) + prefix = "usr/"; + else + continue; + + unprefixed_path = path + strlen (prefix); + + collect_cleanup_for_path (global_patterns, unprefixed_path, prefix, to_remove_ht); + collect_cleanup_for_path ((const char **)self->cleanup, unprefixed_path, prefix, to_remove_ht); - if (g_str_has_prefix (path, "lib/debug/") && - g_str_has_suffix (path, ".debug")) + if (g_str_has_prefix (unprefixed_path, "lib/debug/") && + g_str_has_suffix (unprefixed_path, ".debug")) { - g_autofree char *real_path = g_strdup (path); + g_autofree char *real_path = g_strdup (unprefixed_path); g_autofree char *real_parent = NULL; g_autofree char *parent = NULL; g_autofree char *debug_path = NULL; - debug_path = g_strdup (path + strlen ("lib/debug/")); + debug_path = g_strdup (unprefixed_path + strlen ("lib/debug/")); debug_path[strlen (debug_path) - strlen (".debug")] = 0; while (TRUE) { if (matches_cleanup_for_path (global_patterns, debug_path) || matches_cleanup_for_path ((const char **)self->cleanup, debug_path)) - { - g_hash_table_insert (to_remove_ht, g_strdup (real_path), GINT_TO_POINTER (1)); - } + g_hash_table_insert (to_remove_ht, g_strconcat (prefix, real_path, NULL), GINT_TO_POINTER (1)); real_parent = g_path_get_dirname (real_path); if (strcmp (real_parent, ".") == 0) diff --git a/builder/builder-utils.c b/builder/builder-utils.c index 39c9fb6..c156b10 100644 --- a/builder/builder-utils.c +++ b/builder/builder-utils.c @@ -75,6 +75,7 @@ inplace_basename (const char *path) void xdg_app_collect_matches_for_path_pattern (const char *path, const char *pattern, + const char *add_prefix, GHashTable *to_remove_ht) { const char *rest; @@ -83,7 +84,7 @@ xdg_app_collect_matches_for_path_pattern (const char *path, { rest = xdg_app_path_match_prefix (pattern, inplace_basename (path)); if (rest != NULL) - g_hash_table_insert (to_remove_ht, g_strdup (path), GINT_TO_POINTER (1)); + g_hash_table_insert (to_remove_ht, g_strconcat (add_prefix ? add_prefix : "", path, NULL), GINT_TO_POINTER (1)); } else { @@ -96,7 +97,7 @@ xdg_app_collect_matches_for_path_pattern (const char *path, { const char *slash; g_autofree char *prefix = g_strndup (path, rest-path); - g_hash_table_insert (to_remove_ht, g_steal_pointer (&prefix), GINT_TO_POINTER (1)); + g_hash_table_insert (to_remove_ht, g_strconcat (add_prefix ? add_prefix : "", prefix, NULL), GINT_TO_POINTER (1)); while (*rest == '/') rest++; if (*rest == 0) diff --git a/builder/builder-utils.h b/builder/builder-utils.h index ae3087e..446d993 100644 --- a/builder/builder-utils.h +++ b/builder/builder-utils.h @@ -41,6 +41,7 @@ gboolean xdg_app_matches_path_pattern (const char *path, const char *pattern); void xdg_app_collect_matches_for_path_pattern (const char *path, const char *pattern, + const char *add_prefix, GHashTable *to_remove_ht); G_END_DECLS |