diff options
author | Simon McVittie <smcv@debian.org> | 2022-03-27 12:31:22 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2022-03-27 13:05:46 +0100 |
commit | 18c18085faf264d52605c96566c5fc5f5a28672c (patch) | |
tree | eced7c8a24a111b0905917ea6639bbbc11494f93 | |
parent | 9d9c2a521b74804735885c89029e48d65d049de4 (diff) |
Add patches to fix compilation on Debian 11
3 files changed, 308 insertions, 0 deletions
diff --git a/debian/patches/Move-g_string_replace-backport-to-a-separate-translation-.patch b/debian/patches/Move-g_string_replace-backport-to-a-separate-translation-.patch new file mode 100644 index 0000000..f275daa --- /dev/null +++ b/debian/patches/Move-g_string_replace-backport-to-a-separate-translation-.patch @@ -0,0 +1,265 @@ +From: Simon McVittie <smcv@collabora.com> +Date: Sun, 27 Mar 2022 12:25:34 +0100 +Subject: Move g_string_replace() backport to a separate translation unit + +This will make it simpler to use in rewrite-launchers without +unnecessarily pulling in libsystemd. + +Signed-off-by: Simon McVittie <smcv@collabora.com> +Forwarded: https://github.com/flatpak/xdg-desktop-portal/pull/750 +--- + src/Makefile.am.inc | 2 ++ + src/glib-backports.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/glib-backports.h | 53 +++++++++++++++++++++++++++++++++++++++ + src/xdp-utils.c | 45 --------------------------------- + src/xdp-utils.h | 29 +-------------------- + 5 files changed, 127 insertions(+), 73 deletions(-) + create mode 100644 src/glib-backports.c + create mode 100644 src/glib-backports.h + +diff --git a/src/Makefile.am.inc b/src/Makefile.am.inc +index 0d15b04..3064793 100644 +--- a/src/Makefile.am.inc ++++ b/src/Makefile.am.inc +@@ -72,6 +72,8 @@ xdg_desktop_portal_SOURCES = \ + src/xdg-desktop-portal.c \ + src/file-chooser.c \ + src/file-chooser.h \ ++ src/glib-backports.c \ ++ src/glib-backports.h \ + src/open-uri.c \ + src/open-uri.h \ + src/print.c \ +diff --git a/src/glib-backports.c b/src/glib-backports.c +new file mode 100644 +index 0000000..cb539e8 +--- /dev/null ++++ b/src/glib-backports.c +@@ -0,0 +1,71 @@ ++/* ++ * Copyright © 2014 Red Hat, Inc ++ * Copyright © 2021 Joshua Lee ++ * Copyright © 2021 Emmanuel Fleury ++ * Copyright © 2021 Nelson Ben ++ * Copyright © 2021 Peter Bloomfield ++ * Copyright © 2021 Collabora Ltd. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see <http://www.gnu.org/licenses/>. ++ */ ++ ++#include "config.h" ++ ++#include <gio/gio.h> ++ ++#include "glib-backports.h" ++ ++#if !GLIB_CHECK_VERSION (2, 68, 0) ++/* All this code is backported directly from glib */ ++guint ++g_string_replace (GString *string, ++ const gchar *find, ++ const gchar *replace, ++ guint limit) ++{ ++ gsize f_len, r_len, pos; ++ gchar *cur, *next; ++ guint n = 0; ++ ++ g_return_val_if_fail (string != NULL, 0); ++ g_return_val_if_fail (find != NULL, 0); ++ g_return_val_if_fail (replace != NULL, 0); ++ ++ f_len = strlen (find); ++ r_len = strlen (replace); ++ cur = string->str; ++ ++ while ((next = strstr (cur, find)) != NULL) ++ { ++ pos = next - string->str; ++ g_string_erase (string, pos, f_len); ++ g_string_insert (string, pos, replace); ++ cur = string->str + pos + r_len; ++ n++; ++ /* Only match the empty string once at any given position, to ++ * avoid infinite loops */ ++ if (f_len == 0) ++ { ++ if (cur[0] == '\0') ++ break; ++ else ++ cur++; ++ } ++ if (n == limit) ++ break; ++ } ++ ++ return n; ++} ++#endif /* GLIB_CHECK_VERSION (2, 68, 0) */ +diff --git a/src/glib-backports.h b/src/glib-backports.h +new file mode 100644 +index 0000000..a355f6a +--- /dev/null ++++ b/src/glib-backports.h +@@ -0,0 +1,53 @@ ++/* ++ * Copyright © 2014, 2016 Red Hat, Inc ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see <http://www.gnu.org/licenses/>. ++ * ++ * Authors: ++ * Alexander Larsson <alexl@redhat.com> ++ * Matthias Clasen <mclasen@redhat.com> ++ */ ++ ++#pragma once ++ ++#include <gio/gio.h> ++ ++#ifndef G_DBUS_METHOD_INVOCATION_HANDLED ++#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE ++#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE ++#endif ++ ++#if !GLIB_CHECK_VERSION (2, 58, 0) ++static inline gboolean ++g_hash_table_steal_extended (GHashTable *hash_table, ++ gconstpointer lookup_key, ++ gpointer *stolen_key, ++ gpointer *stolen_value) ++{ ++ if (g_hash_table_lookup_extended (hash_table, lookup_key, stolen_key, stolen_value)) ++ { ++ g_hash_table_steal (hash_table, lookup_key); ++ return TRUE; ++ } ++ else ++ return FALSE; ++} ++#endif ++ ++#if !GLIB_CHECK_VERSION (2, 68, 0) ++guint g_string_replace (GString *string, ++ const gchar *find, ++ const gchar *replace, ++ guint limit); ++#endif +diff --git a/src/xdp-utils.c b/src/xdp-utils.c +index 1de5a4f..609f65e 100644 +--- a/src/xdp-utils.c ++++ b/src/xdp-utils.c +@@ -2343,48 +2343,3 @@ xdp_validate_serialized_icon (GVariant *v, + + return TRUE; + } +- +-#if !GLIB_CHECK_VERSION (2, 68, 0) +-/* All this code is backported directly from glib */ +-guint +-g_string_replace (GString *string, +- const gchar *find, +- const gchar *replace, +- guint limit) +-{ +- gsize f_len, r_len, pos; +- gchar *cur, *next; +- guint n = 0; +- +- g_return_val_if_fail (string != NULL, 0); +- g_return_val_if_fail (find != NULL, 0); +- g_return_val_if_fail (replace != NULL, 0); +- +- f_len = strlen (find); +- r_len = strlen (replace); +- cur = string->str; +- +- while ((next = strstr (cur, find)) != NULL) +- { +- pos = next - string->str; +- g_string_erase (string, pos, f_len); +- g_string_insert (string, pos, replace); +- cur = string->str + pos + r_len; +- n++; +- /* Only match the empty string once at any given position, to +- * avoid infinite loops */ +- if (f_len == 0) +- { +- if (cur[0] == '\0') +- break; +- else +- cur++; +- } +- if (n == limit) +- break; +- } +- +- return n; +-} +- +-#endif /* GLIB_CHECK_VERSION (2, 28, 0) */ +diff --git a/src/xdp-utils.h b/src/xdp-utils.h +index 9861e73..300e6d5 100644 +--- a/src/xdp-utils.h ++++ b/src/xdp-utils.h +@@ -29,10 +29,7 @@ + #include <gio/gio.h> + #include <errno.h> + +-#ifndef G_DBUS_METHOD_INVOCATION_HANDLED +-#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE +-#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE +-#endif ++#include "glib-backports.h" + + #define DESKTOP_PORTAL_OBJECT_PATH "/org/freedesktop/portal/desktop" + +@@ -202,27 +199,3 @@ int _xdp_parse_cgroup_file (FILE *f, + #ifdef HAVE_LIBSYSTEMD + char *_xdp_parse_app_id_from_unit_name (const char *unit); + #endif +- +-#if !GLIB_CHECK_VERSION (2, 58, 0) +-static inline gboolean +-g_hash_table_steal_extended (GHashTable *hash_table, +- gconstpointer lookup_key, +- gpointer *stolen_key, +- gpointer *stolen_value) +-{ +- if (g_hash_table_lookup_extended (hash_table, lookup_key, stolen_key, stolen_value)) +- { +- g_hash_table_steal (hash_table, lookup_key); +- return TRUE; +- } +- else +- return FALSE; +-} +-#endif +- +-#if !GLIB_CHECK_VERSION (2, 68, 0) +-guint g_string_replace (GString *string, +- const gchar *find, +- const gchar *replace, +- guint limit); +-#endif diff --git a/debian/patches/rewrite-launchers-Provide-backported-g_string_replace.patch b/debian/patches/rewrite-launchers-Provide-backported-g_string_replace.patch new file mode 100644 index 0000000..bf8316c --- /dev/null +++ b/debian/patches/rewrite-launchers-Provide-backported-g_string_replace.patch @@ -0,0 +1,41 @@ +From: Simon McVittie <smcv@collabora.com> +Date: Sun, 27 Mar 2022 12:25:54 +0100 +Subject: rewrite-launchers: Provide backported g_string_replace() + +This fixes compilation on Debian 11. + +Signed-off-by: Simon McVittie <smcv@collabora.com> +Forwarded: https://github.com/flatpak/xdg-desktop-portal/pull/750 +--- + src/Makefile.am.inc | 6 +++++- + src/rewrite-launchers.c | 1 + + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/Makefile.am.inc b/src/Makefile.am.inc +index 3064793..96cb7e6 100644 +--- a/src/Makefile.am.inc ++++ b/src/Makefile.am.inc +@@ -187,6 +187,10 @@ xdg_desktop_portal_validate_icon_LDADD = $(GDK_PIXBUF_LIBS) + xdg_desktop_portal_validate_icon_CFLAGS = $(GDK_PIXBUF_CFLAGS) -DHELPER=\"$(BWRAP)\" -D_GNU_SOURCE=1 + + xdg_desktop_portal_rewrite_launchers_SOURCES = src/rewrite-launchers.c +-nodist_xdg_desktop_portal_rewrite_launchers_SOURCES = src/dynamic-launcher.h ++nodist_xdg_desktop_portal_rewrite_launchers_SOURCES = \ ++ src/dynamic-launcher.h \ ++ src/glib-backports.c \ ++ src/glib-backports.h \ ++ $(NULL) + xdg_desktop_portal_rewrite_launchers_LDADD = $(BASE_LIBS) + xdg_desktop_portal_rewrite_launchers_CFLAGS = $(BASE_CFLAGS) +diff --git a/src/rewrite-launchers.c b/src/rewrite-launchers.c +index 9da288b..fead386 100644 +--- a/src/rewrite-launchers.c ++++ b/src/rewrite-launchers.c +@@ -26,6 +26,7 @@ + #include <gio/gdesktopappinfo.h> + + #include "dynamic-launcher.h" ++#include "xdp-utils.h" + + static char * + find_renamed_app_id (const char *old_app_id) diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..7ff7ae2 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +Move-g_string_replace-backport-to-a-separate-translation-.patch +rewrite-launchers-Provide-backported-g_string_replace.patch |