X-Git-Url: https://git.distorted.org.uk/~mdw/termux-packages/blobdiff_plain/9683c9710d67ec5933f5ff5e9ce570e094b690b3..bf9c34a502a17a693e45a512ac2e2140674eefca:/build-package.sh diff --git a/build-package.sh b/build-package.sh index db2adcf4..79222ee4 100755 --- a/build-package.sh +++ b/build-package.sh @@ -8,6 +8,10 @@ termux_error_exit() { exit 1 } +if [ `uname -o` = Android ]; then + termux_error_exit "On-device builds are not supported - see README.md" +fi + # Utility function to download a resource, optionally checking against a checksum. termux_download() { local URL="$1" @@ -83,7 +87,7 @@ termux_setup_golang() { rm -Rf "$TERMUX_COMMON_CACHEDIR/go" "$TERMUX_BUILDGO_FOLDER" termux_download https://storage.googleapis.com/golang/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz \ "$TERMUX_BUILDGO_TAR" \ - de874549d9a8d8d8062be05808509c09a88a248e77ec14eb77453530829ac02b + de874549d9a8d8d8062be05808509c09a88a248e77ec14eb77453530829ac02b ( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" ) } @@ -159,8 +163,8 @@ termux_setup_meson() { # Utility function to setup a current cmake build system termux_setup_cmake() { - local TERMUX_CMAKE_MAJORVESION=3.9 - local TERMUX_CMAKE_MINORVERSION=5 + local TERMUX_CMAKE_MAJORVESION=3.10 + local TERMUX_CMAKE_MINORVERSION=1 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 @@ -168,7 +172,7 @@ termux_setup_cmake() { if [ ! -d "$TERMUX_CMAKE_FOLDER" ]; then termux_download https://cmake.org/files/v$TERMUX_CMAKE_MAJORVESION/$TERMUX_CMAKE_TARNAME \ "$TERMUX_CMAKE_TARFILE" \ - bbe7e2ea703835661bb92fedd485d62dc587ee36daaedaa0a7bebcbf937a1cea + f0f84761a254324ed9076c23fca502eb135ec49c0b752212a6298f317d303438 rm -Rf "$TERMUX_PKG_TMPDIR/cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64" tar xf "$TERMUX_CMAKE_TARFILE" -C "$TERMUX_PKG_TMPDIR" mv "$TERMUX_PKG_TMPDIR/cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64" \ @@ -254,8 +258,8 @@ termux_step_setup_variables() { : "${TERMUX_ANDROID_HOME:="/data/data/com.termux/files/home"}" : "${TERMUX_DEBUG:=""}" : "${TERMUX_PKG_API_LEVEL:="21"}" - : "${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="26.0.1"}" - : "${TERMUX_NDK_VERSION:="15.2"}" + : "${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="27.0.1"}" + : "${TERMUX_NDK_VERSION:="16"}" if [ "x86_64" = "$TERMUX_ARCH" ] || [ "aarch64" = "$TERMUX_ARCH" ]; then TERMUX_ARCH_BITS=64 @@ -364,7 +368,7 @@ termux_step_start_build() { TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}" # Bump the below version if a change is made in toolchain setup to ensure # that everyone gets an updated toolchain: - TERMUX_STANDALONE_TOOLCHAIN+="-v14" + TERMUX_STANDALONE_TOOLCHAIN+="-v3" if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH" @@ -472,13 +476,12 @@ termux_step_extract_package() { folder=`unzip -qql "$file" | head -n1 | tr -s ' ' | cut -d' ' -f5-` rm -Rf $folder unzip -q "$file" + mv $folder "$TERMUX_PKG_SRCDIR" else - folder=`tar tf "$file" | head -1 | sed 's/^.\///' | sed -e 's/\/.*//'` - rm -Rf $folder - tar xf "$file" + mkdir "$TERMUX_PKG_SRCDIR" + tar xf "$file" -C "$TERMUX_PKG_SRCDIR" --strip-components=1 fi set -o pipefail - mv $folder "$TERMUX_PKG_SRCDIR" } # Hook for packages to act just after the package has been extracted. @@ -571,12 +574,12 @@ termux_step_setup_toolchain() { if [ "$TERMUX_PKG_CLANG" = "no" ]; then CFLAGS+=" -Os" else - if [ "$TERMUX_PKG_NAME" = "ruby" -a "$TERMUX_ARCH" = arm ]; then - # This exception is to avoid a broken ruby on 32-bit arm - # with NDK r15c and ruby 2.4.2 - see #1520. - CFLAGS+=" -O1" + # -Oz seems good for clang, see https://github.com/android-ndk/ndk/issues/133. + # However, on arm it has a lot of issues such as #1520, #1680, #1765 and + # https://bugs.llvm.org/show_bug.cgi?id=35379, so use so use -Os there for now: + if [ $TERMUX_ARCH = arm ]; then + CFLAGS+=" -Os" else - # -Oz seems good for clang, see https://github.com/android-ndk/ndk/issues/133 CFLAGS+=" -Oz" fi fi @@ -664,13 +667,15 @@ termux_step_setup_toolchain() { patch --silent -p1; done # elf.h: Taken from glibc since the elf.h in the NDK is lacking. - # sysexits.h: Header-only and used by a few programs. # ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now. - cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h,libintl.h} usr/include + cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,ifaddrs.h,libintl.h} usr/include # Remove from the NDK in favour of that from the libandroid-shmem. - # Also remove as it doesn't work for non-root. - rm usr/include/sys/{shm.h,sem.h} + # Remove as it doesn't work for non-root. + # Remove as we currently provide it from libandroid-support. + # Remove as we currently provide it from libandroid-glob. + # Remove as it's only for future (later than android-27). + rm usr/include/sys/{shm.h,sem.h} usr/include/{iconv.h,glob.h,spawn.h} sed -i "s/define __ANDROID_API__ __ANDROID_API_FUTURE__/define __ANDROID_API__ $TERMUX_PKG_API_LEVEL/" \ usr/include/android/api-level.h @@ -693,13 +698,13 @@ termux_step_setup_toolchain() { local _STL_LIBFILE_NAME=libc++_shared.so if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ]; then - # Setup libgnustl_shared.so in $PREFIX/lib and libstdc++.so as a link to it, + # Setup libc++_shared.so in $PREFIX/lib and libstdc++.so as a link to it, # so that other C++ using packages links to it instead of the default android # C++ library which does not support exceptions or STL: # https://developer.android.com/ndk/guides/cpp-support.html # We do however want to avoid installing this, to avoid problems where e.g. # libm.so on some i686 devices links against libstdc++.so. - # The libgnustl_shared.so library will be packaged in the libgnustl package + # The libc++_shared.so library will be packaged in the libc++ package # which is part of the base Termux installation. mkdir -p "$TERMUX_PREFIX/lib" cd "$TERMUX_PREFIX/lib" @@ -831,6 +836,7 @@ termux_step_configure_autotools () { AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_dot_works=yes" AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_slash_works=yes" AVOID_GNULIB+=" gl_cv_func_mkfifo_works=yes" + AVOID_GNULIB+=" gl_cv_func_mknod_works=yes" AVOID_GNULIB+=" gl_cv_func_realpath_works=yes" AVOID_GNULIB+=" gl_cv_func_select_detects_ebadf=yes" AVOID_GNULIB+=" gl_cv_func_snprintf_posix=yes"