temp/gnome-software: sync upstream and remove pmOS AppStream data (MR 2875)

AppStream data for postmarketOS has been removed until the new format
without a double "--" is deployed. Otherwise transition will be a pain
and we would have to take care of it downstream.

Relates #1384
This commit is contained in:
Pablo Correa Gómez 2022-01-22 18:52:11 +01:00 committed by Oliver Smith
parent 3d210e851c
commit 676b6c20bf
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
6 changed files with 316 additions and 5 deletions

View file

@ -0,0 +1,39 @@
From 3a7f4e433b9909ae1a92f7bd25de37dbefc76db8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= <ablocorrea@hotmail.com>
Date: Tue, 28 Dec 2021 20:03:00 +0100
Subject: [PATCH 1/5] gs-external-appstream-utils: use
external-appstream-system-wide key
The key had been defined when it was introduced, but it was not
implemented in code. The logic that decided whether to install
the external appstream files system-wide or just to the current
user has a bug, where it read "external-appstream-urls" instead
of "external-appstream-system-wide". This is fixed in this commit.
Additionally, before the fix, the memory returned by g_settings_get_strv
was never freed, causing a memory leak. Also, as "external-appstream-urls"
must have been set for the code to reach gs_external_appstream_refresh_url,
gs_external_appstream_refresh_user was dead code. This is also fixed
in this commit
(cherry picked from commit 7e8a1978f0e297fc052456fbc5da9218a1389903)
---
lib/gs-external-appstream-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/gs-external-appstream-utils.c b/lib/gs-external-appstream-utils.c
index 73c56744..39d71b29 100644
--- a/lib/gs-external-appstream-utils.c
+++ b/lib/gs-external-appstream-utils.c
@@ -236,7 +236,7 @@ gs_external_appstream_refresh_url (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- if (g_settings_get_strv (settings, "external-appstream-urls")) {
+ if (g_settings_get_boolean (settings, "external-appstream-system-wide")) {
return gs_external_appstream_refresh_sys (plugin, url,
cache_age,
cancellable,
--
2.25.1

View file

@ -0,0 +1,111 @@
From 413f67451c89d269d3b373cefd4b3a9bb500960e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= <ablocorrea@hotmail.com>
Date: Fri, 31 Dec 2021 00:46:38 +0100
Subject: [PATCH 2/5] gs-external-appstream-utils: hash url to allow same
basename
Component files generated by tools like appstream-generator all
have the same basename: Components-$(ARCH).xml.gz
In consequence, before this patch, if multiple urls are specified
in "external-appstream-urls" and have the same basename, the secondly
downloaded file will either override the first one (user installs),
or skip the download because a file with the said basename already exits
(system-wide installs). Hashing the url and adding the hash to the
basename solves this problem.
(cherry picked from commit 576d336e4994741e64b9384e7e05748b614cf981)
---
lib/gs-external-appstream-utils.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/lib/gs-external-appstream-utils.c b/lib/gs-external-appstream-utils.c
index 39d71b29..82c5f700 100644
--- a/lib/gs-external-appstream-utils.c
+++ b/lib/gs-external-appstream-utils.c
@@ -87,6 +87,7 @@ gs_external_appstream_get_modification_date (const gchar *file_path)
static gboolean
gs_external_appstream_refresh_sys (GsPlugin *plugin,
const gchar *url,
+ const gchar *basename,
guint cache_age,
GCancellable *cancellable,
GError **error)
@@ -96,7 +97,6 @@ gs_external_appstream_refresh_sys (GsPlugin *plugin,
guint status_code;
gboolean file_written;
g_autofree gchar *tmp_file_path = NULL;
- g_autofree gchar *file_name = NULL;
g_autofree gchar *local_mod_date = NULL;
g_autofree gchar *target_file_path = NULL;
g_autoptr(GFileIOStream) iostream = NULL;
@@ -104,8 +104,7 @@ gs_external_appstream_refresh_sys (GsPlugin *plugin,
g_autoptr(SoupMessage) msg = NULL;
/* check age */
- file_name = g_path_get_basename (url);
- target_file_path = gs_external_appstream_utils_get_file_cache_path (file_name);
+ target_file_path = gs_external_appstream_utils_get_file_cache_path (basename);
if (!gs_external_appstream_check (target_file_path, cache_age)) {
g_debug ("skipping updating external appstream file %s: "
"cache age is older than file",
@@ -145,7 +144,7 @@ gs_external_appstream_refresh_sys (GsPlugin *plugin,
/* write the download contents into a file that will be copied into
* the system */
tmp_file_path = gs_utils_get_cache_filename ("external-appstream",
- file_name,
+ basename,
GS_UTILS_CACHE_FLAG_WRITEABLE |
GS_UTILS_CACHE_FLAG_CREATE_DIRECTORY,
error);
@@ -196,18 +195,17 @@ gs_external_appstream_refresh_sys (GsPlugin *plugin,
static gboolean
gs_external_appstream_refresh_user (GsPlugin *plugin,
const gchar *url,
+ const gchar *basename,
guint cache_age,
GCancellable *cancellable,
GError **error)
{
guint file_age;
- g_autofree gchar *basename = NULL;
g_autofree gchar *fullpath = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
/* check age */
- basename = g_path_get_basename (url);
fullpath = g_build_filename (g_get_user_data_dir (),
"app-info",
"xmls",
@@ -236,13 +234,27 @@ gs_external_appstream_refresh_url (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+ g_autofree gchar *basename = NULL;
+ g_autofree gchar *basename_url = g_path_get_basename (url);
+ /* make sure different uris with same basenames differ */
+ g_autofree gchar *hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1,
+ url, -1);
+ if (hash == NULL) {
+ g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED,
+ "Failed to hash url %s", url);
+ return FALSE;
+ }
+ basename = g_strdup_printf ("%s-%s", hash, basename_url);
+
if (g_settings_get_boolean (settings, "external-appstream-system-wide")) {
return gs_external_appstream_refresh_sys (plugin, url,
+ basename,
cache_age,
cancellable,
error);
}
- return gs_external_appstream_refresh_user (plugin, url, cache_age,
+ return gs_external_appstream_refresh_user (plugin, url, basename,
+ cache_age,
cancellable, error);
}
--
2.25.1

View file

@ -0,0 +1,148 @@
From 55c53080dbbd2d81ebd0c3d98bb0e0831d6064d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= <ablocorrea@hotmail.com>
Date: Sat, 15 Jan 2022 22:51:10 +0100
Subject: [PATCH 3/5] appstream: implement parsing media_baseurl
This property was not documented for XML data until quite
recently: https://github.com/ximion/appstream/pull/371
However, remote icons and screenshots generated with appstream-generator
only contain urls relative to media_baseurl property. Fix all relative uris
prepending the corresponding media_baseurl for those objects to be downloadable.
---
lib/gs-appstream.c | 19 +++++++++
lib/gs-appstream.h | 2 +
plugins/core/gs-plugin-appstream.c | 64 ++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+)
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index df91dd0f..8e157595 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1824,3 +1824,22 @@ gs_appstream_component_add_extra_info (XbBuilderNode *component)
break;
}
}
+
+/* Resolve any media URIs which are actually relative
+ * paths against the media_baseurl property */
+void
+gs_appstream_component_fix_url (XbBuilderNode *component, const gchar *baseurl)
+{
+ const gchar *text = xb_builder_node_get_text (component);
+ g_autofree gchar *url = NULL;
+
+ if (text == NULL)
+ return;
+
+ if (g_str_has_prefix (text, "http:") ||
+ g_str_has_prefix (text, "https:"))
+ return;
+
+ url = g_strconcat (baseurl, "/", text, NULL);
+ xb_builder_node_set_text (component, url , -1);
+}
diff --git a/lib/gs-appstream.h b/lib/gs-appstream.h
index 5bddf913..fbc68a1a 100644
--- a/lib/gs-appstream.h
+++ b/lib/gs-appstream.h
@@ -72,5 +72,7 @@ void gs_appstream_component_add_icon (XbBuilderNode *component,
const gchar *str);
void gs_appstream_component_add_provide (XbBuilderNode *component,
const gchar *str);
+void gs_appstream_component_fix_url (XbBuilderNode *component,
+ const gchar *baseurl);
G_END_DECLS
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 5d61c5b6..950316f2 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -133,6 +133,60 @@ gs_plugin_appstream_add_origin_keyword_cb (XbBuilderFixup *self,
return TRUE;
}
+static void
+gs_plugin_appstream_media_baseurl_free (gpointer user_data)
+{
+ g_string_free ((GString *) user_data, TRUE);
+}
+
+static gboolean
+gs_plugin_appstream_media_baseurl_cb (XbBuilderFixup *self,
+ XbBuilderNode *bn,
+ gpointer user_data,
+ GError **error)
+{
+ GString *baseurl = user_data;
+ if (g_strcmp0 (xb_builder_node_get_element (bn), "components") == 0) {
+ const gchar *url = xb_builder_node_get_attr (bn, "media_baseurl");
+ if (url == NULL) {
+ g_string_truncate (baseurl, 0);
+ return TRUE;
+ }
+ g_string_assign (baseurl, url);
+ return TRUE;
+ }
+
+ if (baseurl->len == 0)
+ return TRUE;
+
+ if (g_strcmp0 (xb_builder_node_get_element (bn), "icon") == 0) {
+ const gchar *type = xb_builder_node_get_attr (bn, "type");
+ if (g_strcmp0 (type, "remote") != 0)
+ return TRUE;
+ gs_appstream_component_fix_url (bn, baseurl->str);
+ } else if (g_strcmp0 (xb_builder_node_get_element (bn), "screenshots") == 0) {
+ GPtrArray *screenshots = xb_builder_node_get_children (bn);
+ for (guint i = 0; i < screenshots->len; i++) {
+ XbBuilderNode *screenshot = g_ptr_array_index (screenshots, i);
+ GPtrArray *children = NULL;
+ /* Type-check for security */
+ if (g_strcmp0 (xb_builder_node_get_element (screenshot), "screenshot") != 0) {
+ continue;
+ }
+ children = xb_builder_node_get_children (screenshot);
+ for (guint j = 0; j < children->len; j++) {
+ XbBuilderNode *child = g_ptr_array_index (children, j);
+ const gchar *element = xb_builder_node_get_element (child);
+ if (g_strcmp0 (element, "image") != 0 &&
+ g_strcmp0 (element, "video") != 0)
+ continue;
+ gs_appstream_component_fix_url (child, baseurl->str);
+ }
+ }
+ }
+ return TRUE;
+}
+
static gboolean
gs_plugin_appstream_load_appdata_fn (GsPlugin *plugin,
XbBuilder *builder,
@@ -398,6 +452,8 @@ gs_plugin_appstream_load_appstream_fn (GsPlugin *plugin,
#if LIBXMLB_CHECK_VERSION(0,3,1)
g_autoptr(XbBuilderFixup) fixup4 = NULL;
#endif
+ g_autoptr(XbBuilderFixup) fixup5 = NULL;
+ GString *media_baseurl = g_string_new (NULL);
g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
/* add support for DEP-11 files */
@@ -453,6 +509,14 @@ gs_plugin_appstream_load_appstream_fn (GsPlugin *plugin,
xb_builder_source_add_fixup (source, fixup4);
#endif
+ /* prepend media_baseurl to remote relative URLs */
+ fixup5 = xb_builder_fixup_new ("MediaBaseUrl",
+ gs_plugin_appstream_media_baseurl_cb,
+ media_baseurl,
+ gs_plugin_appstream_media_baseurl_free);
+ xb_builder_fixup_set_max_depth (fixup5, 3);
+ xb_builder_source_add_fixup (source, fixup5);
+
/* success */
xb_builder_import_source (builder, source);
return TRUE;
--
2.25.1

View file

@ -2,7 +2,7 @@
pkgname=gnome-software
pkgver=9999_git20211203
_pkgver=41.3
pkgrel=1
pkgrel=2
pkgdesc="Software lets you install and update applications and system extensions"
url="https://wiki.gnome.org/Apps/Software"
# s390x, mips64 and riscv64 blocked by polkit
@ -10,16 +10,21 @@ arch="all !s390x !mips64 !riscv64"
license="GPL-2.0-or-later"
depends=""
makedepends="meson appstream-dev gdk-pixbuf-dev libxmlb-dev glib-dev gtk+3.0-dev
json-glib-dev libsoup-dev gnome-desktop-dev gspell-dev polkit-dev gtk-doc
ostree-dev flatpak-dev libgudev-dev gnome-online-accounts-dev libhandy1-dev"
json-glib-dev libsoup-dev gspell-dev polkit-dev gtk-doc ostree-dev
flatpak-dev libgudev-dev libhandy1-dev gsettings-desktop-schemas-dev"
options="!check" # lots of failing tests
install="$pkgname.post-upgrade"
subpackages="$pkgname-lang $pkgname-doc $pkgname-dbg
$pkgname-dev $pkgname-lib $pkgname-plugin-flatpak:flatpak_plugin"
_purism_commit="caaad1eaa5d863ffb9b7853907af8c8342dc2d39"
_purism_patches="https://source.puri.sm/Librem5/pureos-store/-/raw/$_purism_commit/debian/patches"
# First patch-set alpine, second pmOS, third Purism
source="https://download.gnome.org/sources/gnome-software/${_pkgver%.*}/gnome-software-$_pkgver.tar.xz
0001-gs-external-appstream-utils-use-external-appstream-s.patch
0002-gs-external-appstream-utils-hash-url-to-allow-same-b.patch
0003-appstream-implement-parsing-media_baseurl.patch
0001-make-updates-page-default-at-startup.patch
0002-disable-Automatic-Updates-options.patch
$_purism_patches/ui/0001-assets-Make-the-up-to-date-picture-fit-phones.patch
@ -97,6 +102,9 @@ flatpak_plugin() {
sha512sums="
7b19ed7e3b6f8662b6351fbb6eddb45f99cdbf9e6912e11b36301cdfd6f62cb3256da031e6640f9ad397384a23530d11488c78a1af60ce130a99838f97f8a0ed gnome-software-41.3.tar.xz
9f08078c9f0df149bc3be65fdcd47e7e1c11023c9fdbfe3fa63bb7f67883cd2ac654e8aa941d1b222b85d600a9cfeed8fb1d0d43091236c8e0e137d4035705a1 0001-gs-external-appstream-utils-use-external-appstream-s.patch
c4ca14d981da8fc93800178aeb2480c8bcaa524a0db283613047e769d4dd8aa9ee603d86cf1353818454e14e25d68b11858e2658e6ff5d7b3fa57c075800deb2 0002-gs-external-appstream-utils-hash-url-to-allow-same-b.patch
986cf69e34d61daea61d6555efc2e4805baf07d6a71fdf0c1e35fd38aef64b50924f64b5650d26d1a5c9841d29cffd3bb2cc869f55ba0c1763b929d5e21cb7b9 0003-appstream-implement-parsing-media_baseurl.patch
388910611f93147ab55ec602035baac6b85cdece9164d2205669ad41adc6a7cdf4d37d7eaf2eee51257bf905ff39eb0a2502679abeb4d95025ab1296ac0adc94 0001-make-updates-page-default-at-startup.patch
40c3aab58f050f88769e6265926762217324ed7748bee7bc3981a04e785133b71b81603dcc22f79c79ecb75298cdca07511031906c5c1eee5d2f122e3d8dab0c 0002-disable-Automatic-Updates-options.patch
ea2d4c6ee37b1fb27773d8908a98e6f6726cd2f72fcc7c41caf243a501896c991346d02ccbc36168c7194d0ba3dfd17660c7af79305a447f521617f0fbefae9e 0001-assets-Make-the-up-to-date-picture-fit-phones.patch
@ -114,5 +122,5 @@ e6869f3d76da7146bc2310a4e4ef2f8e3680e1f15ec81e102779fc4d775f77c05eb4686cfde2d1ea
51f34fce921faf926c546b23004224bd741f01d8e6040f6cd9749e8210c50f2f515588084168bc2841581736c247214c8aaf15abba9a5567d8d6f61b2c96e51a 0014-moderate-page-Use-a-HdyStatusPage.patch
16032fbfa3b18a4fff5ff43f2fceb2db20df3c76fc4799030604f7f1be452382ab00e709fd75daa766371fb445a1bb97de064b6d35bdad9755070c28e9f84836 0015-progress-button-Ellipsize-the-label.patch
fda7c405a9233e6813c8b87bcf7db4f1e6c6ab7a2c3426c6a2eba947572cfcad97e920bd3887a185f768a6a559d6d755b482f63e58fddc4b3f8b11931b287f1a 0016-updates-section-Ellipsize-the-button-label.patch
711dfa147c587a665c18ff15539984fd38d56580c41ce81ea52a35f875770e6dad1ded6d2cb18af70e6e697ad11f9c94c06916f6bbcfe65900df89a8bf8bd723 org.gnome.software.gschema.override
dc83eba4b5da759b6bc72d0f30ba4e9338684eb0d32d3e2b7989341ee6f8efc15b09dda88d1dc3cc6a2de0a2ae22a41c2fdbfe352b5d7c7ecff44c2d6035e17f org.gnome.software.gschema.override
"

View file

@ -0,0 +1,4 @@
#!/bin/sh
# Can be removed once GNOME 41.3 exists in all stable releases
rm -f /var/cache/app-info/xmls/org.gnome.Software-Components-*.xml.gz

View file

@ -1,2 +1,3 @@
[org.gnome.software]
external-appstream-urls=['https://appstream.alpinelinux.org/data/edge/main/Components-main-@CARCH@.xml.gz', 'https://appstream.alpinelinux.org/data/edge/community/Components-community-@CARCH@.xml.gz', 'https://appstream.alpinelinux.org/data/edge/testing/Components-testing-@CARCH@.xml.gz', 'https://mirror.postmarketos.org/appstream/data/master/Components--@CARCH@.xml.gz']
external-appstream-urls=['https://appstream.alpinelinux.org/data/edge/main/Components-@CARCH@.xml.gz', 'https://appstream.alpinelinux.org/data/edge/community/Components-@CARCH@.xml.gz', 'https://appstream.alpinelinux.org/data/edge/testing/Components-@CARCH@.xml.gz']
external-appstream-system-wide=true