aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2023-11-16 00:12:44 +0100
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2023-11-21 22:00:45 +0100
commit7b95445865b8687eff0f8af678cfd3a4da281066 (patch)
treea6f7b9cffcb9f30d1f5272087f7da68d9a3ecd76 /gnu/packages/patches
parent93fd21717f4cbc4d416b354e6a77c7f8e3bdfe58 (diff)
downloadguix-7b95445865b8687eff0f8af678cfd3a4da281066.tar
guix-7b95445865b8687eff0f8af678cfd3a4da281066.tar.gz
gnu: appstream: Load stemmer in all circumstances.
If the default stemmer language is computed to be "en", such as in a Guix build container, then the stemmer would not be loaded. * gnu/packages/patches/appstream-load-stemmer-early.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/freedesktop.scm (appstream) [patches]: Use it here. [#:phases]<disable-failing-tests>: Remove. Change-Id: Iddd6ce5887247df46f670c49f9efc66772c82ff0 Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/appstream-force-reload-stemmer.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/gnu/packages/patches/appstream-force-reload-stemmer.patch b/gnu/packages/patches/appstream-force-reload-stemmer.patch
new file mode 100644
index 0000000000..a2cf84c8b1
--- /dev/null
+++ b/gnu/packages/patches/appstream-force-reload-stemmer.patch
@@ -0,0 +1,89 @@
+From 32182d7a7a67d0d204cd0a37bd211bfd0177bc27 Mon Sep 17 00:00:00 2001
+Message-ID: <32182d7a7a67d0d204cd0a37bd211bfd0177bc27.1700093066.git.vivien@planete-kraus.eu>
+From: Matthias Klumpp <matthias@tenstral.net>
+Date: Thu, 16 Nov 2023 00:59:15 +0100
+Subject: [PATCH] stemmer: Resolve potential issue where stemmer may never be
+ initialized
+
+If the initial locale was equal to the current stemming language, we may
+never have initialized the stemmer (which could lead to crashes or
+stemming being disabled).
+
+So we force the reload to always happen on initialization.
+CC: #558
+---
+ src/as-stemmer.c | 33 +++++++++++++++++++++------------
+ 1 file changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/src/as-stemmer.c b/src/as-stemmer.c
+index 63d45267..16ebd09b 100644
+--- a/src/as-stemmer.c
++++ b/src/as-stemmer.c
+@@ -47,6 +47,8 @@ G_DEFINE_TYPE (AsStemmer, as_stemmer, G_TYPE_OBJECT)
+
+ static gpointer as_stemmer_object = NULL;
+
++static void as_stemmer_reload_internal (AsStemmer *stemmer, const gchar *locale, gboolean force);
++
+ /**
+ * as_stemmer_finalize:
+ **/
+@@ -76,21 +78,14 @@ as_stemmer_init (AsStemmer *stemmer)
+
+ /* we don't use the locale in XML, so it can be POSIX */
+ locale = as_get_current_locale_posix ();
+- stemmer->current_lang = as_utils_locale_to_language (locale);
+
+- as_stemmer_reload (stemmer, stemmer->current_lang);
++ /* force a reload for initialization */
++ as_stemmer_reload_internal (stemmer, locale, TRUE);
+ #endif
+ }
+
+-/**
+- * as_stemmer_reload:
+- * @stemmer: A #AsStemmer
+- * @locale: The stemming language as POSIX locale.
+- *
+- * Allows realoading the #AsStemmer with a different language.
+- */
+-void
+-as_stemmer_reload (AsStemmer *stemmer, const gchar *locale)
++static void
++as_stemmer_reload_internal (AsStemmer *stemmer, const gchar *locale, gboolean force)
+ {
+ #ifdef HAVE_STEMMING
+ g_autofree gchar *lang = NULL;
+@@ -99,7 +94,7 @@ as_stemmer_reload (AsStemmer *stemmer, const gchar *locale)
+ /* check if we need to reload */
+ lang = as_utils_locale_to_language (locale);
+ locker = g_mutex_locker_new (&stemmer->mutex);
+- if (as_str_equal0 (lang, stemmer->current_lang)) {
++ if (!force && as_str_equal0 (lang, stemmer->current_lang)) {
+ g_mutex_locker_free (locker);
+ return;
+ }
+@@ -119,6 +114,20 @@ as_stemmer_reload (AsStemmer *stemmer, const gchar *locale)
+ #endif
+ }
+
++/**
++ * as_stemmer_reload:
++ * @stemmer: A #AsStemmer
++ * @locale: The stemming language as POSIX locale.
++ *
++ * Allows realoading the #AsStemmer with a different language.
++ * Does nothing if the stemmer is already using the selected language.
++ */
++void
++as_stemmer_reload (AsStemmer *stemmer, const gchar *locale)
++{
++ as_stemmer_reload_internal (stemmer, locale, FALSE);
++}
++
+ /**
+ * as_stemmer_stem:
+ * @stemmer: A #AsStemmer
+--
+2.41.0
+