-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Building packages
Once you have properly configured
the build environment, you may start to build packages. Build is started by
executing script build-package.sh
located at the root of termux-packages
repository with passing package name as argument.
Example of building package bash
for architecture arm
:
./build-package.sh -a arm bash
Of you need to build several packages, specify them all on command line. Example:
./build-package.sh bash coreutils htop
Script build-package.sh
accepts several options that affect build behaviour.
-
-a
- The architecture to build for. Accepted values are: aarch64, arm, i686, x86_64. Default isaarch64
. For on-device builds architecture is determined automatically and this option is not available. -
-d
- Build with debug information and turn of compiler optimizations. -
-D
- Build disabled package, i.e. located in directory./disabled-packages
. -
-f
- Force build package even if it already built or installed. -
-i
- Download dependencies instead of building them. Erases data inTERMUX_PREFIX
before starting build. Not available for on-device builds. -
-I
- Download dependencies instead of building them. Unlike option above, this one does not erase data in$TERMUX_PREFIX
and available for on-device builds. -
-q
- Pass necessary arguments tomake
or similar tool to make build quiet. May not work for all packages. -
-s
- Skip dependency check. -
-o
- Specify directory where to place built *.deb files. Default is./debs
.
Build starts at the moment of execution of ./build-package.sh
script and is
split into the following stages (environment initialization steps are omitted):
-
Source the
./packages/$TERMUX_PACKAGE_NAME/build.sh
to obtain metadata such like version, description, dependencies, source URL and package-specific build steps. -
In case if
build-package.sh
got arguments-i
or-I
, download *.deb files from APT repository and extract to$TERMUX_PREFIX
.Otherwise obtain the dependency build order from script
./scripts/buildorder.py
and execute./build-package.sh
with argument-s
for each dependency package. -
Create timestamp file which will be used later.
-
Download package's source code from the URL and verify its SHA-256 checksum. Then extract source code to
$TERMUX_PKG_SRCDIR
. This step is omitted if$TERMUX_PKG_SKIP_SRC_EXTRACT
is set. -
Build package for the host. This step is performed only when
TERMUX_PKG_HOSTBUILD
is set. -
Set up a standalone Android NDK toolchain and apply NDK sysroot patches. This step is performed only one time.
-
Search for patches in
./packages/$TERMUX_PKG_NAME/*.patch
and apply them. -
Configure and compile source code for specified
$TERMUX_ARCH
. -
Install everything into
$TERMUX_PREFIX
. -
Determine files which are modified from time when timestamp file was created (step 3) and extract them into
$TERMUX_TOPDIR/$TERMUX_PKG_NAME/massage
. -
Strip binaries (if non-debug build), gzip manpages, delete unwanted files and fix permissions. Distribute files between subpackages if needed.
-
Archive package data into *.deb files ready for distribution.
Order specifies function sequence. 0 order specifies utility functions.
Suborder specifies a function triggered by the main function. Functions with different suborders are not executed simultaneously.
Order | Function Name | Overridable | Description |
---|---|---|---|
0.1 | termux_error_exit |
no | Stop script and output error. |
0.2 | termux_download |
no | Utility function to download any file. |
0.3 | termux_setup_golang |
no | Setup Go Build environment. |
0.4 | termux_setup_cmake |
no | Setup CMake configure system. |
0.5 | termux_setup_ninja |
no | Setup Ninja make system. |
0.6 | termux_setup_meson |
no | Setup Meson configure system. |
0.7 | termux_setup_protobuf |
no | Setup Protobuf compiler. |
0.8 | termux_setup_rust |
no | Setup Cargo Build. |
1 | termux_step_setup_variables |
no | Setup essential variables like directory locations and flags. |
2 | termux_step_handle_buildarch |
no | Determine architecture to build for. |
3 | termux_step_start_build |
no | Initialize build environment. Source package's build.sh . |
4 | termux_step_get_repo_files |
no | Fetch APT packages information when -i or -I option was supplied. |
5 | termux_extract_dep_info |
no | Obtain package architecture and version for downloading. |
5.1 | termux_download_deb |
no | Download dependency *.deb packages for installation. |
6 | termux_step_get_source |
yes | Obtain package source code and put it in $TERMUX_PKG_SRCDIR . |
6.1 | termux_git_clone_src |
no | Obtain source by git clone, is run if $TERMUX_PKG_SRCURL ends with ".git". |
6.2 | termux_download_src_archive |
no | Download zip or tar archive with package source code. |
6.3 | termux_unpack_src_archive |
no | Extract downloaded archive into $TERMUX_PKG_SRCDIR . |
7 | termux_step_post_get_source |
yes | Hook to run commands immediately after obtaining source code. |
8 | termux_step_handle_host_build |
yes | Determine whether a host build is required. |
8.1 | termux_step_host_build |
yes | Perform a host build. |
9 | termux_step_setup_toolchain |
no | Setup NDK standalone toolchain. |
10 | termux_step_patch_package |
no | Apply to source code all *.patch files located in package's directory. |
11 | termux_step_replace_guess_scripts |
no | Replace config.sub and config.guess scripts. |
12 | termux_step_pre_configure |
yes | Hook to run commands before source configuration. |
13 | termux_step_configure |
yes | Configure sources. By default, it determines build system automatically. |
13.1 | termux_step_configure_autotools |
no | Autotools build configuration. |
13.2 | termux_step_configure_cmake |
no | CMake build configuration. |
13.3 | termux_step_configure_meson |
no | Meson build configuration. |
14 | termux_step_post_configure |
yes | Hook to run commands immediately after configuration. |
15 | termux_step_make |
yes | Compile the source code. |
16 | termux_step_make_install |
yes | Install the compiled artifacts. |
17 | termux_step_post_make_install |
yes | Hook to run commands immediately after installation. |
18 | termux_step_install_service_scripts |
yes | Installs scripts for termux-services |
19 | termux_step_install_license |
yes | Link or copy package-specific LICENSE to ./share/doc/$TERMUX_PKG_NAME . |
20 | termux_step_extract_into_massagedir |
no with make_install
|
Extract files modified in $TERMUX_PREFIX . |
21 | termux_step_massage |
no | Strip binaries, remove unneeded files. |
21.1 | termux_create_subpackages |
no | Creates all subpackages. |
22 | termux_step_post_massage |
yes | Final hook before creating *.deb file(s). |
23 | termux_step_create_datatar |
no | Archive package files. |
24 | termux_step_create_debfile |
no | Create *.deb package. |
24.1 | termux_step_create_debscripts |
yes | Create maintainer scripts, e.g. pre/post installation hooks. |
25 | termux_step_finish_build |
no | Notification of finish. |