[Git][debian-gis-team/osm-gps-map][master] Add upstream patches to use libsoup3.

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Mon Oct 9 18:43:02 BST 2023



Bas Couwenberg pushed to branch master at Debian GIS Project / osm-gps-map


Commits:
d2224755 by Bas Couwenberg at 2023-10-09T19:37:53+02:00
Add upstream patches to use libsoup3.

- - - - -


5 changed files:

- debian/changelog
- debian/control
- + debian/patches/0001-Drop-support-for-libsoup-older-than-2.42.patch
- + debian/patches/0001-Port-to-libsoup3.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -8,6 +8,7 @@ osm-gps-map (1.2.0-3) UNRELEASED; urgency=medium
   * Use execute_before instead of override in rules file.
   * Enable Salsa CI.
   * Switch to dh-sequence-*.
+  * Add upstream patches to use libsoup3.
 
  -- Bas Couwenberg <sebastic at debian.org>  Wed, 18 Jan 2023 17:04:33 +0100
 


=====================================
debian/control
=====================================
@@ -14,7 +14,7 @@ Build-Depends: debhelper-compat (= 13),
                libgirepository1.0-dev,
                libglib2.0-dev,
                libgtk-3-dev,
-               libsoup2.4-dev
+               libsoup-3.0-dev
 Standards-Version: 4.6.2
 Vcs-Browser: https://salsa.debian.org/debian-gis-team/osm-gps-map
 Vcs-Git: https://salsa.debian.org/debian-gis-team/osm-gps-map.git
@@ -29,7 +29,7 @@ Depends: libosmgpsmap-1.0-1 (= ${binary:Version}),
          libcairo2-dev,
          libglib2.0-dev,
          libgtk-3-dev,
-         libsoup2.4-dev,
+         libsoup-3.0-dev,
          ${misc:Depends}
 Description: GTK+ library to embed OpenStreetMap maps - development files
  libosmgpsmap is a library to embed maps in applications that when given GPS


=====================================
debian/patches/0001-Drop-support-for-libsoup-older-than-2.42.patch
=====================================
@@ -0,0 +1,64 @@
+Description: Drop support for libsoup older than 2.42
+ libsoup 2.42 is old enough that no current LTS distro even carries it.
+Author: Hubert Kowalski <h.kowalski at hakger.pl>
+Origin: https://github.com/nzjrs/osm-gps-map/commit/118fd8052f1df6fde7baa0fbeaf1a8cd97c94ab3
+Bug: https://github.com/nzjrs/osm-gps-map/issues/85
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -27,7 +27,7 @@ AC_SYS_LARGEFILE
+ PKG_CHECK_MODULES(GLIB,     [glib-2.0 >= 2.16])
+ PKG_CHECK_MODULES(GTK,      [gtk+-3.0 >= 3.0])
+ PKG_CHECK_MODULES(CAIRO,    [cairo >= 1.8])
+-PKG_CHECK_MODULES(SOUP24,   [libsoup-2.4])
++PKG_CHECK_MODULES(SOUP24,   [libsoup-2.4 >= 2.42])
+ 
+ # The mapviewer demo also calls g_thread_init, so it needs to link against
+ # libgthread-2.0.
+--- a/osmgpsmap-1.0.pc.in
++++ b/osmgpsmap-1.0.pc.in
+@@ -6,6 +6,6 @@ includedir=@includedir@
+ Name: @PACKAGE_NAME@
+ Description: Moving map widget using openstreet map data
+ Version: @PACKAGE_VERSION@
+-Requires: gtk+-3.0 libsoup-2.4
++Requires: gtk+-3.0 libsoup-2.4 >= 2.42
+ Libs: -L${libdir} -losmgpsmap-1.0
+ Cflags: -I${includedir}/osmgpsmap-1.0
+--- a/src/osm-gps-map-widget.c
++++ b/src/osm-gps-map-widget.c
+@@ -150,15 +150,6 @@
+ #define MAX_DOWNLOAD_TILES          10000
+ #define DOT_RADIUS                  4.0
+ 
+-#ifndef SOUP_CHECK_VERSION
+-// SOUP_CHECK_VERSION was introduced only in 2.42
+-#define SOUP_CHECK_VERSION(x, y, z) false
+-#endif
+-
+-#if !SOUP_CHECK_VERSION(2, 42, 0)
+-#define SOUP_OLD_SESSION
+-#endif
+-
+ struct _OsmGpsMapPrivate
+ {
+     GHashTable *tile_queue;
+@@ -1680,18 +1671,11 @@ osm_gps_map_init (OsmGpsMap *object)
+ 
+ 
+     /* set the user agent */
+-#ifdef SOUP_OLD_SESSION
+-    // libsoup pre 2.42.0 had explicit syn/async session
+-    priv->soup_session =
+-        soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT,
+-                                            USER_AGENT, NULL);
+-#else
+     // lisoup since 2.42.0 has universal session, only methods can be sync/async
+     // and we use async
+     priv->soup_session =
+         soup_session_new_with_options(SOUP_SESSION_USER_AGENT,
+                                             USER_AGENT, NULL);
+-#endif
+ 
+     /* Hash table which maps tile d/l URIs to SoupMessage requests, the hashtable
+        must free the key, the soup session unrefs the message */


=====================================
debian/patches/0001-Port-to-libsoup3.patch
=====================================
@@ -0,0 +1,279 @@
+Subject: Port to libsoup3
+Author: Sébastien Noel <sebastien at twolife.be>
+Origin: https://github.com/nzjrs/osm-gps-map/pull/99
+Bug: https://github.com/nzjrs/osm-gps-map/issues/96
+
+--- a/.github/workflows/ci.yml
++++ b/.github/workflows/ci.yml
+@@ -23,7 +23,7 @@ jobs:
+             gtk-doc-tools \
+             libglib2.0-dev \
+             libgtk-3-dev \
+-            libsoup2.4-dev \
++            libsoup-3.0-dev \
+             libgirepository1.0-dev
+       - uses: actions/checkout at v2
+       - name: autogen
+--- a/configure.ac
++++ b/configure.ac
+@@ -27,7 +27,7 @@ AC_SYS_LARGEFILE
+ PKG_CHECK_MODULES(GLIB,     [glib-2.0 >= 2.16])
+ PKG_CHECK_MODULES(GTK,      [gtk+-3.0 >= 3.0])
+ PKG_CHECK_MODULES(CAIRO,    [cairo >= 1.8])
+-PKG_CHECK_MODULES(SOUP24,   [libsoup-2.4 >= 2.42])
++PKG_CHECK_MODULES(SOUP30,   [libsoup-3.0])
+ 
+ # The mapviewer demo also calls g_thread_init, so it needs to link against
+ # libgthread-2.0.
+--- a/docs/reference/Makefile.am
++++ b/docs/reference/Makefile.am
+@@ -71,12 +71,12 @@ AM_CFLAGS=-I$(top_srcdir) -I$(top_buildd
+ 	$(GLIB_CFLAGS) \
+ 	$(GTK_CFLAGS) \
+ 	$(CAIRO_CFLAGS) \
+-	$(SOUP24_CFLAGS)
++	$(SOUP30_CFLAGS)
+ GTKDOC_LIBS=$(top_builddir)/src/libosmgpsmap-1.0.la \
+ 	$(GLIB_LIBS) \
+ 	$(GTK_LIBS) \
+ 	$(CAIRO_LIBS) \
+-	$(SOUP24_LIBS)
++	$(SOUP30_LIBS)
+ 
+ # This includes the standard gtk-doc make rules, copied by gtkdocize.
+ include $(top_srcdir)/gtk-doc.make
+--- a/examples/Makefile.am
++++ b/examples/Makefile.am
+@@ -4,13 +4,13 @@ OSMGPSMAP_CFLAGS =          \
+     $(GLIB_CFLAGS)          \
+     $(GTK_CFLAGS)           \
+     $(CAIRO_CFLAGS)         \
+-    $(SOUP24_CFLAGS)
++    $(SOUP30_CFLAGS)
+ 
+ OSMGPSMAP_LIBS =            \
+     $(GLIB_LIBS)            \
+     $(GTK_LIBS)             \
+     $(CAIRO_LIBS)           \
+-    $(SOUP24_LIBS)
++    $(SOUP30_LIBS)
+ 
+ ## Demo Application
+ noinst_PROGRAMS = mapviewer polygon editable_track
+--- a/osmgpsmap-1.0.pc.in
++++ b/osmgpsmap-1.0.pc.in
+@@ -6,6 +6,6 @@ includedir=@includedir@
+ Name: @PACKAGE_NAME@
+ Description: Moving map widget using openstreet map data
+ Version: @PACKAGE_VERSION@
+-Requires: gtk+-3.0 libsoup-2.4 >= 2.42
++Requires: gtk+-3.0 libsoup-3.0
+ Libs: -L${libdir} -losmgpsmap-1.0
+ Cflags: -I${includedir}/osmgpsmap-1.0
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -5,13 +5,13 @@ OSMGPSMAP_CFLAGS =          \
+ 	$(GLIB_CFLAGS)          \
+ 	$(GTK_CFLAGS)           \
+ 	$(CAIRO_CFLAGS)         \
+-    $(SOUP24_CFLAGS)
++    $(SOUP30_CFLAGS)
+ 
+ OSMGPSMAP_LIBS =            \
+     $(GLIB_LIBS)            \
+     $(GTK_LIBS)             \
+     $(CAIRO_LIBS)           \
+-    $(SOUP24_LIBS)
++    $(SOUP30_LIBS)
+ 
+ ## Shared library
+ libosmgpsmap_1_0_la_CFLAGS =    \
+--- a/src/osm-gps-map-widget.c
++++ b/src/osm-gps-map-widget.c
+@@ -315,7 +315,7 @@ G_DEFINE_TYPE (OsmGpsMap, osm_gps_map, G
+  */
+ static gchar    *replace_string(const gchar *src, const gchar *from, const gchar *to);
+ static gchar    *replace_map_uri(OsmGpsMap *map, const gchar *uri, int zoom, int x, int y);
+-static void     osm_gps_map_tile_download_complete (SoupSession *session, SoupMessage *msg, gpointer user_data);
++static void     osm_gps_map_tile_download_complete (SoupSession *session, GAsyncResult *result, gpointer user_data);
+ static void     osm_gps_map_download_tile (OsmGpsMap *map, int zoom, int x, int y, gboolean redraw);
+ static GdkPixbuf* osm_gps_map_render_tile_upscaled (OsmGpsMap *map, GdkPixbuf *tile, int tile_zoom, int zoom, int x, int y);
+ 
+@@ -731,12 +731,10 @@ osm_gps_map_blit_tile(OsmGpsMap *map, Gd
+     }
+ }
+ 
+-#define MSG_RESPONSE_BODY(a)    ((a)->response_body->data)
+-#define MSG_RESPONSE_LEN(a)     ((a)->response_body->length)
+ #define MSG_RESPONSE_LEN_FORMAT "%"G_GOFFSET_FORMAT
+ 
+ static void
+-osm_gps_map_tile_download_complete (SoupSession *session, SoupMessage *msg, gpointer user_data)
++osm_gps_map_tile_download_complete (SoupSession *session, GAsyncResult *result, gpointer user_data)
+ {
+     FILE *file;
+     OsmTileDownload *dl = (OsmTileDownload *)user_data;
+@@ -744,15 +742,23 @@ osm_gps_map_tile_download_complete (Soup
+     OsmGpsMapPrivate *priv = map->priv;
+     gboolean file_saved = FALSE;
+ 
+-    if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
++    GError *error = NULL;
++    SoupMessage *msg = soup_session_get_async_result_message(session, result);
++    SoupStatus soup_status = soup_message_get_status(msg);
++    GBytes *body = soup_session_send_and_read_finish (session, result, &error);
++
++    GCancellable *cancellable = (GCancellable *)g_hash_table_lookup(priv->tile_queue, dl->uri);
++    g_object_unref (cancellable);
++
++    if (SOUP_STATUS_IS_SUCCESSFUL (soup_status)) {
+         /* save tile into cachedir if one has been specified */
+         if (priv->cache_dir) {
+             if (g_mkdir_with_parents(dl->folder,0700) == 0) {
+                 file = g_fopen(dl->filename, "wb");
+                 if (file != NULL) {
+-                    fwrite (MSG_RESPONSE_BODY(msg), 1, MSG_RESPONSE_LEN(msg), file);
++                    fwrite (g_bytes_get_data(body, NULL), 1, g_bytes_get_size(body), file);
+                     file_saved = TRUE;
+-                    g_debug("Wrote "MSG_RESPONSE_LEN_FORMAT" bytes to %s", MSG_RESPONSE_LEN(msg), dl->filename);
++                    g_debug("Wrote "MSG_RESPONSE_LEN_FORMAT" bytes to %s", g_bytes_get_size(body), dl->filename);
+                     fclose (file);
+ 
+                 }
+@@ -777,7 +783,7 @@ osm_gps_map_tile_download_complete (Soup
+                 /* parse file directly from memory */
+                 if (extension) {
+                     loader = gdk_pixbuf_loader_new_with_type (extension+1, NULL);
+-                    if (!gdk_pixbuf_loader_write (loader, (unsigned char*)MSG_RESPONSE_BODY(msg), MSG_RESPONSE_LEN(msg), NULL))
++                    if (!gdk_pixbuf_loader_write (loader, (unsigned char*)g_bytes_get_data(body, NULL), g_bytes_get_size(body), NULL))
+                     {
+                         g_warning("Error: Decoding of image failed");
+                     }
+@@ -815,21 +821,21 @@ osm_gps_map_tile_download_complete (Soup
+         g_free(dl->filename);
+         g_free(dl);
+     } else {
+-        if ((msg->status_code == SOUP_STATUS_NOT_FOUND) || (msg->status_code == SOUP_STATUS_FORBIDDEN)) {
++        if ((soup_status == SOUP_STATUS_NOT_FOUND) || (soup_status == SOUP_STATUS_FORBIDDEN)) {
+             g_hash_table_insert(priv->missing_tiles, dl->uri, NULL);
+             g_hash_table_remove(priv->tile_queue, dl->uri);
+             g_object_notify(G_OBJECT(map), "tiles-queued");
+-        } else if (msg->status_code == SOUP_STATUS_CANCELLED) {
++        } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+             /* called as application exit or after osm_gps_map_download_cancel_all */
+             g_hash_table_remove(priv->tile_queue, dl->uri);
+             g_object_notify(G_OBJECT(map), "tiles-queued");
+         } else {
+-            g_warning("Error downloading tile: %d - %s", msg->status_code, msg->reason_phrase);
+-            dl->ttl--;
+-            if (dl->ttl) {
+-                soup_session_requeue_message(session, msg);
+-                return;
+-            }
++            g_warning("Error downloading tile: %d - %s", soup_status, soup_status_get_phrase(soup_status));
++            //dl->ttl--;
++            //if (dl->ttl) {
++            //    soup_session_requeue_message(session, msg);
++            //    return;
++            //}
+ 
+             g_hash_table_remove(priv->tile_queue, dl->uri);
+             g_object_notify(G_OBJECT(map), "tiles-queued");
+@@ -879,21 +885,26 @@ osm_gps_map_download_tile (OsmGpsMap *ma
+             if (priv->is_google) {
+                 //Set maps.google.com as the referrer
+                 g_debug("Setting Google Referrer");
+-                soup_message_headers_append(msg->request_headers, "Referer", "http://maps.google.com/");
++                soup_message_headers_append(soup_message_get_request_headers(msg), "Referer", "http://maps.google.com/");
+                 //For google satelite also set the appropriate cookie value
+                 if (priv->uri_format & URI_HAS_Q) {
+                     const char *cookie = g_getenv("GOOGLE_COOKIE");
+                     if (cookie) {
+                         g_debug("Adding Google Cookie");
+-                        soup_message_headers_append(msg->request_headers, "Cookie", cookie);
++                        soup_message_headers_append(soup_message_get_request_headers(msg), "Cookie", cookie);
+                     }
+                 }
+             }
+ 
+-            g_hash_table_insert (priv->tile_queue, dl->uri, msg);
++            GCancellable *cancellable = g_cancellable_new ();
++            g_hash_table_insert (priv->tile_queue, dl->uri, cancellable);
+             g_object_notify (G_OBJECT (map), "tiles-queued");
+             /* the soup session unrefs the message when the download finishes */
+-            soup_session_queue_message (priv->soup_session, msg, osm_gps_map_tile_download_complete, dl);
++            soup_session_send_and_read_async(priv->soup_session, msg,
++                                    G_PRIORITY_DEFAULT,
++                                    cancellable,
++                                    (GAsyncReadyCallback)osm_gps_map_tile_download_complete,
++                                    dl);
+         } else {
+             g_warning("Could not create soup message");
+             g_free(dl->uri);
+@@ -1671,11 +1682,8 @@ osm_gps_map_init (OsmGpsMap *object)
+ 
+ 
+     /* set the user agent */
+-    // lisoup since 2.42.0 has universal session, only methods can be sync/async
+-    // and we use async
+-    priv->soup_session =
+-        soup_session_new_with_options(SOUP_SESSION_USER_AGENT,
+-                                            USER_AGENT, NULL);
++    priv->soup_session = soup_session_new ();
++    soup_session_set_user_agent (priv->soup_session, USER_AGENT);
+ 
+     /* Hash table which maps tile d/l URIs to SoupMessage requests, the hashtable
+        must free the key, the soup session unrefs the message */
+@@ -1906,10 +1914,10 @@ osm_gps_map_set_property (GObject *objec
+                 g_debug("Setting proxy server: %s", priv->proxy_uri);
+ 
+                 GValue val = {0};
+-                SoupURI* uri = soup_uri_new(priv->proxy_uri);
+-                g_value_init(&val, SOUP_TYPE_URI);
++                GUri* uri = g_uri_parse(priv->proxy_uri, SOUP_HTTP_URI_FLAGS, NULL);
++                g_value_init(&val, G_TYPE_URI);
+                 g_value_take_boxed(&val, uri);
+-                g_object_set_property(G_OBJECT(priv->soup_session),SOUP_SESSION_PROXY_URI,&val);
++                g_object_set_property(G_OBJECT(priv->soup_session),"proxy-resolver",&val);
+ 
+             } else {
+                 g_free(priv->proxy_uri);
+@@ -1929,7 +1937,7 @@ osm_gps_map_set_property (GObject *objec
+                 priv->user_agent = NULL;
+                 g_value_set_string (&full_user_agent, USER_AGENT);
+             }
+-            g_object_set_property(G_OBJECT(priv->soup_session),SOUP_SESSION_USER_AGENT, &full_user_agent);
++            g_object_set_property(G_OBJECT(priv->soup_session),"user-agent", &full_user_agent);
+             break;
+         case PROP_TILE_CACHE_DIR:
+             if ( g_value_get_string(value) ) {
+@@ -2971,9 +2979,9 @@ osm_gps_map_download_maps (OsmGpsMap *ma
+ }
+ 
+ static void
+-cancel_message (char *key, SoupMessage *value, SoupSession *user_data)
++cancel_message (char *key, GCancellable *cancellable, void *userdata)
+ {
+-    soup_session_cancel_message (user_data, value, SOUP_STATUS_CANCELLED);
++    g_cancellable_cancel(cancellable);
+ }
+ 
+ /**
+@@ -2981,7 +2989,7 @@ cancel_message (char *key, SoupMessage *
+  * @map: a #OsmGpsMap widget
+  *
+  * Cancels all tiles currently being downloaded. Typically used if you wish to
+- * cacel a large number of tiles queued using osm_gps_map_download_maps()
++ * cancel a large number of tiles queued using osm_gps_map_download_maps()
+  *
+  * Since: 0.7.0
+  **/
+@@ -2989,7 +2997,7 @@ void
+ osm_gps_map_download_cancel_all (OsmGpsMap *map)
+ {
+     OsmGpsMapPrivate *priv = map->priv;
+-    g_hash_table_foreach (priv->tile_queue, (GHFunc)cancel_message, priv->soup_session);
++    g_hash_table_foreach (priv->tile_queue, (GHFunc)cancel_message, NULL);
+ }
+ 
+ /**


=====================================
debian/patches/series
=====================================
@@ -1 +1,3 @@
 01-fix_LFS_support.patch
+0001-Drop-support-for-libsoup-older-than-2.42.patch
+0001-Port-to-libsoup3.patch



View it on GitLab: https://salsa.debian.org/debian-gis-team/osm-gps-map/-/commit/d2224755698c9f57c18273601fe6239a0d290684

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/osm-gps-map/-/commit/d2224755698c9f57c18273601fe6239a0d290684
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20231009/0627f2f7/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list