Subject: [bug#33792] [PATCH] gnu: Add flatpak.

From: Danny Milosavljevic <[email-masked]>
Date: Tue, 18 Dec 2018 19:01:53 +0100

Hi Rutger,

On Tue, 18 Dec 2018 16:12:49 +0100
Rutger Helling <[email-masked]> wrote:

> this patch adds Flatpak.

Try

             (string-append "--with-xml-catalog="
                            (assoc-ref %build-inputs "docbook-xml")
                            "/xml/dtd/docbook/catalog.xml"))

and

         (add-before 'configure 'fix-docbook
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "configure"
               ;; The configure check is overzealous about making sure that
               ;; things are in place -- it uses the xmlcatalog tool to make
               ;; sure that docbook-xsl is available, but this tool can only
               ;; look in one catalog file, unlike the $XML_CATALOG_FILES
               ;; variable that Guix defines.  Fool the test by using the
               ;; docbook-xsl catalog explicitly and get on with life.
               (("\"\\$XML_CATALOG_FILE\" \
\"http://docbook.sourceforge.net/release/xsl/")
                (string-append (car (find-files (assoc-ref inputs "docbook-xsl")
                                                "^catalog.xml$"))
                               " \"http://docbook.sourceforge.net/release/xsl/")))
             #t))

Also, try patching the tests like this:

         (add-after 'unpack 'patch-/var/tmp
           (lambda _
             (substitute* '("tests/libtest.sh"
                            "tests/test-run.sh"
                            "tests/testlibrary.c"
                            "buildutil/tap-test"
                            ; ./common/flatpak-dir.c
                            ; ./common/flatpak-run.c
                            )
               (("/var/tmp") "/tmp"))
             (substitute* "tests/libtest.sh"
              (("/usr/bin/") "")
              (("/bin/") ""))
             #t))

Also, in an earlier iteration I needed the following, but if it works without, then fine!

         (add-before 'check 'set-environment-up
           (lambda _
             ;(mkdir-p "/tmp/b")
             (setenv "HOME" "/tmp")
             ;; Note: needs xattr support.
             (setenv "TMPDIR" "/tmp")
             ;;; TODO /dev/fuse
             (mkdir-p "/tmp/ldconfig.d")
             (call-with-output-file "/tmp/ldconfig.d/ldconfig"
               (lambda (port)
                 (display "#!/bin/sh\nexit 0\n" port)))
             (chmod "/tmp/ldconfig.d/ldconfig" #o755)
             (setenv "PATH" (string-append "/tmp/ldconfig.d:" (getenv "PATH")))
             #t)))))

Additional inputs may be needed.  I had those:

    (inputs
     `(("appstream-glib" ,appstream-glib)
       ("attr" ,attr)
       ("fuse" ,fuse)
       ("glib" ,glib)
       ("gpgme" ,gpgme)
       ("json-glib" ,json-glib)
       ("libarchive" ,libarchive)
       ("libcap" ,libcap)
       ("libseccomp" ,libseccomp)
       ("libsoup" ,libsoup)
       ("libxml2" ,libxml2)
       ("libxau" ,libxau)
       ("nettle" ,nettle)
       ("libostree" ,libostree)
       ("polkit" ,polkit)))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("dbus" ,dbus) ; for the tests
       ("docbook-xml" ,docbook-xml-4.1.2)
       ("docbook-xsl" ,docbook-xsl)
       ("fuse" ,fuse) ; for the tests
       ("gettext-minimal" ,gettext-minimal)
       ;("git" ,git)
       ("glib" ,glib "bin")
       ("gnupg" ,gnupg)
       ("gobject-introspection" ,gobject-introspection)
       ("gtk-doc" ,gtk-doc)
       ("libtool" ,libtool)
       ("pkg-config" ,pkg-config)
       ("which" ,which)
       ("libglnx" ,(origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/GNOME/libglnx.git")
                   (commit "6f1ee5db1400b13a9a0fa0b2274ae34e8710c1aa")))
             (sha256
              (base32
               "137329m4lm3ssmxyyr1cin0xmlpsz4kfk26ydq6i4zf7qz81n64s"))))
       ("bubblewrap" ,(origin
        (method url-fetch)
        (uri (string-append "https://github.com/projectatomic/bubblewrap/archive/"
                            "v0.2.0.tar.gz"))

        (sha256
          (base32
            "17796rqhp5wn3q2lspgqbyk7nk1ixns9m2kgw82j2h2yfyi15mjh"))))
       ("xmltproc" ,libxslt)))
    (home-page "https://www.flatpak.org/")
    (synopsis "Flatpak")
    (description "Flatpak")
    (license license:lgpl2.1+)))

And I fiddled with libglnx:

           (lambda* (#:key inputs #:allow-other-keys)
             (use-modules (system repl debug))
             (set! terminal-width (lambda () 1000000))
             (delete-file-recursively "libglnx")
             (copy-recursively (assoc-ref inputs "libglnx") "libglnx")
             (delete-file-recursively "bsdiff")
             ;(symlink "bsdiff-4.3-endsley" "bsdiff")
             (copy-recursively (assoc-ref inputs "bsdiff") "bsdiff")
             (setenv "NOCONFIGURE" "1")
             (invoke "sh" "autogen.sh"))))))

If it works without, your version may be fine as is.  I just wanted to
share the parts I already had to try.