Skip to content

Build Script Reference

djunekz edited this page Apr 10, 2026 · 2 revisions

Build Script Reference

Complete reference for all variables available in build.sh.


Required Variables

Variable Type Description
TERMUX_PKG_HOMEPAGE URL Homepage or repository of the tool
TERMUX_PKG_DESCRIPTION String Short description (max 80 characters)
TERMUX_PKG_LICENSE String SPDX identifier: MIT, GPL-3.0, Apache-2.0, etc.
TERMUX_PKG_MAINTAINER String Format: @github-username
TERMUX_PKG_VERSION Version Must start with a digit: 1.0.0, 2.1.4
TERMUX_PKG_SRCURL URL Download URL for the source archive
TERMUX_PKG_SHA256 64-char hex SHA256 hash of the file at SRCURL

Optional Variables

Variable Type Description
TERMUX_PKG_DEPENDS String Runtime dependencies (comma-separated)
TERMUX_PKG_BUILD_DEPENDS String Build-only dependencies
TERMUX_PKG_RECOMMENDS String Optional recommended dependencies
TERMUX_PKG_CONFLICTS String Packages that conflict
TERMUX_PKG_REPLACES String Packages this replaces
TERMUX_PKG_SRCDIR String Directory name after extracting the source
TERMUX_PKG_BUILD_IN_SRC Boolean true = build inside the source directory
TERMUX_PKG_MIN_TERMUX_VERSION String Minimum required Termux version

Variable Substitution

You can reference other variables within values:

TERMUX_PKG_VERSION="1.2.4"
TERMUX_PKG_SRCURL="https://github.com/user/tool/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz"

Custom Build Steps

Override the default build behavior with bash functions:

# Runs before the default configure step
termux_step_pre_configure() {
    # custom pre-configure logic
}

# Handles the full install — override for custom install logic
termux_step_make_install() {
    pip install --prefix="$TERMUX_PREFIX" . --break-system-packages
    # or
    npm install -g --prefix="$TERMUX_PREFIX" .
    # or
    install -Dm755 mybinary "$TERMUX_PREFIX/bin/mytool"
}

# Runs after install completes
termux_step_post_make_install() {
    # custom post-install logic
}

Environment Variables Available in build.sh

Variable Value
$TERMUX_PREFIX /data/data/com.termux/files/usr
$TERMUX_HOME /data/data/com.termux/files/home
$TERMUX_ARCH aarch64, arm, x86_64, or i686
$TERMUX_PKG_BUILDDIR Temporary build directory
$TERMUX_PKG_SRCDIR Source directory after extraction

Version Format Rules

Valid formats:

1.0.0
2.3.4
0.1-alpha
3.1.4-rc2

Invalid formats:

v1.2.3      (no v prefix)
latest      (must be a number)
T.G.D-1.0   (must start with a digit)

Recognized Licenses

MIT, GPL-2.0, GPL-3.0, LGPL-2.1, LGPL-3.0,
Apache-2.0, BSD-2-Clause, BSD-3-Clause,
ISC, MPL-2.0, AGPL-3.0, Unlicense, CC0-1.0

For custom licenses, use custom or custom;<license-name>.


Example: Minimal build.sh

TERMUX_PKG_HOMEPAGE=https://github.com/user/tool
TERMUX_PKG_DESCRIPTION="A short description of the tool"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@your-github-username"
TERMUX_PKG_VERSION=1.0.0
TERMUX_PKG_SRCURL=https://github.com/user/tool/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=abc123def456...

Example: Python Script with Custom Install

TERMUX_PKG_HOMEPAGE=https://github.com/author/mytool
TERMUX_PKG_DESCRIPTION="My Python tool for Termux"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@author"
TERMUX_PKG_VERSION=2.0.0
TERMUX_PKG_SRCURL=https://github.com/author/mytool/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=abc123...
TERMUX_PKG_DEPENDS="python, python-pip"
TERMUX_PKG_BUILD_IN_SRC=true

termux_step_make_install() {
    pip install -r requirements.txt --break-system-packages 2>/dev/null || true
    local libdir="$TERMUX_PREFIX/lib/mytool"
    mkdir -p "$libdir"
    cp -r . "$libdir/"
    cat > "$TERMUX_PREFIX/bin/mytool" <<'WRAPPER'
#!/usr/bin/env bash
exec python3 "$TERMUX_PREFIX/lib/mytool/main.py" "$@"
WRAPPER
    chmod 0755 "$TERMUX_PREFIX/bin/mytool"
}

See Also

Clone this wiki locally