builder: Also apply cleanup to changes in usr

tingping/wmclass
Alexander Larsson 2016-01-14 11:16:17 +01:00
parent 7fb1309488
commit f3bf30334c
5 changed files with 28 additions and 21 deletions

View File

@ -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, &current_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);
}

View File

@ -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))
{

View File

@ -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;
if (g_str_has_prefix (path, "lib/debug/") &&
g_str_has_suffix (path, ".debug"))
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 (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)

View File

@ -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)

View File

@ -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