mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-28 17:41:14 -05:00
Convert flatpak_summary_lookup_ref from GVariants
Now it returns a VarRefInfoRef instead of a GVariant
This commit is contained in:
committed by
Alexander Larsson
parent
9f6c60405d
commit
61da44a5e3
@@ -151,7 +151,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, error);
|
||||
flatpak_remote_state_lookup_ref (state, ref, &commit, NULL, NULL, error);
|
||||
if (commit == NULL)
|
||||
{
|
||||
if (error != NULL && *error == NULL)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "flatpak-common-types-private.h"
|
||||
#include "flatpak-context-private.h"
|
||||
#include "flatpak-variant-private.h"
|
||||
#include "libglnx/libglnx.h"
|
||||
|
||||
/* Version history:
|
||||
@@ -135,7 +136,8 @@ gboolean flatpak_remote_state_allow_ref (FlatpakRemoteState *self,
|
||||
gboolean flatpak_remote_state_lookup_ref (FlatpakRemoteState *self,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
GVariant **out_variant,
|
||||
gboolean *out_has_info,
|
||||
VarRefInfoRef *out_info,
|
||||
GError **error);
|
||||
char **flatpak_remote_state_match_subrefs (FlatpakRemoteState *self,
|
||||
const char *ref);
|
||||
|
||||
@@ -357,12 +357,14 @@ flatpak_remote_state_allow_ref (FlatpakRemoteState *self,
|
||||
}
|
||||
|
||||
/* Returns TRUE if the ref is found in the summary or cache. out_checksum and
|
||||
* out_variant are not guaranteed to be set even when the ref is found. */
|
||||
* out_variant are not guaranteed to be set even when the ref is found.
|
||||
* Only use out_info if out_has_info is set. */
|
||||
gboolean
|
||||
flatpak_remote_state_lookup_ref (FlatpakRemoteState *self,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
GVariant **out_variant,
|
||||
gboolean *out_has_info,
|
||||
VarRefInfoRef *out_info,
|
||||
GError **error)
|
||||
{
|
||||
if (!flatpak_remote_state_allow_ref (self, ref))
|
||||
@@ -377,7 +379,9 @@ flatpak_remote_state_lookup_ref (FlatpakRemoteState *self,
|
||||
if (!flatpak_remote_state_ensure_summary (self, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_summary_lookup_ref (self->summary, self->collection_id, ref, out_checksum, out_variant))
|
||||
if (out_has_info)
|
||||
*out_has_info = TRUE;
|
||||
if (!flatpak_summary_lookup_ref (self->summary, self->collection_id, ref, out_checksum, out_info))
|
||||
{
|
||||
if (self->collection_id != NULL)
|
||||
return flatpak_fail_error (error, FLATPAK_ERROR_REF_NOT_FOUND,
|
||||
@@ -396,6 +400,11 @@ flatpak_remote_state_lookup_ref (FlatpakRemoteState *self,
|
||||
|
||||
if (!flatpak_remote_state_lookup_cache (self, ref, NULL, NULL, NULL, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (out_checksum)
|
||||
*out_checksum = NULL;
|
||||
if (out_has_info)
|
||||
*out_has_info = FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -3692,7 +3701,7 @@ flatpak_dir_find_latest_rev (FlatpakDir *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, NULL, error))
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, NULL, NULL, error))
|
||||
return FALSE;
|
||||
if (latest_rev == NULL)
|
||||
return flatpak_fail_error (error, FLATPAK_ERROR_REF_NOT_FOUND,
|
||||
@@ -5285,15 +5294,16 @@ flatpak_dir_mirror_oci (FlatpakDir *self,
|
||||
g_autofree char *registry_uri = NULL;
|
||||
g_autofree char *oci_digest = NULL;
|
||||
g_autofree char *latest_rev = NULL;
|
||||
g_autoptr(GVariant) summary_element = NULL;
|
||||
g_autoptr(GVariant) metadata = NULL;
|
||||
g_autofree char *oci_repository = NULL;
|
||||
VarRefInfoRef latest_rev_info;
|
||||
VarMetadataRef metadata;
|
||||
gboolean has_info;
|
||||
const char *oci_repository = NULL;
|
||||
gboolean res;
|
||||
|
||||
/* We use the summary so that we can reuse any cached json */
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, &summary_element, error))
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, &has_info, &latest_rev_info, error))
|
||||
return FALSE;
|
||||
if (latest_rev == NULL)
|
||||
if (latest_rev == NULL || !has_info)
|
||||
return flatpak_fail_error (error, FLATPAK_ERROR_REF_NOT_FOUND,
|
||||
_("Couldn't find latest checksum for ref %s in remote %s"),
|
||||
ref, state->remote_name);
|
||||
@@ -5305,8 +5315,8 @@ flatpak_dir_mirror_oci (FlatpakDir *self,
|
||||
ref, latest_rev);
|
||||
}
|
||||
|
||||
metadata = g_variant_get_child_value (summary_element, 2);
|
||||
g_variant_lookup (metadata, "xa.oci-repository", "s", &oci_repository);
|
||||
metadata = var_ref_info_get_metadata (latest_rev_info);
|
||||
oci_repository = var_metadata_lookup_string (metadata, "xa.oci-repository", NULL);
|
||||
|
||||
oci_digest = g_strconcat ("sha256:", latest_rev, NULL);
|
||||
|
||||
@@ -5351,27 +5361,28 @@ flatpak_dir_pull_oci (FlatpakDir *self,
|
||||
g_autoptr(FlatpakOciImage) image_config = NULL;
|
||||
g_autofree char *full_ref = NULL;
|
||||
g_autofree char *registry_uri = NULL;
|
||||
g_autofree char *oci_repository = NULL;
|
||||
const char *oci_repository = NULL;
|
||||
g_autofree char *oci_digest = NULL;
|
||||
g_autofree char *checksum = NULL;
|
||||
g_autoptr(GVariant) summary_element = NULL;
|
||||
VarRefInfoRef latest_rev_info;
|
||||
g_autofree char *latest_alt_commit = NULL;
|
||||
g_autoptr(GVariant) metadata = NULL;
|
||||
VarMetadataRef metadata;
|
||||
g_autofree char *latest_rev = NULL;
|
||||
gboolean has_info;
|
||||
G_GNUC_UNUSED g_autofree char *latest_commit =
|
||||
flatpak_dir_read_latest (self, state->remote_name, ref, &latest_alt_commit, cancellable, NULL);
|
||||
g_autofree char *name = NULL;
|
||||
|
||||
/* We use the summary so that we can reuse any cached json */
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, &summary_element, error))
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_rev, &has_info, &latest_rev_info, error))
|
||||
return FALSE;
|
||||
if (latest_rev == NULL)
|
||||
if (latest_rev == NULL || !has_info)
|
||||
return flatpak_fail_error (error, FLATPAK_ERROR_REF_NOT_FOUND,
|
||||
_("Couldn't find latest checksum for ref %s in remote %s"),
|
||||
ref, state->remote_name);
|
||||
|
||||
metadata = g_variant_get_child_value (summary_element, 2);
|
||||
g_variant_lookup (metadata, "xa.oci-repository", "s", &oci_repository);
|
||||
metadata = var_ref_info_get_metadata (latest_rev_info);
|
||||
oci_repository = var_metadata_lookup_string (metadata, "xa.oci-repository", NULL);
|
||||
|
||||
oci_digest = g_strconcat ("sha256:", latest_rev, NULL);
|
||||
|
||||
@@ -5569,7 +5580,7 @@ flatpak_dir_pull (FlatpakDir *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
flatpak_remote_state_lookup_ref (state, ref, &rev, NULL, error);
|
||||
flatpak_remote_state_lookup_ref (state, ref, &rev, NULL, NULL, error);
|
||||
if (rev == NULL && error != NULL && *error == NULL)
|
||||
flatpak_fail_error (error, FLATPAK_ERROR_REF_NOT_FOUND, _("Couldn't find latest checksum for ref %s in remote %s"),
|
||||
ref, state->remote_name);
|
||||
@@ -11351,7 +11362,7 @@ flatpak_dir_remote_has_ref (FlatpakDir *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return flatpak_remote_state_lookup_ref (state, ref, NULL, NULL, NULL);
|
||||
return flatpak_remote_state_lookup_ref (state, ref, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -13970,7 +13981,7 @@ flatpak_dir_fetch_remote_commit (FlatpakDir *self,
|
||||
if (state == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_commit, NULL, error))
|
||||
if (!flatpak_remote_state_lookup_ref (state, ref, &latest_commit, NULL, NULL, error))
|
||||
return NULL;
|
||||
if (latest_commit == NULL)
|
||||
{
|
||||
@@ -14272,7 +14283,7 @@ flatpak_dir_find_remote_related_for_metadata (FlatpakDir *self,
|
||||
|
||||
extension_ref = g_build_filename ("runtime", extension, parts[2], branch, NULL);
|
||||
|
||||
if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL))
|
||||
if (flatpak_remote_state_lookup_ref (state, extension_ref, &checksum, NULL, NULL, NULL))
|
||||
{
|
||||
if (flatpak_filters_allow_ref (NULL, masked, extension_ref))
|
||||
add_related (self, related, extension, extension_collection_id, extension_ref, checksum,
|
||||
@@ -14286,7 +14297,7 @@ flatpak_dir_find_remote_related_for_metadata (FlatpakDir *self,
|
||||
{
|
||||
g_autofree char *subref_checksum = NULL;
|
||||
|
||||
if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL) &&
|
||||
if (flatpak_remote_state_lookup_ref (state, refs[j], &subref_checksum, NULL, NULL, NULL) &&
|
||||
flatpak_filters_allow_ref (NULL, masked, refs[j]))
|
||||
add_related (self, related, extension, extension_collection_id, refs[j], subref_checksum,
|
||||
no_autodownload, download_if, autoprune_unless, autodelete, locale_subset);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "flatpak-installation-private.h"
|
||||
#include "flatpak-transaction-private.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-variant-impl-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:flatpak-transaction
|
||||
@@ -2315,7 +2316,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))
|
||||
flatpak_remote_state_lookup_ref (state, ref, 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,
|
||||
@@ -2503,7 +2504,8 @@ resolve_op_from_metadata (FlatpakTransaction *self,
|
||||
const char *metadata = NULL;
|
||||
g_autoptr(GVariant) sparse_cache = NULL;
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
g_autoptr(GVariant) summary_metadata = NULL;
|
||||
VarRefInfoRef info;
|
||||
gboolean has_info;
|
||||
|
||||
if (!flatpak_remote_state_lookup_cache (state, op->ref, &download_size, &installed_size, &metadata, NULL, &local_error))
|
||||
{
|
||||
@@ -2513,9 +2515,8 @@ resolve_op_from_metadata (FlatpakTransaction *self,
|
||||
else
|
||||
metadata_bytes = g_bytes_new (metadata, strlen (metadata) + 1);
|
||||
|
||||
flatpak_remote_state_lookup_ref (state, op->ref, NULL, &summary_metadata, NULL);
|
||||
if (summary_metadata)
|
||||
op->summary_metadata = g_variant_get_child_value (summary_metadata, 2);
|
||||
if (flatpak_remote_state_lookup_ref (state, op->ref, NULL, &has_info, &info, NULL) && has_info)
|
||||
op->summary_metadata = var_metadata_dup_to_gvariant (var_ref_info_get_metadata (info));
|
||||
|
||||
op->installed_size = installed_size;
|
||||
op->download_size = download_size;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "flatpak-context-private.h"
|
||||
#include "flatpak-error.h"
|
||||
#include "flatpak-utils-http-private.h"
|
||||
#include "flatpak-variant-private.h"
|
||||
#include <ostree.h>
|
||||
#include <json-glib/json-glib.h>
|
||||
|
||||
@@ -157,11 +158,11 @@ GVariant *flatpak_repo_load_summary (OstreeRepo *repo,
|
||||
char ** flatpak_summary_match_subrefs (GVariant *summary,
|
||||
const char *collection_id,
|
||||
const char *ref);
|
||||
gboolean flatpak_summary_lookup_ref (GVariant *summary,
|
||||
const char *collection_id,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
GVariant **out_variant);
|
||||
gboolean flatpak_summary_lookup_ref (GVariant *summary,
|
||||
const char *collection_id,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
VarRefInfoRef *out_info);
|
||||
|
||||
gboolean flatpak_name_matches_one_wildcard_prefix (const char *string,
|
||||
const char * const *maybe_wildcard_prefixes,
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "flatpak-run-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-variant-private.h"
|
||||
#include "flatpak-variant-impl-private.h"
|
||||
#include "libglnx/libglnx.h"
|
||||
#include "valgrind-private.h"
|
||||
@@ -2727,11 +2726,11 @@ flatpak_summary_match_subrefs (GVariant *summary_v,
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_summary_lookup_ref (GVariant *summary_v,
|
||||
const char *collection_id,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
GVariant **out_variant)
|
||||
flatpak_summary_lookup_ref (GVariant *summary_v,
|
||||
const char *collection_id,
|
||||
const char *ref,
|
||||
char **out_checksum,
|
||||
VarRefInfoRef *out_info)
|
||||
{
|
||||
VarSummaryRef summary;
|
||||
VarRefMapRef ref_map;
|
||||
@@ -2755,8 +2754,8 @@ flatpak_summary_lookup_ref (GVariant *summary_v,
|
||||
if (out_checksum)
|
||||
*out_checksum = ostree_checksum_from_bytes (checksum_bytes);
|
||||
|
||||
if (out_variant)
|
||||
*out_variant = var_ref_info_dup_to_gvariant (info);
|
||||
if (out_info)
|
||||
*out_info = info;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user