Merge pull request #900 from pwithnall/lan-and-usb-preparation

LAN/USB preparation refactoring
This commit is contained in:
Matthias Clasen
2017-07-08 20:54:28 -04:00
committed by GitHub
14 changed files with 112 additions and 101 deletions

View File

@@ -150,7 +150,7 @@ export_dir (int source_parent_fd,
else
{
source_printable = g_build_filename (source_relpath, dent->d_name, NULL);
g_debug ("Not exporting non-regular file %s\n", source_printable);
g_debug ("Not exporting non-regular file %s", source_printable);
}
}

View File

@@ -132,7 +132,7 @@ flatpak_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
parts = flatpak_decompose_ref (ref, NULL);
if (parts == NULL)
{
g_debug ("Invalid remote ref %s\n", ref);
g_debug ("Invalid remote ref %s", ref);
continue;
}

View File

@@ -151,11 +151,10 @@ flatpak_builtin_repo (int argc, char **argv,
GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
g_autofree char *location = NULL;
g_autofree char *data = NULL;
gsize size;
g_autoptr(GFile) location = NULL;
g_autoptr(GVariant) summary = NULL;
g_autoptr(GVariant) meta = NULL;
g_autoptr(OstreeRepo) repo = NULL;
context = g_option_context_new (_("LOCATION - Repository maintenance"));
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
@@ -166,16 +165,14 @@ flatpak_builtin_repo (int argc, char **argv,
if (argc < 2)
return usage_error (context, _("LOCATION must be specified"), error);
location = g_build_filename (argv[1], "summary", NULL);
location = g_file_new_for_commandline_arg (argv[1]);
repo = ostree_repo_new (location);
if (!ostree_repo_open (repo, cancellable, error))
return FALSE;
if (!g_file_get_contents (location, &data, &size, error)) {
exit (1);
}
summary = g_variant_new_from_data (OSTREE_SUMMARY_GVARIANT_FORMAT,
data, size,
FALSE, NULL, NULL);
g_variant_ref_sink (summary);
summary = flatpak_repo_load_summary (repo, error);
if (summary == NULL)
return FALSE;
meta = g_variant_get_child_value (summary, 1);
if (opt_info)

View File

@@ -808,7 +808,7 @@ main (int argc,
if (!builder_gc (cache, &error))
{
g_warning ("Failed to GC build cache: %s\n", error->message);
g_warning ("Failed to GC build cache: %s", error->message);
g_clear_error (&error);
}

View File

@@ -1192,7 +1192,7 @@ builder_module_ensure_writable (BuilderModule *self,
const char *path = key;
g_autoptr(GFile) dest = g_file_resolve_relative_path (app_dir, path);
g_debug ("Breaking hardlink %s\n", path);
g_debug ("Breaking hardlink %s", path);
if (!flatpak_break_hardlink (dest, error))
return FALSE;
}

View File

@@ -1341,7 +1341,7 @@ builder_get_debuginfo_file_references (const char *filename, GError **error)
return NULL;
if (elf_end (elf) < 0)
g_warning ("elf_end failed: %s\n", elf_errmsg (elf_errno ()));
g_warning ("elf_end failed: %s", elf_errmsg (elf_errno ()));
res = (char **) g_hash_table_get_keys_as_array (files, NULL);
g_hash_table_steal_all (files);
@@ -1703,7 +1703,7 @@ builder_serializable_find_property_with_error (JsonSerializable *serializable,
GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (serializable), name);
if (pspec == NULL &&
!g_str_has_prefix (name, "x-"))
g_warning ("Unknown property %s for type %s\n", name, g_type_name_from_instance ((GTypeInstance *)serializable));
g_warning ("Unknown property %s for type %s", name, g_type_name_from_instance ((GTypeInstance *)serializable));
return pspec;
}

View File

@@ -381,7 +381,7 @@ append_locations_from_config_file (GPtrArray *locations,
if (!g_key_file_load_from_file (keyfile, file_path, G_KEY_FILE_NONE, &my_error))
{
g_debug ("Could not get list of system installations: %s\n", my_error->message);
g_debug ("Could not get list of system installations: %s", my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error));
goto out;
}
@@ -414,7 +414,7 @@ append_locations_from_config_file (GPtrArray *locations,
path = g_key_file_get_string (keyfile, groups[i], "Path", &my_error);
if (path == NULL)
{
g_debug ("Unable to get path for installation '%s': %s\n", id, my_error->message);
g_debug ("Unable to get path for installation '%s': %s", id, my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error));
goto out;
}
@@ -667,7 +667,7 @@ flatpak_dir_get_system_helper (FlatpakDir *self)
NULL, &error);
if (error != NULL)
{
g_warning ("Can't find org.freedesktop.Flatpak.SystemHelper: %s\n", error->message);
g_warning ("Can't find org.freedesktop.Flatpak.SystemHelper: %s", error->message);
system_helper = NO_SYSTEM_HELPER;
}
else
@@ -1654,7 +1654,7 @@ flatpak_dir_deploy_appstream (FlatpakDir *self,
{
old_checkout_dir = g_file_get_child (arch_dir, old_checksum);
if (!flatpak_rm_rf (old_checkout_dir, cancellable, &tmp_error))
g_warning ("Unable to remove old appstream checkout: %s\n", tmp_error->message);
g_warning ("Unable to remove old appstream checkout: %s", tmp_error->message);
}
if (!g_file_replace_contents (timestamp_file, "", 0, NULL, FALSE,
@@ -2396,7 +2396,7 @@ flatpak_dir_mirror_oci (FlatpakDir *self,
oci_pull_init_progress (progress);
g_debug ("Mirroring OCI image %s\n", oci_digest);
g_debug ("Mirroring OCI image %s", oci_digest);
res = flatpak_mirror_image_from_oci (dst_registry, registry, oci_digest, signature_digest, oci_pull_progress_cb,
progress, cancellable, error);
@@ -2494,7 +2494,7 @@ flatpak_dir_pull_oci (FlatpakDir *self,
oci_pull_init_progress (progress);
g_debug ("Pulling OCI image %s\n", oci_digest);
g_debug ("Pulling OCI image %s", oci_digest);
checksum = flatpak_pull_from_oci (repo, registry, oci_digest, FLATPAK_OCI_MANIFEST (versioned),
remote, ref, signature_digest, oci_pull_progress_cb, progress, cancellable, error);
@@ -2505,7 +2505,7 @@ flatpak_dir_pull_oci (FlatpakDir *self,
if (checksum == NULL)
return FALSE;
g_debug ("Imported OCI image as checksum %s\n", checksum);
g_debug ("Imported OCI image as checksum %s", checksum);
return TRUE;
}
@@ -2546,6 +2546,17 @@ flatpak_dir_pull (FlatpakDir *self,
if (*url == 0)
return TRUE; /* Empty url, silently disables updates */
/* Set up progress reporting. */
if (progress == NULL)
{
glnx_console_lock (&console);
if (console.is_tty)
{
console_progress = ostree_async_progress_new_and_connect (default_progress_changed, &console);
progress = console_progress;
}
}
/* We get the rev ahead of time so that we know it for looking up e.g. extra-data
and to make sure we're atomically using a single rev if we happen to do multiple
pulls (e.g. with subpaths) */
@@ -2561,16 +2572,6 @@ flatpak_dir_pull (FlatpakDir *self,
if (repo == NULL)
repo = self->repo;
if (progress == NULL)
{
glnx_console_lock (&console);
if (console.is_tty)
{
console_progress = ostree_async_progress_new_and_connect (default_progress_changed, &console);
progress = console_progress;
}
}
/* Past this we must use goto out, so we clean up console and
abort the transaction on error */
@@ -6182,7 +6183,7 @@ flatpak_dir_undeploy (FlatpakDir *self,
if (!flatpak_rm_rf (removed_subdir, cancellable, &tmp_error))
{
g_warning ("Unable to remove old checkout: %s\n", tmp_error->message);
g_warning ("Unable to remove old checkout: %s", tmp_error->message);
g_error_free (tmp_error);
}
}
@@ -6305,7 +6306,7 @@ flatpak_dir_cleanup_removed (FlatpakDir *self,
GError *tmp_error = NULL;
if (!flatpak_rm_rf (child, cancellable, &tmp_error))
{
g_warning ("Unable to remove old checkout: %s\n", tmp_error->message);
g_warning ("Unable to remove old checkout: %s", tmp_error->message);
g_error_free (tmp_error);
}
}
@@ -6767,7 +6768,7 @@ flatpak_dir_remote_has_ref (FlatpakDir *self,
summary = fetch_remote_summary_file (self, remote, NULL, NULL, &local_error);
if (summary == NULL)
{
g_debug ("Can't get summary for remote %s: %s\n", remote, local_error->message);
g_debug ("Can't get summary for remote %s: %s", remote, local_error->message);
return FALSE;
}

View File

@@ -2751,7 +2751,7 @@ export_paths_export_context (FlatpakContext *context,
if (!get_xdg_user_dir_from_string (filesystem, &config_key, &rest, &path))
{
g_warning ("Unsupported xdg dir %s\n", filesystem);
g_warning ("Unsupported xdg dir %s", filesystem);
continue;
}
@@ -2763,7 +2763,7 @@ export_paths_export_context (FlatpakContext *context,
/* xdg-user-dirs sets disabled dirs to $HOME, and its in general not a good
idea to set full access to $HOME other than explicitly, so we ignore
these */
g_debug ("Xdg dir %s is $HOME (i.e. disabled), ignoring\n", filesystem);
g_debug ("Xdg dir %s is $HOME (i.e. disabled), ignoring", filesystem);
continue;
}
@@ -2803,7 +2803,7 @@ export_paths_export_context (FlatpakContext *context,
}
else
{
g_warning ("Unexpected filesystem arg %s\n", filesystem);
g_warning ("Unexpected filesystem arg %s", filesystem);
}
}
@@ -3085,7 +3085,7 @@ flatpak_run_add_environment_args (GPtrArray *argv_array,
{
/* We still run along even if we don't get a cgroup, as nothing
really depends on it. Its just nice to have */
g_debug ("Failed to run in transient scope: %s\n", my_error->message);
g_debug ("Failed to run in transient scope: %s", my_error->message);
g_clear_error (&my_error);
}
@@ -3711,7 +3711,7 @@ add_document_portal_args (GPtrArray *argv_array,
{
if (g_dbus_message_to_gerror (reply, &local_error))
{
g_message ("Can't get document portal: %s\n", local_error->message);
g_message ("Can't get document portal: %s", local_error->message);
}
else
{
@@ -4478,7 +4478,7 @@ add_rest_args (const char *app_id,
if (file_forwarding && doc_mount_path == NULL)
{
g_message ("Can't get document portal mount path\n");
g_message ("Can't get document portal mount path");
can_forward = FALSE;
}
else if (file_forwarding)
@@ -4492,7 +4492,7 @@ add_rest_args (const char *app_id,
&local_error);
if (documents == NULL)
{
g_message ("Can't get document portal: %s\n", local_error->message);
g_message ("Can't get document portal: %s", local_error->message);
can_forward = FALSE;
}
}

View File

@@ -2956,6 +2956,59 @@ commit_data_free (gpointer data)
g_free (rev_data);
}
/* For all the refs listed in @cache_v (an xa.cache value) which exist in the
* @summary, insert their data into @commit_data_cache if it isnt already there. */
static void
populate_commit_data_cache (GVariant *metadata,
GVariant *summary,
GHashTable *commit_data_cache /* (element-type utf8 CommitData) */)
{
g_autoptr(GVariant) cache_v = NULL;
g_autoptr(GVariant) cache = NULL;
gsize n, i;
cache_v = g_variant_lookup_value (metadata, "xa.cache", NULL);
if (cache_v == NULL)
return;
cache = g_variant_get_child_value (cache_v, 0);
n = g_variant_n_children (cache);
for (i = 0; i < n; i++)
{
g_autoptr(GVariant) old_element = g_variant_get_child_value (cache, i);
g_autoptr(GVariant) old_ref_v = g_variant_get_child_value (old_element, 0);
const char *old_ref = g_variant_get_string (old_ref_v, NULL);
g_autofree char *old_rev = NULL;
g_autoptr(GVariant) old_commit_data_v = g_variant_get_child_value (old_element, 1);
CommitData *old_rev_data;
if (flatpak_summary_lookup_ref (summary, old_ref, &old_rev, NULL))
{
guint64 old_installed_size, old_download_size;
g_autofree char *old_metadata = NULL;
/* See if we already have the info on this revision */
if (g_hash_table_lookup (commit_data_cache, old_rev))
continue;
g_variant_get_child (old_commit_data_v, 0, "t", &old_installed_size);
old_installed_size = GUINT64_FROM_BE (old_installed_size);
g_variant_get_child (old_commit_data_v, 1, "t", &old_download_size);
old_download_size = GUINT64_FROM_BE (old_download_size);
g_variant_get_child (old_commit_data_v, 2, "s", &old_metadata);
old_rev_data = g_new (CommitData, 1);
old_rev_data->installed_size = old_installed_size;
old_rev_data->download_size = old_download_size;
old_rev_data->metadata_contents = g_steal_pointer (&old_metadata);
g_hash_table_insert (commit_data_cache, g_steal_pointer (&old_rev), old_rev_data);
}
}
}
gboolean
flatpak_repo_update (OstreeRepo *repo,
const char **gpg_key_ids,
@@ -3048,47 +3101,8 @@ flatpak_repo_update (OstreeRepo *repo,
if (old_summary != NULL)
{
g_autoptr(GVariant) extensions = g_variant_get_child_value (old_summary, 1);
g_autoptr(GVariant) cache_v = g_variant_lookup_value (extensions, "xa.cache", NULL);
g_autoptr(GVariant) cache = NULL;
if (cache_v != NULL)
{
cache = g_variant_get_child_value (cache_v, 0);
gsize n, i;
n = g_variant_n_children (cache);
for (i = 0; i < n; i++)
{
g_autoptr(GVariant) old_element = g_variant_get_child_value (cache, i);
g_autoptr(GVariant) old_ref_v = g_variant_get_child_value (old_element, 0);
const char *old_ref = g_variant_get_string (old_ref_v, NULL);
g_autofree char *old_rev = NULL;
g_autoptr(GVariant) old_commit_data_v = g_variant_get_child_value (old_element, 1);
CommitData *old_rev_data;
if (flatpak_summary_lookup_ref (old_summary, old_ref, &old_rev, NULL))
{
guint64 old_installed_size, old_download_size;
g_autofree char *old_metadata = NULL;
/* See if we already have the info on this revision */
if (g_hash_table_lookup (commit_data_cache, old_rev))
continue;
g_variant_get_child (old_commit_data_v, 0, "t", &old_installed_size);
old_installed_size = GUINT64_FROM_BE (old_installed_size);
g_variant_get_child (old_commit_data_v, 1, "t", &old_download_size);
old_download_size = GUINT64_FROM_BE (old_download_size);
g_variant_get_child (old_commit_data_v, 2, "s", &old_metadata);
old_rev_data = g_new (CommitData, 1);
old_rev_data->installed_size = old_installed_size;
old_rev_data->download_size = old_download_size;
old_rev_data->metadata_contents = g_steal_pointer (&old_metadata);
g_hash_table_insert (commit_data_cache, g_steal_pointer (&old_rev), old_rev_data);
}
}
}
populate_commit_data_cache (extensions, old_summary, commit_data_cache);
}
ordered_keys = g_hash_table_get_keys (refs);
@@ -3595,10 +3609,9 @@ flatpak_repo_generate_appstream (OstreeRepo *repo,
GError **error)
{
g_autoptr(GHashTable) all_refs = NULL;
g_autoptr(GHashTable) arches = NULL;
g_autoptr(GHashTable) arches = NULL; /* (element-type utf8 utf8) */
GHashTableIter iter;
gpointer key;
gpointer value;
gboolean skip_commit = FALSE;
arches = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -3611,7 +3624,7 @@ flatpak_repo_generate_appstream (OstreeRepo *repo,
return FALSE;
g_hash_table_iter_init (&iter, all_refs);
while (g_hash_table_iter_next (&iter, &key, &value))
while (g_hash_table_iter_next (&iter, &key, NULL))
{
const char *ref = key;
const char *arch;
@@ -3623,11 +3636,11 @@ flatpak_repo_generate_appstream (OstreeRepo *repo,
arch = split[2];
if (!g_hash_table_contains (arches, arch))
g_hash_table_insert (arches, g_strdup (arch), GINT_TO_POINTER (1));
g_hash_table_add (arches, g_strdup (arch));
}
g_hash_table_iter_init (&iter, arches);
while (g_hash_table_iter_next (&iter, &key, &value))
while (g_hash_table_iter_next (&iter, &key, NULL))
{
GHashTableIter iter2;
const char *arch = key;
@@ -3652,7 +3665,7 @@ flatpak_repo_generate_appstream (OstreeRepo *repo,
appstream_root = flatpak_appstream_xml_new ();
g_hash_table_iter_init (&iter2, all_refs);
while (g_hash_table_iter_next (&iter2, &key, &value))
while (g_hash_table_iter_next (&iter2, &key, NULL))
{
const char *ref = key;
g_auto(GStrv) split = NULL;
@@ -4731,7 +4744,7 @@ flatpak_pull_from_oci (OstreeRepo *repo,
}
/* Success! It is valid */
g_debug ("Verified OCI signature for %s %s\n", signature->critical.identity.ref, digest);
g_debug ("Verified OCI signature for %s %s", signature->critical.identity.ref, digest);
}
annotations = flatpak_oci_manifest_get_annotations (manifest);
@@ -5108,7 +5121,7 @@ stream_closed (GObject *source, GAsyncResult *res, gpointer user_data)
g_autoptr(GError) error = NULL;
if (!g_input_stream_close_finish (stream, res, &error))
g_warning ("Error closing http stream: %s\n", error->message);
g_warning ("Error closing http stream: %s", error->message);
g_main_loop_quit (data->loop);
}

View File

@@ -1449,7 +1449,7 @@ get_dbus_method_handler (FlatpakProxyClient *client, Header *header)
strcmp (method, "ListActivatableNames") == 0)
return HANDLE_FILTER_NAME_LIST_REPLY;
g_warning ("Unknown bus method %s\n", method);
g_warning ("Unknown bus method %s", method);
return HANDLE_DENY;
}
else
@@ -2100,7 +2100,7 @@ got_buffer_from_bus (FlatpakProxyClient *client, ProxySide *side, Buffer *buffer
break;
default:
g_warning ("Unexpected expected reply type %d\n", expected_reply);
g_warning ("Unexpected expected reply type %d", expected_reply);
}
}
else /* Not reply */
@@ -2346,7 +2346,7 @@ client_connected_to_dbus (GObject *source_object,
stream = g_dbus_address_get_stream_finish (res, NULL, &error);
if (stream == NULL)
{
g_warning ("Failed to connect to bus: %s\n", error->message);
g_warning ("Failed to connect to bus: %s", error->message);
g_object_unref (client);
return;
}

View File

@@ -74,7 +74,7 @@ main (int argc, char *argv[])
if (related == NULL)
{
g_warning ("Error: %s\n", error->message);
g_warning ("Error: %s", error->message);
continue;
}

View File

@@ -462,7 +462,7 @@ xdg_permission_store_start (GDBusConnection *connection)
"/org/freedesktop/impl/portal/PermissionStore",
&error))
{
g_warning ("error: %s\n", error->message);
g_warning ("error: %s", error->message);
g_error_free (error);
}
}

View File

@@ -369,7 +369,7 @@ on_bus_acquired (GDBusConnection *connection,
"/org/freedesktop/Flatpak/SessionHelper",
&error))
{
g_warning ("error: %s\n", error->message);
g_warning ("error: %s", error->message);
g_error_free (error);
}
@@ -383,7 +383,7 @@ on_bus_acquired (GDBusConnection *connection,
"/org/freedesktop/Flatpak/Development",
&error))
{
g_warning ("error: %s\n", error->message);
g_warning ("error: %s", error->message);
g_error_free (error);
}
}

View File

@@ -945,7 +945,7 @@ on_bus_acquired (GDBusConnection *connection,
"/org/freedesktop/Flatpak/SystemHelper",
&error))
{
g_warning ("error: %s\n", error->message);
g_warning ("error: %s", error->message);
g_error_free (error);
}
}