1 #!/bin/bash
2 # Waydroid Auto-Packager & Integrator for openSUSE Tumbleweed
3 # Description: Automates compilation, RPM packaging, and system integration.
4 # Usage:
5 # ./waydroid_setup.sh (To install)
6 # ./waydroid_setup.sh uninstall (To remove)
7
8 set -e
9
10 # --- SOURCES ---
11 GITHUB="https://github.com"
12 PATH_GLIBUTIL="$GITHUB/sailfishos/libglibutil.git"
13 PATH_GBINDER="$GITHUB/mer-hybris/libgbinder.git"
14 PATH_PYBINDER="$GITHUB/waydroid/python3-gbinder.git"
15 PATH_MODULES="$GITHUB/choff/anbox-modules.git"
16 PATH_WAYDROID="$GITHUB/waydroid/waydroid.git"
17
18 # --- INSTALLATION LOGIC ---
19 install_waydroid() {
20 echo "--- [1/8] Configuring GRUB (Enabling PSI=1) ---"
21 if ! grep -q "psi=1" /etc/default/grub; then
22 sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="psi=1 /' /etc/default/grub
23 sudo grub2-mkconfig -o /boot/grub2/grub.cfg
24 echo "[!] GRUB updated. System reboot required after installation."
25 fi
26
27 echo "--- [2/8] Installing Build Dependencies ---"
28 sudo zypper install -y git rpm-build python313-devel meson ninja gcc-c++ make pkg-config dkms kernel-default-devel ruby-devel firewalld
29 sudo gem install --no-document fpm
30
31 WORKING_DIR=$HOME/waydroid_factory
32 mkdir -p $WORKING_DIR && cd $WORKING_DIR
33
34 get_source() {
35 [ ! -d "$2" ] && git clone "$1" "$2" || (cd "$2" && git pull)
36 }
37
38 echo "--- [3/8] Building Base Libraries (Local Build) ---"
39 get_source "$PATH_GLIBUTIL" "libglibutil"
40 cd libglibutil && make -j$(nproc) && sudo make install && cd ..
41
42 get_source "$PATH_GBINDER" "libgbinder"
43 cd libgbinder && make -j$(nproc) && sudo make install && sudo ldconfig && cd ..
44
45 echo "--- [4/8] Packaging Kernel Modules (DKMS RPM) ---"
46 get_source "$PATH_MODULES" "anbox-modules"
47 cd anbox-modules
48 B_ROOT="/tmp/waydroid-dkms"
49 rm -rf $B_ROOT && mkdir -p $B_ROOT/usr/src/anbox-1
50 cp -r binder ashmem $B_ROOT/usr/src/anbox-1/
51 echo -e "PACKAGE_NAME=\"anbox\"\nPACKAGE_VERSION=\"1\"\nBUILT_MODULE_NAME=\"ashmem_linux\"\nDEST_MODULE_LOCATION=\"/kernel/drivers/staging/android\"\nBUILT_MODULE_NAME=\"binder_linux\"\nDEST_MODULE_LOCATION=\"/kernel/drivers/staging/android\"\nAUTOINSTALL=\"yes\"" > $B_ROOT/usr/src/anbox-1/dkms.conf
52
53 fpm -s dir -t rpm -n waydroid-kmp-default -v 1 \
54 --after-install <(echo -e "dkms add -m anbox -v 1\ndkms install -m anbox -v 1\nmodprobe binder_linux") \
55 -C $B_ROOT .
56 sudo zypper --no-remote install -y waydroid-kmp-default-*.rpm
57 cd ..
58
59 echo "--- [5/8] Packaging Python 3.13 Bindings ---"
60 get_source "$PATH_PYBINDER" "python3-gbinder"
61 cd python3-gbinder
62 export CFLAGS="-I/usr/local/include/gbinder -I/usr/local/include/gutil"
63 export LDFLAGS="-L/usr/local/lib"
64 python3.13 setup.py build
65 fpm -s python -t rpm --python-bin python3.13 --name python313-gbinder .
66 sudo zypper --no-remote install -y python313-gbinder-*.rpm
67 cd ..
68
69 echo "--- [6/8] Packaging Main Waydroid App ---"
70 get_source "$PATH_WAYDROID" "waydroid"
71 cd waydroid
72 W_VER=$(git describe --tags | sed 's/^v//' | sed 's/-/./g')
73 fpm -s dir -t rpm -n waydroid -v "$W_VER" \
74 --prefix /usr/lib/waydroid --depends python313 --depends waydroid-kmp-default .
75 sudo zypper --no-remote install -y waydroid-*.rpm
76 cd ..
77
78 echo "--- [7/8] Network & Firewall Rules ---"
79 sudo systemctl enable --now firewalld
80 sudo firewall-cmd --permanent --zone=trusted --add-interface=waydroid0
81 sudo firewall-cmd --reload
82
83 echo "--- [8/8] Final Initialization ---"
84 sudo waydroid init
85 sudo systemctl enable --now waydroid-container
86 echo "SUCCESS! Please reboot your system to apply kernel changes."
87 }
88
89 # --- UNINSTALLATION LOGIC ---
90 uninstall_waydroid() {
91 echo "--- Removing Waydroid Components ---"
92 sudo waydroid session stop || true
93 sudo systemctl stop waydroid-container || true
94 sudo zypper remove -y waydroid python313-gbinder waydroid-kmp-default
95 sudo dkms remove -m anbox -v 1 --all || true
96 sudo rm -rf /var/lib/waydroid /home/*/.local/share/waydroid
97 sudo rm -f /usr/local/lib/libgbinder.* /usr/local/lib/libglibutil.*
98 sudo ldconfig
99 echo "Waydroid uninstalled. Please manually remove 'psi=1' from /etc/default/grub if no longer needed."
100 }
101
102 # --- MAIN EXECUTION ---
103 case "$1" in
104 uninstall)
105 uninstall_waydroid
106 ;;
107 *)
108 install_waydroid
109 ;;
110 esac
Summary of what we solved for the community:
- Dynamic Packaging: Used
fpmto convert source code into trackable RPMs forlibgbinderandpython313. - Kernel Resilience: The
waydroid-kmp-defaultRPM uses DKMS to ensure modules survive openSUSE Tumbleweed kernel updates. - Python 3.13 Ready: Specifically tailored for the latest Python version currently in Tumbleweed.
- Out-of-the-box Networking: Automates Firewalld rules for the
waydroid0bridge.
UNTESTED!!!