"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/flatpak-transaction.c" between
flatpak-1.8.2.tar.xz and flatpak-1.8.3.tar.xz

About: Flatpak is a Linux application sandboxing and distribution framework.

flatpak-transaction.c  (flatpak-1.8.2.tar.xz):flatpak-transaction.c  (flatpak-1.8.3.tar.xz)
skipping to change at line 1804 skipping to change at line 1804
} }
static FlatpakTransactionOperation * static FlatpakTransactionOperation *
flatpak_transaction_add_op (FlatpakTransaction *self, flatpak_transaction_add_op (FlatpakTransaction *self,
const char *remote, const char *remote,
const char *ref, const char *ref,
const char **subpaths, const char **subpaths,
const char **previous_ids, const char **previous_ids,
const char *commit, const char *commit,
GFile *bundle, GFile *bundle,
FlatpakTransactionOperationType kind) FlatpakTransactionOperationType kind,
GError **error)
{ {
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (se lf); FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (se lf);
FlatpakTransactionOperation *op; FlatpakTransactionOperation *op;
g_autofree char *subpaths_str = NULL; g_autofree char *subpaths_str = NULL;
g_auto(GStrv) ref_parts = NULL;
subpaths_str = subpaths_to_string (subpaths); subpaths_str = subpaths_to_string (subpaths);
g_debug ("Transaction: %s %s:%s%s%s%s", g_debug ("Transaction: %s %s:%s%s%s%s",
kind_to_str (kind), remote, ref, kind_to_str (kind), remote, ref,
commit != NULL ? "@" : "", commit != NULL ? "@" : "",
commit != NULL ? commit : "", commit != NULL ? commit : "",
subpaths_str); subpaths_str);
/* Sanity check the ref format. */
ref_parts = flatpak_decompose_ref (ref, error);
if (ref_parts == NULL)
return NULL;
op = flatpak_transaction_get_last_op_for_ref (self, ref); op = flatpak_transaction_get_last_op_for_ref (self, ref);
/* If previous_ids is given, then this is a rebase operation. */ /* If previous_ids is given, then this is a rebase operation. */
if (op != NULL && kind_compatible (kind, op->kind, previous_ids != NULL)) if (op != NULL && kind_compatible (kind, op->kind, previous_ids != NULL))
{ {
g_auto(GStrv) old_subpaths = NULL; g_auto(GStrv) old_subpaths = NULL;
g_auto(GStrv) old_previous_ids = NULL; g_auto(GStrv) old_previous_ids = NULL;
old_subpaths = op->subpaths; old_subpaths = op->subpaths;
op->subpaths = flatpak_subpaths_merge (old_subpaths, (char **) subpaths); op->subpaths = flatpak_subpaths_merge (old_subpaths, (char **) subpaths);
skipping to change at line 1906 skipping to change at line 1913
for (i = 0; i < related->len; i++) for (i = 0; i < related->len; i++)
{ {
FlatpakRelated *rel = g_ptr_array_index (related, i); FlatpakRelated *rel = g_ptr_array_index (related, i);
FlatpakTransactionOperation *related_op; FlatpakTransactionOperation *related_op;
if (!rel->delete) if (!rel->delete)
continue; continue;
related_op = flatpak_transaction_add_op (self, op->remote, rel->ref, related_op = flatpak_transaction_add_op (self, op->remote, rel->ref,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
FLATPAK_TRANSACTION_OPERATION FLATPAK_TRANSACTION_OPERATION
_UNINSTALL); _UNINSTALL,
error);
if (related_op == NULL)
return FALSE;
related_op->non_fatal = TRUE; related_op->non_fatal = TRUE;
related_op->fail_if_op_fails = op; related_op->fail_if_op_fails = op;
flatpak_transaction_operation_add_related_to_op (related_op, op); flatpak_transaction_operation_add_related_to_op (related_op, op);
run_operation_before (op, related_op, 1); run_operation_before (op, related_op, 1);
} }
} }
else /* install or update */ else /* install or update */
{ {
for (i = 0; i < related->len; i++) for (i = 0; i < related->len; i++)
{ {
FlatpakRelated *rel = g_ptr_array_index (related, i); FlatpakRelated *rel = g_ptr_array_index (related, i);
FlatpakTransactionOperation *related_op; FlatpakTransactionOperation *related_op;
if (!rel->download) if (!rel->download)
continue; continue;
related_op = flatpak_transaction_add_op (self, op->remote, rel->ref, related_op = flatpak_transaction_add_op (self, op->remote, rel->ref,
(const char **) rel->subpaths , (const char **) rel->subpaths ,
NULL, NULL, NULL, NULL, NULL, NULL,
FLATPAK_TRANSACTION_OPERATION FLATPAK_TRANSACTION_OPERATION
_INSTALL_OR_UPDATE); _INSTALL_OR_UPDATE,
error);
if (related_op == NULL)
return FALSE;
related_op->non_fatal = TRUE; related_op->non_fatal = TRUE;
related_op->fail_if_op_fails = op; related_op->fail_if_op_fails = op;
flatpak_transaction_operation_add_related_to_op (related_op, op); flatpak_transaction_operation_add_related_to_op (related_op, op);
run_operation_before (related_op, op, 1); run_operation_before (related_op, op, 1);
} }
} }
return TRUE; return TRUE;
} }
skipping to change at line 2016 skipping to change at line 2031
return TRUE; return TRUE;
full_runtime_ref = g_strconcat ("runtime/", runtime_ref, NULL); full_runtime_ref = g_strconcat ("runtime/", runtime_ref, NULL);
runtime_op = flatpak_transaction_get_last_op_for_ref (self, full_runtime_ref); runtime_op = flatpak_transaction_get_last_op_for_ref (self, full_runtime_ref);
if (op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL) if (op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL)
{ {
/* If the runtime this app uses is already to be uninstalled, then this un install must happen before /* If the runtime this app uses is already to be uninstalled, then this un install must happen before
the runtime is uninstalled */ the runtime is uninstalled */
if (runtime_op && op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL) if (runtime_op && runtime_op->kind == FLATPAK_TRANSACTION_OPERATION_UNINST ALL)
run_operation_before (op, runtime_op, 1); run_operation_before (op, runtime_op, 1);
return TRUE; return TRUE;
} }
if (priv->disable_deps) if (priv->disable_deps)
return TRUE; return TRUE;
if (runtime_op == NULL) if (runtime_op == NULL)
{ {
skipping to change at line 2042 skipping to change at line 2057
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE; return FALSE;
} }
runtime_remote = find_runtime_remote (self, op->ref, full_runtime_ref, op->kind, error); runtime_remote = find_runtime_remote (self, op->ref, full_runtime_ref, op->kind, error);
if (runtime_remote == NULL) if (runtime_remote == NULL)
return FALSE; return FALSE;
runtime_op = flatpak_transaction_add_op (self, runtime_remote, full_ru ntime_ref, NULL, NULL, NULL, NULL, runtime_op = flatpak_transaction_add_op (self, runtime_remote, full_ru ntime_ref, NULL, NULL, NULL, NULL,
FLATPAK_TRANSACTION_OPERATION FLATPAK_TRANSACTION_OPERATION
_INSTALL_OR_UPDATE); _INSTALL_OR_UPDATE, error);
if (runtime_op == NULL)
return FALSE;
} }
else else
{ {
/* Update if in same dir */ /* Update if in same dir */
if (dir_ref_is_installed (priv->dir, full_runtime_ref, &runtime_remote , NULL)) if (dir_ref_is_installed (priv->dir, full_runtime_ref, &runtime_remote , NULL))
{ {
g_debug ("Updating dependent runtime %s", full_runtime_ref); g_debug ("Updating dependent runtime %s", full_runtime_ref);
runtime_op = flatpak_transaction_add_op (self, runtime_remote, ful l_runtime_ref, NULL, NULL, NULL, NULL, runtime_op = flatpak_transaction_add_op (self, runtime_remote, ful l_runtime_ref, NULL, NULL, NULL, NULL,
FLATPAK_TRANSACTION_OPERA FLATPAK_TRANSACTION_OPERA
TION_UPDATE); TION_UPDATE, error);
if (runtime_op == NULL)
return FALSE;
runtime_op->non_fatal = TRUE; runtime_op->non_fatal = TRUE;
} }
} }
} }
/* Install/Update the runtime before the app */ /* Install/Update the runtime before the app */
if (runtime_op) if (runtime_op)
{ {
if (runtime_op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL) if (runtime_op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL)
return flatpak_fail_error (error, FLATPAK_ERROR_RUNTIME_USED, return flatpak_fail_error (error, FLATPAK_ERROR_RUNTIME_USED,
skipping to change at line 2188 skipping to change at line 2207
/* We don't need remote state for an uninstall, and we don't want a missing /* We don't need remote state for an uninstall, and we don't want a missing
* remote to be fatal */ * remote to be fatal */
if (kind != FLATPAK_TRANSACTION_OPERATION_UNINSTALL) if (kind != FLATPAK_TRANSACTION_OPERATION_UNINSTALL)
{ {
state = flatpak_transaction_ensure_remote_state (self, kind, remote, error ); state = flatpak_transaction_ensure_remote_state (self, kind, remote, error );
if (state == NULL) if (state == NULL)
return FALSE; return FALSE;
} }
op = flatpak_transaction_add_op (self, remote, ref, subpaths, previous_ids, co op = flatpak_transaction_add_op (self, remote, ref, subpaths, previous_ids, co
mmit, bundle, kind); mmit, bundle, kind, error);
if (op == NULL)
return FALSE;
if (external_metadata) if (external_metadata)
op->external_metadata = g_bytes_new (external_metadata, strlen (external_met adata) + 1); op->external_metadata = g_bytes_new (external_metadata, strlen (external_met adata) + 1);
return TRUE; return TRUE;
} }
/** /**
* flatpak_transaction_add_install: * flatpak_transaction_add_install:
* @self: a #FlatpakTransaction * @self: a #FlatpakTransaction
skipping to change at line 2395 skipping to change at line 2416
flatpak_transaction_update_metadata (FlatpakTransaction *self, flatpak_transaction_update_metadata (FlatpakTransaction *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (se lf); FlatpakTransactionPrivate *priv = flatpak_transaction_get_instance_private (se lf);
g_auto(GStrv) remotes = NULL; g_auto(GStrv) remotes = NULL;
int i; int i;
GList *l; GList *l;
gboolean some_updated = FALSE; gboolean some_updated = FALSE;
g_autoptr(GHashTable) ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_f ree, NULL); g_autoptr(GHashTable) ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_f ree, NULL);
gboolean local_only = TRUE;
/* Collect all dir+remotes used in this transaction */ /* Collect all dir+remotes used in this transaction */
if (!flatpak_dir_migrate_config (priv->dir, &some_updated, cancellable, error) ) if (!flatpak_dir_migrate_config (priv->dir, &some_updated, cancellable, error) )
return FALSE; return FALSE;
for (l = priv->ops; l != NULL; l = l->next) for (l = priv->ops; l != NULL; l = l->next)
{ {
FlatpakTransactionOperation *op = l->data; FlatpakTransactionOperation *op = l->data;
g_hash_table_add (ht, g_strdup (op->remote)); g_hash_table_add (ht, g_strdup (op->remote));
local_only = local_only && transaction_is_local_only (self, op->kind);
} }
remotes = (char **) g_hash_table_get_keys_as_array (ht, NULL); remotes = (char **) g_hash_table_get_keys_as_array (ht, NULL);
g_hash_table_steal_all (ht); /* Move ownership to remotes */ g_hash_table_steal_all (ht); /* Move ownership to remotes */
/* Bail early if the entire transaction is local-only, as in that case we
* don’t need updated metadata. */
if (local_only)
return TRUE;
/* Update metadata for said remotes */ /* Update metadata for said remotes */
for (i = 0; remotes[i] != NULL; i++) for (i = 0; remotes[i] != NULL; i++)
{ {
char *remote = remotes[i]; char *remote = remotes[i];
gboolean updated = FALSE; gboolean updated = FALSE;
g_autoptr(GError) my_error = NULL; g_autoptr(GError) my_error = NULL;
g_autoptr(FlatpakRemoteState) state = flatpak_transaction_ensure_remote_st ate (self, FLATPAK_TRANSACTION_OPERATION_UPDATE, remote, NULL); g_autoptr(FlatpakRemoteState) state = flatpak_transaction_ensure_remote_st ate (self, FLATPAK_TRANSACTION_OPERATION_UPDATE, remote, NULL);
g_debug ("Looking for remote metadata updates for %s", remote); g_debug ("Looking for remote metadata updates for %s", remote);
if (!flatpak_dir_update_remote_configuration (priv->dir, remote, state, &u pdated, cancellable, &my_error)) if (!flatpak_dir_update_remote_configuration (priv->dir, remote, state, &u pdated, cancellable, &my_error))
skipping to change at line 2741 skipping to change at line 2769
for (l = priv->ops; l != NULL; l = l->next) for (l = priv->ops; l != NULL; l = l->next)
{ {
FlatpakTransactionOperation *op = l->data; FlatpakTransactionOperation *op = l->data;
g_autoptr(FlatpakRemoteState) state = NULL; g_autoptr(FlatpakRemoteState) state = NULL;
g_autofree char *checksum = NULL; g_autofree char *checksum = NULL;
g_autoptr(GBytes) metadata_bytes = NULL; g_autoptr(GBytes) metadata_bytes = NULL;
if (op->resolved) if (op->resolved)
continue; continue;
if (op->skip)
{
/* We're not yet resolved, but marked skip anyway, this can happen if
during
* request_required_tokens() we were normalized away even though not f
ully resolved.
* For example we got the checksum but need to auth to get the commit,
but the
* checksum we got was the version already installed.
*/
g_assert (op->resolved_commit != NULL);
mark_op_resolved (op, op->resolved_commit, NULL, NULL, NULL);
continue;
}
if (op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL) if (op->kind == FLATPAK_TRANSACTION_OPERATION_UNINSTALL)
{ {
/* We resolve to the deployed metadata, because we need it to uninstal l related ops */ /* We resolve to the deployed metadata, because we need it to uninstal l related ops */
metadata_bytes = load_deployed_metadata (self, op->ref, &checksum); metadata_bytes = load_deployed_metadata (self, op->ref, &checksum);
mark_op_resolved (op, checksum, NULL, metadata_bytes, NULL); mark_op_resolved (op, checksum, NULL, metadata_bytes, NULL);
continue; continue;
} }
if (op->kind == FLATPAK_TRANSACTION_OPERATION_INSTALL_BUNDLE) if (op->kind == FLATPAK_TRANSACTION_OPERATION_INSTALL_BUNDLE)
skipping to change at line 3247 skipping to change at line 3287
{ {
const char *error_message; const char *error_message;
gint32 error_code; gint32 error_code;
if (!g_variant_lookup (results, "error-message", "&s", &error_message)) if (!g_variant_lookup (results, "error-message", "&s", &error_message))
error_message = NULL; error_message = NULL;
if (g_variant_lookup (results, "error-code", "i", &error_code) && error_co de != -1) if (g_variant_lookup (results, "error-code", "i", &error_code) && error_co de != -1)
{ {
if (error_message) if (error_message)
flatpak_fail_error (error, error_code, _("Failed to get tokens for r ef: %s"), error_message); return flatpak_fail_error (error, error_code, _("Failed to get token s for ref: %s"), error_message);
else else
return flatpak_fail_error (error, error_code, _("Failed to get token s for ref")); return flatpak_fail_error (error, error_code, _("Failed to get token s for ref"));
} }
else else
{ {
if (error_message) if (error_message)
return flatpak_fail (error, _("Failed to get tokens for ref: %s"), e rror_message); return flatpak_fail (error, _("Failed to get tokens for ref: %s"), e rror_message);
else else
return flatpak_fail (error, _("Failed to get tokens for ref")); return flatpak_fail (error, _("Failed to get tokens for ref"));
} }
 End of changes. 14 change blocks. 
13 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)