[bug#33792] gnu: Add flatpak.

Message ID 20181218161249.7b6efcb7@mykolab.com
State Accepted
Headers show
Series [bug#33792] gnu: Add flatpak. | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Rutger Helling Dec. 18, 2018, 3:12 p.m. UTC
Hey Guix,

this patch adds Flatpak.

Comments

Danny Milosavljevic Dec. 18, 2018, 6:01 p.m. UTC | #1
Hi Rutger,

On Tue, 18 Dec 2018 16:12:49 +0100
Rutger Helling <rhelling@mykolab.com> 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.
Julien Lepiller Dec. 18, 2018, 7:45 p.m. UTC | #2
Le Tue, 18 Dec 2018 19:01:53 +0100,
Danny Milosavljevic <dannym@scratchpost.org> a écrit :

> Hi Rutger,
> 
> On Tue, 18 Dec 2018 16:12:49 +0100
> Rutger Helling <rhelling@mykolab.com> 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"))))

Just so you know, we already have a bubblewrap package. Maybe you can
use it instead of bundling the sources?

>        ("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.
Rutger Helling Dec. 19, 2018, 8:46 a.m. UTC | #3
@Julien
The patch already uses the system bubblewrap, see the
--with-system-bubblewrap argument.

@Danny
Thanks for sharing your work! Unfortunately it fixed neither the
documentation nor the tests for me. I think the source might have
changed too much. The "--with-xml-catalog" argument no longer exists
and the tests still error on trying to copy something.

I don't think the rest is necessary. I got both GIMP and Firefox 
nightly working. Make sure you use the --user parameter though, or
you'll need root.

For the record, this is how I got Firefox running:
$ flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo 
$ flatpak install --user --from https://firefox-flatpak.mojefedora.cz/org.mozilla.FirefoxNightly.flatpakref
$ flatpak run org.mozilla.FirefoxNightly/x86_64/master

OK to push?

On Tue, 18 Dec 2018 20:45:35 +0100
Julien Lepiller <julien@lepiller.eu> wrote:

> Le Tue, 18 Dec 2018 19:01:53 +0100,
> Danny Milosavljevic <dannym@scratchpost.org> a écrit :
> 
> > Hi Rutger,
> > 
> > On Tue, 18 Dec 2018 16:12:49 +0100
> > Rutger Helling <rhelling@mykolab.com> 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"))))  
> 
> Just so you know, we already have a bubblewrap package. Maybe you can
> use it instead of bundling the sources?
> 
> >        ("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.  
>
Danny Milosavljevic Dec. 19, 2018, 11:38 p.m. UTC | #4
>OK to push?

Yeah, fine by me!
Rutger Helling Dec. 20, 2018, 7:37 a.m. UTC | #5
Corrected the license to lgpl2.1+ instead of lgpl2.1 and pushed as
36e1ab842d5e0c221d15385bc7c535ee81b03ff8, thanks!

On Thu, 20 Dec 2018 00:38:51 +0100
Danny Milosavljevic <dannym@scratchpost.org> wrote:

> >OK to push?  
> 
> Yeah, fine by me!

Patch

From b561716938c635f153769b57300e438afbcad03b Mon Sep 17 00:00:00 2001
From: Rutger Helling <rhelling@mykolab.com>
Date: Tue, 18 Dec 2018 16:09:27 +0100
Subject: [PATCH] gnu: Add flatpak.

* gnu/packages/package-management.scm (flatpak): New variable.
---
 gnu/packages/package-management.scm | 50 +++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 89c9f91db..7b8f4abde 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -50,6 +50,7 @@ 
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages gnuzilla)
   #:use-module (gnu packages graphviz)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages lisp)
@@ -68,8 +69,10 @@ 
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages vim)
+  #:use-module (gnu packages virtualization)
   #:use-module (gnu packages web)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xorg)
   #:use-module (guix build-system emacs)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system meson)
@@ -984,3 +987,50 @@  tools that combines a \"git-like\" model for committing and downloading
 bootable filesystem trees, along with a layer for deploying them and managing
 the bootloader configuration.")
     (license license:lgpl2.0+)))
+
+(define-public flatpak
+  (package
+  (name "flatpak")
+  (version "1.1.0")
+  (source
+   (origin
+    (method url-fetch)
+    (uri (string-append "https://github.com/flatpak/flatpak/releases/download/"
+                        version "/flatpak-" version ".tar.xz"))
+    (sha256
+     (base32
+      "0bkjwh49kajyd78vdh0g9arb352a7rccaifas9zxa78phhja2v2p"))))
+  (build-system gnu-build-system)
+  (arguments
+   '(#:tests? #f ;; Tests fail due to trying to create files where it can't.
+     #:configure-flags (list
+                        "--enable-documentation=no" ;; FIXME
+                        "--enable-system-helper=no"
+                        "--localstatedir=/var"
+                        (string-append "--with-system-bubblewrap=" (assoc-ref
+                                       %build-inputs "bubblewrap") "/bin/bwrap"))))
+  (native-inputs `(("bison" ,bison)
+                   ("gettext" ,gnu-gettext)
+                   ("glib:bin" ,glib "bin") ; for glib-mkenums and gdbus-codegen
+                   ("gobject-introspection" ,gobject-introspection)
+                   ("libcap" ,libcap)
+                   ("pkg-config" ,pkg-config)))
+  (inputs `(("appstream-glib" ,appstream-glib)
+            ("bubblewrap" ,bubblewrap)
+            ("gdk-pixbuf" ,gdk-pixbuf)
+            ("gpgme" ,gpgme)
+            ("json-glib" ,json-glib)
+            ("libarchive" ,libarchive)
+            ("libostree" ,libostree)
+            ("libseccomp" ,libseccomp)
+            ("libsoup" ,libsoup)
+            ("libxau" ,libxau)
+            ("libxml2" ,libxml2)
+            ("nettle" ,nettle)
+            ("util-linux" ,util-linux)))
+  (home-page "https://flatpak.org")
+  (synopsis "System for building, distributing, and running sandboxed desktop
+applications")
+  (description "Flatpak is a system for building, distributing, and running
+sandboxed desktop applications on GNU/Linux.")
+  (license license:lgpl2.1)))
-- 
2.20.1