From 5496c4e4eff6ac03079c4056d2597aa88121da73 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 12 Nov 2020 12:43:32 +0100 Subject: [PATCH] appstream: Pull the right branch if the remote has a subset configured --- common/flatpak-dir.c | 35 ++++++++++++++++++++++----- system-helper/flatpak-system-helper.c | 15 ++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index cbe0b95b..a39717d1 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -4276,6 +4276,7 @@ flatpak_dir_deploy_appstream (FlatpakDir *self, g_autofree char *filter_checksum = NULL; g_autoptr(GRegex) allow_refs = NULL; g_autoptr(GRegex) deny_refs = NULL; + g_autofree char *subset = NULL; /* Keep a shared repo lock to avoid prunes removing objects we're relying on * while we do the checkout. This could happen if the ref changes after we @@ -4309,14 +4310,20 @@ flatpak_dir_deploy_appstream (FlatpakDir *self, if (file_info != NULL) old_dir = g_file_info_get_symlink_target (file_info); - branch = g_strdup_printf ("appstream2/%s", arch); + subset = flatpak_dir_get_remote_subset (self, remote); + + if (subset) + branch = g_strdup_printf ("appstream2/%s-%s", subset, arch); + else + branch = g_strdup_printf ("appstream2/%s", arch); + if (!flatpak_repo_resolve_rev (self->repo, NULL, remote, branch, TRUE, &new_checksum, cancellable, error)) return FALSE; - if (new_checksum == NULL) + if (new_checksum == NULL && subset == NULL) { - /* Fall back to old branch */ + /* Fall back to old branch (only exist on non-subsets) */ g_clear_pointer (&branch, g_free); branch = g_strdup_printf ("appstream/%s", arch); if (!flatpak_repo_resolve_rev (self->repo, NULL, remote, branch, TRUE, @@ -4751,6 +4758,7 @@ flatpak_dir_update_appstream (FlatpakDir *self, g_autoptr(GError) second_error = NULL; g_autoptr(FlatpakRemoteState) state = NULL; g_autofree char *appstream_commit = NULL; + g_autofree char *subset = NULL; g_autoptr(GFile) appstream_sideload_path = NULL; const char *installation; gboolean is_oci; @@ -4761,8 +4769,18 @@ flatpak_dir_update_appstream (FlatpakDir *self, if (arch == NULL) arch = flatpak_get_arch (); - new_branch = g_strdup_printf ("appstream2/%s", arch); - old_branch = g_strdup_printf ("appstream/%s", arch); + subset = flatpak_dir_get_remote_subset (self, remote); + + if (subset) + { + new_branch = g_strdup_printf ("appstream2/%s-%s", subset, arch); + old_branch = g_strdup_printf ("appstream/%s-%s", subset, arch); + } + else + { + new_branch = g_strdup_printf ("appstream2/%s", arch); + old_branch = g_strdup_printf ("appstream/%s", arch); + } is_oci = flatpak_dir_get_remote_oci (self, remote); @@ -13218,11 +13236,16 @@ flatpak_dir_get_remote_subset (FlatpakDir *self, { GKeyFile *config = flatpak_dir_get_repo_config (self); g_autofree char *group = get_group (remote_name); + g_autofree char *subset = NULL; if (config == NULL) return NULL; - return g_key_file_get_string (config, group, "xa.subset", NULL); + subset = g_key_file_get_string (config, group, "xa.subset", NULL); + if (subset == NULL || *subset == 0) + return NULL; + + return g_steal_pointer (&subset); } gboolean diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index 8c0ae79e..60db02e6 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -767,6 +767,7 @@ handle_deploy_appstream (FlatpakSystemHelper *object, g_autoptr(GError) error = NULL; g_autofree char *new_branch = NULL; g_autofree char *old_branch = NULL; + g_autofree char *subset = NULL; gboolean is_oci; g_debug ("DeployAppstream %s %u %s %s %s", arg_repo_path, arg_flags, arg_origin, arg_arch, arg_installation); @@ -798,8 +799,18 @@ handle_deploy_appstream (FlatpakSystemHelper *object, is_oci = flatpak_dir_get_remote_oci (system, arg_origin); - new_branch = g_strdup_printf ("appstream2/%s", arg_arch); - old_branch = g_strdup_printf ("appstream/%s", arg_arch); + subset = flatpak_dir_get_remote_subset (system, arg_origin); + + if (subset) + { + new_branch = g_strdup_printf ("appstream2/%s-%s", subset, arg_arch); + old_branch = g_strdup_printf ("appstream/%s-%s", subset, arg_arch); + } + else + { + new_branch = g_strdup_printf ("appstream2/%s", arg_arch); + old_branch = g_strdup_printf ("appstream/%s", arg_arch); + } if (is_oci) {