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
@suoko
Copy link

suoko commented Jun 11, 2022

==> Installing build dependencies for libglibutil ...
dpkg-buildpackage: info: source package libglibutil-build-deps
dpkg-buildpackage: info: source version 1.0.64
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Equivs Dummy Package Generator <root@ubu>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
 debian/rules clean
dh clean
   dh_clean
error: Found argument '-r' which wasn't expected, or isn't valid in this context

USAGE:
    fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

For more information try --help
dh_clean: error: find .  \( \( \
                \( -path .\*/.git -o -path .\*/.svn -o -path .\*/.bzr -o -path .\*/.hg -o -path .\*/CVS -o -path .\*/.pc -o -path .\*/_darcs \) -prune -o -type f -a \
                \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
                 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
                 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
                 -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
                \) -exec rm -f {} + \) -o \
                \( -type d -a -name autom4te.cache -prune -exec rm -rf {} + \) \) returned exit code 1
make: *** [debian/rules:3: clean] Error 1
dpkg-buildpackage: error: debian/rules clean subprocess returned exit status 2
Error in the build process: exit status 2
dpkg: error: cannot access archive 'libglibutil-build-deps_1.0.64_all.deb': No such file or directory
mk-build-deps: dpkg --unpack failed

@cniw
Copy link
Author

cniw commented Jun 11, 2022

error: Found argument '-r' which wasn't expected, or isn't valid in this context

USAGE:
fd [FLAGS/OPTIONS] [] [...]

For more information try --help
dh_clean: error: find . ( ( \

@suoko I guess it's because you're using the fd command instead of ordinary find maybe use alias or something like that but the -r option doesn't provided in the fd command, so please try to unset their alias.

notes: same with https://gist.github.com/cniw/7a0220ce8b75368f7f57aa422d3fea97?permalink_comment_id=4197198#gistcomment-4197198

@SoulInfernoDE
Copy link

SoulInfernoDE commented Oct 24, 2022

Extract of libglibutil-build-deps (1.0.67) ...
E: Option -o needs an argument.

Fixed it by replacing line 65:
apt -o Debug:

with
apt-get -o Debug:

But still throws some more errors:

dwz: debian/libglibutil/usr/lib/x86_64-linux-gnu/libglibutil.so.1.0.67: .debug_info section not present

and

Now running lintian libglibutil_1.0.67_amd64.changes ...
running with root privileges is not recommended!
E: libglibutil changes: bad-distribution-in-changes-file unstable
E: libglibutil: extended-description-is-empty
E: libglibutil-dev: extended-description-is-empty
E: libglibutil: latest-changelog-entry-without-new-date
E: libglibutil-dev: latest-changelog-entry-without-new-date
E: libglibutil: ldconfig-symlink-referencing-wrong-file usr/lib/x86_64-linux-gnu/libglibutil.so.1 -> libglibutil.so.1.0 instead of libglibutil.so.1.0.67
W: libglibutil: package-name-doesnt-match-sonames libglibutil1
``

My Distro is linux mint 21 vanessa (which is ubuntu based 22.04 jammy)

@mkondratek
Copy link

On raspbian fails at libglibutil build 😕 this is the tail of the build output:

make[1]: Entering directory '/home/pi/waydroid-build/libglibutil'
dh_auto_install -- LIBDIR=usr/lib/arm-linux-gnueabihf install-dev
	make -j4 install DESTDIR=/home/pi/waydroid-build/libglibutil/debian/tmp AM_UPDATE_INFO_DIR=no "INSTALL=install --strip-program=true" LIBDIR=usr/lib/arm-linux-gnueabihf install-dev
make[2]: Entering directory '/home/pi/waydroid-build/libglibutil'
install --strip-program=true -d /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf
install --strip-program=true -d /home/pi/waydroid-build/libglibutil/debian/tmp/usr/include/gutil
install --strip-program=true -d /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf/pkgconfig
install: install: WARNING: ignoring --strip-program option as -s option was not specified
WARNING: ignoring --strip-program option as -s option was not specified
install --strip-program=true -m 755 build/release/libglibutil.so.1.0.67 /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf
install: WARNING: ignoring --strip-program option as -s option was not specified
install: WARNING: ignoring --strip-program option as -s option was not specified
ln -sf libglibutil.so.1.0.67 /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf/libglibutil.so.1.0
ln -sf libglibutil.so.1.0 /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf/libglibutil.so.1
install --strip-program=true -m 644 include/*.h /home/pi/waydroid-build/libglibutil/debian/tmp/usr/include/gutil
install: WARNING: ignoring --strip-program option as -s option was not specified
install --strip-program=true -m 644 build/libglibutil.pc /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf/pkgconfig
install: WARNING: ignoring --strip-program option as -s option was not specified
ln -sf libglibutil.so.1 /home/pi/waydroid-build/libglibutil/debian/tmp/usr/lib/arm-linux-gnueabihf/libglibutil.so
make[2]: Leaving directory '/home/pi/waydroid-build/libglibutil'
make[1]: Leaving directory '/home/pi/waydroid-build/libglibutil'
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_dwz
dwz: debian/libglibutil/usr/lib/arm-linux-gnueabihf/libglibutil.so.1.0.67: .debug_info section not present
dh_dwz: error: dwz -- debian/libglibutil/usr/lib/arm-linux-gnueabihf/libglibutil.so.1.0.67 returned exit code 1
make: *** [debian/rules:16: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b failed

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

any ideas? 🙏

@lindeer
Copy link

lindeer commented Mar 7, 2023

same issue with @mkondratek

@SoulInfernoDE
Copy link

If you change apt to apt-get in every line in the script does it go further for you?

@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