Waydroid on Clear Linux

I’m interested in installing waydroid, but there are setup guides for only the other distros. Will waydroid work properly on Clear and if so, has someone successfully got it running?

̶T̶h̶i̶s̶ ̶i̶s̶ ̶a̶n̶ ̶i̶n̶e̶f̶f̶i̶c̶i̶e̶n̶t̶ ̶g̶u̶i̶d̶e̶ ̶w̶h̶i̶c̶h̶ ̶a̶s̶s̶u̶m̶e̶s̶ ̶a̶ ̶t̶o̶n̶ ̶o̶f̶ ̶t̶h̶i̶n̶g̶s̶,̶ ̶b̶u̶t̶ ̶h̶o̶p̶e̶f̶u̶l̶l̶y̶ ̶t̶h̶i̶s̶ ̶h̶e̶l̶p̶s̶ ̶s̶o̶m̶e̶o̶n̶e̶ ̶o̶u̶t̶.̶
CL Version as of time of writing: 40310
UPDATED: CL version: 40620
UPDATE 2: Guide no longer assumes anything! Removed games-dev and added actual dependencies.
UPDATE 3: CL version: 41230, added /usr/local/lib64 to LD_LIBRARY_PATH
UPDATE 4: get around sudo waydroid init being unable to run lxc commands

Swupd dependencies

sudo swupd bundle-add c-basic c-basic-legacy dev-utils devpkg-dbus devpkg-systemd devpkg-glib devpkg-libseccomp devpkg-openssl devpkg-libcap devpkg-Linux-PAM kvm-host containers-basic

Fulfilling prerequisites
Part 1. Gbinder-Python
Part 2. LXC

Part 1.
You need $PKG_CONFIG_PATH and $LD_LIBRARY_PATH defined (in case you don’t, you can add this to your ~/.bashrc or as .conf file (name of your choosing) under /etc/environment.d/)

export PKG_CONFIG_PATH='/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib64/haswell/pkgconfig:/usr/lib/pkgconfig'
export LD_LIBRARY_PATH='/usr/lib:/usr/local/lib:/usr/lib64:/usr/local/lib64'
/* or add both the above into a paths.conf file under /etc/environment.d/ , just remove export*/

restart shell (logout and login if adding to /etc/environment.d), then confirm by using echo —
echo $PKG_CONFIG_PATH

Libglibutil → Libgbinder → Gbinder-Python

git clone https://github.com/sailfishos/libglibutil.git
make
sudo make install-dev
git clone https://github.com/mer-hybris/libgbinder.git
make
sudo make install-dev
git clone https://github.com/erfanoabdi/gbinder-python.git
python setup.py build_ext --cython
sudo python setup.py install

Part 2. LXC
Follow LXC Bundle Request · Issue #1745 · clearlinux/distribution · GitHub and setup the .conf file under /etc/kernel/cmdline.d/

# mkdir -p /etc/kernel/cmdline.d
# echo systemd.unified_cgroup_hierarchy=1 >> /etc/kernel/cmdline.d/lxc.conf
# echo psi=1 >> /etc/kernel/cmdline.d/lxc.conf
# clr-boot-manager update

Enable the relevant services as per Please add LXD support · Issue #1415 · clearlinux/distribution · GitHub using sudo systemctl enable (servicename)

* libvirtd
* libvirt-guests
* virtlxcd
* virtstoraged
* virtnetworkd
* virtnodedevd

Once you’re done, restart the system and build LXC GitHub - lxc/lxc: LXC - Linux Containers

sudo mkdir /etc/default
/* hacky workaround for distrosysconfdir, you can also make LXC_DISTRO_SYSCONF and point that towards /usr/share/defaults
see https://github.com/lxc/lxc/issues/4178 for error
see https://www.clearlinux.org/clear-linux-documentation/guides/clear/stateless.html#default-configurations for more info*/
git clone https://github.com/lxc/lxc.git
// IMPORTANT: Disable docs, selinux and apparmor by changing their boolean to false in meson_options.txt
meson setup -Dprefix=/usr build
meson compile -C build
sudo ninja install -C build

Installing Waydroid

git clone https://github.com/waydroid/waydroid.git
sudo make install
sudo swupd bundle-add python-data-science
sudo systemctl enable waydroid-container.service
sudo systemctl start waydroid-container.service
sudo waydroid init /* or sudo waydroid init -s GAPPS */
sudo sed -i 's|lxc.apparmor.profile|# lxc.apparmor.profile|g' /var/lib/waydroid/lxc/waydroid/config
waydroid session start

I was banging my head against the wall a lot, but getting waydroid up and running was worth it


UPDATE: I think I have gbinder-python figured out, now it should work without much finagling
In case you want to nuke and try all over again do

sudo rm -rf /etc
sudo rm -rf /var

Taken from Stateless — Documentation for Clear Linux* project

2 Likes

Common issues

ImportError: libgbinder.so: cannot open shared object file: No such file or directory

Try reinstalling the python-data-sciences bundle and using ipython to confirm the import
Once import is successful, try enabling/starting the waydroid-container.service again

sudo swupd bundle-remove python-data-science
sudo swupd bundle-add python-data-science
ipython
In [1]: import gbinder

In [2]: gbinder
Out[2]: <module 'gbinder' from '/usr/lib/python3.12/site-packages/gbinder_python-1.1.2-py3.12-linux-x86_64.egg/gbinder.cpython-312-x86_64-linux-gnu.so'>
OSError: container failed to start

lxc was built without apparmor support, comment it out in the config file for waydroid

sudo sed -i 's|lxc.apparmor.profile|# lxc.apparmor.profile|g' /var/lib/waydroid/lxc/waydroid/config
Skipping clipboard manager server because of missing pyclip package

Install pyclip

git clone https://github.com/spyoungtech/pyclip.git
python setup.py build_ext
sudo python setup.py install
1 Like

How many Waydroid & LXC dependencies aren’t available in Clear? Thinking about adding Waydroid to CF.

libglibutil
libgbinder
gbinder-python
lxc
pyclip
waydroid (sudo make install)

These are all the packages.

Weird quirks:

  • waydroid-container.service can only find libgbinder.so only if the python-data-science bundle is added after waydroid is installed. Probably can get around this by specifying --prefix=/usr when building the first three packages but I’m not sure.
  • I build lxc without apparmor support so updates or installing libhoudini/libndk/widevine/etc will cause waydroid to cause OS Error under my common issues post. Will have to rerun that sed command to comment it out (I haven’t tested building lxc with apparmor support)
  • lxc must specify prefix when building or waydroid will be unable to use lxc commands like lxc-info, they will error out with liblxc.so shared library cannot be found. If commands were run normally they work, but within waydroid they fail. Before I figured out the specify --prefix I tried to build lxc statically but I fail due to skill issue.

Yeah, that’s tricky task, especially getting it to work from /opt. So contributors are welcome :slightly_smiling_face:

waydroid-container.service can only find libgbinder.so only if the python-data-science

My guess your PYTHONPATH is broken or there’s some unknown gbinder dependency.

lxc must specify prefix when building or waydroid will be unable to use lxc commands like lxc-info

The PATH isn’t enough? Anyway, think it’s hard to make it work from /opt without patching Waydroid launcher.

My guess your PYTHONPATH is broken or there’s some unknown gbinder dependency.

This is tested off a clean install of CL with no bundles (last done at 41230), as you can see, i have not set a PYTHONPATH anywhere in my guide.
Extra quirk: python-data-science bundle can be removed later after installing waydroid and waydroid will still work as normal afterwards.

The PATH isn’t enough? Anyway, think it’s hard to make it work from /opt without patching Waydroid launcher.

Where do I sign up to contribute? :grin:
Though I feel like this is going to be a long road

Where do I sign up to contribute? :grin:

Welcome to the club :grin:

Extra quirk: python-data-science bundle can be removed later after installing waydroid and waydroid will still work as normal afterwards.

Weird, maybe this bundle include some useful Python tools or something.