Subject: bug#37850: Glib documentation is missing

From: Pierre Neidhardt <[email-masked]>
Date: Fri, 15 Nov 2019 12:17:30 +0100

You are right, something is wrong with substitute-keyword-arguments.

If I copy-paste the arguments from glib, then add the stuff to build the
doc, everything is fine.

Peter, Ricardo, Marius, any clue what's going on?

Here follows a working definition for glib-with-documentation.
Obviously the copy-pasting of arguments is less than ideal.

--8<---------------cut here---------------start------------->8---
(define-public glib-with-documentation
  (package
    (inherit glib)
    (properties '((hidden? . #f)))
    (outputs (cons "doc" (package-outputs glib))) ; 20 MiB of GTK-Doc reference
    (native-inputs
     `(("gtk-doc" ,gtk-doc)             ; for the doc
       ("docbook-xml" ,docbook-xml)
       ,@(package-native-inputs glib)))
    (arguments
     `( ;; TODO: Uncomment on the next rebuild cycle.
       ;; #:disallowed-references (,tzdata-for-tests)

       #:configure-flags (list "-Dgtk_doc=true")
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'pre-build
           (lambda* (#:key inputs outputs #:allow-other-keys)
             ;; For tests/gdatetime.c.
             (setenv "TZDIR"
                     (string-append (assoc-ref inputs "tzdata")
                                    "/share/zoneinfo"))

             ;; Some tests want write access there.
             (setenv "HOME" (getcwd))
             (setenv "XDG_CACHE_HOME" (getcwd))
             #t))
         (add-after 'unpack 'disable-failing-tests
           (lambda _
             (let ((disable
                    (lambda (test-file test-paths)
                      (define pattern+procs
                        (map (lambda (test-path)
                               (cons
                                ;; XXX: only works for single line statements.
                                (format #f "g_test_add_func.*\"~a\".*" test-path)
                                (const "")))
                             test-paths))
                      (substitute test-file pattern+procs)))
                   (failing-tests
                    '(("glib/tests/thread.c"
                       ( ;; prlimit(2) returns ENOSYS on Linux 2.6.32-5-xen-amd64
                        ;; as found on hydra.gnu.org, and strace(1) doesn't
                        ;; recognize it.
                        "/thread/thread4"))

                      ;; This tries to find programs in FHS directories.
                      ("glib/tests/utils.c"
                       ("/utils/find-program"))

                      ;; This fails because "glib/tests/echo-script" cannot be
                      ;; found.
                      ("glib/tests/spawn-singlethread.c"
                       ("/gthread/spawn-script"))

                      ("glib/tests/timer.c"
                       ( ;; fails if compiler optimizations are enabled, which they
                        ;; are by default.
                        "/timer/stop"))

                      ("gio/tests/gapplication.c"
                       ( ;; XXX: proven to be unreliable.  See:
                        ;;  <https://bugs.debian.org/756273>
                        ;;  <http://bugs.gnu.org/18445>
                        "/gapplication/quit"

                        ;; XXX: fails randomly for unknown reason. See:
                        ;;  <https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00215.html>
                        "/gapplication/local-actions"))

                      ("gio/tests/contenttype.c"
                       ( ;; XXX: requires shared-mime-info.
                        "/contenttype/guess"
                        "/contenttype/guess_svg_from_data"
                        "/contenttype/subtype"
                        "/contenttype/list"
                        "/contenttype/icon"
                        "/contenttype/symbolic-icon"
                        "/contenttype/tree"))

                      ("gio/tests/appinfo.c"
                       ( ;; XXX: requires update-desktop-database.
                        "/appinfo/associations"))

                      ("gio/tests/desktop-app-info.c"
                       ( ;; XXX: requires update-desktop-database.
                        "/desktop-app-info/delete"
                        "/desktop-app-info/default"
                        "/desktop-app-info/fallback"
                        "/desktop-app-info/lastused"
                        "/desktop-app-info/search"))

                      ("gio/tests/gdbus-peer.c"
                       ( ;; Requires /etc/machine-id.
                        "/gdbus/codegen-peer-to-peer"))

                      ("gio/tests/gdbus-unix-addresses.c"
                       ( ;; Requires /etc/machine-id.
                        "/gdbus/x11-autolaunch"))

                      ("gio/tests/gsocketclient-slow.c"
                       ( ;; These tests tries to resolve "localhost", and fails.
                        "/socket-client/happy-eyeballs/slow"
                        "/socket-client/happy-eyeballs/cancellation/delayed")))))
               (for-each (lambda (x) (apply disable x)) failing-tests)
               #t)))
         (replace 'check
           (lambda _
             (setenv "MESON_TESTTHREADS"
                     (number->string (parallel-job-count)))
             ;; Do not run tests marked as "flaky".
             (invoke "meson" "test" "--no-suite" "flaky")))
         ;; TODO: meson does not permit the bindir to be outside of prefix.
         ;; See https://github.com/mesonbuild/meson/issues/2561
         ;; We can remove this once meson is patched.
         (add-after 'install 'move-executables
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (bin (assoc-ref outputs "bin")))
               (mkdir-p bin)
               (rename-file (string-append out "/bin")
                            (string-append bin "/bin"))
               ;; Do not refer to "bindir", which points to "${prefix}/bin".
               ;; We don't patch "bindir" to point to "$bin/bin", because that
               ;; would create a reference cycle between the "out" and "bin"
               ;; outputs.
               (substitute* (list (string-append out "/lib/pkgconfig/gio-2.0.pc")
                                  (string-append out "/lib/pkgconfig/glib-2.0.pc"))
                 (("bindir=\\$\\{prefix\\}/bin") "")
                 (("=\\$\\{bindir\\}/") "="))
               #t)))
         (add-after 'unpack 'make-local-docbook-xml
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((replace-http (lambda (file)
                                   (substitute* file
                                     ;; Warning: gio.xml uses docbook 4.2.
                                     (("http://www.oasis-open.org/docbook/xml/4../docbookx.dtd")
                                      (string-append (assoc-ref inputs "docbook-xml")
                                                     "/xml/dtd/docbook/docbookx.dtd")))) ))
               (replace-http "gio/gdbus-2.0/codegen/codegen_docbook.py")
               (for-each replace-http (find-files "." "\\.xml$"))
               #t)))
         (add-after 'install 'move-doc
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (doc (assoc-ref outputs "doc"))
                   (html (string-append "/share/gtk-doc")))
               (copy-recursively (string-append out html)
                                 (string-append doc html))
               (delete-file-recursively (string-append out html))
               #t))))))))
--8<---------------cut here---------------end--------------->8---

-- 
Pierre Neidhardt
https://ambrevar.xyz/