forked from Mirrors/flatpak-builder
builder: Also apply cleanup to changes in usr
parent
7fb1309488
commit
f3bf30334c
|
@ -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) 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(GPtrArray) added_paths = g_ptr_array_new_with_free_func (g_free);
|
||||||
g_autoptr(GFile) current_root = NULL;
|
g_autoptr(GFile) current_root = NULL;
|
||||||
g_autoptr(GFile) current_files = NULL;
|
|
||||||
g_autoptr(GFile) parent_root = NULL;
|
g_autoptr(GFile) parent_root = NULL;
|
||||||
g_autoptr(GFile) parent_files = NULL;
|
|
||||||
g_autoptr(GVariant) variant = NULL;
|
g_autoptr(GVariant) variant = NULL;
|
||||||
g_autofree char *parent_commit = NULL;
|
g_autofree char *parent_commit = NULL;
|
||||||
int i;
|
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))
|
if (!ostree_repo_read_commit (self->repo, self->last_parent, ¤t_root, NULL, NULL, error))
|
||||||
return NULL;
|
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,
|
if (!ostree_repo_load_variant (self->repo, OSTREE_OBJECT_TYPE_COMMIT, self->last_parent,
|
||||||
&variant, NULL))
|
&variant, NULL))
|
||||||
return 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))
|
if (!ostree_repo_read_commit (self->repo, parent_commit, &parent_root, NULL, NULL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
parent_files = g_file_get_child (parent_root, "files");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_NONE,
|
if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_NONE,
|
||||||
parent_files,
|
parent_root,
|
||||||
current_files,
|
current_root,
|
||||||
modified,
|
modified,
|
||||||
removed,
|
removed,
|
||||||
added,
|
added,
|
||||||
|
@ -531,7 +526,7 @@ builder_cache_get_changes (BuilderCache *self,
|
||||||
|
|
||||||
for (i = 0; i < added->len; i++)
|
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);
|
g_ptr_array_add (added_paths, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -962,7 +962,7 @@ builder_manifest_cleanup (BuilderManifest *self,
|
||||||
for (i = n_keys - 1; i >= 0; i--)
|
for (i = n_keys - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) my_error = NULL;
|
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]);
|
g_print ("Removing %s\n", keys[i]);
|
||||||
if (!g_file_delete (f, NULL, &my_error))
|
if (!g_file_delete (f, NULL, &my_error))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1056,6 +1056,7 @@ builder_module_set_changes (BuilderModule *self,
|
||||||
static void
|
static void
|
||||||
collect_cleanup_for_path (const char **patterns,
|
collect_cleanup_for_path (const char **patterns,
|
||||||
const char *path,
|
const char *path,
|
||||||
|
const char *add_prefix,
|
||||||
GHashTable *to_remove_ht)
|
GHashTable *to_remove_ht)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -1064,7 +1065,7 @@ collect_cleanup_for_path (const char **patterns,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; patterns[i] != NULL; i++)
|
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
|
static gboolean
|
||||||
|
@ -1098,28 +1099,37 @@ builder_module_cleanup_collect (BuilderModule *self,
|
||||||
for (i = 0; i < changed_files->len; i++)
|
for (i = 0; i < changed_files->len; i++)
|
||||||
{
|
{
|
||||||
const char *path = g_ptr_array_index (changed_files, 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);
|
if (g_str_has_prefix (path, "files/"))
|
||||||
collect_cleanup_for_path ((const char **)self->cleanup, path, to_remove_ht);
|
prefix = "files/";
|
||||||
|
else if (g_str_has_prefix (path, "usr/"))
|
||||||
|
prefix = "usr/";
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
if (g_str_has_prefix (path, "lib/debug/") &&
|
unprefixed_path = path + strlen (prefix);
|
||||||
g_str_has_suffix (path, ".debug"))
|
|
||||||
|
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 *real_parent = NULL;
|
||||||
g_autofree char *parent = NULL;
|
g_autofree char *parent = NULL;
|
||||||
g_autofree char *debug_path = 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;
|
debug_path[strlen (debug_path) - strlen (".debug")] = 0;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (matches_cleanup_for_path (global_patterns, debug_path) ||
|
if (matches_cleanup_for_path (global_patterns, debug_path) ||
|
||||||
matches_cleanup_for_path ((const char **)self->cleanup, debug_path))
|
matches_cleanup_for_path ((const char **)self->cleanup, debug_path))
|
||||||
{
|
g_hash_table_insert (to_remove_ht, g_strconcat (prefix, real_path, NULL), GINT_TO_POINTER (1));
|
||||||
g_hash_table_insert (to_remove_ht, g_strdup (real_path), GINT_TO_POINTER (1));
|
|
||||||
}
|
|
||||||
|
|
||||||
real_parent = g_path_get_dirname (real_path);
|
real_parent = g_path_get_dirname (real_path);
|
||||||
if (strcmp (real_parent, ".") == 0)
|
if (strcmp (real_parent, ".") == 0)
|
||||||
|
|
|
@ -75,6 +75,7 @@ inplace_basename (const char *path)
|
||||||
void
|
void
|
||||||
xdg_app_collect_matches_for_path_pattern (const char *path,
|
xdg_app_collect_matches_for_path_pattern (const char *path,
|
||||||
const char *pattern,
|
const char *pattern,
|
||||||
|
const char *add_prefix,
|
||||||
GHashTable *to_remove_ht)
|
GHashTable *to_remove_ht)
|
||||||
{
|
{
|
||||||
const char *rest;
|
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));
|
rest = xdg_app_path_match_prefix (pattern, inplace_basename (path));
|
||||||
if (rest != NULL)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -96,7 +97,7 @@ xdg_app_collect_matches_for_path_pattern (const char *path,
|
||||||
{
|
{
|
||||||
const char *slash;
|
const char *slash;
|
||||||
g_autofree char *prefix = g_strndup (path, rest-path);
|
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 == '/')
|
while (*rest == '/')
|
||||||
rest++;
|
rest++;
|
||||||
if (*rest == 0)
|
if (*rest == 0)
|
||||||
|
|
|
@ -41,6 +41,7 @@ gboolean xdg_app_matches_path_pattern (const char *path,
|
||||||
const char *pattern);
|
const char *pattern);
|
||||||
void xdg_app_collect_matches_for_path_pattern (const char *path,
|
void xdg_app_collect_matches_for_path_pattern (const char *path,
|
||||||
const char *pattern,
|
const char *pattern,
|
||||||
|
const char *add_prefix,
|
||||||
GHashTable *to_remove_ht);
|
GHashTable *to_remove_ht);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue