build-package.sh: support offline preinstalled build tools
First step of making possibility to have offline snapshots of 'termux-packages' repo. Useful for making full repo snapshots. That will allow to preinstall tools like Cmake, Go, Meson to directory stored within packages tree and will not be wiped when using ./clean.sh. Next steps will also implement offlining of the package sources and NDK standalone toolchain.
This commit is contained in:
parent
ae3e39f833
commit
be0b9e9331
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@
|
||||
Session.vim
|
||||
.netrwhist
|
||||
*~
|
||||
/build-tools/
|
||||
/debs/
|
||||
### Vagrant ###
|
||||
scripts/*.log
|
||||
|
@ -4,7 +4,13 @@ termux_setup_cmake() {
|
||||
local TERMUX_CMAKE_VERSION=$TERMUX_CMAKE_MAJORVESION.$TERMUX_CMAKE_MINORVERSION
|
||||
local TERMUX_CMAKE_TARNAME=cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64.tar.gz
|
||||
local TERMUX_CMAKE_TARFILE=$TERMUX_PKG_TMPDIR/$TERMUX_CMAKE_TARNAME
|
||||
local TERMUX_CMAKE_FOLDER=$TERMUX_COMMON_CACHEDIR/cmake-$TERMUX_CMAKE_VERSION
|
||||
local TERMUX_CMAKE_FOLDER
|
||||
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
TERMUX_CMAKE_FOLDER=$TERMUX_SCRIPTDIR/build-tools/cmake-$TERMUX_CMAKE_VERSION
|
||||
else
|
||||
TERMUX_CMAKE_FOLDER=$TERMUX_COMMON_CACHEDIR/cmake-$TERMUX_CMAKE_VERSION
|
||||
fi
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
if [ ! -d "$TERMUX_CMAKE_FOLDER" ]; then
|
||||
|
@ -3,8 +3,14 @@ termux_setup_ghc() {
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
local TERMUX_GHC_VERSION=8.10.1
|
||||
local TERMUX_GHC_TEMP_FOLDER="${TERMUX_COMMON_CACHEDIR}/ghc-${TERMUX_GHC_VERSION}"
|
||||
local TERMUX_GHC_RUNTIME_FOLDER="${TERMUX_COMMON_CACHEDIR}/ghc-${TERMUX_GHC_VERSION}-runtime"
|
||||
local TERMUX_GHC_TAR="${TERMUX_GHC_TEMP_FOLDER}.tar.xz"
|
||||
local TERMUX_GHC_RUNTIME_FOLDER
|
||||
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
TERMUX_GHC_RUNTIME_FOLDER="${TERMUX_SCRIPTDIR}/build-tools/ghc-${TERMUX_GHC_VERSION}-runtime"
|
||||
else
|
||||
TERMUX_GHC_RUNTIME_FOLDER="${TERMUX_COMMON_CACHEDIR}/ghc-${TERMUX_GHC_VERSION}-runtime"
|
||||
fi
|
||||
|
||||
export PATH="$TERMUX_GHC_RUNTIME_FOLDER/bin:$PATH"
|
||||
|
||||
|
@ -4,9 +4,15 @@ termux_setup_golang() {
|
||||
local TERMUX_GO_VERSION=go1.15.3
|
||||
local TERMUX_GO_PLATFORM=linux-amd64
|
||||
|
||||
local TERMUX_BUILDGO_FOLDER=$TERMUX_COMMON_CACHEDIR/${TERMUX_GO_VERSION}
|
||||
local TERMUX_BUILDGO_FOLDER
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
TERMUX_BUILDGO_FOLDER=${TERMUX_SCRIPTDIR}/build-tools/${TERMUX_GO_VERSION}
|
||||
else
|
||||
TERMUX_BUILDGO_FOLDER=${TERMUX_COMMON_CACHEDIR}/${TERMUX_GO_VERSION}
|
||||
fi
|
||||
|
||||
export GOROOT=$TERMUX_BUILDGO_FOLDER
|
||||
export PATH=$GOROOT/bin:$PATH
|
||||
export PATH=${GOROOT}/bin:${PATH}
|
||||
|
||||
if [ -d "$TERMUX_BUILDGO_FOLDER" ]; then return; fi
|
||||
|
||||
|
@ -1,7 +1,14 @@
|
||||
termux_setup_meson() {
|
||||
termux_setup_ninja
|
||||
local MESON_VERSION=0.55.0
|
||||
local MESON_FOLDER=$TERMUX_COMMON_CACHEDIR/meson-$MESON_VERSION-v1
|
||||
local MESON_FOLDER
|
||||
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
MESON_FOLDER=${TERMUX_SCRIPTDIR}/build-tools/meson-${MESON_VERSION}
|
||||
else
|
||||
MESON_FOLDER=${TERMUX_COMMON_CACHEDIR}/meson-${MESON_VERSION}
|
||||
fi
|
||||
|
||||
if [ ! -d "$MESON_FOLDER" ]; then
|
||||
local MESON_TAR_NAME=meson-$MESON_VERSION.tar.gz
|
||||
local MESON_TAR_FILE=$TERMUX_PKG_TMPDIR/$MESON_TAR_NAME
|
||||
|
@ -1,6 +1,12 @@
|
||||
termux_setup_ninja() {
|
||||
local NINJA_VERSION=1.10.0
|
||||
local NINJA_FOLDER=$TERMUX_COMMON_CACHEDIR/ninja-$NINJA_VERSION
|
||||
local NINJA_FOLDER
|
||||
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
NINJA_FOLDER=${TERMUX_SCRIPTDIR}/build-tools/ninja-${NINJA_VERSION}
|
||||
else
|
||||
NINJA_FOLDER=${TERMUX_COMMON_CACHEDIR}/ninja-$NINJA_VERSION
|
||||
fi
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
if [ ! -x "$NINJA_FOLDER/ninja" ]; then
|
||||
|
@ -1,7 +1,13 @@
|
||||
termux_setup_protobuf() {
|
||||
local _PROTOBUF_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/libprotobuf/build.sh; echo \${TERMUX_PKG_VERSION:2}")
|
||||
local _PROTOBUF_ZIP=protoc-$_PROTOBUF_VERSION-linux-x86_64.zip
|
||||
local _PROTOBUF_FOLDER=$TERMUX_COMMON_CACHEDIR/protobuf-$_PROTOBUF_VERSION
|
||||
local _PROTOBUF_FOLDER
|
||||
|
||||
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
|
||||
_PROTOBUF_FOLDER=${TERMUX_SCRIPTDIR}/build-tools/protobuf-${_PROTOBUF_VERSION}
|
||||
else
|
||||
_PROTOBUF_FOLDER=${TERMUX_COMMON_CACHEDIR}/protobuf-${_PROTOBUF_VERSION}
|
||||
fi
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
if [ ! -d "$_PROTOBUF_FOLDER" ]; then
|
||||
|
@ -14,7 +14,7 @@ termux_download() {
|
||||
fi
|
||||
|
||||
local TMPFILE
|
||||
TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.$TERMUX_PKG_NAME.XXXXXXXXX")
|
||||
TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.${TERMUX_PKG_NAME-unnamed}.XXXXXXXXX")
|
||||
echo "Downloading ${URL}"
|
||||
if curl --fail --retry 20 --retry-connrefused --retry-delay 30 --location --output "$TMPFILE" "$URL"; then
|
||||
local ACTUAL_CHECKSUM
|
||||
|
49
scripts/setup-offline-bundle.sh
Executable file
49
scripts/setup-offline-bundle.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
##
|
||||
## Download and install all build tools whether applicable now, so
|
||||
## they will be available later for offline use.
|
||||
##
|
||||
|
||||
set -e -u
|
||||
|
||||
if [ "$(uname -o)" = "Android" ] || [ "$(uname -m)" != "x86_64" ]; then
|
||||
echo "This script supports only x86_64 GNU/Linux systems."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export TERMUX_SCRIPTDIR="$(dirname "$(readlink -f "$0")")/../"
|
||||
mkdir -p "$TERMUX_SCRIPTDIR"/build-tools
|
||||
|
||||
export TERMUX_PACKAGES_OFFLINE=true
|
||||
export TERMUX_ARCH=aarch64
|
||||
export TERMUX_ON_DEVICE_BUILD=false
|
||||
export TERMUX_PKG_TMPDIR=$TERMUX_SCRIPTDIR/build-tools/_tmp
|
||||
export TERMUX_COMMON_CACHEDIR=$TERMUX_PKG_TMPDIR
|
||||
export CC=gcc CXX=g++ LD=ld AR=ar STRIP=strip PKG_CONFIG=pkg-config
|
||||
export CPPFLAGS="" CFLAGS="" CXXFLAGS="" LDFLAGS=""
|
||||
mkdir -p "$TERMUX_PKG_TMPDIR"
|
||||
|
||||
. "$TERMUX_SCRIPTDIR"/scripts/build/termux_download.sh
|
||||
(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_cmake.sh
|
||||
termux_setup_cmake
|
||||
)
|
||||
# GHC fails. Skipping for now.
|
||||
#(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_ghc.sh
|
||||
# termux_setup_ghc
|
||||
#)
|
||||
(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_golang.sh
|
||||
termux_setup_golang
|
||||
)
|
||||
(
|
||||
. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_ninja.sh
|
||||
. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_meson.sh
|
||||
termux_setup_meson
|
||||
)
|
||||
(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_protobuf.sh
|
||||
termux_setup_protobuf
|
||||
)
|
||||
# Offline rust is not supported yet.
|
||||
#(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_rust.sh
|
||||
# termux_setup_rust
|
||||
#)
|
||||
rm -rf "${TERMUX_PKG_TMPDIR}"
|
Loading…
Reference in New Issue
Block a user