Skip to content

Instantly share code, notes, and snippets.

@cniw
Last active July 3, 2024 09:35
Show Gist options
  • Save cniw/98e204d7dbc73a3fa1bf61629b2a2fc1 to your computer and use it in GitHub Desktop.
Save cniw/98e204d7dbc73a3fa1bf61629b2a2fc1 to your computer and use it in GitHub Desktop.
Build Waydroid for Debian or Ubuntu based distro v8
#!/bin/bash
# script name: build_waydroid_v8.sh
# description: Build Waydroid for Debian or Ubuntu based distro v8
# upstream : https://gist.github.com/cniw/98e204d7dbc73a3fa1bf61629b2a2fc1
# author : Wachid Adi Nugroho <wachidadinugroho.maya@gmail.com>
# date : 2022-07-07
NC='\033[0m'
RED='\033[1;91m'
GREEN='\033[1;92m'
if [ ! -f /usr/bin/dpkg ]
then
echo -e "\n${RED}==> Can't run this script because your distro doesn't have dpkg package manager.${NC}\n"
exit 1
fi
echo
echo -e "${GREEN}==> Updating repository ...${NC}"
sudo apt update || exit 1
echo -e "${GREEN}==> Updating repository, done.${NC}\n"
echo -e "${GREEN}==> Installing build tools packages ...${NC}"
sudo apt install -y \
build-essential cdbs devscripts equivs fakeroot \
git git-buildpackage git-lfs || exit 1
echo -e "${GREEN}==> Installing build tools packages, done.${NC}\n"
echo -e "${GREEN}==> Setting up build_changelog command ...${NC}"
sudo curl https://raw.githubusercontent.com/MrCyjaneK/waydroid-build/main/build_changelog \
-o /usr/bin/build_changelog || exit 1
sudo chmod +x ${_} || exit 1
echo -e "${GREEN}==> Setting up build_changelog command, done${NC}\n"
echo -e "${GREEN}==> Setting up build directory ...${NC}"
mkdir -p ~/waydroid-build/packages
cd ${_%/*}
echo -e "${GREEN}==> Setting up build directory, done${NC}\n"
repos=(
"https://github.com/sailfishos/libglibutil.git"
"https://github.com/mer-hybris/libgbinder.git"
"https://github.com/waydroid/gbinder-python.git"
"https://github.com/waydroid/waydroid.git"
)
for i in ${repos[@]}
do
url=${i}
i=${i%*.git}; i=${i##*\/}
echo -e "${GREEN}==========> Start preparing ${i} <==========${NC}"
echo -e "${GREEN}==> Cloning git repository ${i} ...${NC}"
[ -d ${i} ] && sudo rm -rf "${i}"
git clone "${url}" || exit 1
echo -e "${GREEN}==> Cloning git repository ${i}, done.${NC}\n"
cd "${i}"
echo 12 > debian/compat
if [ ! -f debian/changelog ]; then
echo -e "${GREEN}==> Building changelog ${i} ...${NC}"
build_changelog $(git tag -l --sort=authordate | sed 's/[a-z/]//g' | uniq | tail -n1) || exit 1
echo -e "${GREEN}==> Building changelog ${i}, done.${NC}\n"
fi
echo -e "${GREEN}==> Installing build dependencies for ${i} ...${NC}"
sudo mk-build-deps -ir -t "apt -o Debug::pkgProblemResolver=yes -y --no-install-recommends" || exit 1
echo -e "${GREEN}==> Installing build dependencies for ${i}, done.${NC}"
echo -e "${GREEN}==========> Finish preparing ${i} <==========${NC}\n"
echo -e "${GREEN}==========> Start building ${i} <==========${NC}"
echo -e "${GREEN}==> Building package(s): ${i} ...${NC}"
sudo debuild -b -uc -us
if [ ! $? -eq 0 ]
then
echo -e "\n${RED}==> Building package(s): ${i}, failed.${NC}\n"
exit 1
else
echo -e "${GREEN}==> Building package(s): ${i}, done.${NC}"
echo -e "${GREEN}==========> Finish building ${i} <==========${NC}\n"
cd ~/waydroid-build
echo -e "${GREEN}==========> Start installing ${i} <==========${NC}"
echo -e "${GREEN}==> Installing package(s): ${i} ...${NC}"
sudo dpkg -i *.deb
if [ ! $? -eq 0 ]
then
echo -e "${RED}==> Installing ${i}, error.${NC}"
echo -e "${GREEN}==> Trying to fix it ...${NC}"
sudo apt install -f -y || exit 1
echo -e "${GREEN}==> Fixed.${NC}"
fi
echo -e "${GREEN}==> Installing ${i}, success.${NC}"
echo -e "${GREEN}==> Installing package(s): ${i}, done.${NC}"
echo -e "${GREEN}==========> Finish installing ${i} <==========${NC}\n"
mv *.deb packages 2> /dev/null
mv *.ddeb packages 2> /dev/null
sudo rm -rf ${i}
fi
done
echo -e "${GREEN}==> Successfully build and installing all packages${NC}"
echo -e "${GREEN}==> Packages archive saved in $(realpath ~)/waydroid-build/packages/${NC}"
ls -1 ~/waydroid-build/packages/
echo
sudo rm -f ~/waydroid-build/*.* /usr/bin/build_changelog 2> /dev/null
@lindeer
Copy link

lindeer commented Mar 11, 2023

@SoulInfernoDE no, still failed with same issue...

@LUISMAGAIVER341
Copy link

for who uses ARM, you should not do this.
install waydroid with the common way.

@TMDevel89
Copy link

SOLVED some compiling error

If you have the problem "undefined reference to __atomic_load_8" or "undefined reference to __atomic_store_8" while compiling libgbinder use clang for it

sudo apt install clang llvm
# select clang
sudo update-alternatives --config cc
sudo update-alternatives --config c++

# it's also possible to use environment variables (not tested)
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

If you have syntax error while compiling gbinder-python, check if cython exist and if it's version supported

# check if cython exist
python3 -c "import cython; print(cython.__file__)"

# check cython version (min version 3.*.*)
python3 -c "import cython; print(cython.__version__)"

# if pip not installed
sudo apt install python3-pip
sudo python -m pip install --upgrade pip

# update cython
sudo pip3 install --ignore-installed --upgrade cython

@Kustale
Copy link

Kustale commented Jan 8, 2024

Hello, what should i do?

==========> Start building libglibutil <==========
==> Building package(s): libglibutil ...
dpkg-buildpackage -us -uc -ui -b
dpkg-buildpackage: info: source package libglibutil
dpkg-buildpackage: info: source version 1.0.75
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Slava Monich slava@monich.com
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture i386
debian/rules clean
dh clean
dh_auto_clean
make -j4 clean
make[1]: Enter directory '/home/kustale/waydroid-build/libglibutil'make -C test clean
make[2]: Entering directory '/home/kustale/waydroid-build/libglibutil/test' make[3]: Entering directory '/home/kustale/waydroid-build/libglibutil/test/test_datapack' make[3]: Warning : Job server cannot be used: Use -j1. Add '+' to the parent make rule.
make[3]: warning: jobserver not available: use -j1. Add '+' to the parent make rule.
make[3]: warning: jobserver not available: use -j1. Add '+' to the parent make rule.
../common/Makefile:110: *** Multi-target pattern. stoppage.
make[3]: exit directory '/home/kustale/waydroid-build/libglibutil/test/test_datapack' make[2]: *** [Makefile:5: clean] error 2
make[2]: exit directory '/home/kustale/waydroid-build/libglibutil/test' make[1]: *** [Makefile:166: clean] error 2
make[1]: Exiting directory '/home/kustale/waydroid-build/libglibutil' dh_auto_clean: error: make -j4 clean returned exit code 2
make: *** [debian/rules:16: clean] error 25
dpkg-buildpackage: error: debian/rules clean subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b failed

==> Building package(s): libglibutil, failed.

@Hoernchen
Copy link

Hoernchen commented Jan 11, 2024

Try DEB_BUILD_OPTIONS="parallel=1" debuild -b -uc -us
The automatic parallel build breaks.

@Kustale
Copy link

Kustale commented Jan 12, 2024

Try DEB_BUILD_OPTIONS="parallel=1" debuild -b -uc -us The automatic parallel build breaks.

Yes, I tried this and it worked.
However, other tasks are not completed.
So I directly received this script, opened it with an editor, modified it with -eDEB_BUILD_OPTIONS="parallel=1" after debuild, and it was done. (Found on the Internet. Hint in this article)
However, the conclusion was that waydroid failed to run.
When I ran waydroid init, an error occurred saying that gbinder was not found, and in waydroid-script, an error occurred saying that libhoudini does not work on this CPU.
The conclusion is that z3735f is difficult to drive.
Sad...

  • gbinder error fix.
    I just install anbox-modules. It works.
    but libhoudini is failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment