diff options
author | Matthew Leeds <matthew.leeds@endlessm.com> | 2018-08-15 12:04:46 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-17 09:04:24 +0000 |
commit | 1fcffc8950ef81f2d0204eb35ebdade21e97f6d4 (patch) | |
tree | 637981b407f692e1abeab722db7dc5a6951a6211 | |
parent | 9616737c0ba09cc0e943b22f8d85f62f06bf210b (diff) | |
download | flatpak-1fcffc8950ef81f2d0204eb35ebdade21e97f6d4.tar.gz |
create-usb: Properly handle copying subpaths
Currently the create-usb command reads the subpaths listed in the
flatpak deploy data and just passes those to the ostree pull operation
to copy them to the USB. But this is not the correct way to handle them,
and leads to installs from the USB failing in the case where the locale
is partial (more specifically the install of the main ref succeeds but
the install of the locale extension doesn't).
So this commit changes create-usb to handle subpaths the same way
flatpak_dir_pull() and flatpak_dir_deploy() do, which is to copy the
/metadata path along with a subdirectory of /files for each listed
subpath. So in the case of an English partial locale, /metadata and
/files/en will be copied to the USB drive, and those are the subpaths
that will be pulled during the install (if the installing computer also
uses English).
Closes: #1972
Approved by: alexlarsson
-rw-r--r-- | app/flatpak-builtins-create-usb.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/app/flatpak-builtins-create-usb.c b/app/flatpak-builtins-create-usb.c index 2412390c..04c992a5 100644 --- a/app/flatpak-builtins-create-usb.c +++ b/app/flatpak-builtins-create-usb.c @@ -71,6 +71,24 @@ commit_and_subpaths_new (const char *commit, const char * const *subpaths) return c_s; } +static char ** +get_flatpak_subpaths_from_deploy_subpaths (const char * const *subpaths) +{ + g_autoptr(GPtrArray) resolved_subpaths = NULL; + gsize i; + + if (subpaths == NULL || subpaths[0] == NULL) + return NULL; + + resolved_subpaths = g_ptr_array_new_with_free_func (g_free); + g_ptr_array_add (resolved_subpaths, g_strdup ("/metadata")); + for (i = 0; subpaths[i] != NULL; i++) + g_ptr_array_add (resolved_subpaths, g_build_filename ("/files", subpaths[i], NULL)); + g_ptr_array_add (resolved_subpaths, NULL); + + return (char **)g_ptr_array_free (g_steal_pointer (&resolved_subpaths), FALSE); +} + /* Add related refs specified in the metadata of @ref to @all_refs, also * updating @all_collection_ids with any new collection IDs. A warning will be * printed for related refs that are not installed, and they won't be added to @@ -118,6 +136,7 @@ add_related (GHashTable *all_refs, g_autoptr(OstreeCollectionRef) ext_collection_ref = NULL; g_autofree char *ext_collection_id = NULL; g_autofree const char **ext_subpaths = NULL; + g_auto(GStrv) resolved_ext_subpaths = NULL; const char *ext_remote; const char *ext_commit = NULL; CommitAndSubpaths *c_s; @@ -148,7 +167,8 @@ add_related (GHashTable *all_refs, ext_commit = flatpak_deploy_data_get_commit (ext_deploy_data); ext_subpaths = flatpak_deploy_data_get_subpaths (ext_deploy_data); - c_s = commit_and_subpaths_new (ext_commit, ext_subpaths[0] == NULL ? NULL : ext_subpaths); + resolved_ext_subpaths = get_flatpak_subpaths_from_deploy_subpaths (ext_subpaths); + c_s = commit_and_subpaths_new (ext_commit, (const char * const *)resolved_ext_subpaths); g_hash_table_insert (all_collection_ids, g_strdup (ext_collection_id), g_strdup (ext_remote)); ext_collection_ref = ostree_collection_ref_new (ext_collection_id, ext->ref); @@ -180,6 +200,7 @@ add_runtime (GHashTable *all_refs, g_autofree char *runtime_remote = NULL; g_autofree char *runtime_collection_id = NULL; g_autofree const char **runtime_subpaths = NULL; + g_auto(GStrv) resolved_runtime_subpaths = NULL; const char *commit = NULL; const char *runtime_commit = NULL; CommitAndSubpaths *c_s; @@ -216,7 +237,8 @@ add_runtime (GHashTable *all_refs, runtime_commit = flatpak_deploy_data_get_commit (runtime_deploy_data); runtime_subpaths = flatpak_deploy_data_get_subpaths (runtime_deploy_data); - c_s = commit_and_subpaths_new (runtime_commit, runtime_subpaths[0] == NULL ? NULL : runtime_subpaths); + resolved_runtime_subpaths = get_flatpak_subpaths_from_deploy_subpaths (runtime_subpaths); + c_s = commit_and_subpaths_new (runtime_commit, (const char * const *)resolved_runtime_subpaths); g_hash_table_insert (all_collection_ids, g_strdup (runtime_collection_id), g_strdup (runtime_remote)); runtime_collection_ref = ostree_collection_ref_new (runtime_collection_id, runtime_ref); |