Merge pull request #3476 from alexlarsson/drop-p2p

Drop support p2p in favour of simpler side-loading scheme
This commit is contained in:
Alexander Larsson
2020-03-25 09:54:41 +01:00
committed by GitHub
57 changed files with 1898 additions and 3019 deletions

View File

@@ -41,6 +41,7 @@ static char *opt_icon;
static char *opt_redirect_url;
static char *opt_default_branch;
static char *opt_collection_id = NULL;
static gboolean opt_deploy_sideload_collection_id = FALSE;
static gboolean opt_deploy_collection_id = FALSE;
static char **opt_gpg_import;
static char *opt_generate_delta_from;
@@ -68,6 +69,7 @@ static GOptionEntry options[] = {
{ "icon", 0, 0, G_OPTION_ARG_STRING, &opt_icon, N_("URL for an icon for this repository"), N_("URL") },
{ "default-branch", 0, 0, G_OPTION_ARG_STRING, &opt_default_branch, N_("Default branch to use for this repository"), N_("BRANCH") },
{ "collection-id", 0, 0, G_OPTION_ARG_STRING, &opt_collection_id, N_("Collection ID"), N_("COLLECTION-ID") },
{ "deploy-sideload-collection-id", 0, 0, G_OPTION_ARG_NONE, &opt_deploy_sideload_collection_id, N_("Permanently deploy collection ID to client remote configurations, only for sideload support"), NULL },
{ "deploy-collection-id", 0, 0, G_OPTION_ARG_NONE, &opt_deploy_collection_id, N_("Permanently deploy collection ID to client remote configurations"), NULL },
{ "authenticator-name", 0, 0, G_OPTION_ARG_STRING, &opt_authenticator_name, N_("Name of authenticator for this repository"), N_("NAME") },
{ "authenticator-install", 0, 0, G_OPTION_ARG_NONE, &opt_authenticator_install, N_("Autoinstall authenticator for this repository"), NULL },
@@ -577,6 +579,10 @@ flatpak_builtin_build_update_repo (int argc, char **argv,
return FALSE;
}
if (opt_deploy_sideload_collection_id &&
!flatpak_repo_set_deploy_sideload_collection_id (repo, TRUE, error))
return FALSE;
if (opt_deploy_collection_id &&
!flatpak_repo_set_deploy_collection_id (repo, TRUE, error))
return FALSE;

View File

@@ -199,6 +199,18 @@ get_lang_default (FlatpakDir *dir)
return g_strjoinv (";", langs);
}
static char *
parse_string (const char *value, GError **error)
{
return g_strdup (value);
}
static char *
print_string (const char *value)
{
return g_strdup (value);
}
typedef struct
{
const char *name;
@@ -210,6 +222,7 @@ typedef struct
ConfigKey keys[] = {
{ "languages", parse_lang, print_lang, get_lang_default },
{ "extra-languages", parse_locale, print_locale, NULL },
{ "sideload-repos", parse_string, print_string, NULL },
};
static ConfigKey *

View File

@@ -38,12 +38,14 @@ static char *opt_arch;
static char *opt_destination_repo;
static gboolean opt_runtime;
static gboolean opt_app;
static gboolean opt_allow_partial;
static GOptionEntry options[] = {
{ "app", 0, 0, G_OPTION_ARG_NONE, &opt_app, N_("Look for app with the specified name"), NULL },
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, N_("Arch to copy"), N_("ARCH") },
{ "destination-repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_destination_repo, "Use custom repository directory within the mount", N_("DEST") },
{ "runtime", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, N_("Look for runtime with the specified name"), NULL },
{ "allow-partial", 0, 0, G_OPTION_ARG_NONE, &opt_allow_partial, N_("Allow partial commits in the created repo"), NULL },
{ NULL }
};
@@ -120,6 +122,9 @@ add_related (GHashTable *all_refs,
if (deploy_data == NULL)
return FALSE;
if (flatpak_deploy_data_has_subpaths (deploy_data) && !opt_allow_partial)
return flatpak_fail (error, _("Related ref '%s' is only partially installed"), ref);
commit = flatpak_deploy_data_get_commit (deploy_data);
deploy = flatpak_dir_load_deployed (dir, ref, commit, cancellable, error);
@@ -154,6 +159,13 @@ add_related (GHashTable *all_refs,
continue;
}
if (flatpak_deploy_data_has_subpaths (ext_deploy_data))
{
g_printerr (_("Warning: Omitting related ref %s because it is partially installed.\n"),
ext->ref);
continue;
}
ext_remote = flatpak_deploy_data_get_origin (ext_deploy_data);
if (ext_remote == NULL)
return FALSE;
@@ -628,6 +640,11 @@ flatpak_builtin_create_usb (int argc, char **argv, GCancellable *cancellable, GE
deploy_data = flatpak_dir_get_deploy_data (dir, installed_ref, FLATPAK_DEPLOY_VERSION_ANY, cancellable, error);
if (deploy_data == NULL)
return FALSE;
if (flatpak_deploy_data_has_subpaths (deploy_data) && !opt_allow_partial)
return flatpak_fail (error,
_("Ref '%s' is only partially installed"), installed_ref);
commit = flatpak_deploy_data_get_commit (deploy_data);
c_s = commit_and_subpaths_new (commit, NULL);
@@ -655,6 +672,8 @@ flatpak_builtin_create_usb (int argc, char **argv, GCancellable *cancellable, GE
g_autoptr(OstreeCollectionRef) appstream2_collection_ref = NULL;
g_autoptr(FlatpakRemoteState) state = NULL;
g_autoptr(GError) local_error = NULL;
g_autofree char *appstream_refspec = NULL;
g_autofree char *appstream2_refspec = NULL;
g_autofree char *appstream_ref = NULL;
g_autofree char *appstream2_ref = NULL;
const char **remote_arches;
@@ -669,10 +688,13 @@ flatpak_builtin_create_usb (int argc, char **argv, GCancellable *cancellable, GE
g_clear_error (&local_error);
}
/* Add the ostree-metadata ref to the list */
/* Add the ostree-metadata ref to the list if available */
metadata_collection_ref = ostree_collection_ref_new (collection_id, OSTREE_REPO_METADATA_REF);
g_hash_table_insert (all_refs, g_steal_pointer (&metadata_collection_ref),
commit_and_subpaths_new (NULL, NULL));
if (ostree_repo_resolve_collection_ref (src_repo, metadata_collection_ref, FALSE,
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
NULL, NULL, NULL))
g_hash_table_insert (all_refs, g_steal_pointer (&metadata_collection_ref),
commit_and_subpaths_new (NULL, NULL));
/* Add whatever appstream data is available for each arch */
remote_arches = g_hash_table_lookup (remote_arch_map, remote_name);
@@ -682,6 +704,8 @@ flatpak_builtin_create_usb (int argc, char **argv, GCancellable *cancellable, GE
g_autoptr(GPtrArray) dirs = NULL;
g_autoptr(GError) appstream_error = NULL;
g_autoptr(GError) appstream2_error = NULL;
g_autofree char *commit = NULL;
g_autofree char *commit2 = NULL;
/* Try to update the appstream data, but don't fail on error because we
* want this to work offline. */
@@ -697,25 +721,25 @@ flatpak_builtin_create_usb (int argc, char **argv, GCancellable *cancellable, GE
/* Copy the appstream data if it exists. It's optional because without it
* the USB will still be useful to the flatpak CLI even if GNOME Software
* wouldn't display the contents. */
appstream_refspec = g_strdup_printf ("%s:appstream/%s", remote_name, current_arch);
appstream_ref = g_strdup_printf ("appstream/%s", current_arch);
appstream_collection_ref = ostree_collection_ref_new (collection_id, appstream_ref);
if (ostree_repo_resolve_collection_ref (src_repo, appstream_collection_ref, FALSE,
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
NULL, cancellable, &appstream_error))
if (ostree_repo_resolve_rev (src_repo, appstream_refspec, FALSE,
&commit, &appstream_error))
{
g_hash_table_insert (all_refs, g_steal_pointer (&appstream_collection_ref),
commit_and_subpaths_new (NULL, NULL));
commit_and_subpaths_new (commit, NULL));
}
/* Copy the appstream2 data if it exists. */
appstream2_refspec = g_strdup_printf ("%s:appstream2/%s", remote_name, current_arch);
appstream2_ref = g_strdup_printf ("appstream2/%s", current_arch);
appstream2_collection_ref = ostree_collection_ref_new (collection_id, appstream2_ref);
if (ostree_repo_resolve_collection_ref (src_repo, appstream2_collection_ref, FALSE,
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
NULL, cancellable, &appstream2_error))
if (ostree_repo_resolve_rev (src_repo, appstream2_refspec, FALSE,
&commit2, &appstream2_error))
{
g_hash_table_insert (all_refs, g_steal_pointer (&appstream2_collection_ref),
commit_and_subpaths_new (NULL, NULL));
commit_and_subpaths_new (commit2, NULL));
}
else
{

View File

@@ -42,6 +42,7 @@
static char *opt_arch;
static char **opt_gpg_file;
static char **opt_subpaths;
static char **opt_sideload_repos;
static gboolean opt_no_pull;
static gboolean opt_no_deploy;
static gboolean opt_no_related;
@@ -73,6 +74,7 @@ static GOptionEntry options[] = {
{ "reinstall", 0, 0, G_OPTION_ARG_NONE, &opt_reinstall, N_("Uninstall first if already installed"), NULL },
{ "noninteractive", 0, 0, G_OPTION_ARG_NONE, &opt_noninteractive, N_("Produce minimal output and don't ask questions"), NULL },
{ "or-update", 0, 0, G_OPTION_ARG_NONE, &opt_or_update, N_("Update install if already installed"), NULL },
{ "sideload-repo", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_sideload_repos, N_("Use this local repo for sideloads"), N_("PATH") },
{ NULL }
};
@@ -165,6 +167,9 @@ install_bundle (FlatpakDir *dir,
flatpak_transaction_set_disable_related (transaction, opt_no_related);
flatpak_transaction_set_reinstall (transaction, opt_reinstall);
for (int i = 0; opt_sideload_repos != NULL && opt_sideload_repos[i] != NULL; i++)
flatpak_transaction_add_sideload_repo (transaction, opt_sideload_repos[i]);
if (!flatpak_transaction_add_install_bundle (transaction, file, gpg_data, error))
return FALSE;
@@ -239,6 +244,9 @@ install_from (FlatpakDir *dir,
flatpak_transaction_set_reinstall (transaction, opt_reinstall);
flatpak_transaction_set_default_arch (transaction, opt_arch);
for (int i = 0; opt_sideload_repos != NULL && opt_sideload_repos[i] != NULL; i++)
flatpak_transaction_add_sideload_repo (transaction, opt_sideload_repos[i]);
if (!flatpak_transaction_add_install_flatpakref (transaction, file_data, error))
return FALSE;
@@ -392,7 +400,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
matched_kinds, FIND_MATCHING_REFS_FLAGS_FUZZY,
cancellable, &local_error);
else
refs = flatpak_dir_find_remote_refs (this_dir, this_remote, id, branch, this_default_branch, arch,
refs = flatpak_dir_find_remote_refs (this_dir, this_remote, (const char **)opt_sideload_repos, id, branch, this_default_branch, arch,
flatpak_get_default_arch (),
matched_kinds, FIND_MATCHING_REFS_FLAGS_FUZZY,
cancellable, &local_error);
@@ -459,6 +467,9 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
flatpak_transaction_set_disable_related (transaction, opt_no_related);
flatpak_transaction_set_reinstall (transaction, opt_reinstall);
for (i = 0; opt_sideload_repos != NULL && opt_sideload_repos[i] != NULL; i++)
flatpak_transaction_add_sideload_repo (transaction, opt_sideload_repos[i]);
for (i = 0; i < n_prefs; i++)
{
const char *pref = prefs[i];
@@ -484,7 +495,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
matched_kinds, FIND_MATCHING_REFS_FLAGS_FUZZY,
cancellable, error);
else
refs = flatpak_dir_find_remote_refs (dir, remote, id, branch, default_branch, arch,
refs = flatpak_dir_find_remote_refs (dir, remote, (const char **)opt_sideload_repos, id, branch, default_branch, arch,
flatpak_get_default_arch (),
matched_kinds, FIND_MATCHING_REFS_FLAGS_FUZZY,
cancellable, error);

View File

@@ -115,10 +115,7 @@ get_config_from_opts (GKeyFile *config,
}
if (opt_collection_id)
{
g_key_file_set_string (config, group, "collection-id", opt_collection_id);
g_key_file_set_boolean (config, group, "gpg-verify-summary", FALSE);
}
g_key_file_set_string (config, group, "collection-id", opt_collection_id);
if (opt_title)
{

View File

@@ -47,6 +47,7 @@ static gboolean opt_log;
static gboolean opt_show_runtime;
static gboolean opt_show_sdk;
static gboolean opt_cached;
static gboolean opt_sideloaded;
static GOptionEntry options[] = {
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, N_("Arch to install for"), N_("ARCH") },
@@ -61,6 +62,7 @@ static GOptionEntry options[] = {
{ "show-runtime", 0, 0, G_OPTION_ARG_NONE, &opt_show_runtime, N_("Show runtime"), NULL },
{ "show-sdk", 0, 0, G_OPTION_ARG_NONE, &opt_show_sdk, N_("Show sdk"), NULL },
{ "cached", 0, 0, G_OPTION_ARG_NONE, &opt_cached, N_("Use local caches even if they are stale"), NULL },
{ "sideloaded", 0, 0, G_OPTION_ARG_NONE, &opt_sideloaded, N_("Only list refs available as sideloads"), NULL },
{ NULL }
};
@@ -135,12 +137,12 @@ flatpak_builtin_remote_info (int argc, char **argv, GCancellable *cancellable, G
&matched_kinds, &id, &arch, &branch, error))
return FALSE;
ref = flatpak_dir_find_remote_ref (preferred_dir, remote, id, branch, default_branch, arch,
ref = flatpak_dir_find_remote_ref (preferred_dir, remote, NULL, id, branch, default_branch, arch,
matched_kinds, &kind, cancellable, error);
if (ref == NULL)
return FALSE;
state = get_remote_state (preferred_dir, remote, opt_cached, cancellable, error);
state = get_remote_state (preferred_dir, remote, opt_cached, opt_sideloaded, cancellable, error);
if (state == NULL)
return FALSE;
@@ -150,7 +152,7 @@ flatpak_builtin_remote_info (int argc, char **argv, GCancellable *cancellable, G
commit = g_strdup (opt_commit);
else
{
flatpak_remote_state_lookup_ref (state, ref, &commit, NULL, NULL, error);
flatpak_remote_state_lookup_ref (state, ref, &commit, NULL, NULL, NULL, error);
if (commit == NULL)
{
if (error != NULL && *error == NULL)

View File

@@ -41,6 +41,7 @@ static gboolean opt_app;
static gboolean opt_all;
static gboolean opt_only_updates;
static gboolean opt_cached;
static gboolean opt_sideloaded;
static char *opt_arch;
static char *opt_app_runtime;
static const char **opt_cols;
@@ -55,6 +56,7 @@ static GOptionEntry options[] = {
{ "app-runtime", 0, 0, G_OPTION_ARG_STRING, &opt_app_runtime, N_("List all applications using RUNTIME"), N_("RUNTIME") },
{ "columns", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_cols, N_("What information to show"), N_("FIELD,…") },
{ "cached", 0, 0, G_OPTION_ARG_NONE, &opt_cached, N_("Use local caches even if they are stale"), NULL },
{ "sideloaded", 0, 0, G_OPTION_ARG_NONE, &opt_sideloaded, N_("Only list refs available as sideloads"), NULL },
{ NULL }
};
@@ -161,8 +163,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
g_hash_table_iter_init (&iter, refs);
while (g_hash_table_iter_next (&iter, &key, &value))
{
FlatpakCollectionRef *coll_ref = key;
char *ref = coll_ref->ref_name;
char *ref = key;
char *partial_ref;
const char *slash = strchr (ref, '/');
@@ -179,8 +180,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
g_hash_table_iter_init (&iter, refs);
while (g_hash_table_iter_next (&iter, &key, &value))
{
FlatpakCollectionRef *coll_ref = key;
const char *ref = coll_ref->ref_name;
const char *ref = key;
const char *checksum = value;
g_auto(GStrv) parts = NULL;
@@ -234,8 +234,7 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
strcmp (arches[0], parts[2]) != 0)
{
g_autofree char *alt_arch_ref = g_strconcat (parts[0], "/", parts[1], "/", arches[0], "/", parts[3], NULL);
g_autoptr(FlatpakCollectionRef) alt_arch_coll_ref = flatpak_collection_ref_new (coll_ref->collection_id, alt_arch_ref);
if (g_hash_table_lookup (refs, alt_arch_coll_ref))
if (g_hash_table_lookup (refs, alt_arch_ref))
continue;
}
@@ -283,12 +282,12 @@ ls_remote (GHashTable *refs_hash, const char **arches, const char *app_runtime,
if (need_cache_data)
{
const char *metadata = NULL;
g_autofree char *metadata = NULL;
g_autoptr(GKeyFile) metakey = NULL;
if (!flatpak_remote_state_lookup_cache (state, ref,
&download_size, &installed_size, &metadata,
NULL, error))
if (!flatpak_remote_state_load_data (state, ref,
&download_size, &installed_size, &metadata,
error))
return FALSE;
metakey = g_key_file_new ();
@@ -442,7 +441,7 @@ flatpak_builtin_remote_ls (int argc, char **argv, GCancellable *cancellable, GEr
return FALSE;
}
state = get_remote_state (preferred_dir, argv[1], opt_cached, cancellable, error);
state = get_remote_state (preferred_dir, argv[1], opt_cached, opt_sideloaded, cancellable, error);
if (state == NULL)
return FALSE;
@@ -477,7 +476,7 @@ flatpak_builtin_remote_ls (int argc, char **argv, GCancellable *cancellable, GEr
if (flatpak_dir_get_remote_disabled (dir, remote_name))
continue;
state = get_remote_state (dir, remote_name, opt_cached,
state = get_remote_state (dir, remote_name, opt_cached, opt_sideloaded,
cancellable, error);
if (state == NULL)
return FALSE;

View File

@@ -131,7 +131,6 @@ get_config_from_opts (FlatpakDir *dir, const char *remote_name, gboolean *change
if (opt_collection_id)
{
g_key_file_set_string (config, group, "collection-id", opt_collection_id);
g_key_file_set_boolean (config, group, "gpg-verify-summary", FALSE);
*changed = TRUE;
}

View File

@@ -39,6 +39,7 @@
static char *opt_arch;
static char *opt_commit;
static char **opt_subpaths;
static char **opt_sideload_repos;
static gboolean opt_force_remove;
static gboolean opt_no_pull;
static gboolean opt_no_deploy;
@@ -66,6 +67,7 @@ static GOptionEntry options[] = {
{ "subpath", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_subpaths, N_("Only update this subpath"), N_("PATH") },
{ "assumeyes", 'y', 0, G_OPTION_ARG_NONE, &opt_yes, N_("Automatically answer yes for all questions"), NULL },
{ "noninteractive", 0, 0, G_OPTION_ARG_NONE, &opt_noninteractive, N_("Produce minimal output and don't ask questions"), NULL },
{ "sideload-repo", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_sideload_repos, N_("Use this local repo for sideloads"), N_("PATH") },
{ NULL }
};
@@ -141,6 +143,9 @@ flatpak_builtin_update (int argc,
flatpak_transaction_set_disable_dependencies (transaction, opt_no_deps);
flatpak_transaction_set_disable_related (transaction, opt_no_related);
for (int i = 0; opt_sideload_repos != NULL && opt_sideload_repos[i] != NULL; i++)
flatpak_transaction_add_sideload_repo (transaction, opt_sideload_repos[i]);
g_ptr_array_insert (transactions, 0, transaction);
}

View File

@@ -1349,23 +1349,33 @@ FlatpakRemoteState *
get_remote_state (FlatpakDir *dir,
const char *remote,
gboolean cached,
gboolean sideloaded,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GError) local_error = NULL;
FlatpakRemoteState *state;
FlatpakRemoteState *state = NULL;
state = flatpak_dir_get_remote_state (dir, remote, cached, cancellable, &local_error);
if (state == NULL && g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_CACHED))
if (sideloaded)
{
g_clear_error (&local_error);
state = flatpak_dir_get_remote_state (dir, remote, FALSE, cancellable, &local_error);
state = flatpak_dir_get_remote_state_local_only (dir, remote, cancellable, error);
if (state == NULL)
return NULL;
}
if (state == NULL)
else
{
g_propagate_error (error, g_steal_pointer (&local_error));
return NULL;
state = flatpak_dir_get_remote_state (dir, remote, cached, cancellable, &local_error);
if (state == NULL && g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_CACHED))
{
g_clear_error (&local_error);
state = flatpak_dir_get_remote_state (dir, remote, FALSE, cancellable, &local_error);
}
if (state == NULL)
{
g_propagate_error (error, g_steal_pointer (&local_error));
return NULL;
}
}
return state;

View File

@@ -176,6 +176,7 @@ void print_wrapped (int columns,
FlatpakRemoteState * get_remote_state (FlatpakDir *dir,
const char *remote,
gboolean cached,
gboolean sideloaded,
GCancellable *cancellable,
GError **error);

View File

@@ -194,7 +194,7 @@ flatpak_complete_partial_ref (FlatpakCompletion *completion,
if (remote)
{
refs = flatpak_dir_find_remote_refs (dir, completion->argv[1],
refs = flatpak_dir_find_remote_refs (dir, completion->argv[1], NULL,
(element > 1) ? id : NULL,
(element > 3) ? branch : NULL,
NULL, /* default branch */

View File

@@ -33,8 +33,9 @@
*
* Version 1 added appdata-name/summary/version/license
* Version 2 added extension-of/appdata-content-rating
* Version 3 added timestamp
*/
#define FLATPAK_DEPLOY_VERSION_CURRENT 2
#define FLATPAK_DEPLOY_VERSION_CURRENT 3
#define FLATPAK_DEPLOY_VERSION_ANY 0
#define FLATPAK_TYPE_DIR flatpak_dir_get_type ()
@@ -93,7 +94,6 @@ GType flatpak_deploy_get_type (void);
typedef struct
{
char *collection_id; /* (nullable) */
char *ref;
char *commit;
char **subpaths;
@@ -104,6 +104,10 @@ typedef struct
void flatpak_related_free (FlatpakRelated *related);
typedef struct {
OstreeRepo *repo;
GVariant *summary;
} FlatpakSideloadState;
/* The remote state represent the state of the remote at a particular
time, including the summary file and the metadata (which may be from
@@ -117,12 +121,11 @@ typedef struct
GVariant *summary;
GBytes *summary_sig_bytes;
GError *summary_fetch_error;
GVariant *metadata;
GError *metadata_fetch_error;
GRegex *allow_refs;
GRegex *deny_refs;
int refcount;
gint32 default_token_type;
GPtrArray *sideload_repos;
} FlatpakRemoteState;
FlatpakRemoteState *flatpak_remote_state_ref (FlatpakRemoteState *remote_state);
@@ -136,43 +139,44 @@ gboolean flatpak_remote_state_allow_ref (FlatpakRemoteState *self,
gboolean flatpak_remote_state_lookup_ref (FlatpakRemoteState *self,
const char *ref,
char **out_checksum,
gboolean *out_has_info,
guint64 *out_timestamp,
VarRefInfoRef *out_info,
GFile **out_sideload_path,
GError **error);
char **flatpak_remote_state_match_subrefs (FlatpakRemoteState *self,
const char *ref);
GFile *flatpak_remote_state_lookup_sideload_checksum (FlatpakRemoteState *self,
char *checksum);
gboolean flatpak_remote_state_lookup_cache (FlatpakRemoteState *self,
const char *ref,
guint64 *download_size,
guint64 *installed_size,
const char **metadata,
const guchar **maybe_commit_bytes,
GError **error);
gboolean flatpak_remote_state_load_data (FlatpakRemoteState *self,
const char *ref,
guint64 *out_download_size,
guint64 *out_installed_size,
char **out_metadata,
GError **error);
gboolean flatpak_remote_state_lookup_sparse_cache (FlatpakRemoteState *self,
const char *ref,
VarMetadataRef *out_metadata,
GError **error);
GVariant *flatpak_remote_state_load_ref_commit (FlatpakRemoteState *self,
FlatpakDir *dir,
const char *ref,
const char *commit,
GError **error);
void flatpak_remote_state_add_sideload_repo (FlatpakRemoteState *self,
const char *path);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakDir, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakDeploy, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakRelated, flatpak_related_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakRemoteState, flatpak_remote_state_unref)
typedef struct
{
char *collection_id;
char *ref_name;
} FlatpakCollectionRef;
FlatpakCollectionRef * flatpak_collection_ref_new (const char *collection_id,
const char *ref_name);
void flatpak_collection_ref_free (FlatpakCollectionRef *ref);
guint flatpak_collection_ref_hash (gconstpointer ref);
gboolean flatpak_collection_ref_equal (gconstpointer ref1,
gconstpointer ref2);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakCollectionRef, flatpak_collection_ref_free)
typedef enum {
FLATPAK_HELPER_DEPLOY_FLAGS_NONE = 0,
FLATPAK_HELPER_DEPLOY_FLAGS_UPDATE = 1 << 0,
@@ -366,7 +370,9 @@ const char * flatpak_deploy_data_get_commit (GBytes *deploy_data);
const char * flatpak_deploy_data_get_appdata_content_rating_type (GBytes *deploy_data);
GHashTable * flatpak_deploy_data_get_appdata_content_rating (GBytes *deploy_data);
const char ** flatpak_deploy_data_get_subpaths (GBytes *deploy_data);
gboolean flatpak_deploy_data_has_subpaths (GBytes *deploy_data);
guint64 flatpak_deploy_data_get_installed_size (GBytes *deploy_data);
guint64 flatpak_deploy_data_get_timestamp (GBytes *deploy_data);
const char * flatpak_deploy_data_get_alt_id (GBytes *deploy_data);
const char * flatpak_deploy_data_get_eol (GBytes *deploy_data);
const char * flatpak_deploy_data_get_eol_rebase (GBytes *deploy_data);
@@ -461,6 +467,7 @@ gboolean flatpak_dir_ref_is_masked (FlatpakDir *self,
const char *ref);
char * flatpak_dir_find_remote_ref (FlatpakDir *self,
const char *remote,
const char **opt_sideload_repos,
const char *name,
const char *opt_branch,
const char *opt_default_branch,
@@ -471,6 +478,7 @@ char * flatpak_dir_find_remote_ref (FlatpakDir *self,
GError **error);
char ** flatpak_dir_find_remote_refs (FlatpakDir *self,
const char *remote,
const char **opt_sideload_repos,
const char *name,
const char *opt_branch,
const char *opt_default_branch,
@@ -560,8 +568,9 @@ gboolean flatpak_dir_pull (FlatpakDir *self,
FlatpakRemoteState *state,
const char *ref,
const char *opt_rev,
const OstreeRepoFinderResult * const *results,
const char **subpaths,
GFile *sideload_repo,
GBytes *require_metadata,
const char *token,
OstreeRepo *repo,
FlatpakPullFlags flatpak_flags,
@@ -667,6 +676,8 @@ gboolean flatpak_dir_install (FlatpakDir *self,
const char *opt_commit,
const char **subpaths,
const char **previous_ids,
GFile *sideload_repo,
GBytes *require_metadata,
const char *token,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
@@ -691,13 +702,17 @@ gboolean flatpak_dir_needs_update_for_commit_and_subpaths (FlatpakDir *self,
const char *ref,
const char *target_commit,
const char **opt_subpaths);
gboolean flatpak_dir_check_if_installed_ref_needs_update (FlatpakDir *self,
FlatpakRemoteState *state,
const char *ref,
GBytes *deploy_data,
GCancellable *cancellable);
char * flatpak_dir_check_for_update (FlatpakDir *self,
FlatpakRemoteState *state,
const char *ref,
const char *checksum_or_latest,
const char **opt_subpaths,
gboolean no_pull,
OstreeRepoFinderResult ***out_results,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_update (FlatpakDir *self,
@@ -710,9 +725,10 @@ gboolean flatpak_dir_update (FlatpakDir *self,
FlatpakRemoteState *state,
const char *ref,
const char *checksum_or_latest,
const OstreeRepoFinderResult * const *results,
const char **opt_subpaths,
const char **opt_previous_ids,
GFile *sideload_repo,
GBytes *require_metadata,
const char *token,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
@@ -800,8 +816,7 @@ gboolean flatpak_dir_create_suggested_remote_for_ref_file (FlatpakDir *self,
GBytes *data,
GError **error);
char *flatpak_dir_find_remote_by_uri (FlatpakDir *self,
const char *uri,
const char *collection_id);
const char *uri);
gboolean flatpak_dir_has_remote (FlatpakDir *self,
const char *remote_name,
GError **error);
@@ -822,6 +837,7 @@ gboolean flatpak_dir_remove_remote (FlatpakDir *self,
const char *remote_name,
GCancellable *cancellable,
GError **error);
char ** flatpak_dir_get_sideload_repo_paths (FlatpakDir *self);
char ** flatpak_dir_list_remote_config_keys (FlatpakDir *self,
const char *remote_name);
char *flatpak_dir_get_remote_title (FlatpakDir *self,
@@ -897,6 +913,10 @@ FlatpakRemoteState * flatpak_dir_get_remote_state_for_summary (FlatpakDir *sel
GBytes *opt_summary_sig,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_migrate_config (FlatpakDir *self,
gboolean *changed,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_remote_make_oci_summary (FlatpakDir *self,
const char *remote,
gboolean only_cached,
@@ -945,7 +965,8 @@ gboolean flatpak_dir_find_latest_rev (FlatpakDir *self,
const char *ref,
const char *checksum_or_latest,
char **out_rev,
OstreeRepoFinderResult ***out_results,
guint64 *out_timestamp,
GFile **out_sideload_path,
GCancellable *cancellable,
GError **error);
GPtrArray * flatpak_dir_find_remote_auto_install_refs (FlatpakDir *self,
@@ -958,11 +979,6 @@ typedef struct
char *ref;
char *opt_commit;
/* Used during p2p resolve */
OstreeCollectionRef collection_ref; /* owns the collection_id member only, ref_name is from above */
char *local_commit;
char *latest_remote_commit;
/* out */
char *resolved_commit;
GBytes *resolved_metadata;
@@ -982,21 +998,6 @@ void flatpak_dir_resolve_free (FlatpakDirResolve *resolve);
gboolean flatpak_dir_resolve_maybe_resolve_from_metadata (FlatpakDirResolve *resolve,
FlatpakRemoteState *state);
typedef struct _FlatpakDirP2PState FlatpakDirP2PState;
void flatpak_dir_p2p_state_free (FlatpakDirP2PState *state);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakDirP2PState, flatpak_dir_p2p_state_free)
FlatpakDirP2PState *flatpak_dir_prepare_resolve_p2p_refs (FlatpakDir *self,
FlatpakDirResolve **resolves,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_finish_resolve_p2p_refs (FlatpakDir *self,
FlatpakDirResolve **resolves,
const char *token,
FlatpakDirP2PState *state,
GCancellable *cancellable,
GError **error);
char ** flatpak_dir_get_default_locales (FlatpakDir *self);
char ** flatpak_dir_get_default_locale_languages (FlatpakDir *self);
char ** flatpak_dir_get_locales (FlatpakDir *self);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -982,24 +982,26 @@ flatpak_installation_list_installed_refs_by_kind (FlatpakInstallation *self,
return g_steal_pointer (&refs);
}
static void
async_result_cb (GObject *obj,
GAsyncResult *result,
gpointer user_data)
static gboolean
ref_check_for_update (FlatpakDir *dir,
const char *ref,
GHashTable *remote_states,
GCancellable *cancellable)
{
GAsyncResult **result_out = user_data;
g_autoptr(GBytes) deploy_data = NULL;
FlatpakRemoteState *state;
const char *origin = NULL;
*result_out = g_object_ref (result);
}
deploy_data = flatpak_dir_get_deploy_data (dir, ref, FLATPAK_DEPLOY_VERSION_CURRENT, cancellable, NULL);
if (deploy_data == NULL)
return FALSE;
/* Useful as the #GDestroyNotify in NULL-terminated pointer arrays. */
static void
_ostree_collection_ref_free0 (OstreeCollectionRef *ref)
{
if (ref == NULL)
return;
origin = flatpak_deploy_data_get_origin (deploy_data);
state = g_hash_table_lookup (remote_states, origin);
if (state == NULL)
return FALSE;
ostree_collection_ref_free (ref);
return flatpak_dir_check_if_installed_ref_needs_update (dir, state, ref, deploy_data, cancellable);
}
/**
@@ -1026,270 +1028,73 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GPtrArray) updates = NULL; /* (element-type FlatpakInstalledRef) */
g_autoptr(GPtrArray) installed = NULL; /* (element-type FlatpakInstalledRef) */
g_autoptr(GPtrArray) remotes = NULL; /* (element-type FlatpakRemote) */
g_autoptr(GHashTable) remote_commits = NULL; /* (element-type utf8 utf8) */
g_autoptr(GHashTable) remote_states = NULL; /* (element-type utf8 FlatpakRemoteState) */
int i, j;
g_autoptr(FlatpakDir) dir_orig = flatpak_installation_get_dir_maybe_no_repo (self);
g_autoptr(FlatpakDir) dir = NULL;
g_auto(OstreeRepoFinderResultv) results = NULL;
g_autoptr(GAsyncResult) result = NULL;
g_autoptr(GPtrArray) collection_refs = NULL; /* (element-type OstreeCollectionRef) */
g_autoptr(GString) refs_str = NULL;
g_auto(GStrv) remote_names = NULL;
g_autoptr(GPtrArray) updates = NULL; /* (element-type FlatpakInstalledRef) */
g_autoptr(GHashTable) remote_states = NULL; /* (element-type utf8 FlatpakRemoteState) */
g_auto(GStrv) refs_app = NULL;
g_auto(GStrv) refs_runtime = NULL;
remote_commits = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
remotes = flatpak_installation_list_remotes (self, cancellable, error);
if (remotes == NULL)
/* We clone the dir here to make sure we re-read the latest ostree repo config, in case
it has local changes */
dir = flatpak_dir_clone (dir_orig);
if (!flatpak_dir_maybe_ensure_repo (dir, cancellable, error))
return NULL;
for (i = 0; i < remotes->len; i++)
remote_names = flatpak_dir_list_remotes (dir, cancellable, error);
if (remote_names == NULL)
return NULL;
remote_states = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)flatpak_remote_state_unref);
for (int i = 0; remote_names[i] != NULL; ++i)
{
FlatpakRemote *remote = g_ptr_array_index (remotes, i);
g_autoptr(GPtrArray) refs = NULL;
const char *remote = remote_names[i];
g_autoptr(FlatpakRemoteState) state = NULL;
g_autoptr(GError) local_error = NULL;
g_autofree char *collection_id = NULL;
const char *remote_name = flatpak_remote_get_name (remote);
if (flatpak_remote_get_disabled (remote))
if (flatpak_dir_get_remote_disabled (dir, remote))
continue;
/* Remotes with collection IDs will be handled separately below */
collection_id = flatpak_remote_get_collection_id (remote);
if (collection_id != NULL)
continue;
/* We ignore errors here. we don't want one remote to fail us */
refs = flatpak_installation_list_remote_refs_sync (self,
remote_name,
cancellable, &local_error);
if (refs != NULL)
state = flatpak_dir_get_remote_state_optional (dir, remote, FALSE, NULL, &local_error);
if (state == NULL)
{
for (j = 0; j < refs->len; j++)
{
FlatpakRemoteRef *remote_ref = g_ptr_array_index (refs, j);
g_autofree char *full_ref = flatpak_ref_format_ref (FLATPAK_REF (remote_ref));
g_autofree char *key = g_strdup_printf ("%s:%s", remote_name, full_ref);
g_hash_table_insert (remote_commits, g_steal_pointer (&key),
g_strdup (flatpak_ref_get_commit (FLATPAK_REF (remote_ref))));
}
}
else
{
g_debug ("Update: Failed to read remote %s: %s",
flatpak_remote_get_name (remote),
local_error->message);
g_debug ("Update: Failed to read remote %s: %s", remote, local_error->message);
continue;
}
g_hash_table_insert (remote_states, (char *)remote, g_steal_pointer (&state));
}
installed = flatpak_installation_list_installed_refs (self, cancellable, error);
if (installed == NULL)
return NULL;
updates = g_ptr_array_new_with_free_func (g_object_unref);
dir = flatpak_installation_get_dir (self, error);
if (dir == NULL)
return NULL;
remote_states = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) flatpak_remote_state_unref);
for (i = 0; i < installed->len; i++)
if (flatpak_dir_list_refs (dir, "app", &refs_app, cancellable, error))
{
FlatpakRemoteState *state;
FlatpakInstalledRef *installed_ref = g_ptr_array_index (installed, i);
const char *remote_name = flatpak_installed_ref_get_origin (installed_ref);
g_autofree char *full_ref = flatpak_ref_format_ref (FLATPAK_REF (installed_ref));
g_autofree char *key = g_strdup_printf ("%s:%s", remote_name, full_ref);
const char *remote_commit = g_hash_table_lookup (remote_commits, key);
const char *local_commit = flatpak_installed_ref_get_latest_commit (installed_ref);
g_autoptr(GError) local_error = NULL;
if (flatpak_dir_ref_is_masked (dir, full_ref))
continue;
/* Note: local_commit may be NULL here */
if (remote_commit != NULL &&
g_strcmp0 (remote_commit, local_commit) != 0)
{
g_ptr_array_add (updates, g_object_ref (installed_ref));
/* Don't check further, as we already added the installed_ref to @updates. */
continue;
}
/* Check if all "should-download" related refs for the ref are installed.
* If not, add the ref in @updates array so that it can be installed via
* FlatpakTransaction's update-op.
*
* This makes sure that the ref (maybe an app or runtime) remains in usable
* state and fixes itself through an update.
*/
state = g_hash_table_lookup (remote_states, remote_name);
if (state == NULL)
{
state = flatpak_dir_get_remote_state_optional (dir, remote_name, FALSE, cancellable, &local_error);
if (state == NULL)
{
g_debug ("Update: Failed to get remote state for %s: %s",
remote_name, local_error->message);
continue;
}
g_hash_table_insert (remote_states, g_strdup (remote_name), state);
}
if (flatpak_dir_check_installed_ref_missing_related_ref (dir, state, full_ref, cancellable))
{
g_ptr_array_add (updates, g_object_ref (installed_ref));
/* Don't check for runtime, if we already added the installed_ref to @updates. */
continue;
}
if (flatpak_ref_get_kind (FLATPAK_REF (installed_ref)) == FLATPAK_REF_KIND_APP)
{
g_autoptr(GBytes) deploy_data = NULL;
/* This checks if an already installed app has a missing runtime.
* If so, return that installed ref in the updates list, so that FlatpakTransaction
* can resolve one of its operation to install the runtime instead.
*
* Runtime of an app can go missing if an app upgrade makes an app dependent on a new runtime
* entirely. We had couple of cases like that in the past, for example, before it was updated
* to use FlatpakTransaction, updating an app in GNOME Software to a version which needs a
* different runtime would not install that new runtime, leaving the app unusable.
*/
deploy_data = flatpak_dir_get_deploy_data (dir, full_ref, FLATPAK_DEPLOY_VERSION_CURRENT, cancellable, NULL);
if (deploy_data != NULL)
{
g_autoptr(GFile) deploy_dir = NULL;
const gchar *runtime = NULL;
g_autofree gchar *full_runtime_ref = NULL;
runtime = flatpak_deploy_data_get_runtime (deploy_data);
full_runtime_ref = g_strconcat ("runtime/", runtime, NULL);
deploy_dir = flatpak_dir_get_if_deployed (dir, full_runtime_ref, NULL, cancellable);
if (deploy_dir == NULL)
g_ptr_array_add (updates, g_object_ref (installed_ref));
}
}
for (int i = 0; refs_app[i] != NULL; i++)
{
const char *ref = refs_app[i];
if (ref_check_for_update (dir, ref, remote_states, cancellable))
{
g_printerr ("adding update %s\n", ref);
FlatpakInstalledRef *installed_ref = get_ref (dir, ref, cancellable, NULL);
if (installed_ref)
g_ptr_array_add (updates, g_object_ref (installed_ref));
}
}
}
collection_refs = g_ptr_array_new_with_free_func ((GDestroyNotify) _ostree_collection_ref_free0);
refs_str = g_string_new ("");
for (i = 0; i < installed->len; i++)
if (flatpak_dir_list_refs (dir, "runtime", &refs_runtime, cancellable, error))
{
FlatpakInstalledRef *installed_ref = g_ptr_array_index (installed, i);
g_autofree char *ref = flatpak_ref_format_ref (FLATPAK_REF (installed_ref));
g_autofree char *collection_id = NULL;
const char *remote_name = flatpak_installed_ref_get_origin (installed_ref);
if (flatpak_dir_ref_is_masked (dir, ref))
continue;
collection_id = flatpak_dir_get_remote_collection_id (dir, remote_name);
if (collection_id != NULL)
{
OstreeCollectionRef *c_r = ostree_collection_ref_new (collection_id, ref);
g_ptr_array_add (collection_refs, c_r);
if (refs_str->len > 0)
g_string_append (refs_str, ", ");
g_string_append_printf (refs_str, "(%s, %s)", collection_id, ref);
}
}
/* if we do not have any collection refs, then we shouldn't try to find
* dynamic remotes for them, to avoid extra unnecessary processing, and also
* because the refs array cannot be empty in ostree_repo_find_remotes_async
* (otherwise it early returns and we never get our callback called) */
if (collection_refs->len > 0)
{
g_autoptr(GMainContextPopDefault) context = NULL;
g_ptr_array_add (collection_refs, NULL);
context = flatpak_main_context_new_default ();
ostree_repo_find_remotes_async (flatpak_dir_get_repo (dir),
(const OstreeCollectionRef * const *) collection_refs->pdata,
NULL, /* no options */
NULL, /* default finders */
NULL, /* no progress */
cancellable,
async_result_cb,
&result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
results = ostree_repo_find_remotes_finish (flatpak_dir_get_repo (dir), result, error);
if (results == NULL)
return NULL;
if (results[0] == NULL)
g_debug ("No remotes found which provide these refs: [%s]", refs_str->str);
}
for (i = 0; i < installed->len && results != NULL && results[0] != NULL; i++)
{
FlatpakInstalledRef *installed_ref = g_ptr_array_index (installed, i);
const char *remote_name = flatpak_installed_ref_get_origin (installed_ref);
g_autofree char *ref = flatpak_ref_format_ref (FLATPAK_REF (installed_ref));
g_autofree char *collection_id = NULL;
g_autoptr(OstreeCollectionRef) collection_ref = NULL;
collection_id = flatpak_dir_get_remote_collection_id (dir, remote_name);
collection_ref = ostree_collection_ref_new (collection_id, ref);
/* Look for matching remote refs that are updates */
for (j = 0; results[j] != NULL; j++)
{
const char *local_commit, *remote_commit;
local_commit = flatpak_installed_ref_get_latest_commit (installed_ref);
remote_commit = g_hash_table_lookup (results[j]->ref_to_checksum, collection_ref);
if (remote_commit == NULL || g_strcmp0 (remote_commit, local_commit) == 0)
continue;
/* The ref_to_checksum map only tells us if this remote is offering
* the latest commit of the available remotes; we have to check
* ref_to_timestamp to know if the commit is an update or a
* downgrade. If local_commit is NULL assume it's an update until
* proven otherwise.
*/
if (local_commit != NULL)
{
guint64 local_timestamp = 0;
guint64 *remote_timestamp;
g_autoptr(GVariant) commit_v = NULL;
if (ostree_repo_load_commit (flatpak_dir_get_repo (dir), local_commit, &commit_v, NULL, NULL))
local_timestamp = ostree_commit_get_timestamp (commit_v);
remote_timestamp = g_hash_table_lookup (results[j]->ref_to_timestamp, collection_ref);
*remote_timestamp = GUINT64_FROM_BE (*remote_timestamp);
g_debug ("%s: Comparing local timestamp %" G_GUINT64_FORMAT " to remote timestamp %"
G_GUINT64_FORMAT " on ref (%s, %s)", G_STRFUNC, local_timestamp, *remote_timestamp,
collection_ref->collection_id, collection_ref->ref_name);
/* The timestamp could be 0 due to an error reading it. Assume
* it's an update until proven otherwise. */
if (*remote_timestamp != 0 && *remote_timestamp <= local_timestamp)
continue;
}
g_ptr_array_add (updates, g_object_ref (installed_ref));
/* Move on to the next ref so we don't add duplicates */
break;
}
for (int i = 0; refs_runtime[i] != NULL; i++)
{
const char *ref = refs_runtime[i];
if (ref_check_for_update (dir, ref, remote_states, cancellable))
{
g_printerr ("adding update %s\n", ref);
FlatpakInstalledRef *installed_ref = get_ref (dir, ref, cancellable, NULL);
if (installed_ref)
g_ptr_array_add (updates, g_object_ref (installed_ref));
}
}
}
return g_steal_pointer (&updates);
@@ -1302,112 +1107,6 @@ flatpak_installation_list_installed_refs_for_update (FlatpakInstallation *self,
* have a repo.
*
* FIXME: If this were async, the parallelisation could be handled in the caller. */
static gboolean
list_remotes_for_configured_remote (const gchar *remote_name,
FlatpakDir *dir,
gboolean types_filter[],
GPtrArray *remotes /* (element-type FlatpakRemote) */,
GCancellable *cancellable,
GError **error)
{
OstreeRepo *repo;
g_autofree gchar *collection_id = NULL;
OstreeCollectionRef ref;
OstreeCollectionRef ref2;
const OstreeCollectionRef *refs[3] = { NULL, };
g_autofree gchar *appstream_ref = NULL;
g_autofree gchar *appstream2_ref = NULL;
g_auto(OstreeRepoFinderResultv) results = NULL;
g_autoptr(GAsyncResult) result = NULL;
g_autoptr(OstreeRepoFinder) finder_mount = NULL, finder_avahi = NULL;
OstreeRepoFinder *finders[3] = { NULL, };
gsize i;
guint finder_index = 0;
g_autoptr(GMainContextPopDefault) context = NULL;
if (!types_filter[FLATPAK_REMOTE_TYPE_USB] &&
!types_filter[FLATPAK_REMOTE_TYPE_LAN])
return TRUE;
repo = flatpak_dir_get_repo (dir);
if (repo == NULL)
return TRUE;
/* Find the collection ID for @remote_name, or bail if there is none. */
if (!ostree_repo_get_remote_option (repo,
remote_name, "collection-id",
NULL, &collection_id, error))
return FALSE;
if (collection_id == NULL || *collection_id == '\0')
return TRUE;
context = flatpak_main_context_new_default ();
appstream_ref = g_strdup_printf ("appstream/%s", flatpak_get_arch ());
ref.collection_id = collection_id;
ref.ref_name = appstream_ref;
refs[0] = &ref;
appstream2_ref = g_strdup_printf ("appstream2/%s", flatpak_get_arch ());
ref2.collection_id = collection_id;
ref2.ref_name = appstream2_ref;
refs[1] = &ref2;
if (types_filter[FLATPAK_REMOTE_TYPE_USB])
{
finder_mount = OSTREE_REPO_FINDER (ostree_repo_finder_mount_new (NULL));
finders[finder_index++] = finder_mount;
}
if (types_filter[FLATPAK_REMOTE_TYPE_LAN])
{
g_autoptr(GError) local_error = NULL;
finder_avahi = OSTREE_REPO_FINDER (ostree_repo_finder_avahi_new (context));
finders[finder_index++] = finder_avahi;
/* The Avahi finder may fail to start on, for example, a CI server. */
ostree_repo_finder_avahi_start (OSTREE_REPO_FINDER_AVAHI (finder_avahi), &local_error);
if (local_error != NULL)
{
if (finder_index == 1)
return TRUE;
else
{
finders[--finder_index] = NULL;
g_clear_object (&finder_avahi);
}
}
}
ostree_repo_find_remotes_async (repo,
(const OstreeCollectionRef * const *) refs,
NULL, /* no options */
finders,
NULL, /* no progress */
cancellable,
async_result_cb,
&result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
results = ostree_repo_find_remotes_finish (repo, result, error);
if (finder_avahi != NULL)
ostree_repo_finder_avahi_stop (OSTREE_REPO_FINDER_AVAHI (finder_avahi));
if (results == NULL)
return FALSE;
for (i = 0; results[i] != NULL; i++)
{
g_ptr_array_add (remotes,
flatpak_remote_new_from_ostree (results[i]->remote,
results[i]->finder,
dir));
}
return TRUE;
}
/**
* flatpak_installation_list_remotes_by_type:
@@ -1419,6 +1118,10 @@ list_remotes_for_configured_remote (const gchar *remote_name,
*
* Lists only the remotes whose type is included in the @types argument.
*
* Since flatpak 1.7 this will never return any types except FLATPAK_REMOTE_TYPE_STATIC.
* Equivalent functionallity to FLATPAK_REMOTE_TYPE_USB can be had by listing remote refs
* with FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED.
*
* Returns: (transfer container) (element-type FlatpakRemote): a GPtrArray of
* #FlatpakRemote instances
*/
@@ -1436,8 +1139,6 @@ flatpak_installation_list_remotes_by_type (FlatpakInstallation *self,
const guint NUM_FLATPAK_REMOTE_TYPES = 3;
gboolean types_filter[NUM_FLATPAK_REMOTE_TYPES];
gsize i;
const char * const *default_repo_finders = NULL;
OstreeRepo *repo;
remote_names = flatpak_dir_list_remotes (dir, cancellable, error);
if (remote_names == NULL)
@@ -1449,42 +1150,15 @@ flatpak_installation_list_remotes_by_type (FlatpakInstallation *self,
if (!flatpak_dir_maybe_ensure_repo (dir_clone, cancellable, error))
return NULL;
repo = flatpak_dir_get_repo (dir_clone);
if (repo != NULL)
default_repo_finders = ostree_repo_get_default_repo_finders (repo);
/* If NULL or an empty array of types is passed then we use the default set
* provided by ostree, or fall back to using all */
/* If NULL or an empty array of types is passed then we list all types */
for (i = 0; i < NUM_FLATPAK_REMOTE_TYPES; ++i)
{
if (num_types != 0)
if (types != NULL && num_types != 0)
types_filter[i] = FALSE;
else if (default_repo_finders == NULL)
else
types_filter[i] = TRUE;
}
if (default_repo_finders != NULL && num_types == 0)
{
g_autofree char *default_repo_finders_str = g_strjoinv (" ", (gchar **) default_repo_finders);
g_debug ("Using default repo finder list: %s", default_repo_finders_str);
for (const char * const *iter = default_repo_finders; iter && *iter; iter++)
{
const char *default_repo_finder = *iter;
if (strcmp (default_repo_finder, "config") == 0)
types_filter[FLATPAK_REMOTE_TYPE_STATIC] = TRUE;
else if (strcmp (default_repo_finder, "lan") == 0)
types_filter[FLATPAK_REMOTE_TYPE_LAN] = TRUE;
else if (strcmp (default_repo_finder, "mount") == 0)
types_filter[FLATPAK_REMOTE_TYPE_USB] = TRUE;
else
g_debug ("Unknown value in list returned by "
"ostree_repo_get_default_repo_finders(): %s",
default_repo_finder);
}
}
for (i = 0; i < num_types; ++i)
{
g_return_val_if_fail (types[i] < NUM_FLATPAK_REMOTE_TYPES, NULL);
@@ -1493,17 +1167,10 @@ flatpak_installation_list_remotes_by_type (FlatpakInstallation *self,
for (i = 0; remote_names[i] != NULL; ++i)
{
g_autoptr(GError) local_error = NULL;
/* These days we only support static remotes */
if (types_filter[FLATPAK_REMOTE_TYPE_STATIC])
g_ptr_array_add (remotes, flatpak_remote_new_with_dir (remote_names[i],
dir_clone));
/* Add the dynamic mirrors of this remote. */
if (!list_remotes_for_configured_remote (remote_names[i], dir_clone,
types_filter, remotes,
cancellable, &local_error))
g_debug ("Couldn't find remotes for configured remote %s: %s",
remote_names[i], local_error->message);
}
return g_steal_pointer (&remotes);
@@ -1950,6 +1617,10 @@ flatpak_installation_load_app_overrides (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_install_bundle()
* instead. It has a lot more interesting features.
*
* Install an application or runtime from an flatpak bundle file.
* See flatpak-build-bundle(1) for how to create bundles.
*
@@ -2008,6 +1679,10 @@ flatpak_installation_install_bundle (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_install_flatpakref()
* instead. It has a lot more interesting features.
*
* Creates a remote based on the passed in .flatpakref file contents
* in @ref_file_data and returns the #FlatpakRemoteRef that can be used
* to install it.
@@ -2031,7 +1706,6 @@ flatpak_installation_install_ref_file (FlatpakInstallation *self,
g_autofree char *remote = NULL;
g_autofree char *ref = NULL;
g_autofree char *collection_id = NULL;
g_autoptr(FlatpakCollectionRef) coll_ref = NULL;
g_autoptr(GKeyFile) keyfile = g_key_file_new ();
dir = flatpak_installation_get_dir (self, error);
@@ -2049,8 +1723,7 @@ flatpak_installation_install_ref_file (FlatpakInstallation *self,
if (!flatpak_installation_drop_caches (self, cancellable, error))
return NULL;
coll_ref = flatpak_collection_ref_new (collection_id, ref);
return flatpak_remote_ref_new (coll_ref, NULL, remote, NULL);
return flatpak_remote_ref_new (ref, NULL, remote, collection_id, NULL);
}
/**
@@ -2068,6 +1741,9 @@ flatpak_installation_install_ref_file (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_install()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Note that this function was originally written to always return a
@@ -2140,7 +1816,7 @@ flatpak_installation_install_full (FlatpakInstallation *self,
(flags & FLATPAK_INSTALL_FLAGS_NO_DEPLOY) != 0,
(flags & FLATPAK_INSTALL_FLAGS_NO_STATIC_DELTAS) != 0,
FALSE, FALSE, state,
ref, NULL, (const char **) subpaths, NULL, NULL,
ref, NULL, (const char **) subpaths, NULL, NULL, NULL, NULL,
ostree_progress, cancellable, error))
return NULL;
@@ -2174,6 +1850,11 @@ flatpak_installation_install_full (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_install()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Install a new application or runtime.
*
* Note that this function was originally written to always return a
@@ -2218,6 +1899,11 @@ flatpak_installation_install (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_update()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Update an application or runtime.
*
* If the specified package is not installed, then %FLATPAK_ERROR_NOT_INSTALLED
@@ -2249,7 +1935,6 @@ flatpak_installation_update_full (FlatpakInstallation *self,
g_autofree char *remote_name = NULL;
FlatpakInstalledRef *result = NULL;
g_autofree char *target_commit = NULL;
g_auto(OstreeRepoFinderResultv) check_results = NULL;
g_autoptr(FlatpakRemoteState) state = NULL;
g_autoptr(GMainContextPopDefault) main_context = NULL;
@@ -2280,7 +1965,6 @@ flatpak_installation_update_full (FlatpakInstallation *self,
target_commit = flatpak_dir_check_for_update (dir, state, ref, NULL,
(const char **) subpaths,
(flags & FLATPAK_UPDATE_FLAGS_NO_PULL) != 0,
&check_results,
cancellable, error);
if (target_commit == NULL)
return NULL;
@@ -2304,8 +1988,7 @@ flatpak_installation_update_full (FlatpakInstallation *self,
(flags & FLATPAK_UPDATE_FLAGS_NO_STATIC_DELTAS) != 0,
FALSE, FALSE, FALSE, state,
ref, target_commit,
(const OstreeRepoFinderResult * const *) check_results,
(const char **) subpaths, NULL, NULL,
(const char **) subpaths, NULL, NULL, NULL, NULL,
ostree_progress, cancellable, error))
return NULL;
@@ -2338,6 +2021,11 @@ flatpak_installation_update_full (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_update()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Update an application or runtime.
*
* If the specified package is not installed, then %FLATPAK_ERROR_NOT_INSTALLED
@@ -2379,6 +2067,11 @@ flatpak_installation_update (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_unintstall()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Uninstall an application or runtime.
*
* Returns: %TRUE on success
@@ -2415,6 +2108,11 @@ flatpak_installation_uninstall (FlatpakInstallation *self,
* @cancellable: (nullable): a #GCancellable
* @error: return location for a #GError
*
* This is and old deprecated function, you should use
* #FlatpakTransaction and flatpak_transaction_add_unintstall()
* instead. It has a lot more interesting features.
* Install a new application or runtime.
*
* Uninstall an application or runtime.
*
* Returns: %TRUE on success
@@ -2508,9 +2206,9 @@ flatpak_installation_fetch_remote_size_sync (FlatpakInstallation *self,
if (state == NULL)
return FALSE;
return flatpak_remote_state_lookup_cache (state, full_ref,
download_size, installed_size, NULL,
NULL, error);
return flatpak_remote_state_load_data (state, full_ref,
download_size, installed_size, NULL,
error);
}
/**
@@ -2539,7 +2237,8 @@ flatpak_installation_fetch_remote_metadata_sync (FlatpakInstallation *self,
g_autoptr(FlatpakDir) dir = NULL;
g_autoptr(FlatpakRemoteState) state = NULL;
g_autofree char *full_ref = flatpak_ref_format_ref (ref);
const char *res = NULL;
g_autofree char *res = NULL;
gsize len;
dir = flatpak_installation_get_dir (self, error);
if (dir == NULL)
@@ -2549,12 +2248,13 @@ flatpak_installation_fetch_remote_metadata_sync (FlatpakInstallation *self,
if (state == NULL)
return FALSE;
if (!flatpak_remote_state_lookup_cache (state, full_ref,
NULL, NULL, &res,
NULL, error))
if (!flatpak_remote_state_load_data (state, full_ref,
NULL, NULL, &res,
error))
return NULL;
return g_bytes_new (res, strlen (res));
len = strlen (res);
return g_bytes_new_take (g_steal_pointer (&res), len);
}
/**
@@ -2604,6 +2304,7 @@ flatpak_installation_list_remote_refs_sync_full (FlatpakInstallation *self,
g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref);
g_autoptr(FlatpakRemoteState) state = NULL;
g_autoptr(GHashTable) ht = NULL;
g_autoptr(GError) local_error = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
@@ -2612,22 +2313,36 @@ flatpak_installation_list_remote_refs_sync_full (FlatpakInstallation *self,
if (dir == NULL)
return NULL;
state = flatpak_dir_get_remote_state (dir, remote_or_uri, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
if (flags & FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED)
state = flatpak_dir_get_remote_state_local_only (dir, remote_or_uri, cancellable, error);
else
state = flatpak_dir_get_remote_state (dir, remote_or_uri, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
if (state == NULL)
return NULL;
if (!flatpak_dir_list_remote_refs (dir, state, &ht,
cancellable, error))
return NULL;
cancellable, &local_error))
{
if (flags & FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED)
{
/* Just return no sideloaded refs rather than a summary download failed error if there are none */
return g_steal_pointer (&refs);
}
else
{
g_propagate_error (error, g_steal_pointer (&local_error));
return NULL;
}
}
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
FlatpakRemoteRef *ref;
FlatpakCollectionRef *coll_ref = key;
const char *ref_name = key;
const gchar *ref_commit = value;
FlatpakRemoteRef *ref;
ref = flatpak_remote_ref_new (coll_ref, ref_commit, remote_or_uri, state);
ref = flatpak_remote_ref_new (ref_name, ref_commit, remote_or_uri, state->collection_id, state);
if (ref)
g_ptr_array_add (refs, ref);
@@ -2699,8 +2414,6 @@ flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
g_autoptr(GHashTable) ht = NULL;
g_autoptr(FlatpakRemoteState) state = NULL;
g_autofree char *ref = NULL;
g_autoptr(FlatpakCollectionRef) coll_ref = NULL;
g_autofree gchar *collection_id = NULL;
const char *checksum;
if (branch == NULL)
@@ -2710,7 +2423,10 @@ flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
if (dir == NULL)
return NULL;
state = flatpak_dir_get_remote_state_optional (dir, remote_name, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
if (flags & FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED)
state = flatpak_dir_get_remote_state_local_only (dir, remote_name, cancellable, error);
else
state = flatpak_dir_get_remote_state (dir, remote_name, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
if (state == NULL)
return NULL;
@@ -2718,12 +2434,6 @@ flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
cancellable, error))
return NULL;
/* FIXME: Rework to accept the collection ID as an input argument instead */
if (!ostree_repo_get_remote_option (flatpak_dir_get_repo (dir),
remote_name, "collection-id",
NULL, &collection_id, error))
return FALSE;
if (kind == FLATPAK_REF_KIND_APP)
ref = flatpak_build_app_ref (name,
branch,
@@ -2733,102 +2443,10 @@ flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
branch,
arch);
coll_ref = flatpak_collection_ref_new (collection_id, ref);
checksum = g_hash_table_lookup (ht, coll_ref);
/* Check LAN/USB sources too in case we're offline */
if (checksum == NULL && collection_id != NULL && *collection_id != '\0')
{
OstreeRepo *repo;
const char * const *default_repo_finders;
g_autoptr(GAsyncResult) result = NULL;
OstreeCollectionRef ostree_coll_ref;
const OstreeCollectionRef *refs[2] = { NULL, };
OstreeRepoFinder *finders[3] = { NULL, };
guint finder_index = 0;
gsize i;
g_autoptr(GMainContextPopDefault) context = NULL;
g_autoptr(OstreeRepoFinder) finder_mount = NULL, finder_avahi = NULL;
context = flatpak_main_context_new_default ();
ostree_coll_ref.collection_id = collection_id;
ostree_coll_ref.ref_name = ref;
refs[0] = &ostree_coll_ref;
if (!flatpak_dir_ensure_repo (dir, cancellable, error))
return NULL;
repo = flatpak_dir_get_repo (dir);
default_repo_finders = ostree_repo_get_default_repo_finders (repo);
if (default_repo_finders == NULL || g_strv_contains (default_repo_finders, "mount"))
{
finder_mount = OSTREE_REPO_FINDER (ostree_repo_finder_mount_new (NULL));
finders[finder_index++] = finder_mount;
}
if (default_repo_finders == NULL || g_strv_contains (default_repo_finders, "lan"))
{
g_autoptr(GError) local_error = NULL;
finder_avahi = OSTREE_REPO_FINDER (ostree_repo_finder_avahi_new (context));
finders[finder_index++] = finder_avahi;
/* The Avahi finder may fail to start on, for example, a CI server. */
ostree_repo_finder_avahi_start (OSTREE_REPO_FINDER_AVAHI (finder_avahi), &local_error);
if (local_error != NULL)
{
finders[--finder_index] = NULL;
g_clear_object (&finder_avahi);
}
}
if (finders[0] != NULL)
{
g_auto(OstreeRepoFinderResultv) results = NULL;
ostree_repo_find_remotes_async (repo, (const OstreeCollectionRef * const *)refs,
NULL, finders, NULL, cancellable, async_result_cb, &result);
while (result == NULL)
g_main_context_iteration (context, TRUE);
results = ostree_repo_find_remotes_finish (repo, result, error);
if (finder_avahi != NULL)
ostree_repo_finder_avahi_stop (OSTREE_REPO_FINDER_AVAHI (finder_avahi));
if (results == NULL)
return NULL;
for (i = 0; results[i] != NULL; i++)
{
checksum = g_hash_table_lookup (results[i]->ref_to_checksum, &ostree_coll_ref);
if (checksum != NULL)
break;
}
}
}
/* If there was not a match, it may be because the collection ID is
* not set in the local configuration, or it is wrong, so we resort to
* trying to match just the ref name */
if (checksum == NULL)
{
GHashTableIter iter;
gpointer key, value;
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
FlatpakCollectionRef *current = (FlatpakCollectionRef *) key;
if (g_strcmp0 (current->ref_name, ref) == 0)
{
checksum = (const gchar *) value;
break;
}
}
}
checksum = g_hash_table_lookup (ht, ref);
if (checksum != NULL)
return flatpak_remote_ref_new (coll_ref, checksum, remote_name, state);
return flatpak_remote_ref_new (ref, checksum, remote_name, state->collection_id, state);
g_set_error (error, FLATPAK_ERROR, FLATPAK_ERROR_REF_NOT_FOUND,
"Reference %s doesn't exist in remote", ref);
@@ -3008,7 +2626,7 @@ flatpak_installation_list_remote_related_refs_sync (FlatpakInstallation *self,
FlatpakRelated *rel = g_ptr_array_index (related, i);
FlatpakRelatedRef *rel_ref;
rel_ref = flatpak_related_ref_new (rel->collection_id, rel->ref, rel->commit,
rel_ref = flatpak_related_ref_new (rel->ref, rel->commit,
rel->subpaths, rel->download, rel->delete);
if (rel_ref)
@@ -3068,7 +2686,7 @@ flatpak_installation_list_installed_related_refs_sync (FlatpakInstallation *self
FlatpakRelated *rel = g_ptr_array_index (related, i);
FlatpakRelatedRef *rel_ref;
rel_ref = flatpak_related_ref_new (rel->collection_id, rel->ref, rel->commit,
rel_ref = flatpak_related_ref_new (rel->ref, rel->commit,
rel->subpaths, rel->download, rel->delete);
if (rel_ref)

View File

@@ -127,6 +127,7 @@ typedef enum {
* @FLATPAK_QUERY_FLAGS_ONLY_CACHED: Don't do any network i/o, but only return cached data.
* This can return stale data, or a #FLATPAK_ERROR_NOT_CACHED error, however it is a
* lot more efficient if you're doing many requests.
* @FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED: Only list refs available from any eventuall sideload repos. (Snce: 1.7)
*
* Flags to alter the behavior of e.g flatpak_installation_list_remote_refs_sync_full().
*
@@ -135,6 +136,7 @@ typedef enum {
typedef enum {
FLATPAK_QUERY_FLAGS_NONE = 0,
FLATPAK_QUERY_FLAGS_ONLY_CACHED = (1 << 0),
FLATPAK_QUERY_FLAGS_ONLY_SIDELOADED = (1 << 1),
} FlatpakQueryFlags;
/**

View File

@@ -28,8 +28,7 @@
#include <flatpak-related-ref.h>
#include <flatpak-dir-private.h>
FlatpakRelatedRef *flatpak_related_ref_new (const char *collection_id,
const char *full_ref,
FlatpakRelatedRef *flatpak_related_ref_new (const char *full_ref,
const char *commit,
char **subpaths,
gboolean download,

View File

@@ -256,7 +256,6 @@ flatpak_related_ref_get_subpaths (FlatpakRelatedRef *self)
/**
* flatpak_related_ref_new:
* @collection_id: (nullable): the collection ID
* @full_ref: a full ref to refer to
* @commit: (nullable): a commit ID to refer to
* @subpaths: (nullable): a nul-terminated array of subpaths
@@ -268,8 +267,7 @@ flatpak_related_ref_get_subpaths (FlatpakRelatedRef *self)
* Returns: a new ref
*/
FlatpakRelatedRef *
flatpak_related_ref_new (const char *collection_id,
const char *full_ref,
flatpak_related_ref_new (const char *full_ref,
const char *commit,
char **subpaths,
gboolean download,
@@ -297,7 +295,6 @@ flatpak_related_ref_new (const char *collection_id,
"subpaths", subpaths,
"should-download", download,
"should-delete", delete,
"collection-id", collection_id,
NULL);
return ref;

View File

@@ -32,10 +32,6 @@
FlatpakRemote *flatpak_remote_new_with_dir (const char *name,
FlatpakDir *dir);
FlatpakRemote *flatpak_remote_new_from_ostree (OstreeRemote *remote,
OstreeRepoFinder *repo_finder,
FlatpakDir *dir);
gboolean flatpak_remote_commit (FlatpakRemote *self,
FlatpakDir *dir,
GCancellable *cancellable,

View File

@@ -28,9 +28,10 @@
#include <flatpak-remote-ref.h>
#include <flatpak-dir-private.h>
FlatpakRemoteRef *flatpak_remote_ref_new (FlatpakCollectionRef *coll_ref,
FlatpakRemoteRef *flatpak_remote_ref_new (const char *ref,
const char *commit,
const char *remote_name,
const char *collection_id,
FlatpakRemoteState *remote_state);
#endif /* __FLATPAK_REMOTE_REF_PRIVATE_H__ */

View File

@@ -319,19 +319,19 @@ flatpak_remote_ref_get_eol_rebase (FlatpakRemoteRef *self)
}
FlatpakRemoteRef *
flatpak_remote_ref_new (FlatpakCollectionRef *coll_ref,
flatpak_remote_ref_new (const char *full_ref,
const char *commit,
const char *remote_name,
const char *collection_id,
FlatpakRemoteState *state)
{
FlatpakRefKind kind = FLATPAK_REF_KIND_APP;
guint64 download_size = 0, installed_size = 0;
const char *metadata = NULL;
g_autofree char *metadata = NULL;
g_autoptr(GBytes) metadata_bytes = NULL;
g_auto(GStrv) parts = NULL;
FlatpakRemoteRef *ref;
VarMetadataRef sparse_cache;
const char *full_ref = coll_ref->ref_name;
const char *eol = NULL;
const char *eol_rebase = NULL;
@@ -340,15 +340,18 @@ flatpak_remote_ref_new (FlatpakCollectionRef *coll_ref,
return NULL;
if (state &&
!flatpak_remote_state_lookup_cache (state, full_ref,
&download_size, &installed_size, &metadata,
NULL, NULL))
!flatpak_remote_state_load_data (state, full_ref,
&download_size, &installed_size, &metadata,
NULL))
{
g_debug ("Can't find metadata for ref %s", full_ref);
}
if (metadata)
metadata_bytes = g_bytes_new (metadata, strlen (metadata));
{
metadata_bytes = g_bytes_new_take (metadata, strlen (metadata));
metadata = NULL; /* steal */
}
if (state &&
flatpak_remote_state_lookup_sparse_cache (state, full_ref, &sparse_cache, NULL))
@@ -365,9 +368,9 @@ flatpak_remote_ref_new (FlatpakCollectionRef *coll_ref,
"name", parts[1],
"arch", parts[2],
"branch", parts[3],
"collection-id", coll_ref->collection_id,
"commit", commit,
"remote-name", remote_name,
"collection-id", collection_id,
"installed-size", installed_size,
"download-size", download_size,
"metadata", metadata_bytes,

View File

@@ -1037,40 +1037,6 @@ flatpak_remote_new_with_dir (const char *name,
return self;
}
static FlatpakRemoteType
repo_finder_to_remote_type (OstreeRepoFinder *repo_finder)
{
if (OSTREE_IS_REPO_FINDER_AVAHI (repo_finder))
return FLATPAK_REMOTE_TYPE_LAN;
else if (OSTREE_IS_REPO_FINDER_MOUNT (repo_finder))
return FLATPAK_REMOTE_TYPE_USB;
else
return FLATPAK_REMOTE_TYPE_STATIC;
}
FlatpakRemote *
flatpak_remote_new_from_ostree (OstreeRemote *remote,
OstreeRepoFinder *repo_finder,
FlatpakDir *dir)
{
g_autofree gchar *url = NULL;
FlatpakRemotePrivate *priv;
FlatpakRemote *self = g_object_new (FLATPAK_TYPE_REMOTE,
"name", ostree_remote_get_name (remote),
"type", repo_finder_to_remote_type (repo_finder),
NULL);
priv = flatpak_remote_get_instance_private (self);
if (dir)
priv->dir = g_object_ref (dir);
url = ostree_remote_get_url (remote);
if (url != NULL)
flatpak_remote_set_url (self, url);
return self;
}
/**
* flatpak_remote_new:
* @name: a name
@@ -1250,26 +1216,9 @@ flatpak_remote_commit (FlatpakRemote *self,
if (priv->local_collection_id_set)
{
if (priv->local_collection_id != NULL)
{
g_key_file_set_string (config, group, "collection-id", priv->local_collection_id);
/* When a collection ID is set, flatpak uses signed per-repo and
* per-commit metadata instead of summary signatures. */
g_key_file_set_boolean (config, group, "gpg-verify-summary", FALSE);
}
g_key_file_set_string (config, group, "collection-id", priv->local_collection_id);
else
{
g_autoptr(GError) local_error = NULL;
gboolean gpg_verify_value;
g_key_file_remove_key (config, group, "collection-id", NULL);
/* Without a collection ID gpg-verify-summary should go back to
* matching gpg-verify. */
gpg_verify_value = g_key_file_get_boolean (config, group, "gpg-verify", &local_error);
if (local_error == NULL)
g_key_file_set_boolean (config, group, "gpg-verify-summary", gpg_verify_value);
}
g_key_file_remove_key (config, group, "collection-id", NULL);
}
if (priv->local_title_set)

View File

@@ -109,6 +109,7 @@ struct _FlatpakTransactionOperation
gboolean resolved;
char *resolved_commit;
GFile *resolved_sideload_path;
GBytes *resolved_metadata;
GKeyFile *resolved_metakey;
GBytes *resolved_old_metadata;
@@ -155,6 +156,7 @@ struct _FlatpakTransactionPrivate
GHashTable *last_op_for_ref;
GHashTable *remote_states; /* (element-type utf8 FlatpakRemoteState) */
GPtrArray *extra_dependency_dirs;
GPtrArray *extra_sideload_repos;
GList *ops;
GPtrArray *added_origin_remotes;
@@ -479,6 +481,27 @@ flatpak_transaction_add_dependency_source (FlatpakTransaction *self,
flatpak_installation_clone_dir_noensure (installation));
}
/**
* flatpak_transaction_add_sideload_repo:
* @self: a #FlatpakTransaction
* @path: a path to a local flatpak repository
*
* Adds an extra local ostree repo as source for installation. This is equivalent
* with setting the xa.sideload-repos global option, but can be done dynamically.
* If the option is set both sources are used.
*
* Since: 1.7.1
*/
void
flatpak_transaction_add_sideload_repo (FlatpakTransaction *self,
const char *path)
{
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self);
g_ptr_array_add (priv->extra_sideload_repos,
g_strdup (path));
}
/**
* flatpak_transaction_add_default_dependency_sources:
* @self: a #FlatpakTransaction
@@ -588,6 +611,8 @@ flatpak_transaction_operation_finalize (GObject *object)
if (self->external_metadata)
g_bytes_unref (self->external_metadata);
g_free (self->resolved_commit);
if (self->resolved_sideload_path)
g_object_unref (self->resolved_sideload_path);
if (self->resolved_metadata)
g_bytes_unref (self->resolved_metadata);
if (self->resolved_metakey)
@@ -870,6 +895,7 @@ flatpak_transaction_finalize (GObject *object)
g_ptr_array_unref (priv->added_origin_remotes);
g_ptr_array_free (priv->extra_dependency_dirs, TRUE);
g_ptr_array_free (priv->extra_sideload_repos, TRUE);
G_OBJECT_CLASS (flatpak_transaction_parent_class)->finalize (object);
}
@@ -1241,6 +1267,7 @@ flatpak_transaction_init (FlatpakTransaction *self)
priv->remote_states = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) flatpak_remote_state_unref);
priv->added_origin_remotes = g_ptr_array_new_with_free_func (g_free);
priv->extra_dependency_dirs = g_ptr_array_new_with_free_func (g_object_unref);
priv->extra_sideload_repos = g_ptr_array_new_with_free_func (g_free);
priv->can_run = TRUE;
}
@@ -1619,8 +1646,17 @@ flatpak_transaction_ensure_remote_state (FlatpakTransaction *self,
state = flatpak_dir_get_remote_state_optional (priv->dir, remote, FALSE, NULL, error);
g_printerr ("flatpak_transaction_ensure_remote_state\n");
if (state)
g_hash_table_insert (priv->remote_states, state->remote_name, flatpak_remote_state_ref (state));
{
g_hash_table_insert (priv->remote_states, state->remote_name, flatpak_remote_state_ref (state));
for (int i = 0; i < priv->extra_sideload_repos->len; i++)
{
const char *path = g_ptr_array_index (priv->extra_sideload_repos, i);
flatpak_remote_state_add_sideload_repo (state, path);
}
}
return state;
}
@@ -2237,6 +2273,9 @@ flatpak_transaction_update_metadata (FlatpakTransaction *self,
/* Collect all dir+remotes used in this transaction */
if (!flatpak_dir_migrate_config (priv->dir, &some_updated, cancellable, error))
return FALSE;
for (l = priv->ops; l != NULL; l = l->next)
{
FlatpakTransactionOperation *op = l->data;
@@ -2316,7 +2355,7 @@ flatpak_transaction_add_auto_install (FlatpakTransaction *self,
g_autoptr(FlatpakRemoteState) state = flatpak_transaction_ensure_remote_state (self, FLATPAK_TRANSACTION_OPERATION_UPDATE, remote, NULL);
if (state != NULL &&
flatpak_remote_state_lookup_ref (state, ref, NULL, NULL, NULL, NULL))
flatpak_remote_state_lookup_ref (state, ref, NULL, NULL, NULL, NULL, NULL))
{
g_debug ("Auto adding install of %s from remote %s", ref, remote);
if (!flatpak_transaction_add_ref (self, remote, ref, NULL, NULL, NULL,
@@ -2413,6 +2452,7 @@ emit_eol_and_maybe_skip (FlatpakTransaction *self,
static void
mark_op_resolved (FlatpakTransactionOperation *op,
const char *commit,
GFile *sideload_path,
GBytes *metadata,
GBytes *old_metadata)
{
@@ -2424,6 +2464,10 @@ mark_op_resolved (FlatpakTransactionOperation *op,
op->resolved = TRUE;
op->resolved_commit = g_strdup (commit);
if (sideload_path)
op->resolved_sideload_path = g_object_ref (sideload_path);
if (metadata)
{
g_autoptr(GKeyFile) metakey = g_key_file_new ();
@@ -2452,12 +2496,13 @@ static void
resolve_op_end (FlatpakTransaction *self,
FlatpakTransactionOperation *op,
const char *checksum,
GFile *sideload_path,
GBytes *metadata_bytes)
{
g_autoptr(GBytes) old_metadata_bytes = NULL;
old_metadata_bytes = load_deployed_metadata (self, op->ref, NULL);
mark_op_resolved (op, checksum, metadata_bytes, old_metadata_bytes);
mark_op_resolved (op, checksum, sideload_path, metadata_bytes, old_metadata_bytes);
emit_eol_and_maybe_skip (self, op);
}
@@ -2466,6 +2511,7 @@ static void
resolve_op_from_commit (FlatpakTransaction *self,
FlatpakTransactionOperation *op,
const char *checksum,
GFile *sideload_path,
GVariant *commit_data)
{
g_autoptr(GBytes) metadata_bytes = NULL;
@@ -2489,33 +2535,38 @@ resolve_op_from_commit (FlatpakTransaction *self,
g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE, "s", &op->eol);
g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE, "s", &op->eol_rebase);
resolve_op_end (self, op, checksum, metadata_bytes);
resolve_op_end (self, op, checksum, sideload_path, metadata_bytes);
}
static void
resolve_op_from_metadata (FlatpakTransaction *self,
FlatpakTransactionOperation *op,
const char *checksum,
FlatpakRemoteState *state)
static gboolean
try_resolve_op_from_metadata (FlatpakTransaction *self,
FlatpakTransactionOperation *op,
const char *checksum,
GFile *sideload_path,
FlatpakRemoteState *state)
{
g_autoptr(GBytes) metadata_bytes = NULL;
guint64 download_size = 0;
guint64 installed_size = 0;
const char *metadata = NULL;
VarMetadataRef sparse_cache;
g_autoptr(GError) local_error = NULL;
VarRefInfoRef info;
gboolean has_info;
g_autofree char *summary_checksum = NULL;
if (!flatpak_remote_state_lookup_cache (state, op->ref, &download_size, &installed_size, &metadata, NULL, &local_error))
{
g_message (_("Warning: Can't find %s metadata for dependencies: %s"), op->ref, local_error->message);
g_clear_error (&local_error);
}
else
metadata_bytes = g_bytes_new (metadata, strlen (metadata) + 1);
/* Ref has to match the actual commit in the summary */
if (state->summary == NULL ||
!flatpak_summary_lookup_ref (state->summary, NULL, op->ref, &summary_checksum, NULL) ||
strcmp (summary_checksum, checksum) != 0)
return FALSE;
if (flatpak_remote_state_lookup_ref (state, op->ref, NULL, &has_info, &info, NULL) && has_info)
/* And, we must have the actual cached data in the summary */
if (!flatpak_remote_state_lookup_cache (state, op->ref,
&download_size, &installed_size, &metadata, NULL))
return FALSE;
metadata_bytes = g_bytes_new (metadata, strlen (metadata) + 1);
if (flatpak_remote_state_lookup_ref (state, op->ref, NULL, NULL, &info, NULL, NULL))
op->summary_metadata = var_metadata_dup_to_gvariant (var_ref_info_get_metadata (info));
op->installed_size = installed_size;
@@ -2530,7 +2581,8 @@ resolve_op_from_metadata (FlatpakTransaction *self,
op->token_type = GINT32_FROM_LE (var_metadata_lookup_int32 (sparse_cache, FLATPAK_SPARSE_CACHE_KEY_TOKEN_TYPE, op->token_type));
}
resolve_op_end (self, op, checksum, metadata_bytes);
resolve_op_end (self, op, checksum, sideload_path, metadata_bytes);
return TRUE;
}
static gboolean
@@ -2543,171 +2595,6 @@ op_may_need_token (FlatpakTransactionOperation *op)
op->kind == FLATPAK_TRANSACTION_OPERATION_INSTALL_OR_UPDATE);
}
static gboolean
resolve_p2p_ops (FlatpakTransaction *self,
GList *p2p_ops,
GCancellable *cancellable,
GError **error)
{
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self);
g_autoptr(GPtrArray) resolves = g_ptr_array_new_with_free_func ((GDestroyNotify) flatpak_dir_resolve_free);
g_autoptr(FlatpakDirP2PState) state = NULL;
gboolean got_new_need_token;
GList *l;
int i;
for (l = p2p_ops; l != NULL; l = l->next)
{
FlatpakTransactionOperation *op = l->data;
FlatpakDirResolve *resolve;
g_debug ("resolving %s using p2p", op->ref);
g_assert (op->kind != FLATPAK_TRANSACTION_OPERATION_UNINSTALL);
g_assert (op->kind != FLATPAK_TRANSACTION_OPERATION_INSTALL_BUNDLE);
g_assert (!op->resolved);
resolve = flatpak_dir_resolve_new (op->remote, op->ref, op->commit);
g_ptr_array_add (resolves, resolve);
}
g_ptr_array_add (resolves, NULL);
/* This does the metadata checks and resolving of no-op updates. */
state = flatpak_dir_prepare_resolve_p2p_refs (priv->dir, (FlatpakDirResolve **) resolves->pdata,
cancellable, error);
if (state == NULL)
return FALSE;
/* Resolve any ops that we can resolve from the ostree-metadata info */
for (i = 0, l = p2p_ops; l != NULL; i++, l = l->next)
{
FlatpakTransactionOperation *op = l->data;
FlatpakDirResolve *resolve = g_ptr_array_index (resolves, i);
if (resolve->resolved_commit == NULL)
{
g_autoptr(FlatpakRemoteState) state = flatpak_transaction_ensure_remote_state (self, op->kind, op->remote, NULL);
if (state != NULL)
flatpak_dir_resolve_maybe_resolve_from_metadata (resolve, state);
}
}
/* We now pre-resolved all p2p operations, which is all we can do without full access
to the commit objects. To get the commit objects we might need a token, but the information
about whether we need a token or not is in the commit object. This is a catch-22, which we
break by using the extracted commit info in the ostree-metadata branch. There is a minor
risk that this is out-of-sync with the exact information in the commit if using a p2p mirror
with an old version of the app, but the latest ostree-metadata version. The need-token info
is unlikely to change though, and the worst case issue here is some permission error during
download, so this is not *unsafe*, just kinda iffy.
*/
got_new_need_token = FALSE;
for (i = 0, l = p2p_ops; l != NULL; i++, l = l->next)
{
FlatpakTransactionOperation *op = l->data;
FlatpakDirResolve *resolve = g_ptr_array_index (resolves, i);
if (resolve->resolved_commit != NULL)
continue; /* Already resolved this (as no-op) */
if (op_may_need_token (op))
{
g_autoptr(FlatpakRemoteState) state = NULL;
VarMetadataRef sparse_cache;
gint32 token_type;
state = flatpak_transaction_ensure_remote_state (self, op->kind, op->remote, error);
if (state == NULL)
return FALSE;
token_type = state->default_token_type;
if (flatpak_remote_state_lookup_sparse_cache (state, op->ref, &sparse_cache, NULL))
token_type = GINT32_FROM_LE (var_metadata_lookup_int32 (sparse_cache, FLATPAK_SPARSE_CACHE_KEY_TOKEN_TYPE, token_type));
if (token_type > 0)
{
/* We set op->need_token here from the ostree-repo
so we query a token for this, later we'll
override it with the resolved value */
op->token_type = token_type;
got_new_need_token = TRUE;
}
}
}
if (got_new_need_token)
{
if (!request_required_tokens (self, NULL, cancellable, error))
return FALSE;
}
/* We can't get all the resolve commit objects in one pull request,
because the token can be different for each ref, so we need to
split things up by token.*/
g_autoptr(GPtrArray) non_token_resolves = g_ptr_array_new ();
g_autoptr(GHashTable) token_resolves_ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_ptr_array_unref);
for (i = 0, l = p2p_ops; l != NULL; i++, l = l->next)
{
FlatpakTransactionOperation *op = l->data;
FlatpakDirResolve *resolve = g_ptr_array_index (resolves, i);
if (resolve->resolved_commit != NULL)
continue; /* Already resolved this (as no-op) */
if (op->resolved_token)
{
GPtrArray *token_resolves = g_hash_table_lookup (token_resolves_ht, op->resolved_token);
if (token_resolves == NULL)
{
token_resolves = g_ptr_array_new ();
g_hash_table_insert (token_resolves_ht, op->resolved_token, token_resolves);
}
g_ptr_array_add (token_resolves, resolve);
}
else
{
g_ptr_array_add (non_token_resolves, resolve);
}
}
/* This does the downloads of the actual commit objects that are needed. */
/* First refs that need no token */
g_ptr_array_add (non_token_resolves, NULL); // NULL terminate
if (!flatpak_dir_finish_resolve_p2p_refs (priv->dir, (FlatpakDirResolve **) non_token_resolves->pdata, NULL,
state, cancellable, error))
return FALSE;
/* Then once per token */
GLNX_HASH_TABLE_FOREACH_KV(token_resolves_ht, const char *, token, GPtrArray *, token_resolves)
{
g_ptr_array_add (token_resolves, NULL); // NULL terminate
if (!flatpak_dir_finish_resolve_p2p_refs (priv->dir, (FlatpakDirResolve **) token_resolves->pdata, token,
state, cancellable, error))
return FALSE;
}
for (i = 0, l = p2p_ops; l != NULL; i++, l = l->next)
{
FlatpakTransactionOperation *op = l->data;
FlatpakDirResolve *resolve = g_ptr_array_index (resolves, i);
op->download_size = resolve->download_size;
op->installed_size = resolve->installed_size;
op->eol = g_strdup (resolve->eol);
op->eol_rebase = g_strdup (resolve->eol_rebase);
op->token_type = resolve->token_type;
resolve_op_end (self, op, resolve->resolved_commit, resolve->resolved_metadata);
}
return TRUE;
}
/* Resolving an operation means figuring out the target commit
checksum and the metadata for that commit, so that we can handle
dependencies from it, and verify versions. */
@@ -2718,14 +2605,12 @@ resolve_ops (FlatpakTransaction *self,
{
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self);
GList *l;
g_autoptr(GList) collection_id_ops = NULL;
for (l = priv->ops; l != NULL; l = l->next)
{
FlatpakTransactionOperation *op = l->data;
g_autoptr(FlatpakRemoteState) state = NULL;
g_autofree char *checksum = NULL;
g_autoptr(GVariant) commit_data = NULL;
g_autoptr(GBytes) metadata_bytes = NULL;
if (op->resolved)
@@ -2736,14 +2621,14 @@ resolve_ops (FlatpakTransaction *self,
/* We resolve to the deployed metadata, because we need it to uninstall related ops */
metadata_bytes = load_deployed_metadata (self, op->ref, &checksum);
mark_op_resolved (op, checksum, metadata_bytes, NULL);
mark_op_resolved (op, checksum, NULL, metadata_bytes, NULL);
continue;
}
if (op->kind == FLATPAK_TRANSACTION_OPERATION_INSTALL_BUNDLE)
{
g_assert (op->commit != NULL);
mark_op_resolved (op, op->commit, op->external_metadata, NULL);
mark_op_resolved (op, op->commit, NULL, op->external_metadata, NULL);
continue;
}
@@ -2769,51 +2654,83 @@ resolve_ops (FlatpakTransaction *self,
/* Should we use local state */
if (transaction_is_local_only (self, op->kind))
{
commit_data = flatpak_dir_read_latest_commit (priv->dir, op->remote, op->ref, &checksum, NULL, error);
g_autoptr(GVariant) commit_data = flatpak_dir_read_latest_commit (priv->dir, op->remote, op->ref, &checksum, NULL, error);
if (commit_data == NULL)
return FALSE;
resolve_op_from_commit (self, op, checksum, commit_data);
}
else if (state->collection_id == NULL) /* In the non-p2p case we have all the info available in the summary, so use it */
{
g_autoptr(GError) local_error = NULL;
if (op->commit != NULL)
checksum = g_strdup (op->commit);
else if (!flatpak_dir_find_latest_rev (priv->dir, state, op->ref, op->commit, &checksum,
NULL, cancellable, &local_error))
{
/* An unavailable remote summary shouldn't be fatal if we already have the ref */
commit_data = flatpak_dir_read_latest_commit (priv->dir, op->remote, op->ref, &checksum, NULL, NULL);
if (commit_data == NULL)
{
g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
}
else
{
g_message (_("Warning: Treating remote fetch error as non-fatal since %s is already installed: %s"),
op->ref, local_error->message);
g_clear_error (&local_error);
}
}
/* TODO: This only gets the metadata for the latest only, we need to handle the case
where the user specified a commit, or p2p doesn't have the latest commit available */
resolve_op_from_metadata (self, op, checksum, state);
resolve_op_from_commit (self, op, checksum, NULL, commit_data);
}
else
{
/* This is a (potential) p2p operation, so rather than do these individually we queue them up in an operation later */
collection_id_ops = g_list_prepend (collection_id_ops, op);
g_autoptr(GError) local_error = NULL;
g_autoptr(GFile) sideload_path = NULL;
if (op->commit != NULL)
{
checksum = g_strdup (op->commit);
/* Check if this is available offline and if so, use that */
sideload_path = flatpak_remote_state_lookup_sideload_checksum (state, op->commit);
}
else
{
g_autofree char *latest_checksum = NULL;
g_autoptr(GFile) latest_sideload_path = NULL;
g_autofree char *local_checksum = NULL;
guint64 latest_timestamp;
g_autoptr(GVariant) local_commit_data = flatpak_dir_read_latest_commit (priv->dir, op->remote, op->ref, &local_checksum, NULL, NULL);
if (flatpak_dir_find_latest_rev (priv->dir, state, op->ref, op->commit,
&latest_checksum, &latest_timestamp, &latest_sideload_path,
cancellable, &local_error))
{
/* If we found the latest in a sideload repo, it may be older that what is locally available, check timestamps.
* Note: If the timestamps are equal (timestamp granularity issue), assume we want to update */
if (latest_sideload_path != NULL && local_commit_data &&
ostree_commit_get_timestamp (local_commit_data) > latest_timestamp)
{
g_debug ("Installed commit %s newer than sideloaded %s, ignoring", local_checksum, latest_checksum);
checksum = g_steal_pointer (&local_checksum);
}
else
{
/* Otherwise, use whatever we found */
checksum = g_steal_pointer (&latest_checksum);
sideload_path = g_steal_pointer (&latest_sideload_path);
}
}
else
{
/* Ref not available in the remote (maybe offline), resolve to local version if installed */
if (local_commit_data == NULL)
{
g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
}
g_message (_("Warning: Treating remote fetch error as non-fatal since %s is already installed: %s"),
op->ref, local_error->message);
g_clear_error (&local_error);
checksum = g_steal_pointer (&local_checksum);
}
}
/* First try to resolve via metadata (if remote is available and its metadata matches the commit version) */
if (!try_resolve_op_from_metadata (self, op, checksum, sideload_path, state))
{
/* Else try to load the commit object */
g_autoptr(GVariant) commit_data = NULL;
commit_data = flatpak_remote_state_load_ref_commit (state, priv->dir,
op->ref, checksum, error);
if (commit_data == NULL)
return FALSE;
resolve_op_from_commit (self, op, checksum, sideload_path, commit_data);
}
}
}
if (collection_id_ops != NULL &&
!resolve_p2p_ops (self, collection_id_ops, cancellable, error))
return FALSE;
return TRUE;
}
@@ -3101,9 +3018,6 @@ request_tokens_for_remote (FlatpakTransaction *self,
copy_summary_data (extra_builder, state->summary, "xa.oci-registry-uri");
}
if (state->collection_id)
g_variant_builder_add (extra_builder, "{sv}", "collection-id", g_variant_new_string (state->collection_id));
if (flatpak_dir_get_no_interaction (priv->dir))
g_variant_builder_add (extra_builder, "{sv}", "no-interaction", g_variant_new_boolean (TRUE));
@@ -3371,13 +3285,12 @@ flatpak_transaction_get_installation (FlatpakTransaction *self)
static gboolean
remote_is_already_configured (FlatpakTransaction *self,
const char *url,
const char *collection_id)
const char *url)
{
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (self);
g_autofree char *old_remote = NULL;
old_remote = flatpak_dir_find_remote_by_uri (priv->dir, url, collection_id);
old_remote = flatpak_dir_find_remote_by_uri (priv->dir, url);
/* Note: we don't check priv->extra_dependency_dirs because the transaction
* can only operate on one installation so any install/update ops need to
@@ -3393,7 +3306,6 @@ handle_suggested_remote_name (FlatpakTransaction *self, GKeyFile *keyfile, GErro
g_autofree char *suggested_name = NULL;
g_autofree char *name = NULL;
g_autofree char *url = NULL;
g_autofree char *collection_id = NULL;
g_autoptr(GKeyFile) config = NULL;
g_autoptr(GBytes) gpg_key = NULL;
gboolean res;
@@ -3411,11 +3323,7 @@ handle_suggested_remote_name (FlatpakTransaction *self, GKeyFile *keyfile, GErro
if (url == NULL)
return TRUE;
collection_id = g_key_file_get_string (keyfile, FLATPAK_REF_GROUP, FLATPAK_REF_DEPLOY_COLLECTION_ID_KEY, NULL);
if (collection_id == NULL || *collection_id == '\0')
collection_id = g_key_file_get_string (keyfile, FLATPAK_REF_GROUP, FLATPAK_REF_COLLECTION_ID_KEY, NULL);
if (remote_is_already_configured (self, url, collection_id))
if (remote_is_already_configured (self, url))
return TRUE;
/* The name is already used, ignore */
@@ -3462,7 +3370,6 @@ handle_runtime_repo_deps (FlatpakTransaction *self,
g_autoptr(GBytes) gpg_key = NULL;
g_autofree char *group = NULL;
g_autoptr(GError) local_error = NULL;
g_autofree char *runtime_collection_id = NULL;
g_autoptr(SoupSession) soup_session = NULL;
char *t;
int i;
@@ -3541,9 +3448,8 @@ handle_runtime_repo_deps (FlatpakTransaction *self,
group = g_strdup_printf ("remote \"%s\"", new_remote);
runtime_url = g_key_file_get_string (config, group, "url", NULL);
g_assert (runtime_url != NULL);
runtime_collection_id = g_key_file_get_string (config, group, "collection-id", NULL);
if (remote_is_already_configured (self, runtime_url, runtime_collection_id))
if (remote_is_already_configured (self, runtime_url))
return TRUE;
res = FALSE;
@@ -3764,6 +3670,8 @@ _run_op_kind (FlatpakTransaction *self,
remote_state, op->ref, op->resolved_commit,
(const char **) op->subpaths,
(const char **) op->previous_ids,
op->resolved_sideload_path,
op->resolved_metadata,
op->resolved_token,
progress->ostree_progress,
cancellable, error);
@@ -3811,9 +3719,10 @@ _run_op_kind (FlatpakTransaction *self,
priv->max_op >= APP_UPDATE,
priv->max_op == APP_INSTALL || priv->max_op == RUNTIME_INSTALL,
remote_state, op->ref, op->resolved_commit,
NULL,
(const char **) op->subpaths,
(const char **) op->previous_ids,
op->resolved_sideload_path,
op->resolved_metadata,
op->resolved_token,
progress->ostree_progress,
cancellable, &local_error);

View File

@@ -230,6 +230,9 @@ FLATPAK_EXTERN
void flatpak_transaction_add_dependency_source (FlatpakTransaction *self,
FlatpakInstallation *installation);
FLATPAK_EXTERN
void flatpak_transaction_add_sideload_repo (FlatpakTransaction *self,
const char *path);
FLATPAK_EXTERN
void flatpak_transaction_add_default_dependency_sources (FlatpakTransaction *self);
FLATPAK_EXTERN
gboolean flatpak_transaction_run (FlatpakTransaction *transaction,

View File

@@ -450,6 +450,9 @@ gboolean flatpak_repo_set_collection_id (OstreeRepo *repo,
gboolean flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
gboolean deploy_collection_id,
GError **error);
gboolean flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
gboolean deploy_collection_id,
GError **error);
gboolean flatpak_repo_set_gpg_keys (OstreeRepo *repo,
GBytes *bytes,
GError **error);

View File

@@ -2876,7 +2876,7 @@ flatpak_parse_repofile (const char *remote_name,
/* If a collection ID is set, refs are verified from commit metadata rather
* than the summary file. */
g_key_file_set_boolean (config, group, "gpg-verify-summary",
(gpg_key != NULL && collection_id == NULL));
(gpg_key != NULL));
authenticator_name = g_key_file_get_string (keyfile, FLATPAK_REPO_GROUP,
FLATPAK_REPO_AUTHENTICATOR_NAME_KEY, NULL);
@@ -3114,6 +3114,18 @@ flatpak_repo_set_deploy_collection_id (OstreeRepo *repo,
return ostree_repo_write_config (repo, config, error);
}
gboolean
flatpak_repo_set_deploy_sideload_collection_id (OstreeRepo *repo,
gboolean deploy_collection_id,
GError **error)
{
g_autoptr(GKeyFile) config = NULL;
config = ostree_repo_copy_config (repo);
g_key_file_set_boolean (config, "flatpak", "deploy-sideload-collection-id", deploy_collection_id);
return ostree_repo_write_config (repo, config, error);
}
gboolean
flatpak_repo_set_gpg_keys (OstreeRepo *repo,
GBytes *bytes,
@@ -3534,6 +3546,7 @@ flatpak_repo_update (OstreeRepo *repo,
g_autofree char *old_ostree_metadata_checksum = NULL;
g_autoptr(GVariant) old_ostree_metadata_v = NULL;
gboolean deploy_collection_id = FALSE;
gboolean deploy_sideload_collection_id = FALSE;
config = ostree_repo_get_config (repo);
@@ -3547,6 +3560,7 @@ flatpak_repo_update (OstreeRepo *repo,
default_branch = g_key_file_get_string (config, "flatpak", "default-branch", NULL);
gpg_keys = g_key_file_get_string (config, "flatpak", "gpg-keys", NULL);
redirect_url = g_key_file_get_string (config, "flatpak", "redirect-url", NULL);
deploy_sideload_collection_id = g_key_file_get_boolean (config, "flatpak", "deploy-sideload-collection-id", NULL);
deploy_collection_id = g_key_file_get_boolean (config, "flatpak", "deploy-collection-id", NULL);
authenticator_name = g_key_file_get_string (config, "flatpak", "authenticator-name", NULL);
if (g_key_file_has_key (config, "flatpak", "authenticator-install", NULL))
@@ -3588,6 +3602,9 @@ flatpak_repo_update (OstreeRepo *repo,
if (deploy_collection_id && collection_id != NULL)
g_variant_builder_add (builder, "{sv}", OSTREE_META_KEY_DEPLOY_COLLECTION_ID,
g_variant_new_string (collection_id));
else if (deploy_sideload_collection_id && collection_id != NULL)
g_variant_builder_add (builder, "{sv}", "xa.deploy-collection-id",
g_variant_new_string (collection_id));
else if (deploy_collection_id)
g_debug ("Ignoring deploy-collection-id=true because no collection ID is set.");

View File

@@ -167,6 +167,7 @@
<arg type='h' name='fd_index' direction='out'/>
<arg type='s' name='src_dir' direction='out'/>
</method>
</interface>
</node>

View File

@@ -164,6 +164,16 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--deploy-sideload-collection-id</option></term>
<listitem><para>
This is similar to --deploy-collection-id, but it only applies the
deploy to clients newer than flatpak 1.7 which supports the new form
of sideloades.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--gpg-sign=KEYID</option></term>

View File

@@ -159,6 +159,15 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--allow-partial</option></term>
<listitem><para>
Allow exporting partially installed commits, for example locale extensions without all languages. These can cause
problems when installing them, for example if the language config is different on the installing side.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>

View File

@@ -256,6 +256,16 @@
Assume that all <arg choice="plain">REF</arg>s are runtimes if not explicitly specified.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--sideload-repo=PATH</option></term>
<listitem><para>
Adds an extra local ostree repo as source for installation. This is equivalent
with setting the xa.sideload-repos global option, but can be done without modifying the configuration.
If the option is already set both sources are used.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-y</option></term>

View File

@@ -215,6 +215,16 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--sideload-repo=PATH</option></term>
<listitem><para>
Adds an extra local ostree repo as source for installation. This is equivalent
with setting the xa.sideload-repos global option, but can be done without modifying the configuration.
If the option is already set both sources are used.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-y</option></term>
<term><option>--assumeyes</option></term>

View File

@@ -515,7 +515,6 @@ handle_deploy (FlatpakSystemHelper *object,
g_autoptr(FlatpakOciVersioned) versioned = NULL;
g_autoptr(FlatpakOciImage) image_config = NULL;
g_autoptr(FlatpakRemoteState) state = NULL;
FlatpakCollectionRef collection_ref;
g_autoptr(GHashTable) remote_refs = NULL;
g_autofree char *checksum = NULL;
const char *verified_digest;
@@ -594,10 +593,7 @@ handle_deploy (FlatpakSystemHelper *object,
return TRUE;
}
collection_ref.collection_id = state->collection_id;
collection_ref.ref_name = (char *) arg_ref;
verified_digest = g_hash_table_lookup (remote_refs, &collection_ref);
verified_digest = g_hash_table_lookup (remote_refs, arg_ref);
if (!verified_digest)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
@@ -674,7 +670,7 @@ handle_deploy (FlatpakSystemHelper *object,
ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL);
if (!flatpak_dir_pull (system, state, arg_ref, NULL, NULL, (const char **) arg_subpaths, NULL, NULL,
if (!flatpak_dir_pull (system, state, arg_ref, NULL, (const char **) arg_subpaths, NULL, NULL, NULL, NULL,
FLATPAK_PULL_FLAGS_NONE, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, ostree_progress,
NULL, &error))
{
@@ -911,11 +907,11 @@ handle_deploy_appstream (FlatpakSystemHelper *object,
ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL);
if (!flatpak_dir_pull (system, state, new_branch, NULL, NULL, NULL, NULL, NULL,
if (!flatpak_dir_pull (system, state, new_branch, NULL, NULL, NULL, NULL, NULL, NULL,
FLATPAK_PULL_FLAGS_NONE, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, ostree_progress,
NULL, &first_error))
{
if (!flatpak_dir_pull (system, state, old_branch, NULL, NULL, NULL, NULL, NULL,
if (!flatpak_dir_pull (system, state, old_branch, NULL, NULL, NULL, NULL, NULL, NULL,
FLATPAK_PULL_FLAGS_NONE, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, ostree_progress,
NULL, &second_error))
{
@@ -1142,7 +1138,9 @@ handle_configure (FlatpakSystemHelper *object,
return TRUE;
}
if ((strcmp (arg_key, "languages") != 0) && (strcmp (arg_key, "extra-languages") != 0))
if ((strcmp (arg_key, "languages") != 0) &&
(strcmp (arg_key, "extra-languages") != 0) &&
(strcmp (arg_key, "sideload-repos") != 0))
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Unsupported key: %s", arg_key);
@@ -1235,7 +1233,7 @@ handle_update_remote (FlatpakSystemHelper *object,
return TRUE;
}
if (summary_sig_bytes == NULL && state->collection_id == NULL)
if (summary_sig_bytes == NULL)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"UpdateRemote requires a summary signature");
@@ -1355,6 +1353,7 @@ handle_ensure_repo (FlatpakSystemHelper *object,
{
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GError) local_error = NULL;
g_debug ("EnsureRepo %u %s", arg_flags, arg_installation);
@@ -1378,6 +1377,9 @@ handle_ensure_repo (FlatpakSystemHelper *object,
return TRUE;
}
if (!flatpak_dir_migrate_config (system, NULL, NULL, &local_error))
g_warning ("Failed to migrate configuration for installation %s: %s", arg_installation, local_error->message);
flatpak_system_helper_complete_ensure_repo (object, invocation);
return TRUE;

View File

@@ -11,15 +11,13 @@ TEST_MATRIX= \
tests/test-repo@user.wrap \
tests/test-repo@system.wrap \
tests/test-repo@system-norevokefs.wrap \
tests/test-repo@collections.wrap \
tests/test-repo@collections-server-only.wrap \
tests/test-sideload@user.wrap \
tests/test-sideload@system.wrap \
tests/test-bundle@user.wrap \
tests/test-bundle@system.wrap \
tests/test-bundle@system-norevokefs.wrap \
tests/test-oci-registry@user.wrap \
tests/test-oci-registry@system.wrap \
tests/test-auth@nocollections.wrap \
tests/test-auth@collections.wrap \
$(NULL)
TEST_MATRIX_DIST= \
tests/test-basic.sh \
@@ -30,16 +28,16 @@ TEST_MATRIX_DIST= \
tests/test-default-remotes.sh \
tests/test-extensions.sh \
tests/test-oci.sh \
tests/test-unsigned-summaries.sh \
tests/test-update-remote-configuration.sh \
tests/test-override.sh \
tests/test-update-portal.sh \
tests/test-auth.sh \
$(NULL)
TEST_MATRIX_EXTRA_DIST= \
tests/test-run.sh \
tests/test-info.sh \
tests/test-repo.sh \
tests/test-sideload.sh \
tests/test-bundle.sh \
tests/test-oci-registry.sh \
tests/test-auth.sh \
$(NULL)

View File

@@ -177,17 +177,17 @@ TEST_MATRIX_SOURCE = \
tests/test-http-utils.sh \
tests/test-run.sh{{user+system+system-norevokefs},{nodeltas+deltas}} \
tests/test-info.sh{user+system} \
tests/test-repo.sh{user+system+system-norevokefs+collections+collections-server-only} \
tests/test-repo.sh{user+system+system-norevokefs} \
tests/test-sideload.sh{user+system} \
tests/test-default-remotes.sh \
tests/test-extensions.sh \
tests/test-bundle.sh{user+system+system-norevokefs} \
tests/test-oci.sh \
tests/test-oci-registry.sh{{user+system} \
tests/test-unsigned-summaries.sh \
tests/test-update-remote-configuration.sh \
tests/test-override.sh \
tests/test-update-portal.sh \
tests/test-auth.sh{nocollections+collections} \
tests/test-auth.sh \
$(NULL)
update-test-matrix:

View File

@@ -30,8 +30,23 @@ else
test_builddir=$(dirname $0)
fi
# All the asserts and ok functions below are wrapped such that they
# don't output any set -x traces of their internals (but still echo
# errors to stderr). This way the log output focuses on tracing what
# is essential to the test (the asserts being run and errors from them)
assert_not_reached () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
echo $@ 1>&2; exit 1
} 3> /dev/null
}
ok () {
# Wrap this to avoid set -x showing the echo commands
{
echo "ok $@";
echo "================ $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]} ================";
} 2> /dev/null
}
test_tmpdir=$(pwd)
@@ -109,99 +124,129 @@ fi
export FLATPAK="${CMD_PREFIX} flatpak"
assert_streq () {
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
{ { local BASH_XTRACEFD=3; } 2> /dev/null
test "$1" = "$2" || (echo 1>&2 "$1 != $2 at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1)
} 3> /dev/null
}
assert_not_streq () {
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
{ { local BASH_XTRACEFD=3; } 2> /dev/null
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2 at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1)
} 3> /dev/null
}
assert_has_file () {
test -f "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
{ { local BASH_XTRACEFD=3; } 2> /dev/null
test -f "$1" || (echo 1>&2 "Couldn't find '$1' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1)
} 3> /dev/null
}
assert_has_symlink () {
test -L "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
{ { local BASH_XTRACEFD=3; } 2> /dev/null
test -L "$1" || (echo 1>&2 "Couldn't find '$1' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1)
} 3> /dev/null
}
assert_has_dir () {
test -d "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
{ { local BASH_XTRACEFD=3; } 2> /dev/null
test -d "$1" || (echo 1>&2 "Couldn't find '$1' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1)
} 3> /dev/null
}
assert_not_has_file () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if test -f "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' exists"
echo 1>&2 "File '$1' exists at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_not_file_has_content () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if grep -q -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' incorrectly matches regexp '$2'"
echo 1>&2 "File '$1' incorrectly matches regexp '$2' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_file_has_mode () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
mode=$(stat -c '%a' $1)
if [ "$mode" != "$2" ]; then
echo 1>&2 "File '$1' has wrong mode: expected $2, but got $mode"
echo 1>&2 "File '$1' has wrong mode: expected $2, but got $mode at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_not_has_dir () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if test -d "$1"; then
echo 1>&2 "Directory '$1' exists"; exit 1
echo 1>&2 "Directory '$1' exists at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"; exit 1
fi
} 3> /dev/null
}
assert_file_has_content () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if ! grep -q -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' doesn't match regexp '$2'"
echo 1>&2 "File '$1' doesn't match regexp '$2' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_log_has_gpg_signature_error () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if ! grep -q -e "GPG signatures found, but none are in trusted keyring" "$1"; then
if ! grep -q -e "Can't check signature: public key not found" "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' doesn't have gpg signature error"
echo 1>&2 "File '$1' doesn't have gpg signature error at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
fi
} 3> /dev/null
}
assert_symlink_has_content () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if ! readlink "$1" | grep -q -e "$2"; then
readlink "$1" |sed -e 's/^/# /' >&2
echo 1>&2 "Symlink '$1' doesn't match regexp '$2'"
echo 1>&2 "Symlink '$1' doesn't match regexp '$2' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_file_empty() {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if test -s "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' is not empty"
echo 1>&2 "File '$1' is not empty at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
assert_remote_has_config () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
ostree config --repo=$FL_DIR/repo get --group 'remote "'"$1"'"' "$2" > key-output
assert_file_has_content key-output "$3"
} 3> /dev/null
}
assert_remote_has_no_config () {
{ { local BASH_XTRACEFD=3; } 2> /dev/null
if ostree config --repo=$FL_DIR/repo get --group 'remote "'"$1"'"' "$2" > /dev/null; then
echo 1>&2 "Remote '$1' unexpectedly has key '$2'"
echo 1>&2 "Remote '$1' unexpectedly has key '$2' at $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[0]}"
exit 1
fi
} 3> /dev/null
}
export FL_GPG_HOMEDIR=${TEST_DATA_DIR}/gpghome
@@ -257,10 +302,14 @@ httpd () {
rm -f httpd-pipe
mkfifo httpd-pipe
$(dirname $0)/$COMMAND "$DIR" 3> httpd-pipe &
PYTHONUNBUFFERED=1 $(dirname $0)/$COMMAND "$DIR" 3> httpd-pipe 2>&1 | tee --append httpd-log &
read < httpd-pipe
}
httpd_clear_log () {
truncate -s 0 httpd-log
}
setup_repo_no_add () {
REPONAME=${1:-test}
if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then
@@ -458,6 +507,12 @@ gdb_bt () {
gdb -batch -ex "run" -ex "thread apply all bt" -ex "quit 1" --args "$@"
}
commit_to_path () {
COMMIT=$1
EXT=$2
echo "objects/$(echo $COMMIT | cut -b 1-2)/$(echo $COMMIT | cut -b 3-)".${EXT}
}
cleanup () {
/bin/kill -9 $DBUS_SESSION_BUS_PID
gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye || true

View File

@@ -99,7 +99,7 @@ assert_failed_with_401
echo -n the-secret > ${XDG_RUNTIME_DIR}/required-token
${FLATPAK} ${U} update -y org.test.Hello
echo "ok installed build-exported token-type app"
ok "installed build-exported token-type app"
# Drop token-type on main version
make_updated_app test "" master UPDATE3
@@ -121,7 +121,7 @@ assert_failed_with_401
echo -n the-secret > ${XDG_RUNTIME_DIR}/required-token
${FLATPAK} ${U} install -y test-repo org.test.Hello//copy
echo "ok installed build-commit-from token-type app"
ok "installed build-commit-from token-type app"
EXPORT_ARGS="--token-type=2" make_updated_app test "" master UPDATE4
mark_need_token app/org.test.Hello/$ARCH/master the-secret
@@ -151,4 +151,4 @@ export BROWSER=curl
EXPORT_ARGS="--token-type=2" make_updated_app test "" master UPDATE5
mark_need_token app/org.test.Hello/$ARCH/master the-secret
echo "ok update with webflow"
ok "update with webflow"

View File

@@ -31,13 +31,13 @@ ${FLATPAK} --version > version_out
VERSION=`cat "$test_builddir/package_version.txt"`
assert_file_has_content version_out "^Flatpak $VERSION$"
echo "ok version"
ok "version"
${FLATPAK} --help > help_out
assert_file_has_content help_out "^Usage:$"
echo "ok help"
ok "help"
${FLATPAK} --default-arch > arch
@@ -45,14 +45,14 @@ ${FLATPAK} --supported-arches > arches
assert_streq `head -1 arches` `cat arch`
echo "ok default arch"
ok "default arch"
${FLATPAK} --gl-drivers > drivers
assert_file_has_content drivers "^default$";
assert_file_has_content drivers "^host$";
echo "ok gl drivers"
ok "gl drivers"
for cmd in install update uninstall list info config repair create-usb \
search run override make-current enter ps document-export \
@@ -69,7 +69,7 @@ do
assert_file_has_content help_out "flatpak $cmd"
done
echo "ok command help"
ok "command help"
for cmd in list ps remote-ls remotes documents history;
do
@@ -80,28 +80,28 @@ do
assert_file_has_content help_out "^ help"
done
echo "ok columns help"
ok "columns help"
${FLATPAK} >out 2>&1 || true
assert_file_has_content out "^error: No command specified$"
assert_file_has_content out "flatpak --help"
echo "ok missing command"
ok "missing command"
${FLATPAK} indo >out 2>&1 || true
assert_file_has_content out "^error: .* 'info'"
assert_file_has_content out "flatpak --help"
echo "ok misspelt command"
ok "misspelt command"
${FLATPAK} info >out 2>&1 || true
assert_file_has_content out "^error: NAME must be specified$"
assert_file_has_content out "flatpak info --help"
echo "ok info missing NAME"
ok "info missing NAME"
for cmd in config make-current override remote-add repair; do
${FLATPAK} $cmd --system --user >out 2>&1 || true
@@ -114,4 +114,4 @@ for cmd in config make-current override remote-add repair; do
assert_file_has_content out "^error: Multiple installations specified"
done
echo "ok ONE_DIR commands"
ok "ONE_DIR commands"

View File

@@ -38,7 +38,7 @@ ${FLATPAK} build-update-repo --collection-id=org.test.Collection repos/test
assert_file_has_content repos/test/config '^collection-id=org\.test\.Collection$'
echo "ok 1 update repo to add collection ID"
ok "1 update repo to add collection ID"
# Test that youre not allowed to change the collection ID once its already set.
if ${FLATPAK} build-update-repo --collection-id=org.test.Collection2 repos/test 2> build-update-repo-error-log; then
@@ -48,22 +48,22 @@ fi
assert_file_has_content repos/test/config '^collection-id=org\.test\.Collection$'
assert_not_file_has_content repos/test/config '^collection-id=org\.test\.Collection2$'
echo "ok 2 collection ID cannot be changed"
ok "2 collection ID cannot be changed"
${FLATPAK} build-update-repo --title="My little repo" repos/test
assert_file_has_content repos/test/config '^title=My little repo$'
echo "ok can update repo title"
ok "can update repo title"
${FLATPAK} build-update-repo --redirect-url=http://no.where/ repos/test
assert_file_has_content repos/test/config '^redirect-url=http://no\.where/$'
echo "ok can update redirect url"
ok "can update redirect url"
${FLATPAK} build-update-repo --default-branch=no-such-branch repos/test
assert_file_has_content repos/test/config '^default-branch=no-such-branch$'
echo "ok can update default branch"
ok "can update default branch"

View File

@@ -35,14 +35,14 @@ assert_has_file bundles/hello.flatpak
${FLATPAK} build-bundle repos/test --runtime --repo-url=file://`pwd`/repos/test --gpg-keys=${FL_GPG_HOMEDIR}/pubring.gpg bundles/platform.flatpak org.test.Platform
assert_has_file bundles/platform.flatpak
echo "ok create bundles server-side"
ok "create bundles server-side"
rm bundles/hello.flatpak
${FLATPAK} ${U} install -y test-repo org.test.Hello
${FLATPAK} build-bundle $FL_DIR/repo --repo-url=file://`pwd`/repos/test --gpg-keys=${FL_GPG_HOMEDIR}/pubring.gpg bundles/hello.flatpak org.test.Hello
assert_has_file bundles/hello.flatpak
echo "ok create bundles client-side"
ok "create bundles client-side"
${FLATPAK} uninstall ${U} -y org.test.Hello
${FLATPAK} install ${U} -y --bundle bundles/hello.flatpak
@@ -90,7 +90,7 @@ $FLATPAK remote-list ${U} -d | grep hello-origin > /dev/null
$FLATPAK remote-list ${U} -d | grep hello-origin | grep no-enumerate > /dev/null
assert_has_file $FL_DIR/repo/hello-origin.trustedkeys.gpg
echo "ok install app bundle"
ok "install app bundle"
${FLATPAK} uninstall -y --force-remove ${U} org.test.Platform
@@ -123,12 +123,12 @@ $FLATPAK remote-list ${U} -d | grep platform-origin > /dev/null
$FLATPAK remote-list ${U} -d | grep platform-origin | grep no-enumerate > /dev/null
assert_has_file $FL_DIR/repo/platform-origin.trustedkeys.gpg
echo "ok install runtime bundle"
ok "install runtime bundle"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandbox$'
echo "ok run"
ok "run"
OLD_COMMIT=`${FLATPAK} ${U} info --show-commit org.test.Hello`
@@ -140,7 +140,7 @@ if [ x${USE_SYSTEMDIR-} != xyes ] ; then
assert_streq "$OLD_COMMIT" "$ALSO_OLD_COMMIT"
fi
echo "ok null update"
ok "null update"
make_updated_app
@@ -153,7 +153,7 @@ assert_not_streq "$OLD_COMMIT" "$NEW_COMMIT"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandboxUPDATED$'
echo "ok update"
ok "update"
make_updated_app test org.test.Collection.test master UPDATED2
@@ -169,4 +169,4 @@ assert_not_streq "$NEW_COMMIT" "$NEW2_COMMIT"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandboxUPDATED2$'
echo "ok update as bundle"
ok "update as bundle"

View File

@@ -36,7 +36,7 @@ ${FLATPAK} complete "flatpak a" 9 "a" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
EOF
echo "ok complete a commands"
ok "complete a commands"
${FLATPAK} complete "flatpak b" 9 "b" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -51,7 +51,7 @@ build-sign
build-update-repo
EOF
echo "ok complete b commands"
ok "complete b commands"
${FLATPAK} complete "flatpak i" 9 "i" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -59,7 +59,7 @@ info
install
EOF
echo "ok complete i commands"
ok "complete i commands"
${FLATPAK} complete "flatpak --" 10 "--" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -76,7 +76,7 @@ ${FLATPAK} complete "flatpak --" 10 "--" | sort > complete_out
--version
EOF
echo "ok complete global options"
ok "complete global options"
${FLATPAK} complete "flatpak list --" 15 "--" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -95,14 +95,14 @@ ${FLATPAK} complete "flatpak list --" 15 "--" | sort > complete_out
--verbose
EOF
echo "ok complete list options"
ok "complete list options"
${FLATPAK} complete "flatpak create-usb /" 20 "/" | sort > complete_out
#(diff -u complete_out - || echo "fail") <<EOF
#__FLATPAK_DIR
#EOF
echo "ok complete create-usb"
ok "complete create-usb"
${FLATPAK} complete "flatpak list --arch=" 20 "--arch=" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -112,7 +112,7 @@ i386
x86_64
EOF
echo "ok complete --arch"
ok "complete --arch"
${FLATPAK} complete "flatpak override --allow=" 25 "--allow=" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -122,14 +122,14 @@ devel
multiarch
EOF
echo "ok complete --allow"
ok "complete --allow"
${FLATPAK} complete "flatpak config --set l" 23 "l" > complete_out
(diff -u complete_out - || exit 1) <<EOF
languages
EOF
echo "ok complete config"
ok "complete config"
${FLATPAK} complete "flatpak info o" 16 "o" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -138,14 +138,14 @@ org.test.Hello.Locale
org.test.Platform
EOF
echo "ok complete ref"
ok "complete ref"
${FLATPAK} complete "flatpak permission-reset o" 26 "o" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
org.test.Hello
EOF
echo "ok complete partial ref"
ok "complete partial ref"
for cmd in build-bundle build-commit-from build-export build-finish \
build-import-bundle build-init build-sign build-update-repo \
@@ -159,7 +159,7 @@ for cmd in build-bundle build-commit-from build-export build-finish \
assert_not_file_has_content complete_out "^--installation="
done
echo "ok complete NO_DIR commands"
ok "complete NO_DIR commands"
for cmd in history info list run update mask \
config install make-current override remote-add repair \
@@ -172,7 +172,7 @@ for cmd in history info list run update mask \
assert_file_has_content complete_out "^--installation="
done
echo "ok complete non-NO_DIR commands"
ok "complete non-NO_DIR commands"
${FLATPAK} complete "flatpak list --columns=" 24 "--columns=" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -194,19 +194,19 @@ size
version
EOF
echo "ok complete list --columns="
ok "complete list --columns="
${FLATPAK} complete "flatpak list --columns=all" 27 "--columns=all" | sort > complete_out
assert_file_empty complete-out
echo "ok complete list --columns=all"
ok "complete list --columns=all"
${FLATPAK} complete "flatpak list --columns=hel" 27 "--columns=hel" | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
help
EOF
echo "ok complete list --columns=hel"
ok "complete list --columns=hel"
${FLATPAK} complete "flatpak list --columns=arch," 29 "--columns=arch," | sort > complete_out
(diff -u complete_out - || exit 1) <<EOF
@@ -225,5 +225,5 @@ arch,size
arch,version
EOF
echo "ok complete list --columns=arch,"
ok "complete list --columns=arch,"

View File

@@ -29,28 +29,28 @@ echo "1..5"
${FLATPAK} config --list > list_out
assert_file_has_content list_out "^languages:"
echo "ok config list"
ok "config list"
${FLATPAK} config --set languages "de;fr"
${FLATPAK} config --get languages > get_out
assert_file_has_content get_out "^de;fr"
echo "ok config set"
ok "config set"
${FLATPAK} config --set languages "*"
${FLATPAK} config --get languages > get_out
assert_file_has_content get_out "*"
echo "ok config languages *"
ok "config languages *"
${FLATPAK} config --set languages "all"
${FLATPAK} config --get languages > get_out
assert_file_has_content get_out "all"
echo "ok config languages *"
ok "config languages *"
${FLATPAK} config --unset languages
${FLATPAK} config --get languages > get_out
assert_file_has_content get_out "^[*]unset[*]"
echo "ok config unset"
ok "config unset"

View File

@@ -65,14 +65,14 @@ assert_remote_has_no_config added-default xa.icon-is-set
assert_remote_has_no_config added-default xa.noenumerate
assert_remote_has_no_config added-default xa.filter
echo "ok pre-existing installation"
ok "pre-existing installation"
rm -rf $FL_DIR
${FLATPAK} --system remotes > remotes
assert_file_has_content remotes "added-default"
echo "ok non-existing installation"
ok "non-existing installation"
${FLATPAK} --system remotes > remotes
assert_file_has_content remotes "added-default"
@@ -83,7 +83,7 @@ ${FLATPAK} --system remote-delete added-default
${FLATPAK} --system remotes > remotes
assert_not_file_has_content remotes "added-default"
echo "ok allow remove"
ok "allow remove"
rm -rf $FL_DIR
rm -rf $FLATPAK_CONFIG_DIR/remotes.d/*
@@ -109,7 +109,7 @@ assert_remote_has_no_config added-default xa.comment
assert_remote_has_no_config added-default xa.description
assert_remote_has_no_config added-default xa.homepage
echo "ok pre-existing remote"
ok "pre-existing remote"
rm -rf $FL_DIR
rm -rf $FLATPAK_CONFIG_DIR/remotes.d/*
@@ -130,4 +130,4 @@ assert_file_has_content remotes "added-default"
assert_remote_has_no_config added-default xa.filter
echo "ok override default filter"
ok "override default filter"

View File

@@ -101,7 +101,7 @@ $(dirname $0)/make-test-app.sh repos/test "" master "" > /dev/null
# Modify platform metadata
ostree checkout -U --repo=repos/test runtime/org.test.Platform/${ARCH}/master platform
add_extensions platform
ostree commit --repo=repos/test --owner-uid=0 --owner-gid=0 --no-xattrs --canonical-permissions --branch=runtime/org.test.Platform/${ARCH}/master -s "modified metadata" platform
${FLATPAK} build-export --disable-sandbox repos/test platform --files=files master
${FLATPAK} build-update-repo repos/test
${FLATPAK} remote-add --user --no-gpg-verify test-repo repos/test
@@ -150,12 +150,12 @@ run_sh org.test.Hello "ls -lR /usr/foo/multiversion"
assert_has_extension_file /usr multiversion/master/extension-org.test.Multiversion.master:master
assert_has_extension_file /usr multiversion/notmaster/extension-org.test.Multiversion.notmaster:not-master
echo "ok runtime extensions"
ok "runtime extensions"
# Modify app metadata
ostree checkout -U --repo=repos/test app/org.test.Hello/${ARCH}/master hello
add_extensions hello
ostree commit --repo=repos/test --owner-uid=0 --owner-gid=0 --no-xattrs --canonical-permissions --branch=app/org.test.Hello/${ARCH}/master -s "modified metadata" hello
${FLATPAK} build-export --disable-sandbox repos/test hello master
${FLATPAK} build-update-repo repos/test
${FLATPAK} --user update -y org.test.Hello master
@@ -174,4 +174,4 @@ assert_not_has_extension_file /app dir2/foo/exists
assert_has_extension_file /app multiversion/master/extension-org.test.Multiversion.master:master
assert_has_extension_file /app multiversion/notmaster/extension-org.test.Multiversion.notmaster:not-master
echo "ok app extensions"
ok "app extensions"

View File

@@ -96,7 +96,7 @@ assert_ok "/?expires-past" $test_tmpdir/output
assert_ok "/?expires-past" $test_tmpdir/output
rm -f $test_tmpdir/output*
echo 'ok http cache lifetimes'
ok 'http cache lifetimes'
# Revalidation with an etag
assert_ok "/?etag&no-cache" $test_tmpdir/output
@@ -108,7 +108,7 @@ assert_ok "/?modified-time&no-cache" $test_tmpdir/output
assert_304 "/?modified-time&no-cache" $test_tmpdir/output
rm -f $test_tmpdir/output*
echo 'ok http revalidation'
ok 'http revalidation'
# Test compressed downloading and storage
assert_ok --compressed "/compress" $test_tmpdir/output
@@ -116,7 +116,7 @@ contents=$(gunzip -c < $test_tmpdir/output)
assert_streq $contents path=/compress
rm -f $test_tmpdir/output*
echo 'ok compressed download'
ok 'compressed download'
# Test uncompressed downloading with compressed storage
assert_ok --compressed "/compress?ignore-accept-encoding" $test_tmpdir/output
@@ -124,18 +124,18 @@ contents=$(gunzip -c < $test_tmpdir/output)
assert_streq $contents path=/compress?ignore-accept-encoding
rm -f $test_tmpdir/output*
echo 'ok compress after download'
ok 'compress after download'
# Testing that things work without xattr support
if have_xattrs $test_tmpdir ; then
echo "ok no-xattrs # skip /tmp doesn't have user xattr support"
ok "no-xattrs # skip /tmp doesn't have user xattr support"
else
assert_ok "/?etag&no-cache" $test_tmpdir/output
assert_has_file $test_tmpdir/output.flatpak.http
assert_304 "/?etag&no-cache" $test_tmpdir/output
rm -f $test_tmpdir/output*
echo "ok no-xattrs"
ok "no-xattrs"
fi
# Testing with xattr support
@@ -152,7 +152,7 @@ if have_xattrs $xattrs_tempdir ; then
assert_not_has_file $xattrs_tempdir/output.flatpak.http
assert_304 "/?etag&no-cache" $xattrs_tempdir/output
rm -f $xattrs_tempdir/output*
echo "ok xattrs"
ok "xattrs"
else
echo "ok xattrs # skip /var/tmp has user no xattr support"
ok "xattrs # skip /var/tmp has user no xattr support"
fi

View File

@@ -17,40 +17,40 @@ ${FLATPAK} info -rcos org.test.Hello > info
assert_file_has_content info "^app/org\.test\.Hello/$(flatpak --default-arch)/master test-repo ${COMMIT}"
echo "ok info -rcos"
ok "info -rcos"
${FLATPAK} info --show-permissions org.test.Hello > info
assert_file_empty info
echo "ok info --show-permissions"
ok "info --show-permissions"
${FLATPAK} info --show-location org.test.Hello > info
assert_file_has_content info "app/org\.test\.Hello/$(flatpak --default-arch)/master/${COMMIT}"
echo "ok info --show-location"
ok "info --show-location"
${FLATPAK} info --show-runtime org.test.Hello > info
assert_file_has_content info "^org\.test\.Platform/$(flatpak --default-arch)/master$"
echo "ok info --show-runtime"
ok "info --show-runtime"
${FLATPAK} info --show-sdk org.test.Hello > info
assert_file_has_content info "^org\.test\.Platform/$(flatpak --default-arch)/master$"
echo "ok info --show-sdk"
ok "info --show-sdk"
${FLATPAK} info --show-extensions org.test.Hello > info
assert_file_has_content info "Extension: runtime/org\.test\.Hello\.Locale/$(flatpak --default-arch)/master$"
echo "ok info --show-extensions"
ok "info --show-extensions"
${FLATPAK} info --file-access=home org.test.Hello > info
assert_file_has_content info "^hidden$"
echo "ok info --file-access"
ok "info --file-access"

View File

@@ -49,7 +49,7 @@ ${FLATPAK} remote-add ${U} oci-registry "oci+http://127.0.0.1:${port}"
images=$(${FLATPAK} remote-ls ${U} --columns=app oci-registry | sort | tr '\n' ' ' | sed 's/ $//')
assert_streq "$images" "org.test.Hello org.test.Platform"
echo "ok list remote"
ok "list remote"
# Pull appstream data
@@ -69,13 +69,13 @@ gunzip -c $appstream > appstream-uncompressed
assert_file_has_content appstream-uncompressed '<id>org\.test\.Hello\.desktop</id>'
assert_has_file $icondir/64x64/org.test.Hello.png
echo "ok appstream"
ok "appstream"
# Test that 'flatpak search' works
${FLATPAK} search org.test.Hello > search-results
assert_file_has_content search-results "Print a greeting"
echo "ok search"
ok "search"
# Replace with the app image with detached icons, check that the icons work
@@ -88,7 +88,7 @@ assert_has_file $icondir/64x64/org.test.Hello.png
new_icon_hash=(md5sum $icondir/64x64/org.test.Hello.png)
assert_streq $old_icon_hash $new_icon_hash
echo "ok detached icons"
ok "detached icons"
# Try installing from the remote
@@ -97,7 +97,7 @@ ${FLATPAK} ${U} install -y oci-registry org.test.Hello
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandbox$'
echo "ok install"
ok "install"
make_updated_app oci
@@ -116,7 +116,7 @@ assert_not_streq "$OLD_COMMIT" "$NEW_COMMIT"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandboxUPDATED$'
echo "ok update"
ok "update"
# Remove the app from the registry, check that things were removed properly
@@ -131,7 +131,7 @@ assert_not_file_has_content $appstream '<id>org\.test\.Hello\.desktop</id>'
assert_not_has_file $icondir/64x64/org.test.Hello.png
assert_not_has_file $icondir/64x64
echo "ok appstream change"
ok "appstream change"
# Change the remote to a non-OCI remote, check that we cleaned up
@@ -149,7 +149,7 @@ assert_not_has_file $base/oci/oci-registry.index.gz
assert_not_has_file $base/oci/oci-registry.summary
assert_not_has_dir $base/appstream/oci-registry
echo "ok change remote to non-OCI"
ok "change remote to non-OCI"
# Change it back and refetch
@@ -168,7 +168,7 @@ assert_not_has_file $base/oci/oci-registry.index.gz
assert_not_has_file $base/oci/oci-registry.summary
assert_not_has_dir $base/appstream/oci-registry
echo "ok delete remote"
ok "delete remote"
# Try installing the platform via a flatpakref file.
@@ -188,7 +188,7 @@ assert_file_has_content remotes-list '^platform-origin'
assert_has_file $base/oci/platform-origin.index.gz
echo "ok install via flatpakref"
ok "install via flatpakref"
# Uninstall, check that the origin remote was pruned, and files were
# cleaned up properly
@@ -200,7 +200,7 @@ assert_not_file_has_content remotes '^platform-origin'
assert_not_has_file $base/oci/platform-origin.index.gz
echo "ok prune origin remote"
ok "prune origin remote"
# Install from a (non-OCI) bundle, check that the repo-url is respected
@@ -213,7 +213,7 @@ assert_file_has_content remotes-list "^platform-origin.*[ ]oci+http://127\.0\.0
assert_has_file $base/oci/platform-origin.index.gz
echo "ok install via bundle"
ok "install via bundle"
# Install an app from a bundle
@@ -226,7 +226,7 @@ assert_file_has_content remotes-list "^hello-origin.*[ ]oci+http://127\.0\.0\.1
assert_has_file $base/oci/hello-origin.index.gz
echo "ok app install via bundle"
ok "app install via bundle"
# Install an updated app bundle with a different origin
@@ -240,4 +240,4 @@ assert_file_has_content remotes-list "^hello-origin.*[ ]http://127\.0\.0\.1:${p
assert_not_has_file $base/oci/hello-origin.index.gz
echo "ok change remote origin via bundle"
ok "change remote origin via bundle"

View File

@@ -53,7 +53,7 @@ assert_file_has_content $image "org\.freedesktop\.appstream\.appdata.*<summary>P
assert_file_has_content $image "org\.freedesktop\.appstream\.icon-64"
assert_file_has_content $image org.flatpak.ref.*app/org.test.Hello/x86_64/master
echo "ok export oci"
ok "export oci"
ostree --repo=repo2 init --mode=archive-z2
@@ -65,4 +65,4 @@ assert_has_dir checked-out/files
assert_has_file checked-out/files/bin/hello.sh
assert_has_file checked-out/metadata
echo "ok import oci"
ok "import oci"

View File

@@ -26,7 +26,7 @@ ${FLATPAK} override --user --show org.test.Hello > override
assert_file_has_content override "^\[Context\]$"
assert_file_has_content override "^sockets=wayland;!ssh-auth;$"
echo "ok override --socket"
ok "override --socket"
reset_overrides
@@ -37,7 +37,7 @@ ${FLATPAK} override --user --show org.test.Hello > override
assert_file_has_content override "^\[Context\]$"
assert_file_has_content override "^devices=dri;!kvm;$"
echo "ok override --device"
ok "override --device"
reset_overrides
@@ -48,7 +48,7 @@ ${FLATPAK} override --user --show org.test.Hello > override
assert_file_has_content override "^\[Context\]$"
assert_file_has_content override "^shared=network;!ipc;$"
echo "ok override --share"
ok "override --share"
reset_overrides
@@ -59,7 +59,7 @@ ${FLATPAK} override --user --show org.test.Hello > override
assert_file_has_content override "^\[Context\]$"
assert_file_has_content override "^features=multiarch;!bluetooth;$"
echo "ok override --allow"
ok "override --allow"
reset_overrides
@@ -71,7 +71,7 @@ assert_file_has_content override "^\[Environment\]$"
assert_file_has_content override "^FOO=BAR$"
assert_file_has_content override "^BAR=$"
echo "ok override --env"
ok "override --env"
${FLATPAK} override --user --filesystem=home org.test.Hello
${FLATPAK} override --user --filesystem=xdg-desktop/foo:create org.test.Hello
@@ -87,7 +87,7 @@ assert_file_has_content override "^filesystems=.*xdg-documents;.*$"
assert_file_has_content override "^filesystems=.*xdg-desktop/foo:create;.*$"
assert_file_has_content override "^filesystems=.*xdg-config:ro;.*$"
echo "ok override --filesystem"
ok "override --filesystem"
reset_overrides
@@ -102,7 +102,7 @@ assert_file_has_content override "^org\.foo\.Own=own$"
assert_file_has_content override "^org\.foo\.Talk=talk$"
assert_file_has_content override "^org\.foo\.NoTalk=none$"
echo "ok override session bus names"
ok "override session bus names"
reset_overrides
@@ -117,7 +117,7 @@ assert_file_has_content override "^org\.foo\.Own\.System=own$"
assert_file_has_content override "^org\.foo\.Talk\.System=talk$"
assert_file_has_content override "^org\.foo\.NoTalk\.System=none$"
echo "ok override system bus names"
ok "override system bus names"
reset_overrides
@@ -132,9 +132,9 @@ elif [ -S "${XDG_RUNTIME_DIR}/wayland-0" ]; then
${FLATPAK} run --command=ls org.test.Hello -- /run/user/1000 > out
assert_not_file_has_content out "wayland-0"
echo "ok sandbox wayland socket"
ok "sandbox wayland socket"
else
echo "ok sandbox wayland socket # skip not supported without Wayland"
ok "sandbox wayland socket # skip not supported without Wayland"
fi
reset_overrides
@@ -150,9 +150,9 @@ elif [ -d "/dev/dri" ]; then
${FLATPAK} run --command=ls org.test.Hello -- /dev > out
assert_not_file_has_content out "dri"
echo "ok sandbox dri device"
ok "sandbox dri device"
else
echo "ok sandbox dri device # skip not supported without /dev/dri"
ok "sandbox dri device # skip not supported without /dev/dri"
fi
reset_overrides
@@ -165,7 +165,7 @@ if ! skip_one_without_bwrap "sandbox dri device"; then
FOO=bar ${FLATPAK} run --command=sh org.test.Hello -c 'echo $FOO' > out
assert_file_has_content out "BAR"
echo "ok sandbox env"
ok "sandbox env"
fi
reset_overrides
@@ -183,7 +183,7 @@ if ! skip_one_without_bwrap "sandbox filesystem"; then
rm $HOME/example
echo "ok sandbox filesystem"
ok "sandbox filesystem"
fi
reset_overrides
@@ -193,5 +193,5 @@ if ! skip_one_without_bwrap "persist"; then
${FLATPAK} run --command=sh org.test.Hello -c "echo goodbye > $HOME/example/bye"
assert_file_has_content $HOME/.var/app/org.test.Hello/example/bye goodbye
echo "ok persist"
ok "persist"
fi

View File

@@ -89,7 +89,7 @@ assert_has_symlink $FL_DIR/appstream/test-repo/$ARCH/active
assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml
assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml.gz
echo "ok update compat appstream"
ok "update compat appstream"
# Then regenerate new appstream branch and verify that we update to it
update_repo
@@ -103,33 +103,33 @@ assert_has_symlink $FL_DIR/appstream/test-repo/$ARCH/active
assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml
assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml.gz
echo "ok update appstream"
ok "update appstream"
if [ x${USE_COLLECTIONS_IN_CLIENT-} != xyes ] ; then
install_repo test-no-gpg
echo "ok install without gpg key"
ok "install without gpg key"
${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
else
echo "ok install without gpg key # skip not supported for collections"
ok "install without gpg key # skip not supported for collections"
fi
install_repo local-test-no-gpg
${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
${FLATPAK} ${U} update --appstream local-test-no-gpg-repo
echo "ok local without gpg key"
ok "local without gpg key"
install_repo test-gpg2
echo "ok with alternative gpg key"
ok "with alternative gpg key"
if ${FLATPAK} ${U} install -y test-repo org.test.Platform 2> install-error-log; then
assert_not_reached "Should not be able to install again from different remote without reinstall"
fi
echo "ok failed to install again from different remote"
ok "failed to install again from different remote"
${FLATPAK} ${U} install -y --reinstall test-repo org.test.Platform
echo "ok re-install"
ok "re-install"
${FLATPAK} ${U} uninstall -y org.test.Hello
@@ -140,7 +140,7 @@ assert_file_has_content install-log "org\.test\.Hello"
${FLATPAK} ${U} list -d > list-log
assert_file_has_content list-log "org\.test\.Hello"
echo "ok typo correction works for install"
ok "typo correction works for install"
${FLATPAK} ${U} uninstall -y org.test.Hello
@@ -168,7 +168,7 @@ if [ x${USE_COLLECTIONS_IN_CLIENT-} != xyes ] ; then
${FLATPAK} ${U} remote-modify --enable test-no-gpg-repo
fi
echo "ok missing remote name auto-corrects for install"
ok "missing remote name auto-corrects for install"
port=$(cat httpd-port)
if ${FLATPAK} ${U} install -y http://127.0.0.1:${port}/nonexistent.flatpakref 2> install-error-log; then
@@ -176,7 +176,7 @@ if ${FLATPAK} ${U} install -y http://127.0.0.1:${port}/nonexistent.flatpakref 2>
fi
assert_file_has_content install-error-log "Server returned status 404: Not Found"
echo "ok install fails gracefully for 404 URLs"
ok "install fails gracefully for 404 URLs"
# Use a new remote so we can be sure it doesn't match any existing one's URL
setup_repo_no_add flatpakref org.test.Collection.Flatpakref
@@ -214,7 +214,7 @@ if [ $NUM_REMOTES_AFTER -ne $((NUM_REMOTES_BEFORE + 1)) ]; then
assert_not_reached "install of flatpakref should only add one remote"
fi
echo "ok install flatpakref normalizes remote URL trailing slash"
ok "install flatpakref normalizes remote URL trailing slash"
${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
@@ -228,7 +228,7 @@ if ${FLATPAK} ${U} install test-missing-gpg-repo org.test.Hello 2> install-error
fi
assert_log_has_gpg_signature_error install-error-log
echo "ok fail with missing gpg key"
ok "fail with missing gpg key"
if ${FLATPAK} ${U} install test-wrong-gpg-repo org.test.Platform 2> install-error-log; then
assert_not_reached "Should not be able to install with wrong gpg key"
@@ -240,7 +240,7 @@ if ${FLATPAK} ${U} install test-wrong-gpg-repo org.test.Hello 2> install-error-l
fi
assert_log_has_gpg_signature_error install-error-log
echo "ok fail with wrong gpg key"
ok "fail with wrong gpg key"
make_required_version_app () {
APP_ID=${1}
@@ -303,7 +303,7 @@ assert_file_has_content install-error-log "needs a later flatpak version"
${FLATPAK} ${U} uninstall -y --all
echo "ok handles version requirements"
ok "handles version requirements"
${FLATPAK} ${U} remotes -d | grep ^test-repo > repo-info
assert_not_file_has_content repo-info "new-title"
@@ -315,7 +315,7 @@ ${FLATPAK} ${U} install -y test-repo org.test.Platform
${FLATPAK} ${U} remotes -d | grep ^test-repo > repo-info
assert_file_has_content repo-info "new-title"
echo "ok update metadata"
ok "update metadata"
if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then
COPY_COLLECTION_ID=org.test.Collection.test
@@ -339,7 +339,7 @@ assert_not_file_has_content appdata.xml "org\.test\.Hello\.desktop"
${FLATPAK} repo --branches repos/test-copy > branches-log
assert_file_has_content branches-log "^app/org\.test\.Hello/.*eol=Reason1"
echo "ok eol build-commit-from"
ok "eol build-commit-from"
${FLATPAK} ${U} install -y test-repo org.test.Hello
@@ -376,7 +376,7 @@ ${FLATPAK} ${U} uninstall -y org.test.Hello
# Remove eol for future tests
EXPORT_ARGS="" make_updated_app
echo "ok eol build-export"
ok "eol build-export"
if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then
REBASE_COLLECTION_ID=org.test.Collection.rebase
@@ -422,7 +422,7 @@ assert_has_file $HOME/.var/app/org.test.Hello/data/another-file
${FLATPAK} ${U} uninstall -y org.test.NewHello org.test.Platform
echo "ok eol-rebase"
ok "eol-rebase"
${FLATPAK} ${U} install -y test-repo org.test.Platform
@@ -442,7 +442,7 @@ update_repo test-gpg3 org.test.Collection.test
${FLATPAK} ${U} install -y test-repo org.test.Hello
assert_file_has_content $FL_DIR/app/org.test.Hello/$ARCH/master/active/files/bin/hello.sh UPDATED
echo "ok redirect url and gpg key"
ok "redirect url and gpg key"
# Test https://github.com/flatpak/flatpak/issues/3222
mkdir -p $FL_DIR/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/$ARCH/
@@ -452,13 +452,13 @@ ${FLATPAK} ${U} update -y org.test.Hello
assert_not_has_file $FL_DIR/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/$ARCH/master
assert_has_file $FL_DIR/repo/refs/remotes/test-repo/app/org.test.Hello/$ARCH/master
echo "ok mirror ref deletion on update"
ok "mirror ref deletion on update"
${FLATPAK} ${U} list --arch=$ARCH --columns=ref > list-log
assert_file_has_content list-log "org\.test\.Hello"
assert_file_has_content list-log "org\.test\.Platform"
echo "ok flatpak list --arch --columns works"
ok "flatpak list --arch --columns works"
if ${FLATPAK} ${INVERT_U} uninstall -y org.test.Platform org.test.Hello; then
assert_not_reached "Should not be able to uninstall ${INVERT_U} when installed ${U}"
@@ -471,7 +471,7 @@ ${FLATPAK} ${U} list -d > list-log
assert_not_file_has_content list-log "org\.test\.Hello"
assert_not_file_has_content list-log "org\.test\.Platform"
echo "ok uninstall vs installations"
ok "uninstall vs installations"
${FLATPAK} ${U} install -y test-repo org.test.Hello
@@ -490,7 +490,7 @@ ${FLATPAK} ${U} list -d > list-log
assert_not_file_has_content list-log "org\.test\.Hello"
assert_not_file_has_content list-log "org\.test\.Platform"
echo "ok uninstall dependencies"
ok "uninstall dependencies"
${FLATPAK} ${U} install -y test-repo org.test.Hello
@@ -498,14 +498,14 @@ ${FLATPAK} ${U} install -y test-repo org.test.Hello
${FLATPAK} ${U} uninstall -y hello
${FLATPAK} ${U} uninstall -y platform
echo "ok typo correction works for uninstall"
ok "typo correction works for uninstall"
${FLATPAK} ${U} install -y test-repo org.test.Hello master
${FLATPAK} ${U} uninstall -y org.test.Hello master
${FLATPAK} ${U} uninstall -y org.test.Platform master
echo "ok install and uninstall support 'NAME BRANCH' syntax"
ok "install and uninstall support 'NAME BRANCH' syntax"
${FLATPAK} ${U} install -y --no-deploy test-repo org.test.Hello
@@ -526,7 +526,7 @@ ${FLATPAK} ${U} list -d > list-log
assert_file_has_content list-log "org\.test\.Hello"
assert_file_has_content list-log "org\.test\.Platform"
echo "ok install with --no-deploy and then --no-pull"
ok "install with --no-deploy and then --no-pull"
${FLATPAK} ${U} uninstall -y org.test.Hello org.test.Platform
@@ -550,7 +550,7 @@ ${FLATPAK} ${U} list -d > list-log
assert_file_has_content list-log "org\.test\.Hello"
assert_file_has_content list-log "org\.test\.Platform"
echo "ok install with --no-deploy and then --no-pull works with typo correction"
ok "install with --no-deploy and then --no-pull works with typo correction"
${FLATPAK} uninstall -y --all
@@ -558,7 +558,7 @@ ${FLATPAK} ${U} list -d > list-log
assert_not_file_has_content list-log "org\.test\.Hello"
assert_not_file_has_content list-log "org\.test\.Platform"
echo "ok uninstall --all"
ok "uninstall --all"
${FLATPAK} ${U} install -y test-repo org.test.Hello
@@ -575,7 +575,7 @@ assert_not_file_has_content list-log "org\.test\.Hello\.Locale"
setup_repo
echo "ok uninstall with missing remote"
ok "uninstall with missing remote"
${FLATPAK} ${U} list -a --columns=application > list-log
assert_file_has_content list-log "org\.test\.Platform"
@@ -585,7 +585,7 @@ ${FLATPAK} ${U} uninstall -y --unused
${FLATPAK} ${U} list -a --columns=application > list-log
assert_not_file_has_content list-log "org\.test\.Platform"
echo "ok uninstall --unused"
ok "uninstall --unused"
# Test that remote-ls works in all of the following cases:
# * system remote, and --system is used
@@ -619,14 +619,14 @@ else
assert_file_has_content remote-ls-error-log "Remote \"test-repo\" not found"
fi
echo "ok remote-ls"
ok "remote-ls"
# Test that remote-ls can take a file:// URI
ostree --repo=repos/test summary -u
${FLATPAK} remote-ls file://`pwd`/repos/test > repo-list
assert_file_has_content repo-list "org\.test\.Hello"
echo "ok remote-ls URI"
ok "remote-ls URI"
# Test that remote-modify works in all of the following cases:
# * system remote, and --system is used
@@ -668,7 +668,7 @@ else
assert_file_has_content remote-modify-error-log "Remote \"test-repo\" not found"
fi
echo "ok remote-modify"
ok "remote-modify"
# Test that remote-delete works in all of the following cases:
# * system remote, and --system is used
@@ -710,7 +710,7 @@ else
assert_file_has_content remote-delete-error-log "Remote \"test-repo\" not found"
fi
echo "ok remote-delete"
ok "remote-delete"
# Test that remote-info works in all of the following cases:
# * system remote, and --system is used
@@ -744,7 +744,7 @@ else
assert_file_has_content remote-info-error-log "Remote \"test-repo\" not found"
fi
echo "ok remote-info"
ok "remote-info"
${FLATPAK} ${U} remote-ls -d -a test-repo > remote-ls-log
assert_file_has_content remote-ls-log "app/org\.test\.Hello"
@@ -767,11 +767,11 @@ assert_not_file_has_content remote-ls-log "app/org\.test\.Hello"
assert_not_file_has_content remote-ls-log "runtime/org\.test\.Hello\.Locale"
assert_file_has_content remote-ls-log "runtime/org\.test\.Platform"
if ${FLATPAK} ${U} remote-info test-repo org.test.Hello > remote-ref-info; then
if ${FLATPAK} ${U} remote-info test-repo org.test.Hello > remote-ref-info 2> /dev/null; then
assert_not_reached "flatpak remote-info test-repo org.test.Hello should fail due to filter"
fi
if ${FLATPAK} ${U} install -y test-repo org.test.Hello; then
if ${FLATPAK} ${U} install -y test-repo org.test.Hello 2> /dev/null; then
assert_not_reached "should not be able to install org.test.Hello should fail due to filter"
fi
@@ -803,7 +803,7 @@ assert_file_has_content remote-ls-log "app/org\.test\.Hello"
assert_file_has_content remote-ls-log "runtime/org\.test\.Hello\.Locale"
assert_file_has_content remote-ls-log "runtime/org\.test\.Platform"
echo "ok filter"
ok "filter"
# Try installing it from a flatpakrepo file. Dont uninstall afterwards because
# we need it for the next test.
@@ -877,4 +877,4 @@ assert_remote_has_config new-repo xa.filter "${test_srcdir}/test.filter"
${FLATPAK} ${U} remote-add --if-not-exists new-repo test.flatpakrepo
assert_remote_has_no_config new-repo xa.filter
echo "ok flatpakrepo"
ok "flatpakrepo"

View File

@@ -67,18 +67,18 @@ $FLATPAK info ${U} org.test.Hello > /dev/null
$FLATPAK info ${U} org.test.Hello | grep test-repo > /dev/null
$FLATPAK info ${U} org.test.Hello | grep $ID > /dev/null
echo "ok install"
ok "install"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandbox$'
echo "ok hello"
ok "hello"
run_sh org.test.Platform cat /.flatpak-info >runtime-fpi
assert_file_has_content runtime-fpi "[Runtime]"
assert_file_has_content runtime-fpi "^runtime=runtime/org\.test\.Platform/$ARCH/stable$"
echo "ok run a runtime"
ok "run a runtime"
if run org.test.Nonexistent 2> run-error-log; then
assert_not_reached "Unexpectedly able to run non-existent runtime"
@@ -95,12 +95,12 @@ if run runtime/org.test.Nonexistent 2> run-error-log; then
fi
assert_file_has_content run-error-log "error: runtime/org\.test\.Nonexistent/\*unspecified\*/\*unspecified\* not installed"
echo "ok error handling for invalid refs"
ok "error handling for invalid refs"
run_sh org.test.Hello cat /run/user/`id -u`/flatpak-info > fpi
assert_file_has_content fpi '^name=org\.test\.Hello$'
echo "ok flatpak-info"
ok "flatpak-info"
run_sh org.test.Hello readlink /proc/self/ns/net > unshared_net_ns
ARGS="--share=network" run_sh org.test.Hello readlink /proc/self/ns/net > shared_net_ns
@@ -165,7 +165,7 @@ else
echo "not testing \$HOME binding, \$HOME/.flatpak-tests/ does not exist" >&2
fi
echo "ok namespaces"
ok "namespaces"
test_overrides () {
local dir="$1"
@@ -207,7 +207,7 @@ else
echo "not testing \$HOME binding overrides, \$HOME/.flatpak-tests/ does not exist" >&2
fi
echo "ok overrides"
ok "overrides"
OLD_COMMIT=`${FLATPAK} ${U} info --show-commit org.test.Hello`
@@ -218,7 +218,7 @@ if [ x${USE_SYSTEMDIR-} != xyes ] ; then
assert_streq "$OLD_COMMIT" "$ALSO_OLD_COMMIT"
fi
echo "ok null update"
ok "null update"
make_updated_app "" "" stable
@@ -231,7 +231,7 @@ assert_not_streq "$OLD_COMMIT" "$NEW_COMMIT"
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandboxUPDATED$'
echo "ok update"
ok "update"
ostree --repo=repos/test reset app/org.test.Hello/$ARCH/stable "$OLD_COMMIT"
update_repo
@@ -244,7 +244,7 @@ NEW_NEW_COMMIT=`${FLATPAK} ${U} info --show-commit org.test.Hello`
assert_streq "$NEW_COMMIT" "$NEW_NEW_COMMIT"
echo "ok backwards update"
ok "backwards update"
make_updated_app "" "" stable UPDATED2
@@ -265,7 +265,7 @@ NEW_COMMIT=`${FLATPAK} ${U} info --show-commit org.test.Hello`
assert_not_streq "$OLD_COMMIT" "$NEW_COMMIT"
echo "ok install --or-update"
ok "install --or-update"
DIR=`mktemp -d`
${FLATPAK} build-init ${DIR} org.test.Split org.test.Platform org.test.Platform stable
@@ -348,7 +348,7 @@ assert_has_file $FL_DIR/app/org.test.Split/$ARCH/stable/active/files/e/data
assert_not_has_file $FL_DIR/app/org.test.Split/$ARCH/stable/active/files/f
assert_not_has_file $FL_DIR/app/org.test.Split/$ARCH/stable/active/files/nope
echo "ok subpaths"
ok "subpaths"
VERSION=`cat "$test_builddir/package_version.txt"`
@@ -408,7 +408,7 @@ assert_file_has_content err_version.txt "needs a later flatpak version"
assert_not_has_file $FL_DIR/app/org.test.CurrentVersion/$ARCH/stable/active/files/updated
assert_has_file $FL_DIR/app/org.test.OldVersion/$ARCH/stable/active/files/updated
echo "ok version checks"
ok "version checks"
rm -rf app
flatpak build-init app org.test.Writable org.test.Platform org.test.Platform stable
@@ -416,7 +416,8 @@ mkdir -p app/files/a-dir
chmod a+rwx app/files/a-dir
flatpak build-finish --command=hello.sh app
# Note: not --canonical-permissions
ostree --repo=repos/test commit --owner-uid=0 --owner-gid=0 --no-xattrs ${FL_GPGARGS} --branch=app/org.test.Writable/$ARCH/stable app
${FLATPAK} build-export -vv --disable-sandbox --files=files repos/test app stable
ostree --repo=repos/test commit --keep-metadata=xa.metadata --owner-uid=0 --owner-gid=0 --no-xattrs ${FL_GPGARGS} --branch=app/org.test.Writable/$ARCH/stable app
update_repo
# In the system-helper case this fails to install due to the permission canonicalization happening in the
@@ -426,7 +427,7 @@ if ${FLATPAK} ${U} install -y test-repo org.test.Writable; then
assert_file_has_mode $FL_DIR/app/org.test.Writable/$ARCH/stable/active/files/a-dir 775
fi
echo "ok no world writable dir"
ok "no world writable dir"
rm -rf app
flatpak build-init app org.test.Setuid org.test.Platform org.test.Platform stable
@@ -435,7 +436,8 @@ touch app/files/exe
chmod u+s app/files/exe
flatpak build-finish --command=hello.sh app
# Note: not --canonical-permissions
ostree --repo=repos/test commit --owner-uid=0 --owner-gid=0 --no-xattrs ${FL_GPGARGS} --branch=app/org.test.Setuid/$ARCH/stable app
${FLATPAK} build-export -vv --disable-sandbox --files=files repos/test app stable
ostree -v --repo=repos/test commit --keep-metadata=xa.metadata --owner-uid=0 --owner-gid=0 --no-xattrs ${FL_GPGARGS} --branch=app/org.test.Setuid/$ARCH/stable app
update_repo
if ${FLATPAK} ${U} install -y test-repo org.test.Setuid &> err2.txt; then
@@ -443,7 +445,7 @@ if ${FLATPAK} ${U} install -y test-repo org.test.Setuid &> err2.txt; then
fi
assert_file_has_content err2.txt [Ii]nvalid
echo "ok no setuid"
ok "no setuid"
rm -rf app
flatpak build-init app org.test.App org.test.Platform org.test.Platform stable
@@ -458,4 +460,4 @@ ${FLATPAK} ${U} info -m org.test.App > out
assert_file_has_content out "^sdk=org\.test\.Sdk/$(flatpak --default-arch)/stable$"
echo "ok --sdk option"
ok "--sdk option"

208
tests/test-sideload.sh Normal file
View File

@@ -0,0 +1,208 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
USE_COLLECTIONS_IN_SERVER=yes
USE_COLLECTIONS_IN_CLIENT=yes
. $(dirname $0)/libtest.sh
skip_without_bwrap
skip_revokefs_without_fuse
echo "1..9"
#Regular repo
setup_repo
# Ensure we have the full locale extension:
${FLATPAK} ${U} config --set languages "*"
${FLATPAK} ${U} install -y test-repo org.test.Hello
mkdir usb_dir
${FLATPAK} ${U} create-usb --destination-repo=repo usb_dir org.test.Hello
assert_has_file usb_dir/repo/config
assert_has_file usb_dir/repo/summary
assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/${ARCH}/master
assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/runtime/org.test.Hello.Locale/${ARCH}/master
assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/runtime/org.test.Platform/${ARCH}/master
assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/appstream2/${ARCH}
${FLATPAK} ${U} uninstall -y --all
ok "created sideloaded repo"
${FLATPAK} ${U} remote-modify --url="http://no.127.0.0.1:${port}/test" test-repo
if ${FLATPAK} ${U} install -y test-repo org.test.Hello &> /dev/null; then
assert_not_reached "Should not be able to install with wrong url"
fi
SIDELOAD_REPO=$(realpath usb_dir/repo)
${FLATPAK} ${U} config --set sideload-repos ${SIDELOAD_REPO}
${FLATPAK} ${U} config --get sideload-repos > sideload-repos
assert_file_has_content sideload-repos ${SIDELOAD_REPO}
${FLATPAK} ${U} install -y test-repo org.test.Hello
assert_has_file $FL_DIR/app/org.test.Hello/$ARCH/master/active/metadata
assert_has_file $FL_DIR/repo/refs/remotes/test-repo/app/org.test.Hello/${ARCH}/master
assert_not_has_file $FL_DIR/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/${ARCH}/master
ok "installed sideloaded app"
${FLATPAK} ${U} config --unset sideload-repos
${FLATPAK} ${U} uninstall -y org.test.Hello
${FLATPAK} ${U} install --sideload-repo=${SIDELOAD_REPO} -y test-repo org.test.Hello
assert_has_file $FL_DIR/app/org.test.Hello/$ARCH/master/active/metadata
assert_has_file $FL_DIR/repo/refs/remotes/test-repo/app/org.test.Hello/${ARCH}/master
assert_not_has_file $FL_DIR/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/${ARCH}/master
${FLATPAK} ${U} config --set sideload-repos ${SIDELOAD_REPO}
ok "installed w/ runtime sideload option"
# Remove old appstream checkouts so we can update from the sideload
rm -rf $FL_DIR/appstream/test-repo/$ARCH/
rm -rf $FL_DIR/repo/refs/remotes/test-repo/appstream2/$ARCH
ostree prune --repo=$FL_DIR/repo --refs-only
${FLATPAK} ${U} update --appstream test-repo
assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml
ok "updated sideloaded appstream"
${FLATPAK} ${U} remote-modify --url="http://127.0.0.1:${port}/test" test-repo
${FLATPAK} ${U} uninstall -y --all
# Disable sideload repo and "break" online repo
${FLATPAK} ${U} config --unset sideload-repos
mv repos/test/objects repos/test/objects.disabled
httpd_clear_log
# Ensure this fails (but still loads summary)
if ${FLATPAK} ${U} install -y test-repo org.test.Hello &> install-error-log; then
assert_not_reached "Disabled online install broken"
fi
assert_file_has_content install-error-log "Server returned status 404: Not Found"
assert_file_has_content httpd-log "GET .*commit .*404"
assert_file_has_content install-error-log "Server returned status 404: Not Found"
${FLATPAK} ${U} config --set sideload-repos ${SIDELOAD_REPO}
${FLATPAK} ${U} install -y test-repo org.test.Hello
assert_has_file $FL_DIR/app/org.test.Hello/$ARCH/master/active/metadata
# Re-enable online repo
mv repos/test/objects.disabled repos/test/objects
ok "installed sideloaded app when online"
OLD_COMMIT=$(cat repos/test/refs/heads/app/org.test.Hello/${ARCH}/master)
# Make new app version
make_updated_app
update_repo
NEW_COMMIT=$(cat repos/test/refs/heads/app/org.test.Hello/$ARCH/master)
# (Re)install the new version (online), ensure we used sideload repo for objects shared between new and old version
SHARED_OBJECT=$(ostree ls --repo=repos/test -C app/org.test.Hello/$ARCH/master /files/share/applications/org.test.Hello.desktop | awk '{ print $5 }')
SHARED_OBJECT_PATH=$(commit_to_path $SHARED_OBJECT filez)
${FLATPAK} ${U} uninstall -y app/org.test.Hello/$ARCH/master
httpd_clear_log
${FLATPAK} ${U} install -y app/org.test.Hello/$ARCH/master
assert_not_file_has_content httpd-log "GET /test/${SHARED_OBJECT_PATH}"
# Prepare sideload repo for NEW_COMMIT
${FLATPAK} ${U} create-usb --destination-repo=repo2 usb_dir org.test.Hello
UPDATED_COMMIT=$( ${FLATPAK} ${U} info --show-commit app/org.test.Hello/${ARCH}/master )
assert_streq "$NEW_COMMIT" "$UPDATED_COMMIT"
# Update again should do nothing
${FLATPAK} ${U} update -y
UPDATED_COMMIT=$( ${FLATPAK} ${U} info --show-commit app/org.test.Hello/${ARCH}/master )
assert_streq "$NEW_COMMIT" "$UPDATED_COMMIT"
# Ensure that offline update don't downgrade to older version
${FLATPAK} ${U} remote-modify --url="http://no.127.0.0.1:${port}/test" test-repo
${FLATPAK} ${U} update -y
UPDATED_COMMIT=$( ${FLATPAK} ${U} info --show-commit app/org.test.Hello/${ARCH}/master )
assert_streq "$NEW_COMMIT" "$UPDATED_COMMIT"
ok "updates from sideload don't go backwards"
if [ x${USE_SYSTEMDIR-} == xyes ]; then
# --commit + --system works only as root, so lets just "fake it" by installing the current sideload version
${FLATPAK} ${U} uninstall -y --no-related org.test.Hello
${FLATPAK} ${U} install -y org.test.Hello
else
# Try (offline) to update to the old version
${FLATPAK} ${U} update -y --commit $OLD_COMMIT org.test.Hello
fi
UPDATED_COMMIT=$( ${FLATPAK} ${U} info --show-commit app/org.test.Hello/${ARCH}/master )
assert_streq "$OLD_COMMIT" "$UPDATED_COMMIT"
ok "update to explicit old version"
# Switch to updated usb repo
mv usb_dir/repo usb_dir/repo.old
mv usb_dir/repo2 usb_dir/repo
# Try with --sideload-repo instead of config
${FLATPAK} ${U} config --unset sideload-repos
# And update to it (offline)
${FLATPAK} ${U} update -y --sideload-repo=${SIDELOAD_REPO}
UPDATED_COMMIT=$( ${FLATPAK} ${U} info --show-commit app/org.test.Hello/${ARCH}/master )
assert_streq "$NEW_COMMIT" "$UPDATED_COMMIT"
# Re enable (go online)
${FLATPAK} ${U} remote-modify --url="http://127.0.0.1:${port}/test" test-repo
ok "update offline to new version"
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
ostree --repo=$FL_DIR/repo config set --group='remote "test-repo"' gpg-verify-summary false
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
${FLATPAK} ${U} update -y
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
ok "migrate to gpg-verify-summary"

View File

@@ -1,136 +0,0 @@
#!/bin/bash
#
# Copyright © 2017 Endless Mobile, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Authors:
# - Philip Withnall <withnall@endlessm.com>
set -euo pipefail
. $(dirname $0)/libtest.sh
skip_without_bwrap
skip_revokefs_without_fuse
echo "1..7"
# Configure a repository and set up a collection ID for it. Check that setting
# the collection ID in the remote config disables summary signature checking.
setup_repo
install_repo
echo -e "[core]\ncollection-id=org.test.Collection" >> repos/test/config
${FLATPAK} remote-modify ${U} test-repo --collection-id org.test.Collection
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
assert_file_has_content ${FL_DIR}/repo/config '^collection-id=org\.test\.Collection$'
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify=false$'
echo "ok 1 repo config with collections"
# Test that building an app with a collection ID set produces the right
# metadata in the resulting repository.
DIR=$(mktemp -d)
${FLATPAK} build-init ${DIR} org.test.App org.test.Platform org.test.Platform
mkdir -p ${DIR}/files/a
echo "a" > ${DIR}/files/a/data
${FLATPAK} build-finish ${DIR} --socket=x11 --share=network --command=true
${FLATPAK} build-export ${FL_GPGARGS} --update-appstream repos/test --collection-id org.test.Collection ${DIR} master
update_repo
ostree --repo=repos/test refs > refs
assert_file_has_content refs "^app/org\.test\.App/$ARCH/master$"
assert_file_has_content refs '^ostree-metadata$'
assert_file_has_content refs "^appstream/${ARCH}$"
assert_file_has_content refs "^appstream2/${ARCH}$"
ostree --repo=repos/test refs --collections > refs-collections
assert_file_has_content refs-collections "^(org\.test\.Collection, app/org\.test\.App/$ARCH/master)$"
assert_file_has_content refs-collections '^(org\.test\.Collection, ostree-metadata)$'
assert_file_has_content refs-collections "^(org\.test\.Collection, appstream/${ARCH})$"
assert_file_has_content refs-collections "^(org\.test\.Collection, appstream2/${ARCH})$"
assert_has_file repos/test/summary.sig
ostree --repo=repos/test summary --view > summary
assert_file_has_content summary '^Collection ID (ostree\.summary\.collection-id): org\.test\.Collection$'
assert_file_has_content summary '^xa\.cache: '
ostree --repo=repos/test show --raw ostree-metadata > metadata
assert_file_has_content metadata "'xa\.cache': "
assert_file_has_content metadata "'ostree\.collection-binding': <'org\.test\.Collection'>"
assert_file_has_content metadata "'ostree\.ref-binding': <\['ostree-metadata'\]>"
echo "ok 2 create app with collections"
# Try installing the app.
${FLATPAK} ${U} install -y test-repo org.test.App master
${FLATPAK} ${U} uninstall -y org.test.App
echo "ok 3 install app with collections"
# Regenerate the summary so it doesnt contain xa.cache and is unsigned; try installing again.
ostree --repo=repos/test summary --update
assert_not_has_file repos/test/summary.sig
ostree --repo=repos/test summary --view > summary
assert_file_has_content summary '^Collection ID (ostree\.summary\.collection-id): org\.test\.Collection$'
assert_not_file_has_content summary '^xa\.cache: '
${FLATPAK} ${U} install -y test-repo org.test.App master
${FLATPAK} ${U} uninstall -y org.test.App
echo "ok 4 install app with collections from unsigned summary"
# Try installing it from a flatpakref file. Dont uninstall afterwards because
# we need it for the next test.
cat << EOF > org.test.App.flatpakref
[Flatpak Ref]
Title=Test App
Name=org.test.App
Branch=master
Url=http://127.0.0.1:$(cat httpd-port)/test
IsRuntime=False
GPGKey=${FL_GPG_BASE64}
#RuntimeRepo=http://127.0.0.1:$(cat httpd-port)/test
DeployCollectionID=org.test.Collection
EOF
${FLATPAK} ${U} install -y --from ./org.test.App.flatpakref
${FLATPAK} ${U} uninstall -y org.test.App
echo "ok 5 install app with collections from flatpakref"
# Update the repo metadata and check that it changes in the ostree-metadata branch
# and the summary file.
${FLATPAK} build-update-repo ${FL_GPGARGS} --title "New title" repos/test
assert_has_file repos/test/summary.sig
ostree --repo=repos/test summary --view > summary
assert_file_has_content summary '^Collection ID (ostree\.summary\.collection-id): org\.test\.Collection$'
assert_file_has_content summary '^xa\.title: '
ostree --repo=repos/test show --raw ostree-metadata > metadata
assert_file_has_content metadata "'xa\.title': "
assert_file_has_content metadata "'ostree\.collection-binding': <'org\.test\.Collection'>"
assert_file_has_content metadata "'ostree\.ref-binding': <\['ostree-metadata'\]>"
echo "ok 6 update repo metadata"
# Try to install the app again, which should pull the updated repository
# metadata as a side effect.
${FLATPAK} ${U} install -y test-repo org.test.App master
assert_file_has_content ${FL_DIR}/repo/config '^xa\.title=New title$'
echo "ok 7 pull updated repo metadata"

View File

@@ -130,7 +130,6 @@ progress_cb (PortalFlatpakUpdateMonitor *object,
GVariant *arg_info,
UpdateData *data)
{
g_autofree char *args = g_variant_print (arg_info, FALSE);
guint32 op = 0;
guint32 n_ops = 0;
guint32 progress = 0;

View File

@@ -66,15 +66,15 @@ done
# Make sure monitor is dead
kill -9 $MONITOR_PID
echo "ok monitor updates"
ok "monitor updates"
run_with_sandboxed_bus ${test_builddir}/test-update-portal update monitor.pid
echo "ok update self"
ok "update self"
run_with_sandboxed_bus ${test_builddir}/test-update-portal update-null monitor.pid
echo "ok null-update self"
ok "null-update self"
make_updated_app test "" master UPDATE3
@@ -88,7 +88,7 @@ run_with_sandboxed_bus ${test_builddir}/test-update-portal update-fail monitor.p
rm -rf repos/test/objects
mv repos/test/orig-objects repos/test/objects
echo "ok update fail"
ok "update fail"
${FLATPAK} ${U} mask "org.test.Hello*"
@@ -108,7 +108,7 @@ run_with_sandboxed_bus ${test_builddir}/test-update-portal update-null monitor.p
${FLATPAK} ${U} mask --remove "org.test.Hello*"
echo "ok update vs masked"
ok "update vs masked"
BUILD_FINISH_ARGS="--filesystem=host" make_updated_app test "" master UPDATE41
run_with_sandboxed_bus ${test_builddir}/test-update-portal update-notsupp monitor.pid
@@ -125,4 +125,4 @@ run_with_sandboxed_bus ${test_builddir}/test-update-portal update-notsupp monito
make_updated_app test "" master UPDATE45
run_with_sandboxed_bus ${test_builddir}/test-update-portal update monitor.pid
echo "ok update with changed permissions"
ok "update with changed permissions"

View File

@@ -63,21 +63,38 @@ assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify=false$'
assert_not_file_has_content ${FL_DIR}/repo/config '^collection-id='
assert_not_file_has_content ${FL_DIR}/repo/config '^collection-id='
echo "ok 1 update repo config without deploying collection ID"
ok "1 update repo config without deploying collection ID"
# Now mark the collection ID as to be deployed. The client configuration should
# be updated.
UPDATE_REPO_ARGS="--collection-id=org.test.Collection --deploy-collection-id" update_repo
assert_file_has_content repos/test/config '^deploy-collection-id=true$'
${FLATPAK} ${U} update -y org.test.App master
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify-summary=false$'
assert_file_has_content ${FL_DIR}/repo/config '^gpg-verify=true$'
assert_not_file_has_content ${FL_DIR}/repo/config '^gpg-verify=false$'
assert_file_has_content ${FL_DIR}/repo/config '^collection-id=org\.test\.Collection$'
echo "ok 2 update repo config to deploy collection ID"
# Try the deploy for sideload only method
sed -i "s/deploy-collection-id=true//" repos/test/config
assert_not_file_has_content repos/test/config '^deploy-collection-id=true$'
flatpak remote-modify --collection-id= test-repo
assert_not_file_has_content ${FL_DIR}/repo/config '^collection-id=org\.test\.Collection$'
UPDATE_REPO_ARGS="--collection-id=org.test.Collection --deploy-sideload-collection-id" update_repo
assert_file_has_content repos/test/config '^deploy-sideload-collection-id=true$'
${FLATPAK} ${U} update -y org.test.App master
assert_file_has_content ${FL_DIR}/repo/config '^collection-id=org\.test\.Collection$'
ok "2 update repo config to deploy collection ID"
# Try updating the collection ID to some other non-empty value on the server.
# The client should ignore the update (otherwise we have a security vulnerability).
@@ -93,4 +110,4 @@ ${FLATPAK} ${U} update org.test.App master
assert_file_has_content ${FL_DIR}/repo/config '^collection-id=org\.test\.Collection$'
assert_not_file_has_content ${FL_DIR}/repo/config '^collection-id=net\.malicious\.NewCollection$'
echo "ok 3 update repo config with different collection ID"
ok "3 update repo config with different collection ID"

View File

@@ -18,18 +18,6 @@ for feature in $(echo $1 | sed "s/^.*@\(.*\).wrap/\1/" | tr "," "\n"); do
nodeltas)
export USE_DELTAS=no
;;
nocollections)
export USE_COLLECTIONS_IN_SERVER=no
export USE_COLLECTIONS_IN_CLIENT=no
;;
collections)
export USE_COLLECTIONS_IN_SERVER=yes
export USE_COLLECTIONS_IN_CLIENT=yes
;;
collections-server-only)
export USE_COLLECTIONS_IN_SERVER=yes
export USE_COLLECTIONS_IN_CLIENT=no
;;
labels)
export USE_OCI_LABELS=yes
;;

View File

@@ -623,10 +623,10 @@ test_remote (void)
res = ostree_repo_open (repo, NULL, &error);
g_assert_no_error (error);
g_assert_true (res);
res = ostree_repo_get_remote_boolean_option (repo, repo_name, "gpg-verify-summary", TRUE, &gpg_verify_summary, &error);
res = ostree_repo_get_remote_boolean_option (repo, repo_name, "gpg-verify-summary", FALSE, &gpg_verify_summary, &error);
g_assert_no_error (error);
g_assert_true (res);
g_assert_false (gpg_verify_summary);
g_assert_true (gpg_verify_summary);
/* Temporarily unset the collection ID */
flatpak_remote_set_collection_id (remote, NULL);
@@ -933,9 +933,6 @@ test_list_refs_in_remotes (void)
g_autoptr(FlatpakRemote) remote = NULL;
g_autofree char *repo_dir = g_build_filename (testdir, repo_name, NULL);
g_autofree char *repo_uri = NULL;
g_autoptr(GHashTable) collection_ids = g_hash_table_new_full (g_str_hash,
g_str_equal,
NULL, NULL);
g_autoptr(GHashTable) ref_specs = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
@@ -971,13 +968,9 @@ test_list_refs_in_remotes (void)
for (guint i = 0; i < refs1->len; ++i)
{
FlatpakRef *ref = g_ptr_array_index (refs1, i);
g_hash_table_add (collection_ids, (gchar *) flatpak_ref_get_collection_id (ref));
g_hash_table_add (ref_specs, flatpak_ref_format_ref (ref));
}
/* we have a locale extension for each app, thus the 2 */
g_assert_cmpuint (2 * g_hash_table_size (collection_ids), ==, refs1->len);
/* Ensure that listing the refs by using a remote's URI will get us the
* same results as using the name */
repo_uri = flatpak_remote_get_url (remote);