From b896fb0b168124734eef9b5066255b91a68a25e2 Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Tue, 22 Oct 2024 21:12:31 +0100 Subject: [PATCH] Add initial waydroid support for testing from https://github.com/webOS-ports/meta-webos-ports/tree/kirkstone Signed-off-by: Alex J Lennon --- .../python/python3-pyclip_0.5.4.bb | 15 +++ .../libgbinder/libgbinder-radio.bb | 27 +++++ recipes-support/libgbinder/libgbinder.bb | 34 ++++++ .../libgbinder/libgbinder/gbinder.conf | 2 + recipes-support/libglibutil/libglibutil.bb | 24 ++++ ...-away-from-deprecated-distutils.core.patch | 38 +++++++ .../waydroid/python3-gbinder_git.bb | 29 +++++ recipes-support/waydroid/waydroid-data.bb | 45 ++++++++ recipes-support/waydroid/waydroid.bb | 107 ++++++++++++++++++ .../waydroid/waydroid/gbinder.conf | 2 + .../waydroid/waydroid-container.service | 14 +++ .../waydroid/waydroid/waydroid-init.service | 14 +++ 12 files changed, 351 insertions(+) create mode 100644 recipes-devtools/python/python3-pyclip_0.5.4.bb create mode 100644 recipes-support/libgbinder/libgbinder-radio.bb create mode 100644 recipes-support/libgbinder/libgbinder.bb create mode 100644 recipes-support/libgbinder/libgbinder/gbinder.conf create mode 100644 recipes-support/libglibutil/libglibutil.bb create mode 100644 recipes-support/waydroid/python3-gbinder/0001-setup.py-Migrate-away-from-deprecated-distutils.core.patch create mode 100644 recipes-support/waydroid/python3-gbinder_git.bb create mode 100644 recipes-support/waydroid/waydroid-data.bb create mode 100644 recipes-support/waydroid/waydroid.bb create mode 100644 recipes-support/waydroid/waydroid/gbinder.conf create mode 100644 recipes-support/waydroid/waydroid/waydroid-container.service create mode 100644 recipes-support/waydroid/waydroid/waydroid-init.service diff --git a/recipes-devtools/python/python3-pyclip_0.5.4.bb b/recipes-devtools/python/python3-pyclip_0.5.4.bb new file mode 100644 index 0000000..a1db8cd --- /dev/null +++ b/recipes-devtools/python/python3-pyclip_0.5.4.bb @@ -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" diff --git a/recipes-support/libgbinder/libgbinder-radio.bb b/recipes-support/libgbinder/libgbinder-radio.bb new file mode 100644 index 0000000..1a4c643 --- /dev/null +++ b/recipes-support/libgbinder/libgbinder-radio.bb @@ -0,0 +1,27 @@ +# Copyright (c) 2019 Christophe Chapuis + +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} +} diff --git a/recipes-support/libgbinder/libgbinder.bb b/recipes-support/libgbinder/libgbinder.bb new file mode 100644 index 0000000..bfc46f0 --- /dev/null +++ b/recipes-support/libgbinder/libgbinder.bb @@ -0,0 +1,34 @@ +# Copyright (c) 2019 Christophe Chapuis + +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}" diff --git a/recipes-support/libgbinder/libgbinder/gbinder.conf b/recipes-support/libgbinder/libgbinder/gbinder.conf new file mode 100644 index 0000000..d88b701 --- /dev/null +++ b/recipes-support/libgbinder/libgbinder/gbinder.conf @@ -0,0 +1,2 @@ +[General] +ApiLevel = 28 diff --git a/recipes-support/libglibutil/libglibutil.bb b/recipes-support/libglibutil/libglibutil.bb new file mode 100644 index 0000000..7d04a51 --- /dev/null +++ b/recipes-support/libglibutil/libglibutil.bb @@ -0,0 +1,24 @@ +# Copyright (c) 2019 Christophe Chapuis + +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} +} diff --git a/recipes-support/waydroid/python3-gbinder/0001-setup.py-Migrate-away-from-deprecated-distutils.core.patch b/recipes-support/waydroid/python3-gbinder/0001-setup.py-Migrate-away-from-deprecated-distutils.core.patch new file mode 100644 index 0000000..b3e6313 --- /dev/null +++ b/recipes-support/waydroid/python3-gbinder/0001-setup.py-Migrate-away-from-deprecated-distutils.core.patch @@ -0,0 +1,38 @@ +From 32cfbabe5ed37815358cc3515ce6551b6b7b87ae Mon Sep 17 00:00:00 2001 +From: Herrie +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 +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): diff --git a/recipes-support/waydroid/python3-gbinder_git.bb b/recipes-support/waydroid/python3-gbinder_git.bb new file mode 100644 index 0000000..038e799 --- /dev/null +++ b/recipes-support/waydroid/python3-gbinder_git.bb @@ -0,0 +1,29 @@ +# Copyright (C) 2015 Khem Raj +# 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" + diff --git a/recipes-support/waydroid/waydroid-data.bb b/recipes-support/waydroid/waydroid-data.bb new file mode 100644 index 0000000..871ed4b --- /dev/null +++ b/recipes-support/waydroid/waydroid-data.bb @@ -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" diff --git a/recipes-support/waydroid/waydroid.bb b/recipes-support/waydroid/waydroid.bb new file mode 100644 index 0000000..18791de --- /dev/null +++ b/recipes-support/waydroid/waydroid.bb @@ -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 diff --git a/recipes-support/waydroid/waydroid/gbinder.conf b/recipes-support/waydroid/waydroid/gbinder.conf new file mode 100644 index 0000000..59c49f0 --- /dev/null +++ b/recipes-support/waydroid/waydroid/gbinder.conf @@ -0,0 +1,2 @@ +[General] +ApiLevel = 30 diff --git a/recipes-support/waydroid/waydroid/waydroid-container.service b/recipes-support/waydroid/waydroid/waydroid-container.service new file mode 100644 index 0000000..2ab0be0 --- /dev/null +++ b/recipes-support/waydroid/waydroid/waydroid-container.service @@ -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 diff --git a/recipes-support/waydroid/waydroid/waydroid-init.service b/recipes-support/waydroid/waydroid/waydroid-init.service new file mode 100644 index 0000000..33d0d5d --- /dev/null +++ b/recipes-support/waydroid/waydroid/waydroid-init.service @@ -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