diff --git a/app/flatpak-builtins-install.c b/app/flatpak-builtins-install.c index a4340c5ec..23a3b1c69 100644 --- a/app/flatpak-builtins-install.c +++ b/app/flatpak-builtins-install.c @@ -181,7 +181,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro if (!flatpak_dir_install (dir, opt_no_pull, opt_no_deploy, - ref, repository, opt_subpaths, + ref, repository, (const char **)opt_subpaths, NULL, cancellable, error)) return FALSE; diff --git a/app/flatpak-builtins-update.c b/app/flatpak-builtins-update.c index 33e6c4c03..e89073d58 100644 --- a/app/flatpak-builtins-update.c +++ b/app/flatpak-builtins-update.c @@ -73,7 +73,6 @@ do_update (FlatpakDir * dir, GError **error) { g_autofree char *repository = NULL; - g_auto(GStrv) subpaths = NULL; repository = flatpak_dir_get_origin (dir, ref, cancellable, error); if (repository == NULL) @@ -82,14 +81,10 @@ do_update (FlatpakDir * dir, if (flatpak_dir_get_remote_disabled (dir, repository)) g_print ("Not updating %s due to disabled remote %s\n", ref, repository); - subpaths = flatpak_dir_get_subpaths (dir, ref, cancellable, error); - if (subpaths == NULL) - return FALSE; - if (!flatpak_dir_update (dir, opt_no_pull, opt_no_deploy, - ref, repository, opt_commit, opt_subpaths, + ref, repository, opt_commit, (const char **)opt_subpaths, NULL, cancellable, error)) return FALSE; diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index a0302afbd..9a97a3419 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -1235,7 +1235,7 @@ gboolean flatpak_dir_pull (FlatpakDir *self, const char *repository, const char *ref, - char **subpaths, + const char **subpaths, OstreeRepo *repo, OstreeRepoPullFlags flags, OstreeAsyncProgress *progress, @@ -1384,7 +1384,7 @@ flatpak_dir_pull_untrusted_local (FlatpakDir *self, const char *src_path, const char *remote_name, const char *ref, - char **subpaths, + const char **subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error) @@ -2818,7 +2818,7 @@ gboolean flatpak_dir_deploy_install (FlatpakDir *self, const char *ref, const char *origin, - char **subpaths, + const char **subpaths, GCancellable *cancellable, GError **error) { @@ -2892,6 +2892,7 @@ gboolean flatpak_dir_deploy_update (FlatpakDir *self, const char *ref, const char *checksum_or_latest, + const char **opt_subpaths, GCancellable *cancellable, GError **error) { @@ -2918,7 +2919,7 @@ flatpak_dir_deploy_update (FlatpakDir *self, old_origin, ref, checksum_or_latest, - old_subpaths, + opt_subpaths ? opt_subpaths : old_subpaths, old_deploy_data, cancellable, &my_error)) { @@ -3027,7 +3028,7 @@ flatpak_dir_install (FlatpakDir *self, gboolean no_deploy, const char *ref, const char *remote_name, - char **subpaths, + const char **opt_subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error) @@ -3036,7 +3037,8 @@ flatpak_dir_install (FlatpakDir *self, { g_autoptr(OstreeRepo) child_repo = NULL; g_auto(GLnxLockFile) child_repo_lock = GLNX_LOCK_FILE_INIT; - char *empty_subpaths[] = {NULL}; + const char *empty_subpaths[] = {NULL}; + const char **subpaths; g_autofree char *child_repo_path = NULL; FlatpakSystemHelper *system_helper; FlatpakHelperDeployFlags helper_flags = 0; @@ -3045,6 +3047,11 @@ flatpak_dir_install (FlatpakDir *self, system_helper = flatpak_dir_get_system_helper (self); g_assert (system_helper != NULL); + if (opt_subpaths) + subpaths = opt_subpaths; + else + subpaths = empty_subpaths; + if (!ostree_repo_remote_get_url (self->repo, remote_name, &url, @@ -3086,7 +3093,7 @@ flatpak_dir_install (FlatpakDir *self, if (!flatpak_system_helper_call_deploy_sync (system_helper, child_repo_path ? child_repo_path : "", helper_flags, ref, remote_name, - (const char * const *) (subpaths ? subpaths : empty_subpaths), + (const char * const *) subpaths, cancellable, error)) return FALSE; @@ -3099,14 +3106,14 @@ flatpak_dir_install (FlatpakDir *self, if (!no_pull) { - if (!flatpak_dir_pull (self, remote_name, ref, subpaths, NULL, OSTREE_REPO_PULL_FLAGS_NONE, progress, + if (!flatpak_dir_pull (self, remote_name, ref, opt_subpaths, NULL, OSTREE_REPO_PULL_FLAGS_NONE, progress, cancellable, error)) return FALSE; } if (!no_deploy) { - if (!flatpak_dir_deploy_install (self, ref, remote_name, subpaths, + if (!flatpak_dir_deploy_install (self, ref, remote_name, opt_subpaths, cancellable, error)) return FALSE; } @@ -3237,16 +3244,37 @@ flatpak_dir_update (FlatpakDir *self, const char *ref, const char *remote_name, const char *checksum_or_latest, - char **subpaths, + const char **opt_subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error) { + g_autoptr(GVariant) deploy_data = NULL; + g_autofree const char **old_subpaths = NULL; + const char *empty_subpaths[] = {NULL}; + const char **subpaths; + + deploy_data = flatpak_dir_get_deploy_data (self, ref, + cancellable, NULL); + + if (opt_subpaths) + { + subpaths = opt_subpaths; + } + else if (deploy_data != NULL) + { + old_subpaths = flatpak_deploy_data_get_subpaths (deploy_data); + subpaths = old_subpaths; + } + else + { + subpaths = empty_subpaths; + } + if (flatpak_dir_use_system_helper (self)) { g_autoptr(OstreeRepo) child_repo = NULL; g_auto(GLnxLockFile) child_repo_lock = GLNX_LOCK_FILE_INIT; - char *empty_subpaths[] = {NULL}; g_autofree char *latest_checksum = NULL; g_autofree char *active_checksum = NULL; FlatpakSystemHelper *system_helper; @@ -3310,7 +3338,7 @@ flatpak_dir_update (FlatpakDir *self, if (!flatpak_system_helper_call_deploy_sync (system_helper, child_repo_path ? child_repo_path : "", helper_flags, ref, remote_name, - (const char * const *) empty_subpaths, + subpaths, cancellable, error)) return FALSE; @@ -3322,7 +3350,6 @@ flatpak_dir_update (FlatpakDir *self, return TRUE; } - if (!no_pull) { if (!flatpak_dir_pull (self, remote_name, ref, subpaths, @@ -3333,7 +3360,7 @@ flatpak_dir_update (FlatpakDir *self, if (!no_deploy) { - if (!flatpak_dir_deploy_update (self, ref, checksum_or_latest, + if (!flatpak_dir_deploy_update (self, ref, checksum_or_latest, subpaths, cancellable, error)) return FALSE; } @@ -3820,7 +3847,6 @@ out: return ret; } - gboolean flatpak_dir_prune (FlatpakDir *self, GCancellable *cancellable, diff --git a/common/flatpak-dir.h b/common/flatpak-dir.h index 46d3c3609..703fee8e4 100644 --- a/common/flatpak-dir.h +++ b/common/flatpak-dir.h @@ -208,7 +208,7 @@ gboolean flatpak_dir_update_appstream (FlatpakDir *self, gboolean flatpak_dir_pull (FlatpakDir *self, const char *repository, const char *ref, - char **subpaths, + const char **subpaths, OstreeRepo *repo, OstreeRepoPullFlags flags, OstreeAsyncProgress *progress, @@ -218,7 +218,7 @@ gboolean flatpak_dir_pull_untrusted_local (FlatpakDir *self, const char *src_path, const char *remote_name, const char *ref, - char **subpaths, + const char **subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error); @@ -277,12 +277,13 @@ gboolean flatpak_dir_deploy (FlatpakDir *self, gboolean flatpak_dir_deploy_update (FlatpakDir *self, const char *ref, const char *checksum, + const char **opt_subpaths, GCancellable *cancellable, GError **error); gboolean flatpak_dir_deploy_install (FlatpakDir *self, const char *ref, const char *origin, - char **subpaths, + const char **subpaths, GCancellable *cancellable, GError **error); gboolean flatpak_dir_install (FlatpakDir *self, @@ -290,7 +291,7 @@ gboolean flatpak_dir_install (FlatpakDir *self, gboolean no_deploy, const char *ref, const char *remote_name, - char **subpaths, + const char **subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error); @@ -306,7 +307,7 @@ gboolean flatpak_dir_update (FlatpakDir *self, const char *ref, const char *remote_name, const char *checksum_or_latest, - char **subpaths, + const char **opt_subpaths, OstreeAsyncProgress *progress, GCancellable *cancellable, GError **error); diff --git a/lib/flatpak-installation.c b/lib/flatpak-installation.c index 17702ac71..19d4f7224 100644 --- a/lib/flatpak-installation.c +++ b/lib/flatpak-installation.c @@ -1119,7 +1119,6 @@ flatpak_installation_update (FlatpakInstallation *self, g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; g_autofree char *remote_name = NULL; FlatpakInstalledRef *result = NULL; - g_auto(GStrv) subpaths = NULL; ref = flatpak_compose_ref (kind == FLATPAK_REF_KIND_APP, name, branch, arch, error); if (ref == NULL) @@ -1138,10 +1137,6 @@ flatpak_installation_update (FlatpakInstallation *self, if (remote_name == NULL) return NULL; - subpaths = flatpak_dir_get_subpaths (dir, ref, cancellable, error); - if (subpaths == NULL) - return FALSE; - /* Pull, prune, etc are not threadsafe, so we work on a copy */ dir_clone = flatpak_dir_clone (dir); @@ -1159,7 +1154,7 @@ flatpak_installation_update (FlatpakInstallation *self, if (!flatpak_dir_update (dir_clone, (flags & FLATPAK_UPDATE_FLAGS_NO_PULL) != 0, (flags & FLATPAK_UPDATE_FLAGS_NO_DEPLOY) != 0, - ref, remote_name, NULL, subpaths, + ref, remote_name, NULL, NULL, ostree_progress, cancellable, error)) goto out; diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index 0acbb27f6..726d45b54 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -208,7 +208,7 @@ handle_deploy (FlatpakSystemHelper *object, if (!flatpak_dir_pull_untrusted_local (system, arg_repo_path, arg_origin, arg_ref, - (char **) arg_subpaths, + (const char **) arg_subpaths, NULL, NULL, &error)) { @@ -242,7 +242,7 @@ handle_deploy (FlatpakSystemHelper *object, main_context = g_main_context_new (); g_main_context_push_thread_default (main_context); - if (!flatpak_dir_pull (system, arg_origin, arg_ref, (char **)arg_subpaths, NULL, + if (!flatpak_dir_pull (system, arg_origin, arg_ref, (const char **)arg_subpaths, NULL, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, NULL, NULL, &error)) { @@ -258,9 +258,8 @@ handle_deploy (FlatpakSystemHelper *object, { if (is_update) { - /* TODO: This doesn't support a custom subpath */ if (!flatpak_dir_deploy_update (system, arg_ref, - NULL, NULL, &error)) + NULL, (const char **)arg_subpaths, NULL, &error)) { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Error deploying: %s", error->message); @@ -270,7 +269,7 @@ handle_deploy (FlatpakSystemHelper *object, else { if (!flatpak_dir_deploy_install (system, arg_ref, arg_origin, - (char **) arg_subpaths, + (const char **) arg_subpaths, NULL, &error)) { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,