Files and directories available inside build environment:
./debs- directory where built packages will be placed. Does not exist by default.
./disabled-packages- directory with packages excluded from main build tree due to various reasons.
./ndk-patches- directory with patches for Android NDK sysroot.
./packages- directory where all packages (scripts and patches) are located.
./sample- sample structure for creating new package.
./scripts- internal parts of build system and some utility scripts.
./build-all.sh- script for building all available packages.
./build-package.sh- script for building one or more packages.
./clean.sh- script for cleaning build environment.
Using official Docker image is a recommended way for building Termux packages which ensures that you have same environment as Termux maintainers and therefore builds are reproducible.
If you have Docker installed and running, then launching build environment should be as simple as running
Wait until latest image will be downloaded and then container's shell prompt
should appear. The
termux-packages folder will be mounted as
You may execute commands inside container without launching interactive shell
by supplying them as arguments to
./scripts/run-docker.sh ./build-package.sh libandroid-support
Sometimes Docker image should be updated. Following command will update image and delete outdated container:
Building own Docker image
Dockerfile is located
./scripts/ directory and configured to build Ubuntu-based image.
To build the Docker image, execute following commands:
cd ./scripts docker build -t termux/package-builder .
If you are getting error like
-bash: /tmp/setup-ubuntu.sh: Permission denied,
make sure that all
*.sh files have permission
umask is 0022.
Docker on Windows
For Windows users there is a PowerShell script available:
You can have multiple containers running in parallel. Just set different container name as environment variable:
Using unofficial Docker image.
You can use a custom Docker image as environment variable
TERMUX_BUILDER_IMAGE_NAME, but it also recommended to set a custom name for the container (like above):
export TERMUX_BUILDER_IMAGE_NAME=username/termux-custom-builder export CONTAINER_NAME=custom-builder1 ./scripts/run-docker.sh
There is a Vagrantfile for setting up a VirtualBox Ubuntu installation.
vagrant plugin install vagrant-disksizeto install disksize plugin for Vagrant.
cd scripts && vagrant upto setup and launch the virtual machine.
vagrant sshto ssh into the virtual machine.
We have scripts that automate installation of packages used in build process.
For now only Ubuntu and Arch Linux distributions are supported. Note that all
scripts execute commands under
For Arch Linux:
Additionally you will need to install Android SDK and NDK. By default, it
is expected that both SDK and NDK are installed into
$HOME/lib, so it is
recommended to use following script to properly setup them:
Our build system can be used to build packages on device. Though with some limitations as our build scripts expect that utilities used at run time available outside of Termux prefix (sysroot).
Warning: devices on which
termux-exec is not working are unsupported !
If you wish to use your Termux installation, execute the following command inside
the root directory of cloned
Note that files generated in build process are installed to
$PREFIX and are
not tracked by package manager. It also highly recommended to backup both
$PREFIX before building any package.
Changing default behaviour
Following environment variables affect behaviour of Termux build system:
TERMUX_TOPDIR- Specifies the base directory for Termux build environment. Standalone toolchain, downloaded sources, package build directories will be created here. Default is
TERMUX_PREFIX- Specifies path to Termux system root. Default is
/data/data/com.termux/files/usr. Cannot be changed when building on device.
TERMUX_ANDROID_HOME- Specifies path to Termux home directory. Default is
/data/data/com.termux/files/home. Cannot be changed when building on device.
TERMUX_MAKE_PROCESSES- Specifies amount of jobs that should be spawned by utility
make. Default is output of command
TERMUX_PKG_API_LEVEL- Specifies Android API level against which packages will be compiled. Default is 24 for branch "master" and 21 for branch "android-5".
TERMUX_PKG_MAINTAINER- Specifies a value that should be written to package's maintainer field. Default is
Fredrik Fornwall @fornwall.
TERMUX_PACKAGES_DIRECTORIES- Specifies a root directory of package tree. Default is
These variables are overridden with arguments
TERMUX_ARCH- Specifies CPU architecture for which packages should be cross-compiled. Default is
aarch64. Cannot be changed when building on device.
TERMUX_DEBUG- Perform debug build. Debug information won't be stripped from binaries and compiler optimizations will be turned off.
TERMUX_INSTALL_DEPS- If set to
true, then dependencies will be installed from the APT repository rather than built.
TERMUX_NO_CLEAN- Special option for use with
TERMUX_INSTALL_DEPS. If set to
true, then Termux system root will not be wiped before extracting dependencies. When building on device, this variable should be always
TERMUX_QUIET_BUILD- If set, additional arguments will be passed to utility
maketo reduce output in compilation process.
TERMUX_SKIP_DEPCHECK- If set, then no dependency checks will be done.
TERMUX_DEBDIR- Path to directory where built
*.debfiles will be placed.
Custom default values for environment variables can be set through file
Important note about Termux prefix
In Termux, prefix is equivalent of the root file system on Linux distributions.
If you decided to change
$TERMUX_PREFIX, you are on your own. It is not
possible to mix packages from different prefixes as changing one assumes that
compiled packages will never be used in a Termux environment.
Those who decided to change
$TERMUX_PREFIX should change
as well to avoid path problems.