Subject: [bug#67473] [PATCH gnome-team v5 11/19] gnu: Deprecate libsoup-minimal.

From: Vivien Kraus <[email-masked]>
Date: Mon, 4 Dec 2023 19:27:11 +0100

This patch makes the old libsoup-minimal a full package, by adding a "doc"
output, -Ddocs=enabled to the configure-flags, a 'move-doc phase and
gettext-minimal and gi-docgen to the native-inputs. The libsoup-minimal-2
package inherits from that and must undo all these changes on top of the
existing fixes (change origin, change tests fixes).

Finally, libsoup-minimal is re-introduced as a deprecated-package.

* gnu/packages/gnome.scm (libsoup): New variable from the old libsoup-minimal.
[outputs]: Add "out" and "doc".
[#:configure-flags]: Replace -Ddocs=disabled with -Ddocs=enabled.
[#:phases]: Add 'move-doc.
[native-inputs]: Add gettext-minimal and gi-docgen.
(libsoup-minimal-2): Inherit from libsoup instead of libsoup-minimal.
[name]: Set to "libsoup-minimal".
[outputs]: Delete "doc".
[#:configure-flags]: Delete -Ddocs=enabled since the package base has docs.
[#:phases]: Replace with libsoup-minimal-2 test fixes.
[native-inputs]: Delete gettext-minimal and gi-docgen.
(libsoup-minimal): New variable.

Change-Id: Id797a568fb4a90a84260fd7727f7a57121a26a2d
---
 gnu/packages/gnome.scm | 71 +++++++++++++++---------------------------
 1 file changed, 25 insertions(+), 46 deletions(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 2b24453e8f..25d964e596 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -5017,9 +5017,9 @@ (define-public libshumate
 as OpenStreetMap, OpenCycleMap, OpenAerialMap and Maps.")
     (license license:lgpl2.1+)))
 
-(define-public libsoup-minimal
+(define-public libsoup
   (package
-    (name "libsoup-minimal")
+    (name "libsoup")
     (version "3.4.4")
     (source (origin
               (method url-fetch)
@@ -5030,9 +5030,10 @@ (define-public libsoup-minimal
                (base32
                 "1an5n2sa70f40my4g20lk38s5ib99c32bzzg8gm91v9nbxr6f719"))))
     (build-system meson-build-system)
+    (outputs '("out" "doc"))
     (arguments
      (list
-      #:configure-flags #~(list "-Ddocs=disabled")
+      #:configure-flags #~(list "-Ddocs=enabled")
       #:phases
       #~(modify-phases %standard-phases
           (add-after 'unpack 'adjust-tests
@@ -5050,9 +5051,16 @@ (define-public libsoup-minimal
               (substitute* "tests/meson.build"
                 ((".*'name': 'hsts'.*") ""))
               (substitute* "tests/hsts-db-test.c"
-                ((".*/hsts-db/subdomains.*") "")))))))
+                ((".*/hsts-db/subdomains.*") ""))))
+          (add-after 'install 'move-doc
+            (lambda _
+              (mkdir-p (string-append #$output:doc "/share"))
+              (rename-file (string-append #$output "/share/doc")
+                           (string-append #$output:doc "/share/doc")))))))
     (native-inputs
-     (list `(,glib "bin") ;for glib-mkenums
+     (list gettext-minimal
+           `(,glib "bin") ;for glib-mkenums
+           gi-docgen
            gobject-introspection
            pkg-config
            python-wrapper
@@ -5083,7 +5091,8 @@ (define-public libsoup-minimal
 ;;; An older variant kept to build the 'rest' package.
 (define-public libsoup-minimal-2
   (package
-    (inherit libsoup-minimal)
+    (inherit libsoup)
+    (name "libsoup-minimal")
     (version "2.74.3")
     (source (origin
               (method url-fetch)
@@ -5093,15 +5102,17 @@ (define-public libsoup-minimal-2
               (sha256
                (base32
                 "04rgv6hkyhgi7lak9865yxgbgky6gc635p7w6nhcbj64rx0prdz4"))))
+    (outputs (delete "doc" (package-outputs libsoup)))
     (arguments
      (substitute-keyword-arguments (package-arguments libsoup-minimal)
        ((#:configure-flags configure-flags)
-        ;; The option named changed between libsoup 2 and libsoup 3.
         #~(cons "-Dgtk_doc=false"
-                (delete "-Ddocs=disabled" #$configure-flags)))
+                (delete "-Ddocs=enabled" #$configure-flags)))
        ((#:phases phases)
-        #~(modify-phases #$phases
-            (replace 'adjust-tests
+        #~(modify-phases %standard-phases
+            ;; Cannot reuse #$phases here, because it references the "doc"
+            ;; output of this package, so Guix expects a "doc" output.
+            (add-after 'unpack 'adjust-tests
               (lambda _
                 ;; Disable the SSL test, failing since 2.68 and resolved in
                 ;; libsoup 3.
@@ -5109,43 +5120,11 @@ (define-public libsoup-minimal-2
                   (("[ \t]*\\['ssl', true, \\[\\]\\],") ""))))))))
     (native-inputs
      (modify-inputs (package-native-inputs libsoup-minimal)
-       (replace "vala" vala-0.52)))))
+       (replace "vala" vala-0.52)
+       (delete "gettext-minimal" "gi-docgen")))))
 
-(define-public libsoup
-  (package/inherit libsoup-minimal
-    (name "libsoup")
-    (outputs (cons "doc" (package-outputs libsoup-minimal)))
-    (arguments
-     (substitute-keyword-arguments (package-arguments libsoup-minimal)
-       ((#:configure-flags configure-flags)
-        #~(cons "-Ddocs=enabled"
-                ;; The default value is 'auto', meaning it could be skipped.
-                (delete "-Ddocs=disabled" #$configure-flags)))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (replace 'adjust-tests
-              (lambda _
-                ;; This test fails due to missing /etc/nsswitch.conf
-                ;; in the build environment.
-                (substitute* "tests/unix-socket-test.c"
-                  ((".*/sockets/unconnected.*") ""))
-
-                ;; These fail because "subdomain.localhost" does not resolve in
-                ;; the build environment.  Moreover, the hsts-test suite fails on
-                ;; i686-linux because of errors from `session_get_uri' like
-                ;; "Unexpected status 200 OK (expected 301 Moved Permanently)"
-                ;; (see: https://gitlab.gnome.org/GNOME/libsoup/-/issues/239).
-                (substitute* "tests/meson.build"
-                  ((".*'name': 'hsts'.*") ""))
-                (substitute* "tests/hsts-db-test.c"
-                  ((".*/hsts-db/subdomains.*") ""))))
-            (add-after 'install 'move-doc
-              (lambda _
-                (mkdir-p (string-append #$output:doc "/share"))
-                (rename-file (string-append #$output "/share/doc")
-                             (string-append #$output:doc "/share/doc"))))))))
-    (native-inputs (modify-inputs (package-native-inputs libsoup-minimal)
-                     (prepend gettext-minimal gi-docgen)))))
+(define-public libsoup-minimal
+  (deprecated-package "libsoup-minimal" libsoup))
 
 (define-public libsecret
   (package
-- 
2.41.0