"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/flatpak-utils.c" between
flatpak-1.15.1.tar.xz and flatpak-1.15.2.tar.xz

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

flatpak-utils.c  (flatpak-1.15.1.tar.xz):flatpak-utils.c  (flatpak-1.15.2.tar.xz)
skipping to change at line 123 skipping to change at line 123
return FALSE; return FALSE;
va_list args; va_list args;
va_start (args, fmt); va_start (args, fmt);
GError *new = g_error_new_valist (FLATPAK_ERROR, code, fmt, args); GError *new = g_error_new_valist (FLATPAK_ERROR, code, fmt, args);
va_end (args); va_end (args);
g_propagate_error (error, g_steal_pointer (&new)); g_propagate_error (error, g_steal_pointer (&new));
return FALSE; return FALSE;
} }
void
flatpak_debug2 (const char *format, ...)
{
va_list var_args;
va_start (var_args, format);
g_logv (G_LOG_DOMAIN "2",
G_LOG_LEVEL_DEBUG,
format, var_args);
va_end (var_args);
}
gboolean gboolean
flatpak_write_update_checksum (GOutputStream *out, flatpak_write_update_checksum (GOutputStream *out,
gconstpointer data, gconstpointer data,
gsize len, gsize len,
gsize *out_bytes_written, gsize *out_bytes_written,
GChecksum *checksum, GChecksum *checksum,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
if (out) if (out)
skipping to change at line 631 skipping to change at line 619
static GHashTable * static GHashTable *
load_kernel_module_list (void) load_kernel_module_list (void)
{ {
GHashTable *modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); GHashTable *modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_autofree char *modules_data = NULL; g_autofree char *modules_data = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
char *start, *end; char *start, *end;
if (!g_file_get_contents ("/proc/modules", &modules_data, NULL, &error)) if (!g_file_get_contents ("/proc/modules", &modules_data, NULL, &error))
{ {
g_debug ("Failed to read /proc/modules: %s", error->message); g_info ("Failed to read /proc/modules: %s", error->message);
return modules; return modules;
} }
/* /proc/modules is a table of modules. /* /proc/modules is a table of modules.
* Columns are split by spaces and rows by newlines. * Columns are split by spaces and rows by newlines.
* The first column is the name. */ * The first column is the name. */
start = modules_data; start = modules_data;
while (TRUE) while (TRUE)
{ {
end = strchr (start, ' '); end = strchr (start, ' ');
skipping to change at line 755 skipping to change at line 743
flatpak_get_bwrap (void) flatpak_get_bwrap (void)
{ {
const char *e = g_getenv ("FLATPAK_BWRAP"); const char *e = g_getenv ("FLATPAK_BWRAP");
if (e != NULL) if (e != NULL)
return e; return e;
return HELPER; return HELPER;
} }
gboolean gboolean
flatpak_bwrap_is_unprivileged (void)
{
const char *path = g_find_program_in_path (flatpak_get_bwrap ());
struct stat st;
/* Various features are supported only if bwrap exists and is not setuid */
return
path != NULL &&
stat (path, &st) == 0 &&
(st.st_mode & S_ISUID) == 0;
}
gboolean
flatpak_get_allowed_exports (const char *source_path, flatpak_get_allowed_exports (const char *source_path,
const char *app_id, const char *app_id,
FlatpakContext *context, FlatpakContext *context,
char ***allowed_extensions_out, char ***allowed_extensions_out,
char ***allowed_prefixes_out, char ***allowed_prefixes_out,
gboolean *require_exact_match_out) gboolean *require_exact_match_out)
{ {
g_autoptr(GPtrArray) allowed_extensions = g_ptr_array_new_with_free_func (g_fr ee); g_autoptr(GPtrArray) allowed_extensions = g_ptr_array_new_with_free_func (g_fr ee);
g_autoptr(GPtrArray) allowed_prefixes = g_ptr_array_new_with_free_func (g_free ); g_autoptr(GPtrArray) allowed_prefixes = g_ptr_array_new_with_free_func (g_free );
gboolean require_exact_match = FALSE; gboolean require_exact_match = FALSE;
skipping to change at line 3197 skipping to change at line 3198
g_variant_get_data (summary), g_variant_get_data (summary),
g_variant_get_size (summary)); g_variant_get_size (summary));
filename = g_strconcat (digest, ".gz", NULL); filename = g_strconcat (digest, ".gz", NULL);
path = g_build_filename ("summaries", filename, NULL); path = g_build_filename ("summaries", filename, NULL);
/* Check for pre-existing (non-truncated) copy and avoid re-writing it */ /* Check for pre-existing (non-truncated) copy and avoid re-writing it */
if (fstatat (repo_dfd, path, &stbuf, 0) == 0 && if (fstatat (repo_dfd, path, &stbuf, 0) == 0 &&
stbuf.st_size != 0) stbuf.st_size != 0)
{ {
g_debug ("Reusing digested summary at %s for %s", path, name); g_info ("Reusing digested summary at %s for %s", path, name);
return g_steal_pointer (&digest); return g_steal_pointer (&digest);
} }
data = g_variant_get_data_as_bytes (summary); data = g_variant_get_data_as_bytes (summary);
compressed_data = flatpak_zlib_compress_bytes (data, -1, error); compressed_data = flatpak_zlib_compress_bytes (data, -1, error);
if (compressed_data == NULL) if (compressed_data == NULL)
return NULL; return NULL;
if (!glnx_file_replace_contents_at (repo_dfd, path, if (!glnx_file_replace_contents_at (repo_dfd, path,
g_bytes_get_data (compressed_data, NULL), g_bytes_get_data (compressed_data, NULL),
g_bytes_get_size (compressed_data), g_bytes_get_size (compressed_data),
ostree_repo_get_disable_fsync (repo) ? GLN X_FILE_REPLACE_NODATASYNC : GLNX_FILE_REPLACE_DATASYNC_NEW, ostree_repo_get_disable_fsync (repo) ? GLN X_FILE_REPLACE_NODATASYNC : GLNX_FILE_REPLACE_DATASYNC_NEW,
cancellable, error)) cancellable, error))
return NULL; return NULL;
g_debug ("Wrote digested summary at %s for %s", path, name); g_info ("Wrote digested summary at %s for %s", path, name);
return g_steal_pointer (&digest); return g_steal_pointer (&digest);
} }
static gboolean static gboolean
flatpak_repo_save_digested_summary_delta (OstreeRepo *repo, flatpak_repo_save_digested_summary_delta (OstreeRepo *repo,
const char *from_digest, const char *from_digest,
const char *to_digest, const char *to_digest,
GBytes *delta, GBytes *delta,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
skipping to change at line 3242 skipping to change at line 3243
cancellable, cancellable,
error)) error))
return FALSE; return FALSE;
path = g_build_filename ("summaries", filename, NULL); path = g_build_filename ("summaries", filename, NULL);
/* Check for pre-existing copy of same size and avoid re-writing it */ /* Check for pre-existing copy of same size and avoid re-writing it */
if (fstatat (repo_dfd, path, &stbuf, 0) == 0 && if (fstatat (repo_dfd, path, &stbuf, 0) == 0 &&
stbuf.st_size == g_bytes_get_size (delta)) stbuf.st_size == g_bytes_get_size (delta))
{ {
g_debug ("Reusing digested summary-diff for %s", filename); g_info ("Reusing digested summary-diff for %s", filename);
return TRUE; return TRUE;
} }
if (!glnx_file_replace_contents_at (repo_dfd, path, if (!glnx_file_replace_contents_at (repo_dfd, path,
g_bytes_get_data (delta, NULL), g_bytes_get_data (delta, NULL),
g_bytes_get_size (delta), g_bytes_get_size (delta),
ostree_repo_get_disable_fsync (repo) ? GLN X_FILE_REPLACE_NODATASYNC : GLNX_FILE_REPLACE_DATASYNC_NEW, ostree_repo_get_disable_fsync (repo) ? GLN X_FILE_REPLACE_NODATASYNC : GLNX_FILE_REPLACE_DATASYNC_NEW,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
g_debug ("Wrote digested summary delta at %s", path); g_info ("Wrote digested summary delta at %s", path);
return TRUE; return TRUE;
} }
gboolean gboolean
flatpak_is_app_runtime_or_appstream_ref (const char *ref) flatpak_is_app_runtime_or_appstream_ref (const char *ref)
{ {
return return
g_str_has_prefix (ref, "appstream/") || g_str_has_prefix (ref, "appstream/") ||
g_str_has_prefix (ref, "appstream2/") || g_str_has_prefix (ref, "appstream2/") ||
g_str_has_prefix (ref, "app/") || g_str_has_prefix (ref, "app/") ||
skipping to change at line 3315 skipping to change at line 3316
VarMetadataRef index_metadata = var_summary_index_get_metadata (index); VarMetadataRef index_metadata = var_summary_index_get_metadata (index);
VarSummaryIndexSubsummariesRef subsummaries = var_summary_index_get_subsummari es (index); VarSummaryIndexSubsummariesRef subsummaries = var_summary_index_get_subsummari es (index);
gsize n_subsummaries = var_summary_index_subsummaries_get_length (subsummaries ); gsize n_subsummaries = var_summary_index_subsummaries_get_length (subsummaries );
guint32 cache_version; guint32 cache_version;
g_autoptr(GHashTable) commit_data_cache = commit_data_cache_new (); g_autoptr(GHashTable) commit_data_cache = commit_data_cache_new ();
cache_version = GUINT32_FROM_LE (var_metadata_lookup_uint32 (index_metadata, " xa.cache-version", 0)); cache_version = GUINT32_FROM_LE (var_metadata_lookup_uint32 (index_metadata, " xa.cache-version", 0));
if (cache_version < FLATPAK_XA_CACHE_VERSION) if (cache_version < FLATPAK_XA_CACHE_VERSION)
{ {
/* Need to re-index to get all data */ /* Need to re-index to get all data */
g_debug ("Old summary cache version %d, not using cache", cache_version); g_info ("Old summary cache version %d, not using cache", cache_version);
return NULL; return NULL;
} }
for (gsize i = 0; i < n_subsummaries; i++) for (gsize i = 0; i < n_subsummaries; i++)
{ {
VarSummaryIndexSubsummariesEntryRef entry = var_summary_index_subsummaries _get_at (subsummaries, i); VarSummaryIndexSubsummariesEntryRef entry = var_summary_index_subsummaries _get_at (subsummaries, i);
const char *name = var_summary_index_subsummaries_entry_get_key (entry); const char *name = var_summary_index_subsummaries_entry_get_key (entry);
const char *s; const char *s;
g_autofree char *subset = NULL; g_autofree char *subset = NULL;
VarSubsummaryRef subsummary = var_summary_index_subsummaries_entry_get_val ue (entry); VarSubsummaryRef subsummary = var_summary_index_subsummaries_entry_get_val ue (entry);
skipping to change at line 3337 skipping to change at line 3338
const guchar *checksum_bytes; const guchar *checksum_bytes;
g_autofree char *digest = NULL; g_autofree char *digest = NULL;
g_autoptr(GVariant) summary_v = NULL; g_autoptr(GVariant) summary_v = NULL;
VarSummaryRef summary; VarSummaryRef summary;
VarRefMapRef ref_map; VarRefMapRef ref_map;
gsize n_refs; gsize n_refs;
checksum_bytes = var_subsummary_peek_checksum (subsummary, &checksum_bytes _len); checksum_bytes = var_subsummary_peek_checksum (subsummary, &checksum_bytes _len);
if (G_UNLIKELY (checksum_bytes_len != OSTREE_SHA256_DIGEST_LEN)) if (G_UNLIKELY (checksum_bytes_len != OSTREE_SHA256_DIGEST_LEN))
{ {
g_debug ("Invalid checksum for digested summary, not using cache"); g_info ("Invalid checksum for digested summary, not using cache");
return NULL; return NULL;
} }
digest = ostree_checksum_from_bytes (checksum_bytes); digest = ostree_checksum_from_bytes (checksum_bytes);
s = strrchr (name, '-'); s = strrchr (name, '-');
if (s != NULL) if (s != NULL)
subset = g_strndup (name, s - name); subset = g_strndup (name, s - name);
else else
subset = g_strdup (""); subset = g_strdup ("");
summary_v = flatpak_repo_load_digested_summary (repo, digest, NULL); summary_v = flatpak_repo_load_digested_summary (repo, digest, NULL);
if (summary_v == NULL) if (summary_v == NULL)
{ {
g_debug ("Failed to load digested summary %s, not using cache", digest ); g_info ("Failed to load digested summary %s, not using cache", digest) ;
return NULL; return NULL;
} }
/* Note that all summaries refered to by the index is in new format */ /* Note that all summaries refered to by the index is in new format */
summary = var_summary_from_gvariant (summary_v); summary = var_summary_from_gvariant (summary_v);
ref_map = var_summary_get_ref_map (summary); ref_map = var_summary_get_ref_map (summary);
n_refs = var_ref_map_get_length (ref_map); n_refs = var_ref_map_get_length (ref_map);
for (gsize j = 0; j < n_refs; j++) for (gsize j = 0; j < n_refs; j++)
{ {
VarRefMapEntryRef e = var_ref_map_get_at (ref_map, j); VarRefMapEntryRef e = var_ref_map_get_at (ref_map, j);
skipping to change at line 3383 skipping to change at line 3384
if (!flatpak_is_app_runtime_or_appstream_ref (ref)) if (!flatpak_is_app_runtime_or_appstream_ref (ref))
continue; continue;
commit_bytes = var_ref_info_peek_checksum (info, &commit_bytes_len); commit_bytes = var_ref_info_peek_checksum (info, &commit_bytes_len);
if (G_UNLIKELY (commit_bytes_len != OSTREE_SHA256_DIGEST_LEN)) if (G_UNLIKELY (commit_bytes_len != OSTREE_SHA256_DIGEST_LEN))
continue; continue;
if (!var_metadata_lookup (commit_metadata, "xa.data", NULL, &xa_data_v ) || if (!var_metadata_lookup (commit_metadata, "xa.data", NULL, &xa_data_v ) ||
!var_variant_is_type (xa_data_v, G_VARIANT_TYPE ("(tts)"))) !var_variant_is_type (xa_data_v, G_VARIANT_TYPE ("(tts)")))
{ {
g_debug ("Missing xa.data for ref %s, not using cache", ref); g_info ("Missing xa.data for ref %s, not using cache", ref);
return NULL; return NULL;
} }
xa_data = var_cache_data_from_variant (xa_data_v); xa_data = var_cache_data_from_variant (xa_data_v);
rev = ostree_checksum_from_bytes (commit_bytes); rev = ostree_checksum_from_bytes (commit_bytes);
rev_data = g_hash_table_lookup (commit_data_cache, rev); rev_data = g_hash_table_lookup (commit_data_cache, rev);
if (rev_data == NULL) if (rev_data == NULL)
{ {
g_auto(GVariantBuilder) sparse_builder = FLATPAK_VARIANT_BUILDER_I NITIALIZER; g_auto(GVariantBuilder) sparse_builder = FLATPAK_VARIANT_BUILDER_I NITIALIZER;
skipping to change at line 3659 skipping to change at line 3660
g_autoptr(GBytes) superblock_content = glnx_fd_readall_bytes (fd, cancellable, error); g_autoptr(GBytes) superblock_content = glnx_fd_readall_bytes (fd, cancellable, error);
if (!superblock_content) if (!superblock_content)
return NULL; return NULL;
g_autoptr(GChecksum) checksum = g_checksum_new (G_CHECKSUM_SHA256); g_autoptr(GChecksum) checksum = g_checksum_new (G_CHECKSUM_SHA256);
g_checksum_update (checksum, g_bytes_get_data (superblock_content, NULL), g_by tes_get_size (superblock_content)); g_checksum_update (checksum, g_bytes_get_data (superblock_content, NULL), g_by tes_get_size (superblock_content));
len = sizeof digest; len = sizeof digest;
g_checksum_get_digest (checksum, digest, &len); g_checksum_get_digest (checksum, digest, &len);
return g_variant_new_from_data (G_VARIANT_TYPE ("ay"), return g_variant_new_from_data (G_VARIANT_TYPE ("ay"),
g_memdup (digest, len), len, g_memdup2 (digest, len), len,
FALSE, g_free, FALSE); FALSE, g_free, FALSE);
} }
static char * static char *
appstream_ref_get_subset (const char *ref) appstream_ref_get_subset (const char *ref)
{ {
if (!g_str_has_prefix (ref, "appstream2/")) if (!g_str_has_prefix (ref, "appstream2/"))
return NULL; return NULL;
const char *rest = ref + strlen ("appstream2/"); const char *rest = ref + strlen ("appstream2/");
skipping to change at line 4287 skipping to change at line 4288
g_variant_builder_add (metadata_builder, "{sv}", "xa.default-branch", g_variant_builder_add (metadata_builder, "{sv}", "xa.default-branch",
g_variant_new_string (default_branch)); g_variant_new_string (default_branch));
if (deploy_collection_id && collection_id != NULL) if (deploy_collection_id && collection_id != NULL)
g_variant_builder_add (metadata_builder, "{sv}", OSTREE_META_KEY_DEPLOY_COLL ECTION_ID, g_variant_builder_add (metadata_builder, "{sv}", OSTREE_META_KEY_DEPLOY_COLL ECTION_ID,
g_variant_new_string (collection_id)); g_variant_new_string (collection_id));
else if (deploy_sideload_collection_id && collection_id != NULL) else if (deploy_sideload_collection_id && collection_id != NULL)
g_variant_builder_add (metadata_builder, "{sv}", "xa.deploy-collection-id", g_variant_builder_add (metadata_builder, "{sv}", "xa.deploy-collection-id",
g_variant_new_string (collection_id)); g_variant_new_string (collection_id));
else if (deploy_collection_id) else if (deploy_collection_id)
g_debug ("Ignoring deploy-collection-id=true because no collection ID is set ."); g_info ("Ignoring deploy-collection-id=true because no collection ID is set. ");
if (authenticator_name) if (authenticator_name)
g_variant_builder_add (metadata_builder, "{sv}", "xa.authenticator-name", g_variant_builder_add (metadata_builder, "{sv}", "xa.authenticator-name",
g_variant_new_string (authenticator_name)); g_variant_new_string (authenticator_name));
if (authenticator_install != -1) if (authenticator_install != -1)
g_variant_builder_add (metadata_builder, "{sv}", "xa.authenticator-install", g_variant_builder_add (metadata_builder, "{sv}", "xa.authenticator-install",
g_variant_new_boolean (authenticator_install)); g_variant_new_boolean (authenticator_install));
g_variant_builder_add (metadata_builder, "{sv}", "xa.cache-version", g_variant_builder_add (metadata_builder, "{sv}", "xa.cache-version",
skipping to change at line 4749 skipping to change at line 4750
ext = strchr (dent->d_name, '.'); ext = strchr (dent->d_name, '.');
if (ext != NULL) if (ext != NULL)
{ {
if (strcmp (ext, ".gz") == 0 && strlen (dent->d_name) == 64 + 3) if (strcmp (ext, ".gz") == 0 && strlen (dent->d_name) == 64 + 3)
{ {
char *sha256 = g_strndup (dent->d_name, 64); char *sha256 = g_strndup (dent->d_name, 64);
/* Keep all the referenced summaries */ /* Keep all the referenced summaries */
if (g_hash_table_contains (digested_summary_cache, sha256)) if (g_hash_table_contains (digested_summary_cache, sha256))
{ {
g_debug ("Keeping referenced summary %s", dent->d_name); g_info ("Keeping referenced summary %s", dent->d_name);
continue; continue;
} }
/* Remove rest */ /* Remove rest */
remove = TRUE; remove = TRUE;
} }
else if (strcmp (ext, ".delta") == 0) else if (strcmp (ext, ".delta") == 0)
{ {
const char *dash = strchr (dent->d_name, '-'); const char *dash = strchr (dent->d_name, '-');
if (dash != NULL && dash < ext && (ext - dash) == 1 + 64) if (dash != NULL && dash < ext && (ext - dash) == 1 + 64)
{ {
char *to_sha256 = g_strndup (dash + 1, 64); char *to_sha256 = g_strndup (dash + 1, 64);
/* Only keep deltas going to a generated summary */ /* Only keep deltas going to a generated summary */
if (g_hash_table_contains (digested_summaries, to_sha256)) if (g_hash_table_contains (digested_summaries, to_sha256))
{ {
g_debug ("Keeping delta to generated summary %s", dent->d_ name); g_info ("Keeping delta to generated summary %s", dent->d_n ame);
continue; continue;
} }
/* Remove rest */ /* Remove rest */
remove = TRUE; remove = TRUE;
} }
} }
else if (strcmp (ext, ".idx.sig") == 0) else if (strcmp (ext, ".idx.sig") == 0)
{ {
g_autofree char *digest = g_strndup (dent->d_name, strlen (dent->d _name) - strlen (".idx.sig")); g_autofree char *digest = g_strndup (dent->d_name, strlen (dent->d _name) - strlen (".idx.sig"));
skipping to change at line 4789 skipping to change at line 4790
if (g_strcmp0 (digest, old_index_digest) == 0) if (g_strcmp0 (digest, old_index_digest) == 0)
continue; /* Always keep previous one, to avoid some races */ continue; /* Always keep previous one, to avoid some races */
/* Remove the rest */ /* Remove the rest */
remove = TRUE; remove = TRUE;
} }
} }
if (remove) if (remove)
{ {
g_debug ("Removing old digested summary file %s", dent->d_name); g_info ("Removing old digested summary file %s", dent->d_name);
if (unlinkat (iter.fd, dent->d_name, 0) != 0) if (unlinkat (iter.fd, dent->d_name, 0) != 0)
{ {
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }
} }
else else
g_debug ("Keeping unexpected summary file %s", dent->d_name); g_info ("Keeping unexpected summary file %s", dent->d_name);
} }
return TRUE; return TRUE;
} }
/* Update the metadata in the summary file for @repo, and then re-sign the file. /* Update the metadata in the summary file for @repo, and then re-sign the file.
* If the repo has a collection ID set, additionally store the metadata on a * If the repo has a collection ID set, additionally store the metadata on a
* contentless commit in a well-known branch, which is the preferred way of * contentless commit in a well-known branch, which is the preferred way of
* broadcasting per-repo metadata (putting it in the summary file is deprecated, * broadcasting per-repo metadata (putting it in the summary file is deprecated,
* but kept for backwards compatibility). * but kept for backwards compatibility).
skipping to change at line 4974 skipping to change at line 4975
if (summary_index) if (summary_index)
index_digest = g_compute_checksum_for_data (G_CHECKSUM_SHA256, index_digest = g_compute_checksum_for_data (G_CHECKSUM_SHA256,
g_variant_get_data (summary_inde x), g_variant_get_data (summary_inde x),
g_variant_get_size (summary_inde x)); g_variant_get_size (summary_inde x));
if (old_index) if (old_index)
old_index_digest = g_compute_checksum_for_data (G_CHECKSUM_SHA256, old_index_digest = g_compute_checksum_for_data (G_CHECKSUM_SHA256,
g_variant_get_data (old_inde x), g_variant_get_data (old_inde x),
g_variant_get_size (old_inde x)); g_variant_get_size (old_inde x));
/* Release the memory-mapped summary index file before replacing it,
to avoid failure on filesystems like cifs */
g_clear_pointer (&old_index, g_variant_unref);
if (!flatpak_repo_save_summary_index (repo, summary_index, index_digest, index _sig, cancellable, error)) if (!flatpak_repo_save_summary_index (repo, summary_index, index_digest, index _sig, cancellable, error))
return FALSE; return FALSE;
if (!flatpak_repo_save_compat_summary (repo, compat_summary, &old_compat_sig_m time, cancellable, error)) if (!flatpak_repo_save_compat_summary (repo, compat_summary, &old_compat_sig_m time, cancellable, error))
return FALSE; return FALSE;
if (gpg_key_ids) if (gpg_key_ids)
{ {
if (!ostree_repo_add_gpg_signature_summary (repo, if (!ostree_repo_add_gpg_signature_summary (repo,
gpg_key_ids, gpg_key_ids,
skipping to change at line 5310 skipping to change at line 5315
const char *size, const char *size,
GError **error) GError **error)
{ {
g_autofree char *icon_name = g_strconcat (id, ".png", NULL); g_autofree char *icon_name = g_strconcat (id, ".png", NULL);
g_autoptr(GFile) size_dir = g_file_get_child (icons_dir, size); g_autoptr(GFile) size_dir = g_file_get_child (icons_dir, size);
g_autoptr(GFile) icon_file = g_file_get_child (size_dir, icon_name); g_autoptr(GFile) icon_file = g_file_get_child (size_dir, icon_name);
const char *checksum; const char *checksum;
if (!ostree_repo_file_ensure_resolved (OSTREE_REPO_FILE(icon_file), NULL)) if (!ostree_repo_file_ensure_resolved (OSTREE_REPO_FILE(icon_file), NULL))
{ {
g_debug ("No icon at size %s for %s", size, id); g_info ("No icon at size %s for %s", size, id);
return TRUE; return TRUE;
} }
checksum = ostree_repo_file_get_checksum (OSTREE_REPO_FILE(icon_file)); checksum = ostree_repo_file_get_checksum (OSTREE_REPO_FILE(icon_file));
if (!ostree_mutable_tree_replace_file (size_mtree, icon_name, checksum, error) ) if (!ostree_mutable_tree_replace_file (size_mtree, icon_name, checksum, error) )
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
skipping to change at line 5606 skipping to change at line 5611
g_autoptr(OstreeMutableTree) icons_mtree = NULL; g_autoptr(OstreeMutableTree) icons_mtree = NULL;
g_autoptr(OstreeMutableTree) icons_flatpak_mtree = NULL; g_autoptr(OstreeMutableTree) icons_flatpak_mtree = NULL;
g_autoptr(OstreeMutableTree) size1_mtree = NULL; g_autoptr(OstreeMutableTree) size1_mtree = NULL;
g_autoptr(OstreeMutableTree) size2_mtree = NULL; g_autoptr(OstreeMutableTree) size2_mtree = NULL;
const char *compat_arch; const char *compat_arch;
compat_arch = flatpak_get_compat_arch (arch); compat_arch = flatpak_get_compat_arch (arch);
const char *branch_names[] = { "appstream", "appstream2" }; const char *branch_names[] = { "appstream", "appstream2" };
const char *collection_id; const char *collection_id;
if (subset != NULL && *subset != 0) if (subset != NULL && *subset != 0)
g_debug ("Generating appstream for %s, subset %s", arch, subset); g_info ("Generating appstream for %s, subset %s", arch, subset);
else else
g_debug ("Generating appstream for %s", arch); g_info ("Generating appstream for %s", arch);
collection_id = ostree_repo_get_collection_id (repo); collection_id = ostree_repo_get_collection_id (repo);
if (!flatpak_mtree_ensure_dir_metadata (repo, mtree, cancellable, error)) if (!flatpak_mtree_ensure_dir_metadata (repo, mtree, cancellable, error))
return FALSE; return FALSE;
if (!flatpak_mtree_create_dir (repo, mtree, "icons", &icons_mtree, error)) if (!flatpak_mtree_create_dir (repo, mtree, "icons", &icons_mtree, error))
return FALSE; return FALSE;
if (!flatpak_mtree_create_dir (repo, icons_mtree, "64x64", &size1_mtree, error )) if (!flatpak_mtree_create_dir (repo, icons_mtree, "64x64", &size1_mtree, error ))
skipping to change at line 5668 skipping to change at line 5673
continue; continue;
} }
commit_v = g_hash_table_lookup (all_commits, ref); commit_v = g_hash_table_lookup (all_commits, ref);
g_assert (commit_v != NULL); g_assert (commit_v != NULL);
commit_metadata = var_commit_get_metadata (var_commit_from_gvariant (commi t_v)); commit_metadata = var_commit_get_metadata (var_commit_from_gvariant (commi t_v));
if (var_metadata_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE , NULL, NULL) || if (var_metadata_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE , NULL, NULL) ||
var_metadata_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE _REBASE, NULL, NULL)) var_metadata_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_ENDOFLIFE _REBASE, NULL, NULL))
{ {
g_debug (_("%s is end-of-life, ignoring for appstream"), flatpak_decom posed_get_ref (ref)); g_info (_("%s is end-of-life, ignoring for appstream"), flatpak_decomp osed_get_ref (ref));
continue; continue;
} }
if (*subset != 0) if (*subset != 0)
{ {
VarVariantRef xa_subsets_v; VarVariantRef xa_subsets_v;
gboolean in_subset = FALSE; gboolean in_subset = FALSE;
if (var_metadata_lookup (commit_metadata, "xa.subsets", NULL, &xa_subs ets_v)) if (var_metadata_lookup (commit_metadata, "xa.subsets", NULL, &xa_subs ets_v))
{ {
skipping to change at line 5760 skipping to change at line 5765
if (parent) if (parent)
{ {
g_autoptr(GFile) parent_root = NULL; g_autoptr(GFile) parent_root = NULL;
if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancel lable, error)) if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancel lable, error))
return FALSE; return FALSE;
if (g_file_equal (root, parent_root)) if (g_file_equal (root, parent_root))
{ {
skip_commit = TRUE; skip_commit = TRUE;
g_debug ("Not updating %s, no change", branch); g_info ("Not updating %s, no change", branch);
} }
} }
if (!skip_commit) if (!skip_commit)
{ {
g_autoptr(GVariantDict) metadata_dict = NULL; g_autoptr(GVariantDict) metadata_dict = NULL;
g_autoptr(GVariant) metadata = NULL; g_autoptr(GVariant) metadata = NULL;
/* Add bindings to the metadata. Do this even if P2P support is not /* Add bindings to the metadata. Do this even if P2P support is not
* enabled, as it might be enable for other flatpak builds. */ * enabled, as it might be enable for other flatpak builds. */
skipping to change at line 5811 skipping to change at line 5816
if (!ostree_repo_sign_commit (repo, if (!ostree_repo_sign_commit (repo,
commit_checksum, commit_checksum,
keyid, keyid,
gpg_homedir, gpg_homedir,
cancellable, cancellable,
error)) error))
return FALSE; return FALSE;
} }
} }
g_debug ("Creating appstream branch %s", branch); g_info ("Creating appstream branch %s", branch);
if (collection_id != NULL) if (collection_id != NULL)
{ {
const OstreeCollectionRef collection_ref = { (char *) collection_i d, branch }; const OstreeCollectionRef collection_ref = { (char *) collection_i d, branch };
ostree_repo_transaction_set_collection_ref (repo, &collection_ref, commit_checksum); ostree_repo_transaction_set_collection_ref (repo, &collection_ref, commit_checksum);
} }
else else
{ {
ostree_repo_transaction_set_ref (repo, NULL, branch, commit_checks um); ostree_repo_transaction_set_ref (repo, NULL, branch, commit_checks um);
} }
} }
skipping to change at line 6982 skipping to change at line 6987
for (i = 0; manifest->layers[i] != NULL; i++) for (i = 0; manifest->layers[i] != NULL; i++)
{ {
FlatpakOciDescriptor *layer = manifest->layers[i]; FlatpakOciDescriptor *layer = manifest->layers[i];
FlatpakOciDescriptor *delta_layer = NULL; FlatpakOciDescriptor *delta_layer = NULL;
if (delta_manifest) if (delta_manifest)
delta_layer = flatpak_oci_manifest_find_delta_for (delta_manifest, old_d iffid, image_config->rootfs.diff_ids[i]); delta_layer = flatpak_oci_manifest_find_delta_for (delta_manifest, old_d iffid, image_config->rootfs.diff_ids[i]);
if (delta_layer) if (delta_layer)
{ {
g_debug ("Using OCI delta %s for layer %s", delta_layer->digest, layer ->digest); g_info ("Using OCI delta %s for layer %s", delta_layer->digest, layer- >digest);
g_autofree char *delta_digest = NULL; g_autofree char *delta_digest = NULL;
glnx_autofd int delta_fd = flatpak_oci_registry_download_blob (registr y, oci_repository, FALSE, glnx_autofd int delta_fd = flatpak_oci_registry_download_blob (registr y, oci_repository, FALSE,
delta_l ayer->digest, (const char **)delta_layer->urls, delta_l ayer->digest, (const char **)delta_layer->urls,
oci_lay er_progress, &progress_data, oci_lay er_progress, &progress_data,
cancell able, error); cancell able, error);
if (delta_fd == -1) if (delta_fd == -1)
return FALSE; return FALSE;
delta_digest = flatpak_oci_registry_apply_delta_to_blob (dst_registry, delta_fd, old_root, cancellable, error); delta_digest = flatpak_oci_registry_apply_delta_to_blob (dst_registry, delta_fd, old_root, cancellable, error);
if (delta_digest == NULL) if (delta_digest == NULL)
skipping to change at line 7171 skipping to change at line 7176
const char *expected_digest; const char *expected_digest;
if (delta_manifest) if (delta_manifest)
delta_layer = flatpak_oci_manifest_find_delta_for (delta_manifest, old_d iffid, image_config->rootfs.diff_ids[i]); delta_layer = flatpak_oci_manifest_find_delta_for (delta_manifest, old_d iffid, image_config->rootfs.diff_ids[i]);
opts.autocreate_parents = TRUE; opts.autocreate_parents = TRUE;
opts.ignore_unsupported_content = TRUE; opts.ignore_unsupported_content = TRUE;
if (delta_layer) if (delta_layer)
{ {
g_debug ("Using OCI delta %s for layer %s", delta_layer->digest, layer ->digest); g_info ("Using OCI delta %s for layer %s", delta_layer->digest, layer- >digest);
expected_digest = image_config->rootfs.diff_ids[i]; /* The delta recre ates the uncompressed tar so use that digest */ expected_digest = image_config->rootfs.diff_ids[i]; /* The delta recre ates the uncompressed tar so use that digest */
} }
else else
{ {
layer_fd = glnx_steal_fd (&blob_fd); layer_fd = glnx_steal_fd (&blob_fd);
expected_digest = layer->digest; expected_digest = layer->digest;
} }
blob_fd = flatpak_oci_registry_download_blob (registry, oci_repository, FA LSE, blob_fd = flatpak_oci_registry_download_blob (registry, oci_repository, FA LSE,
delta_layer ? delta_layer->d igest : layer->digest, delta_layer ? delta_layer->d igest : layer->digest,
skipping to change at line 8229 skipping to change at line 8234
if (dir != NULL) if (dir != NULL)
{ {
GFile *dir_path = NULL; GFile *dir_path = NULL;
g_autofree char *dir_path_str = NULL; g_autofree char *dir_path_str = NULL;
g_autofree char *dir_name = NULL; g_autofree char *dir_name = NULL;
dir_path = flatpak_dir_get_path (dir); dir_path = flatpak_dir_get_path (dir);
if (dir_path != NULL) if (dir_path != NULL)
dir_path_str = g_file_get_path (dir_path); dir_path_str = g_file_get_path (dir_path);
dir_name = flatpak_dir_get_name (dir); dir_name = flatpak_dir_get_name (dir);
g_debug ("Opening %s flatpak installation at path %s", dir_name, dir_path_ str); g_info ("Opening %s flatpak installation at path %s", dir_name, dir_path_s tr);
} }
} }
gboolean gboolean
flatpak_check_required_version (const char *ref, flatpak_check_required_version (const char *ref,
GKeyFile *metakey, GKeyFile *metakey,
GError **error) GError **error)
{ {
g_auto(GStrv) required_versions = NULL; g_auto(GStrv) required_versions = NULL;
const char *group; const char *group;
 End of changes. 27 change blocks. 
36 lines changed or deleted 41 lines changed or added

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