Skip to content

Commit

Permalink
Add initial waydroid support for testing
Browse files Browse the repository at this point in the history
from https://github.com/webOS-ports/meta-webos-ports/tree/kirkstone

Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>
  • Loading branch information
ajlennon committed Oct 22, 2024
1 parent d4ecf6b commit b896fb0
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 0 deletions.
15 changes: 15 additions & 0 deletions recipes-devtools/python/python3-pyclip_0.5.4.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DESCRIPTION = "Cross-platform clipboard utilities supporting both binary and text data."
HOMEPAGE = "https://github.com/spyoungtech/pyclip"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=2b42edef8fa55315f34f2370b4715ca9"

SRC_URI[sha256sum] = "bd7cf7ebfc6e6080d48c21007a7f09661afdec00de54a3fd48903717e67b53ea"

inherit pypi setuptools3

do_configure:append () {
install -d ${S}/docs
cp ${S}/README.md ${S}/docs/README.md
}

BBCLASSEXTEND = "native nativesdk"
27 changes: 27 additions & 0 deletions recipes-support/libgbinder/libgbinder-radio.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2019 Christophe Chapuis <chris.chapuis@gmail.com>

DESCRIPTION = "Library used to interact with Android's binder module."
LICENSE = "BSD-3-Clause"
SECTION = "webos/support"
LIC_FILES_CHKSUM = "file://LICENSE;md5=d87dfa6305062e57b880f060fcc92f34"

DEPENDS = "libgbinder glib-2.0 libglibutil"

inherit pkgconfig

SRC_URI = "git://github.com/mer-hybris/libgbinder-radio.git;branch=master;protocol=https"
S = "${WORKDIR}/git"

PV = "1.5.6"
SRCREV = "48036159207d2ab9b8590f74600074aa2467ee23"

CFLAGS += "--sysroot=${RECIPE_SYSROOT} "
LDFLAGS += "--sysroot=${RECIPE_SYSROOT} "

EXTRA_OEMAKE = "KEEP_SYMBOLS=1 CROSS_COMPILE=${TARGET_PREFIX} CC='${CC}' "
PARALLEL_MAKE = ""

do_install() {
make install DESTDIR=${D}
make install-dev DESTDIR=${D}
}
34 changes: 34 additions & 0 deletions recipes-support/libgbinder/libgbinder.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2019 Christophe Chapuis <chris.chapuis@gmail.com>

DESCRIPTION = "Library used to interact with Android's binder module."
LICENSE = "BSD-3-Clause"
SECTION = "webos/support"
LIC_FILES_CHKSUM = "file://LICENSE;md5=78995ef51510572817bf9586588261b3"

DEPENDS = "glib-2.0 libglibutil"

inherit pkgconfig

SRC_URI = "git://github.com/mer-hybris/libgbinder.git;branch=master;protocol=https \
file://gbinder.conf \
"
S = "${WORKDIR}/git"

PV = "1.1.35"
SRCREV = "e3f705c4cc6b820d8885b565fc7995e02dd196b3"

EXTRA_OEMAKE = "KEEP_SYMBOLS=1"
PARALLEL_MAKE = ""

do_install() {
make install DESTDIR=${D}
make install-dev DESTDIR=${D}
}

# Install libgbinder's config for Halium 9.0, we do this here, since for Waydroid we need a different API version it seems, so better to split it for mainline targets such as PinePhone and qemux86-64.
do_install:append:halium() {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/gbinder.conf ${D}${sysconfdir}/gbinder.conf
}

FILES:${PN} += " ${sysconfdir}"
2 changes: 2 additions & 0 deletions recipes-support/libgbinder/libgbinder/gbinder.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[General]
ApiLevel = 28
24 changes: 24 additions & 0 deletions recipes-support/libglibutil/libglibutil.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2019 Christophe Chapuis <chris.chapuis@gmail.com>

DESCRIPTION = "Library of glib utilities."
LICENSE = "BSD-3-Clause"
SECTION = "webos/support"
LIC_FILES_CHKSUM = "file://LICENSE;md5=d06f24f367f70ea228818e7442fa90c7"

DEPENDS = "glib-2.0"

inherit pkgconfig

SRC_URI = "git://github.com/sailfishos/libglibutil.git;protocol=https;branch=master"
S = "${WORKDIR}/git"

PV = "1.0.75-1+git${SRCPV}"
SRCREV = "4e110017fd4f852a3b1e5616baf111813be9fe92"

EXTRA_OEMAKE = "KEEP_SYMBOLS=1"
PARALLEL_MAKE = ""

do_install() {
make install DESTDIR=${D}
make install-dev DESTDIR=${D}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 32cfbabe5ed37815358cc3515ce6551b6b7b87ae Mon Sep 17 00:00:00 2001
From: Herrie <Github.com@herrie.org>
Date: Sat, 23 Jul 2022 20:38:22 +0200
Subject: [PATCH] setup.py: Migrate away from deprecated distutils.core to
setuptools

distutils will be removed in Python 3.12, but already gives issues with 3.10 as well.

/mnt/5ba5d474-0b2d-49d6-a5a6-9de20c3ac967/kirkstone/webos-ports/tmp-glibc/work/core2-64-webos-linux/python3-gbinder/1.0.0+gitAUTOINC+da16278f0d-r0/git/setup.py:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.core import setup, Extension
Compiling gbinder.pyx because it changed.
[1/1] Cythonizing gbinder.pyx
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: invalid command 'bdist_wheel'
ERROR: 'python3 setup.py bdist_wheel sdist --cython' execution failed.
WARNING: exit code 1 from a shell command.

Signed-off-by: Herman van Hazendonk <github.com@herrie.org>
Upstream-Status: Pending
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index ed2b1ed..6060f84 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
import sys, subprocess
-from distutils.core import setup, Extension
+from setuptools import setup, Extension


def pkgconfig(package, kw):
29 changes: 29 additions & 0 deletions recipes-support/waydroid/python3-gbinder_git.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (C) 2015 Khem Raj <raj.khem@gmail.com>
# Released under the MIT license (see COPYING.MIT for the terms)

DESCRIPTION = "Cython extension module for gbinder"
HOMEPAGE = "https://github.com/waydroid/gbinder-python"
LICENSE = "GPL-3.0-only"
SECTION = "devel/python"
LIC_FILES_CHKSUM = "file://LICENSE;md5=1ebbd3e34237af26da5dc08a4e440464"

# We're stuck @ 1.1.1 untill we are at cython3, build breaks with https://github.com/waydroid/gbinder-python/commit/4d8cb8f56da9e8159ea1b2ef76ddfa0253563db7
PV = "1.1.1+git${SRCPV}"
SRCREV = "990c3007eeac3e015fb38aecd76dd010b4b75a1e"
SRC_URI = "git://github.com/waydroid/gbinder-python.git;branch=bullseye;protocol=https \
file://0001-setup.py-Migrate-away-from-deprecated-distutils.core.patch \
"

S = "${WORKDIR}/git"

DEPENDS = "libgbinder python3-cython-native libglibutil"

RDEPENDS:${PN}:class-native = ""
DEPENDS:append:class-native = " python-native "

SETUPTOOLS_BUILD_ARGS = "sdist --cython"

inherit setuptools3 pkgconfig

BBCLASSEXTEND = "native"

45 changes: 45 additions & 0 deletions recipes-support/waydroid/waydroid-data.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
SUMMARY = "Waydroid uses a container-based approach to boot a full Android system"
DESCRIPTION = "Android image file for Waydroid"
# this isn't very clear, there is no information in build.anbox.io and it surely doesn't
# cover all components included in this built image, e.g.
# https://aur.archlinux.org/packages/waydroid-image says Apache license
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9"

# works only for following 4 archs
COMPATIBLE_MACHINE ?= "(^$)"
COMPATIBLE_MACHINE:x86-64 = "(.*)"
COMPATIBLE_MACHINE:armv7a = "(.*)"
COMPATIBLE_MACHINE:armv7ve = "(.*)"
COMPATIBLE_MACHINE:aarch64 = "(.*)"

WAYDROID_ARCH:x86-64 = "waydroid_x86_64"
WAYDROID_ARCH:aarch64 = "waydroid_arm64"
WAYDROID_SYSTEM_IMAGE = "lineage-18.1-20231028-VANILLA-${WAYDROID_ARCH}-system.zip"
WAYDROID_VENDOR_IMAGE = "lineage-18.1-20231028-MAINLINE-${WAYDROID_ARCH}-vendor.zip"
WAYDROID_VENDOR_IMAGE:halium = "lineage-18.1-20231028-HALIUM_11-${WAYDROID_ARCH}-vendor.zip"

SHA256SUM_SYSTEM:x86-64 = "992853ed6849fd26cb750d880016ff605910661229fb3ab22447a7e6f1c8c112"
SHA256SUM_VENDOR:x86-64 = "c0057b233c5dddf7b8f3bb046d3114fa34589c776743ced61840615d4d48f5bc"

SHA256SUM_SYSTEM:aarch64 = "406adff7e346eab019a51287e49765a6d6c24d62c0a47eb74eb8ea9ad2c384ee"
SHA256SUM_VENDOR:aarch64 = "e67f0d92907bd74083f1f83da701609c94c4cdbd8ba7c662c27d3e94194aac70"

SHA256SUM_VENDOR:halium = "cd5b1394f35c97c0284f365e52588eecd7b89b6aa28624aefca55aff509143e5"

SRC_URI = "https://sourceforge.net/projects/waydroid/files/images/system/lineage/${WAYDROID_ARCH}/${WAYDROID_SYSTEM_IMAGE};name=system \
https://sourceforge.net/projects/waydroid/files/images/vendor/${WAYDROID_ARCH}/${WAYDROID_VENDOR_IMAGE};name=vendor \
"

SRC_URI[system.sha256sum] = "${SHA256SUM_SYSTEM}"
SRC_URI[vendor.sha256sum] = "${SHA256SUM_VENDOR}"

do_install() {
install -dm755 "${D}/usr/share/waydroid-extra/images"

# makepkg have extracted the zips
install -m 0644 "${WORKDIR}/system.img" "${D}/usr/share/waydroid-extra/images"
install -m 0644 "${WORKDIR}/vendor.img" "${D}/usr/share/waydroid-extra/images"
}

FILES:${PN} += "/usr/share/waydroid-extra/images"
107 changes: 107 additions & 0 deletions recipes-support/waydroid/waydroid.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
SUMMARY = "Waydroid uses a container-based approach to boot a full Android system"
DESCRIPTION = "Runtime for Android applications which runs a full Android system \
in a container using Linux namespaces (user, ipc, net, mount) to \
separate the Android system fully from the host."
LICENSE = "GPL-3.0-only"
LIC_FILES_CHKSUM = "file://LICENSE;md5=1ebbd3e34237af26da5dc08a4e440464"

SECTION = "webos/support"

SRCREV = "41f309f4c185a2c716723c081274eb56eb9263ff"
SPV = "1.4.2"
PV = "${SPV}+git${SRCPV}"


RDEPENDS:${PN} += "waydroid-data lxc python3-gbinder python3-pygobject libgbinder python3-pyclip"

# these modules are directly included in android-flavored kernels
# Note: Waydroid requires kernel >= 3.18 !
RRECOMMENDS:${PN} += " \
kernel-module-ashmem-linux \
kernel-module-binder-linux \
"

SRC_URI = "git://github.com/herrie82/waydroid.git;branch=herrie/luneos;protocol=https \
file://gbinder.conf \
"
S = "${WORKDIR}/git"

# Needs quite new kernel (probably >= 3.18) and from LuneOS supported machines
# only qemux86, qemux86-64, rpi, Pine64 and other mainline) MACHINEs have it
# Unlink ashmem, binder drop qemux86 here, because waydroid-data is available only
# for following 4 archs (x86-64, armv7a, armv7ve, aarch64)
COMPATIBLE_MACHINE ?= "(^$)"
COMPATIBLE_MACHINE:qemux86-64 = "(.*)"
COMPATIBLE_MACHINE:rpi = "(.*)"
COMPATIBLE_MACHINE:pinephone = "(.*)"
COMPATIBLE_MACHINE:pinephonepro = "(.*)"
COMPATIBLE_MACHINE:pinetab2 = "(.*)"
COMPATIBLE_MACHINE:mido-halium = "(.*)"
COMPATIBLE_MACHINE:tissot = "(.*)"
COMPATIBLE_MACHINE:imx8mm-lpddr4-evk = "(.*)"

inherit pkgconfig
#inherit webos_app
#inherit webos_filesystem_paths
#inherit webos_systemd
inherit systemd

WEBOS_SYSTEMD_SERVICE = "waydroid-init.service waydroid-container.service"

CLEANBROKEN = "1"

EXTRA_OEMAKE = "SYSD_DIR=${systemd_system_unitdir} USE_NFTABLES="1" WAYDROID_VERSION=${SPV}"

do_install() {
make install_luneos DESTDIR=${D}
}

# Provided by libgbinder already for Halium devices, but necessary to add for non-Halium devices.

do_install:append:pinephone() {
install -Dm644 -t "${D}${sysconfdir}" "${WORKDIR}/gbinder.conf"
}

do_install:append:pinephonepro() {
install -Dm644 -t "${D}${sysconfdir}" "${WORKDIR}/gbinder.conf"
}

do_install:append:pinetab2() {
install -Dm644 -t "${D}${sysconfdir}" "${WORKDIR}/gbinder.conf"
}

do_install:append:qemux86-64() {
install -Dm644 -t "${D}${sysconfdir}" "${WORKDIR}/gbinder.conf"
}

do_install:append:imx8mm-lpddr4-evk() {
install -Dm644 -t "${D}${sysconfdir}" "${WORKDIR}/gbinder.conf"
}

FILES:${PN} += " \
${sysconfdir} \
${libdir} \
${datadir}/dbus-1 \
${datadir}/polkit-1 \
${prefix}/libexec \
/usr/palm/applications/id.waydro.container \
"


# Usage
# =====
# Below is obsolete since Waydroid can now just be started from Launcher, however it's good to keep for reference
#
# mkdir -p /run/luna-session/
# mount --bind /tmp/luna-session /run/luna-session/
# export XDG_RUNTIME_DIR=/run/luna-session
# export XDG_SESSION_TYPE=wayland
# -- also, make sure /etc/gbinder.conf has "ApiLevel = 30" (Halium 9 needs API 28)
#
# Then:
# 0. waydroid init (just once, but needs network !)
# 1. either
# waydroid show-full-ui
# or
# waydroid session start
# waydroid app launch com.android.settings
2 changes: 2 additions & 0 deletions recipes-support/waydroid/waydroid/gbinder.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[General]
ApiLevel = 30
14 changes: 14 additions & 0 deletions recipes-support/waydroid/waydroid/waydroid-container.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Waydroid Container
After=waydroid-init.service
Requires=surface-manager.service

[Service]
BusName=id.waydro.Container
EnvironmentFile=/etc/id.waydro.Container/waydroid.env
ExecStartPre=/bin/mkdir -p /tmp/luna-session
ExecStartPre=/bin/ln -s /tmp/luna-session /run/luna-session
ExecStart=/usr/bin/waydroid -w container start

[Install]
WantedBy=multi-user.target
14 changes: 14 additions & 0 deletions recipes-support/waydroid/waydroid/waydroid-init.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Waydroid init
After=surface-manager.service

[Service]
Type=oneshot
EnvironmentFile=/etc/id.waydro.Container/waydroid.env
ExecStartPre=/bin/mkdir -p /tmp/luna-session
ExecStartPre=/bin/ln -s /tmp/luna-session /run/luna-session
ExecStart=/usr/bin/waydroid init
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

0 comments on commit b896fb0

Please sign in to comment.