Add Waydroid

OpenSubmitted by phodina.
Details
2 participants
  • Liliana Marie Prikler
  • phodina
Owner
unassigned
Severity
normal
P
P
phodina wrote on 10 Nov 2021 02:33
(name . Guix Patches)(address . guix-patches@gnu.org)
iYmPmvusAplbe5X4cU55Ujwo5l9cWEZ8e6PRtK6Md65HdM-bvo-sGnvm_ZkmbBfsRk6LLJLvaRe4VxgqiEOxnd0VzqKMiua4DfkhuQYNLMo=@protonmail.com
Hi,

in the following patches there's added support for Waydroid [1]- allowing you to run Android applications in LXC containers.

However, there is still issue that the following kernel options need to be enabled.

CONFIG_ASHMEM=m
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=m
CONFIG_ANDROID_BINDERFS=n
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

I'd like to ask how to proceed. Probably add these as configuration in the gnu/packages/linux.scm and then create a new kernel with these enabled, right?

Should I then add dependency of waydroid package on this kernel?

Petr

Attachment: file
P
P
phodina wrote on 10 Nov 2021 02:37
[PATCH 1/4] gnu: Add libglibutil.
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
OdeTLBG5QlqX97nEBGy9o2DKstnFnEwvfDLIL2C3dLf0fw846OHRNPnYM1TyJybcYoEe0K_4wBUM4RAzozLjPdMPIF9Fp7eVD-03hJg7jg4=@protonmail.com
* gnu/packages/glib.scm (libglibutil): New variable.

Toggle diff (70 lines)
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 8ed1e3a944..6d8a6801da 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
 ;;; Copyright © 2020 Arthur Margerit <ruhtra.mar@gmail.com>
+;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -68,6 +69,7 @@ (define-module (gnu packages glib)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system python)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -749,6 +751,49 @@ (define-public glibmm-2.64
       `(("libsigc++" ,libsigc++)
         ("glib" ,glib)))))

+(define-public libglibutil
+  (package
+    (name "libglibutil")
+    (version "1.0.55")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.sailfishos.org/mer-core/libglibutil")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0zrxccpyfz4jf14zr6fj9b88p340s66lw5cnqkapfa72kl1rnp4q"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list (string-append "CC=" ,(cc-for-target))
+                          (string-append "DESTDIR=" %output))
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'remove-usr-prefix
+           (lambda* _
+             (substitute* "libglibutil.pc.in"
+               (("/usr/include") (string-append %output "/include")))
+             (substitute* "Makefile"
+               (("usr/") ""))))
+         (add-after 'install 'install-dev
+           (lambda* _
+             (invoke "make" "install-dev" (string-append "DESTDIR=" %output))))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (chdir "test")
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               (chdir "..") #t))))))
+    (native-inputs `(("pkg-config" ,pkg-config)))
+    (inputs `(("glib" ,glib)))
+    (home-page "https://git.sailfishos.org/mer-core/libglibutil")
+    (synopsis "GLib utilites")
+    (description "This package provides library of glib utilities.")
+    (license license:bsd-3)))
+
 (define-public python2-pygobject-2
   (package
     (name "python2-pygobject")
--
2.33.1
P
P
phodina wrote on 10 Nov 2021 02:38
[PATCH 2/4] gnu: Add libgbinder.
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
f0X-fmjm6HpduBHb9LOM6szjKRf30FPp9PkW4LfeCuokGHn0dwF36saOvMdaodwMl0Bo0sncib1Etr7ZZANwLu6-sV6c7SWCzlEH8wGaBOc=@protonmail.com
* gnu/packages/glib.scm (libgbinder): New variable.

Toggle diff (64 lines)
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 6d8a6801da..4f3e026d1b 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -751,6 +751,59 @@ (define-public glibmm-2.64
       `(("libsigc++" ,libsigc++)
         ("glib" ,glib)))))

+(define-public libgbinder
+  (package
+    (name "libgbinder")
+    (version "1.1.13")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mer-hybris/libgbinder")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "054kghsyyxk7lbsgwis1fczbgjlh0g0x6smwvcczd8dqacfclvpy"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list (string-append "CC=" ,(cc-for-target))
+                          (string-append "DESTDIR=" %output))
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'fix-pkg-config-in
+           (lambda* _
+             (substitute* "Makefile"
+               (("usr/") ""))
+             (substitute* "libgbinder.pc.in"
+               (("@libdir@") (string-append (assoc-ref %outputs "out") "/lib"))
+               (("/usr/include") (string-append %output "/include")))))
+         (add-after 'install 'install-dev
+           (lambda* _
+             (invoke "make" "install-dev" (string-append "DESTDIR=" %output))))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (chdir "test")
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               (chdir "..") #t))))))
+    (native-inputs `(("bison" ,bison)
+                     ("flex" ,flex)
+                     ("pkg-config" ,pkg-config)))
+    (inputs `(("glib" ,glib)
+              ("libglibutil" ,libglibutil)))
+    (home-page "https://github.com/mer-hybris/libgbinder")
+    (synopsis "GLib-style interface to binder")
+    (description "This package provides GLib-style interface to binder:
+@enumerate
+@item Integration with GLib event loop
+@item Detection of 32 vs 64 bit kernel at runtime
+@item Asynchronous transactions that don't block the event thread
+@item Stable service manager and low-level transation APIs
+@end enumerate")
+    (license license:bsd-3)))
+
 (define-public libglibutil
   (package
     (name "libglibutil")
--
2.33.1
P
P
phodina wrote on 10 Nov 2021 02:38
[PATCH 3/4] gnu: Add python-gbinder.
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
7QtNhomJeWJORkBXmW-URZhK86zqNDlMhu0kJCfLqCylsZc9rK48bBPumKeMQFh1BZzYulgZMpgSrbRV7soqEvKx1CmHbyh_ymrTceqeVZc=@protonmail.com
* gnu/packages/glib.scm (python-gbinder): New variable.

Toggle diff (42 lines)
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index 4f3e026d1b..d9e50a69c8 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -847,6 +847,37 @@ (define-public libglibutil
     (description "This package provides library of glib utilities.")
     (license license:bsd-3)))

+(define-public python-gbinder
+  (package
+    (name "python-gbinder")
+    (version "1.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/erfanoabdi/gbinder-python")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0jgblzakjgsy0cj93bmh5gr7qnl2xgsrm0wzc6xjvzry9lrbs360"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (replace 'build
+           (lambda* _
+             (invoke "python" "setup.py" "build_ext" "--inplace" "--cython"))))))
+    (native-inputs `(("python-cython" ,python-cython)
+                     ("pkg-config" ,pkg-config)))
+    (inputs `(("glib" ,glib)
+              ("libgbinder" ,libgbinder)
+              ("libglibutil" ,libglibutil)))
+    (home-page "https://github.com/erfanoabdi/gbinder-python")
+    (synopsis "Python bindings for libgbinder")
+    (description "This package provides Python bindings for libgbinder.")
+    (license license:gpl3+)))
+
 (define-public python2-pygobject-2
   (package
     (name "python2-pygobject")
--
2.33.1
P
P
phodina wrote on 10 Nov 2021 02:39
[PATCH 4/4] gnu: Add waydroid.
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
5RLyma8o5V0_Xhn_sSJGxZYF4XMzJtrEna-xE5UU-suoRiBa7vaxBdDUEBgKSBMb94O68CnqEzPkcuFA4qasS4rHR4lh-ch-S1k-mFn6d4U=@protonmail.com
* gnu/packages/virtualization.scm (waydroid): New variable.

Toggle diff (77 lines)
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 1817f6dc22..d47d8402f6 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -2005,6 +2005,72 @@ (define-public bochs
 DOS or Microsoft Windows.")
     (license license:lgpl2.0+)))

+(define-public waydroid
+  (package
+    (name "waydroid")
+    (version "1.2.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/waydroid/waydroid")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "03d87sh443kn0j2mpih1g909khkx3wgb04h605f9jhd0znskkbmw"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (delete 'build)                ; no setup.py
+         (delete 'check)                ; no test suite
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (lib (string-append out "/lib/waydroid"))
+                    (tools (string-append lib "/tools"))
+                    (data (string-append lib "/data"))
+                    (apps (string-append out "/share/applications"))
+                    (bin (string-append out "/bin"))
+                    (site (string-append out "/lib/python"
+                                         ,(version-major+minor
+                                           (package-version python))
+                                         "/site-packages"))
+                    (path (getenv "PYTHONPATH")))
+               (mkdir-p tools)
+               (mkdir-p data)
+               (mkdir-p apps)
+               (mkdir-p bin)
+               (copy-recursively "tools" tools)
+               (copy-recursively "data" data)
+               (install-file (string-append data "/Waydroid.desktop")
+                             (string-append apps))
+               (substitute* (string-append apps "/Waydroid.desktop")
+                 (("/usr") lib))
+               (install-file "waydroid.py" lib)
+               (symlink (string-append lib "/waydroid.py") (string-append bin
+                                                                          "/waydroid.py"))
+               (wrap-program (string-append bin "/waydroid.py")
+                 `("PYTHONPATH" ":" prefix (,site ,path)))))))))
+    (inputs `(("bash-minimal" ,bash-minimal)
+              ("dnsmasq" ,dnsmasq)
+              ("libgbinder" ,libgbinder)
+              ("lxc" ,lxc)
+              ("nftables" ,nftables)
+              ("python" ,python)
+              ("python-gbinder" ,python-gbinder)
+              ("python-pygobject" ,python-pygobject)))
+    (home-page "https://waydro.id")
+    (synopsis "Container-based approach to boot a full Android system")
+    (description "Waydroid uses Linux namespaces @code{(user, pid, uts, net,
+mount, ipc)} to run a full Android system in a container and provide Android
+applications.  The Android inside the container has direct access to needed
+underlying hardware.  The Android runtime environment ships with a minimal
+customized Android system image based on LineageOS.  The used image is
+currently based on Android 10.")
+    (license license:gpl3)))
+
 (define-public xen
   (package
     (name "xen")
--
2.33.1
L
L
Liliana Marie Prikler wrote on 15 Nov 2021 21:03
0bf1daa639bbc322ac0653da7699c005766cc0ad.camel@gmail.com
Hi,

Am Mittwoch, den 10.11.2021, 01:39 +0000 schrieb phodina:
Toggle quote (12 lines)
> [...]
> + (description "Waydroid uses Linux namespaces @code{(user, pid,
> uts, net,
> +mount, ipc)} to run a full Android system in a container and provide
> Android
> +applications. The Android inside the container has direct access to
> needed
> +underlying hardware. The Android runtime environment ships with a
> minimal
> +customized Android system image based on LineageOS. The used image
> is
> +currently based on Android 10.")
How exactly/when is this RTE built? Is it just included as a blob?
P
P
phodina wrote on 15 Nov 2021 23:30
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
vMf9WQUigGEQAYfNaISeMXbINkVbvnj8h55D54uJPRIiSzMv1ZsKVr2vHkVegQSQ6tqr-KAWWtYq77qhJVYNrtKhw6ctNcrTs5jpCYQwcy8=@protonmail.com
Hi Liliana,

On Monday, November 15th, 2021 at 9:03 PM, Liliana Marie Prikler <liliana.prikler@gmail.com> wrote:

Toggle quote (30 lines)
> Hi,
>
> Am Mittwoch, den 10.11.2021, 01:39 +0000 schrieb phodina:
>
> > [...]
> >
> > - (description "Waydroid uses Linux namespaces @code{(user, pid,
> >
> > uts, net,
> >
> > +mount, ipc)} to run a full Android system in a container and provide
> >
> > Android
> >
> > +applications. The Android inside the container has direct access to
> >
> > needed
> >
> > +underlying hardware. The Android runtime environment ships with a
> >
> > minimal
> >
> > +customized Android system image based on LineageOS. The used image
> >
> > is
> >
> > +currently based on Android 10.")
>
> How exactly/when is this RTE built? Is it just included as a blob?

Nope, it's downloaded as part of the =waydroid init= command.

You can see the RTE here:
$ ls /var/lib/waydroid/images/
system.img vendor.img

On waydroid website [1] they provide instructions on how to create this runtime environment - basically "+-" Android rootfs.

I cameacross a channel [2] with Android support but haven't had the chance to test it yet. Then again I'm not sure if that's the right way as there are phones that run close to vanilla Linux [3]. Though this technological solution enables Android apps to run on those phones.

But it also has drawback as it requires custom kernel.

Though these patches require support in the kernel [3] and LXD service running [4] at least.

Currently I'm able to run the waydroid container and get shell over adb.

However, for some unknown reason I can't launch the UI.

That might be due to the fact I run Sway VM. I'll test this with GDM as this is recommended in the issues on github and report back.

Petr

P
P
phodina wrote on 3 Dec 2021 16:00
(name . 51737@debbugs.gnu.org)(address . 51737@debbugs.gnu.org)
1IgTsyR1Izq-_tDhbSbaUt57O-ElCeseDKi6urdyGx7-FJLkmBi90YhpOoBAl3KMmuvPZfSKPm9ay89-OVGIhDmjN5vycEMnoY-ibSi7yRI=@protonmail.com
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 51737@debbugs.gnu.org