setup-offline-bundle.sh: add support for downloading package sources

This commit is contained in:
Leonid Pliushch 2020-10-23 00:27:56 +03:00
parent 468ae7cc1e
commit 195314fe20
3 changed files with 60 additions and 7 deletions

16
.gitignore vendored
View File

@ -1,12 +1,20 @@
### Vim ###
# Vim
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
/build-tools/
/debs/
### Vagrant ###
# Vagrant
scripts/*.log
scripts/.vagrant/
# Built *.deb files.
/debs/
# Preinstalled build tools.
/build-tools/
# Predownloaded packages sources.
/packages/*/cache

View File

@ -96,8 +96,14 @@ termux_step_setup_variables() {
export prefix=${TERMUX_PREFIX}
export PREFIX=${TERMUX_PREFIX}
if [ "${TERMUX_PACKAGES_OFFLINE-false}" = "true" ]; then
# In "offline" mode store/pick cache from directory with
# build.sh script.
TERMUX_PKG_CACHEDIR=$TERMUX_PKG_BUILDER_DIR/cache
else
TERMUX_PKG_CACHEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/cache
fi
TERMUX_PKG_BUILDDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/build
TERMUX_PKG_CACHEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/cache
TERMUX_PKG_MASSAGEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/massage
TERMUX_PKG_PACKAGEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/package
TERMUX_PKG_SRCDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/src

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
##
## Download and install all build tools whether applicable now, so
## they will be available later for offline use.
## Download all package sources and install all build tools whether possible,
## so they will be available offline.
##
set -e -u
@ -23,6 +23,7 @@ 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"
# Build tools.
. "$TERMUX_SCRIPTDIR"/scripts/build/termux_download.sh
(. "$TERMUX_SCRIPTDIR"/scripts/build/setup/termux_setup_cmake.sh
termux_setup_cmake
@ -47,3 +48,41 @@ mkdir -p "$TERMUX_PKG_TMPDIR"
# termux_setup_rust
#)
rm -rf "${TERMUX_PKG_TMPDIR}"
(test -d "$TERMUX_SCRIPTDIR"/build-tools/android-sdk && test -d "$TERMUX_SCRIPTDIR"/build-tools/android-ndk && exit 0
"$TERMUX_SCRIPTDIR"/scripts/setup-android-sdk.sh
)
# Package sources.
for p in "$TERMUX_SCRIPTDIR"/packages/*; do
(
. "$TERMUX_SCRIPTDIR"/scripts/properties.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_step_get_source.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_git_clone_src.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_download_src_archive.sh
. "$TERMUX_SCRIPTDIR"/scripts/build/get_source/termux_unpack_src_archive.sh
TERMUX_PKG_NAME=$(basename "$p")
TERMUX_PKG_CACHEDIR="${p}/cache"
TERMUX_PKG_METAPACKAGE=false
# Set some variables to dummy values to avoid errors.
TERMUX_PKG_TMPDIR="${TERMUX_PKG_CACHEDIR}/.tmp"
TERMUX_PKG_SRCDIR="${TERMUX_PKG_CACHEDIR}/.src"
TERMUX_PREFIX=/data/data/com.termux/files/usr
TERMUX_ANDROID_HOME=/data/data/com.termux/files/home
TERMUX_HOST_PLATFORM=aarch64-linux-android
TERMUX_ARCH_BITS=64
mkdir -p "$TERMUX_PKG_CACHEDIR" "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR"
cd "$TERMUX_PKG_CACHEDIR"
. "${p}"/build.sh
${TERMUX_PKG_METAPACKAGE} && continue
echo "Downloading sources for '$TERMUX_PKG_NAME'..."
termux_step_get_source
# Delete dummy src and tmp directories.
rm -rf "$TERMUX_PKG_TMPDIR" "$TERMUX_PKG_SRCDIR"
)
done