Browse Source

Initial push

android-5
Fredrik Fornwall 10 years ago
parent
commit
59f0d218a6
  1. 26
      build-all.sh
  2. 663
      build-package.sh
  3. 88
      buildorder.py
  4. 9
      check-pie.sh
  5. 16
      check-versions.sh
  6. 5
      clean-rebuild-all.sh
  7. 3
      install-sdk.sh
  8. 9
      list-packages.sh
  9. 120
      ndk_patches/JNIHelp.h
  10. 111
      ndk_patches/arpa-ftp.patch
  11. 88
      ndk_patches/arpa-tftp.patch
  12. 17
      ndk_patches/fcntl.h.patch
  13. 24
      ndk_patches/grp.h.patch
  14. 18
      ndk_patches/in.h.patch
  15. 47
      ndk_patches/pwd.patch
  16. 13
      ndk_patches/route.h.patch
  17. 31
      ndk_patches/sha1.h
  18. 22
      ndk_patches/stdio.h.patch
  19. 18
      ndk_patches/string.h.patch
  20. 5
      ndk_patches/sys-fcntl.patch
  21. 11
      ndk_patches/sys-wait.h.patch
  22. 114
      ndk_patches/sysexits.h
  23. 78
      ndk_patches/syslog.patch
  24. 12
      ndk_patches/termios.h.patch
  25. 55
      ndk_patches/unistd.patch
  26. 18
      ndk_patches/user.h.patch
  27. 93
      packages/aapt/build.sh
  28. 31
      packages/aapt/log.h
  29. 78
      packages/aapt/thread_defs.h
  30. 9
      packages/angband/build.sh
  31. 26
      packages/angband/configure.patch
  32. 28
      packages/angband/no_langinfo.patch
  33. 81
      packages/ant/ant
  34. 21
      packages/ant/build.sh
  35. 7
      packages/apr-util/build.sh
  36. 15
      packages/apr/Makefile.in.patch
  37. 7
      packages/apr/build.sh
  38. 11
      packages/apt/Makefile.patch
  39. 35
      packages/apt/apt-get.patch
  40. 46
      packages/apt/apt-key.patch
  41. 26
      packages/apt/apt-pkg-init-dir.patch
  42. 12
      packages/apt/apt-pkg-makefile-no-libutil.patch
  43. 3
      packages/apt/apt-transport-https.subpackage.sh
  44. 32
      packages/apt/aptconfiguration.patch
  45. 47
      packages/apt/build.sh
  46. 44
      packages/apt/cdrumtl.patch
  47. 18
      packages/apt/cmndline-no-strchrnul.patch
  48. 15
      packages/apt/configure.ac.patch
  49. 24
      packages/apt/configure.patch
  50. 12
      packages/apt/connect-use-socklen_t.patch
  51. 27
      packages/apt/debrecords-cc-no-langinfo.patch
  52. 18
      packages/apt/debsrcrecords.patch
  53. 26
      packages/apt/debsystem-paths.patch
  54. 26
      packages/apt/dpkgpm.cc.patch
  55. 67
      packages/apt/fileutl.patch
  56. 12
      packages/apt/ftp-use-socklen_t.patch
  57. 12
      packages/apt/gpgv.patch
  58. 11
      packages/apt/install-progress-cc-include-termios-h.patch
  59. 19
      packages/apt/netrc.patch
  60. 12
      packages/apt/no-usr-bin-test.patch
  61. 33
      packages/apt/private-install-no-statvfs.patch
  62. 25
      packages/apt/private-output-no-langinfo.patch
  63. 65
      packages/apt/strutl.c.patch
  64. 12
      packages/apt/test-interactive-helper-makefile-no-libpthread.patch
  65. BIN
      packages/apt/trusted.gpg
  66. 16
      packages/apt/vendor.patch
  67. 57
      packages/aria2/Makefile.in.patch
  68. 12
      packages/aria2/a2io.h.patch
  69. 9
      packages/aria2/build.sh
  70. 12
      packages/autoconf/General.pm.patch
  71. 15
      packages/autoconf/build.sh
  72. 5
      packages/automake/build.sh
  73. 12
      packages/bash/bash.patch
  74. 19
      packages/bash/build.sh
  75. 13
      packages/bash/dont_endpwent_in_shell_c.patch
  76. 15
      packages/bash/etc_hosts_and_profile_path.patch
  77. 39
      packages/bash/getpwd.patch.disabled
  78. 13
      packages/bash/y.tab.c.patch
  79. 6
      packages/bc/build.sh
  80. 13
      packages/binutils/binutils.patch
  81. 11
      packages/binutils/build.sh
  82. 12
      packages/binutils/gold_layout_printf_cast.patch
  83. 12
      packages/binutils/gold_printf_cast.patch
  84. 3
      packages/binutils/ldd
  85. 18
      packages/binutils/ldmain.c.patch
  86. 12
      packages/binutils/native_lib_dirs.patch
  87. 7
      packages/bison/build.sh
  88. 19
      packages/brogue/build.sh
  89. 28
      packages/brogue/curses-platform.c.patch
  90. 12
      packages/brogue/no_i586.patch
  91. 12
      packages/busybox/ash.patch
  92. 41
      packages/busybox/build.sh
  93. 1033
      packages/busybox/busybox.config
  94. 15
      packages/busybox/change_identity.c.patch
  95. 28
      packages/busybox/crond.c.patch
  96. 16
      packages/busybox/crontab.c.patch
  97. 146
      packages/busybox/dpkg.patch
  98. 17
      packages/busybox/ftpd.c.patch
  99. 39
      packages/busybox/httpd.patch
  100. 35
      packages/busybox/iplink.patch

26
build-all.sh

@ -0,0 +1,26 @@
#!/bin/bash
# build-all.sh - script to build all packages with a build order specified by buildorder.py
set -e -u -o pipefail
BUILDSCRIPT=`dirname $0`/build-package.sh
BUILDORDER_FILE=$HOME/termux/_buildall/buildorder.txt
if [ -e $BUILDORDER_FILE ]; then
echo "Continuing with existing buildorder file: $BUILDORDER_FILE"
else
rm -Rf $HOME/termux /data/data $HOME/termux/_buildall
mkdir -p $HOME/termux/_buildall
./buildorder.py packages > $BUILDORDER_FILE
fi
exec >> $HOME/termux/_buildall/ALL.out 2>> $HOME/termux/_buildall/ALL.err
for package in `cat $BUILDORDER_FILE`; do
echo -n "Building $package... " >> $HOME/termux/_buildall/ALL.out
BUILD_START=`date "+%s"`
bash -x $BUILDSCRIPT $package > $HOME/termux/_buildall/${package}.out 2> $HOME/termux/_buildall/${package}.err
BUILD_END=`date "+%s"`
BUILD_SECONDS=$(( $BUILD_END - $BUILD_START ))
echo "done in $BUILD_SECONDS"
done

663
build-package.sh

@ -0,0 +1,663 @@
#!/bin/bash
# Required setup for ubuntu (only tested on 15.04):
# $ apt install asciidoc automake bison cmake flex gettext libglib2.0-dev help2man libc6-dev-i386 libcurl4-openssl-dev libgdk-pixbuf2.0-dev libncurses5-dev libtool lzip m4 mercurial pkg-config scons texinfo xmlto xutils-dev
# where libc6-dev-i386 is needed by luajit host part of the build for <sys/cdefs.h>
# xutils-dev provides 'makedepend' which openssl build uses
# gettext provides 'msgfmt' which apt build uses
# libcurl4-openssl-dev is needed by apt build
# libglib2.0-dev provides 'glib-genmarshal' which glib build uses
# libgdk-pixbuf2.0-dev provides 'gdk-pixbuf-query-loaders' which librsvg build uses
# Required setup for mac (not regularly used, and may not build all packages):
# $ port install asciidoc bison cmake flex gnutar help2man lzip mercurial p5-libwww-perl pkgconfig scons xmlto
# where Busybox requires that sed is gsed: ln -s /opt/local/bin/gsed /opt/local/bin/sed
set -e -o pipefail -u
if [ "$#" -ne 1 ]; then echo "ERROR: Specify one argument!"; exit 1; fi
export TERMUX_PKG_NAME=$1
export TERMUX_SCRIPTDIR=`cd $(dirname $0); pwd`
export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/packages/$TERMUX_PKG_NAME
export TERMUX_PKG_BUILDER_SCRIPT=$TERMUX_PKG_BUILDER_DIR/build.sh
if test ! -f $TERMUX_PKG_BUILDER_SCRIPT; then echo "ERROR: No such package builder: ${TERMUX_PKG_BUILDER_SCRIPT}!"; exit 1; fi
echo "termux - building $1..."
test -t 1 && printf "\033]0;$1...\007"
# Read settings from .termuxrc if existing
test -f $HOME/.termuxrc && . $HOME/.termuxrc
# Configurable settings
: ${NDK:="${HOME}/lib/android-ndk"}
: ${ANDROID_HOME:="${HOME}/lib/android-sdk"}
if [ ! -d "$NDK" ]; then echo 'ERROR: $NDK not defined as pointing at a directory - define it pointing at a android NDK installation!'; exit 1; fi
: ${TERMUX_MAKE_PROCESSES:='4'}
: ${TERMUX_TOPDIR:="$HOME/termux"}
: ${TERMUX_ARCH:="arm"}
: ${TERMUX_HOST_PLATFORM:="${TERMUX_ARCH}-linux-android"}
if [ $TERMUX_ARCH = "arm" ]; then TERMUX_HOST_PLATFORM="${TERMUX_HOST_PLATFORM}eabi"; fi
: ${TERMUX_PREFIX:='/data/data/com.termux/files/usr'}
: ${TERMUX_ANDROID_HOME:='/data/data/com.termux/files/home'}
: ${TERMUX_DEBUG:=""}
: ${TERMUX_PROCESS_DEB:=""}
: ${TERMUX_GCC_VERSION:="4.9"}
: ${TERMUX_API_LEVEL:="21"}
: ${TERMUX_STANDALONE_TOOLCHAIN:="$HOME/lib/android-standalone-toolchain-${TERMUX_ARCH}-api${TERMUX_API_LEVEL}-gcc${TERMUX_GCC_VERSION}"}
: ${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="22.0.1"}
# We do not put all of build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/ into PATH
# to avoid stuff like arm-linux-androideabi-ld there to conflict with ones from
# the standalone toolchain.
TERMUX_DX=$ANDROID_HOME/build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/dx
# We put this after system PATH to avoid picking up toolchain stripped python
export PATH=$PATH:$TERMUX_STANDALONE_TOOLCHAIN/bin
# Make $TERMUX_TAR and $TERMUX_TOUCH point at gnu versions:
export TERMUX_TAR="tar"
test `uname` = "Darwin" && TERMUX_TAR=gnutar
export TERMUX_TOUCH="touch"
test `uname` = "Darwin" && TERMUX_TOUCH=gtouch
# Compute NDK version. We remove the first character (the r in e.g. r9d) to get a version number which can be used in packages):
export TERMUX_NDK_VERSION=`cut -d ' ' -f 1 $NDK/RELEASE.TXT | cut -c 2-`
export prefix=${TERMUX_PREFIX} # prefix is used by some makefiles
#export ACLOCAL="aclocal -I $TERMUX_PREFIX/share/aclocal"
export AR=$TERMUX_HOST_PLATFORM-ar
export AS=${TERMUX_HOST_PLATFORM}-gcc
export CC=$TERMUX_HOST_PLATFORM-gcc
export CPP=${TERMUX_HOST_PLATFORM}-cpp
export CXX=$TERMUX_HOST_PLATFORM-g++
export CC_FOR_BUILD=gcc
export LD=$TERMUX_HOST_PLATFORM-ld
export OBJDUMP=$TERMUX_HOST_PLATFORM-objdump
# Setup pkg-config for cross-compiling:
export PKG_CONFIG=$TERMUX_STANDALONE_TOOLCHAIN/bin/${TERMUX_HOST_PLATFORM}-pkg-config
export PKG_CONFIG_LIBDIR=$TERMUX_PREFIX/lib/pkgconfig
export RANLIB=$TERMUX_HOST_PLATFORM-ranlib
export READELF=$TERMUX_HOST_PLATFORM-readelf
export STRIP=$TERMUX_HOST_PLATFORM-strip
_SPECSFLAG="-specs=$TERMUX_SCRIPTDIR/termux.spec"
export CFLAGS="$_SPECSFLAG"
export LDFLAGS="$_SPECSFLAG -L${TERMUX_PREFIX}/lib"
if [ "$TERMUX_ARCH" = "arm" ]; then
# For hard support: http://blog.alexrp.com/2014/02/18/android-hard-float-support/
# "First, to utilize the hard float ABI, you must either compile every last component of your application
# as hard float (the -mhard-float GCC/Clang switch), or mark individual functions with the appropriate
# __attribute__ to indicate the desired ABI. For example, to mark a function so that it’s called with the
# soft float ABI, stick __attribute__((pcs("aapcs"))) on it.
# Note that the NDK will link to a libm which uses the aforementioned attribute on all of its functions.
# This means that if you use libm functions a lot, you’re not likely to get much of a boost in those places.
# The way to fix this is to add -mhard-float -D_NDK_MATH_NO_SOFTFP=1 to your GCC/Clang command line. Then
# add -lm_hard to your linker command line (or -Wl,-lm_hard if you just invoke GCC/Clang to link). This will
# make your application link statically to a libm compiled for the hard float ABI. The only downside of this
# is that your application will increase somewhat in size."
CFLAGS+=" -march=armv7-a -mfpu=neon -mhard-float -Wl,--no-warn-mismatch"
LDFLAGS+=" -march=armv7-a -Wl,--no-warn-mismatch"
elif [ $TERMUX_ARCH = "i686" ]; then
# From $NDK/docs/CPU-ARCH-ABIS.html:
CFLAGS+=" -march=i686 -msse3 -mstackrealign -mfpmath=sse"
fi
if [ -n "$TERMUX_DEBUG" ]; then
CFLAGS+=" -g3 -Og -fstack-protector --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
else
CFLAGS+=" -Os"
fi
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="-I${TERMUX_PREFIX}/include"
export ac_cv_func_getpwent=no
export ac_cv_func_getpwnam=no
export ac_cv_func_getpwuid=no
if [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then
_TERMUX_NDK_TOOLCHAIN_NAME=""
if [ "arm" = $TERMUX_ARCH ]; then
_TERMUX_NDK_TOOLCHAIN_NAME="$TERMUX_HOST_PLATFORM"
elif [ "i686" = $TERMUX_ARCH ]; then
_TERMUX_NDK_TOOLCHAIN_NAME="x86"
fi
bash $NDK/build/tools/make-standalone-toolchain.sh --platform=android-$TERMUX_API_LEVEL --toolchain=${_TERMUX_NDK_TOOLCHAIN_NAME}-${TERMUX_GCC_VERSION} \
--install-dir=$TERMUX_STANDALONE_TOOLCHAIN --system=`uname | tr '[:upper:]' '[:lower:]'`-x86_64
if [ "arm" = $TERMUX_ARCH ]; then
# Fix to allow e.g. <bits/c++config.h> to be included:
cp $TERMUX_STANDALONE_TOOLCHAIN/include/c++/$TERMUX_GCC_VERSION/arm-linux-androideabi/armv7-a/bits/* $TERMUX_STANDALONE_TOOLCHAIN/include/c++/$TERMUX_GCC_VERSION/bits
fi
cd $TERMUX_STANDALONE_TOOLCHAIN/sysroot
for f in $TERMUX_SCRIPTDIR/ndk_patches/*.patch; do
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $f | \
sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
patch -p1;
echo "PATCHING FILE $f done!"
done
# sha1.h was removed from android ndk for platforms above 19, but needed by the aapt package
# JNIHelp.h is also used by aapt
# sysexits.h is header-only and used by some unix code
cp $TERMUX_SCRIPTDIR/ndk_patches/{sha1.h,sysexits.h,JNIHelp.h} $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include
fi
export TERMUX_COMMON_CACHEDIR="$TERMUX_TOPDIR/_cache"
export TERMUX_COMMON_DEBDIR="$TERMUX_TOPDIR/_deb"
mkdir -p $TERMUX_COMMON_CACHEDIR $TERMUX_COMMON_DEBDIR
# Get fresh versions of config.sub and config.guess
for f in config.sub config.guess; do test ! -f $TERMUX_COMMON_CACHEDIR/$f && curl "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=${f};hb=HEAD" > $TERMUX_COMMON_CACHEDIR/$f; done
# Have a debian-binary file ready for deb packaging:
test ! -f $TERMUX_COMMON_CACHEDIR/debian-binary && echo "2.0" > $TERMUX_COMMON_CACHEDIR/debian-binary
# The host tuple that may be given to --host configure flag, but normally autodetected so not needed explicitly
TERMUX_HOST_TUPLE=`sh $TERMUX_COMMON_CACHEDIR/config.guess`
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
TERMUX_PKG_TMPDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/tmp
TERMUX_PKG_HOSTBUILD_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/host-build
TERMUX_PKG_PLATFORM_INDEPENDENT=""
TERMUX_PKG_NO_DEVELSPLIT=""
TERMUX_PKG_BUILD_REVISION="0" # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=""
TERMUX_PKG_EXTRA_HOSTBUILD_CONFIGURE_ARGS=""
TERMUX_PKG_EXTRA_MAKE_ARGS=""
TERMUX_PKG_BUILD_IN_SRC=""
TERMUX_PKG_RM_AFTER_INSTALL=""
TERMUX_PKG_DEPENDS=""
TERMUX_PKG_HOMEPAGE=""
TERMUX_PKG_DESCRIPTION="FIXME:Add description"
TERMUX_PKG_FOLDERNAME=""
TERMUX_PKG_KEEP_STATIC_LIBRARIES="false"
TERMUX_PKG_KEEP_HEADER_FILES="false"
TERMUX_PKG_ESSENTIAL=""
TERMUX_PKG_CONFFILES=""
# Set if a host build should be done in TERMUX_PKG_HOSTBUILD_DIR:
TERMUX_PKG_HOSTBUILD=""
TERMUX_PKG_MAINTAINER="Fredrik Fornwall <fredrik@fornwall.net>"
# Cleanup old state
rm -Rf $TERMUX_PKG_BUILDDIR $TERMUX_PKG_PACKAGEDIR $TERMUX_PKG_SRCDIR $TERMUX_PKG_TMPDIR $TERMUX_PKG_MASSAGEDIR
# Ensure folders present (but not $TERMUX_PKG_SRCDIR, it will be created in build)
mkdir -p $TERMUX_PKG_BUILDDIR $TERMUX_PKG_PACKAGEDIR $TERMUX_PKG_TMPDIR $TERMUX_PKG_CACHEDIR $TERMUX_PKG_MASSAGEDIR $PKG_CONFIG_LIBDIR $TERMUX_PREFIX/{bin,lib,share,tmp}
# If $TERMUX_PREFIX already exists, it may have been built for a different arch
TERMUX_ARCH_FILE=/data/TERMUX_ARCH
if [ -f "${TERMUX_ARCH_FILE}" ]; then
TERMUX_PREVIOUS_ARCH=`cat $TERMUX_ARCH_FILE`
if [ $TERMUX_PREVIOUS_ARCH != $TERMUX_ARCH ]; then
TERMUX_DATA_BACKUPDIRS=$TERMUX_TOPDIR/_databackups
mkdir -p $TERMUX_DATA_BACKUPDIRS
TERMUX_DATA_PREVIOUS_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_PREVIOUS_ARCH
TERMUX_DATA_CURRENT_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_ARCH
echo "NOTE: Different archs - building for $TERMUX_ARCH, but current $TERMUX_PREVIOUS_ARCH"
echo " Saving current /data/data to $TERMUX_DATA_PREVIOUS_BACKUPDIR"
# Save current /data (removing old backup if any)
if test -e $TERMUX_DATA_PREVIOUS_BACKUPDIR; then
echo "ERROR: Directory already exists"
exit 1
fi
mv /data/data $TERMUX_DATA_PREVIOUS_BACKUPDIR
# Restore new one (if any)
if [ -d $TERMUX_DATA_CURRENT_BACKUPDIR ]; then
echo " Restoring old backupdir from $TERMUX_DATA_CURRENT_BACKUPDIR"
mv $TERMUX_DATA_CURRENT_BACKUPDIR /data/data
fi
fi
fi
echo $TERMUX_ARCH > $TERMUX_ARCH_FILE
if [ ! -f $PKG_CONFIG ]; then
echo "Creating pkg-config wrapper..."
# We use path to host pkg-config to avoid picking up a cross-compiled pkg-config later on
_HOST_PKGCONFIG=`which pkg-config`
mkdir -p $TERMUX_STANDALONE_TOOLCHAIN/bin $PKG_CONFIG_LIBDIR
cat > $PKG_CONFIG <<HERE
#!/bin/sh
export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR
# export PKG_CONFIG_SYSROOT_DIR=${TERMUX_PREFIX}
exec $_HOST_PKGCONFIG "\$@"
HERE
chmod +x $PKG_CONFIG
# Add a pkg-config file for the system zlib
cat > $PKG_CONFIG_LIBDIR/zlib.pc <<HERE
Name: zlib
Description: zlib compression library
Version: 1.2.3
Requires:
Libs: -L$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib -lz
Cflags: -I$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include
HERE
sleep 1 # Sleep so that zlib.c get older timestamp then TERMUX_BUILD_TS_FILE.
fi
TERMUX_ELF_CLEANER=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner
if [ ! -f $TERMUX_ELF_CLEANER ]; then
g++ -std=c++11 -Wall -Wextra -pedantic -Os $TERMUX_SCRIPTDIR/packages/termux-tools/termux-elf-cleaner.cpp -o $TERMUX_ELF_CLEANER
fi
# Keep track of when build started so we can see what files have been created
export TERMUX_BUILD_TS_FILE=$TERMUX_PKG_TMPDIR/timestamp_$TERMUX_PKG_NAME
rm -f $TERMUX_BUILD_TS_FILE && touch $TERMUX_BUILD_TS_FILE
# Run just after sourcing $TERMUX_PKG_BUILDER_SCRIPT
termux_step_extract_package () {
if [ -z "${TERMUX_PKG_SRCURL:=""}" ]; then
mkdir -p $TERMUX_PKG_SRCDIR
return
fi
cd $TERMUX_PKG_TMPDIR
filename=`basename $TERMUX_PKG_SRCURL`
file=$TERMUX_PKG_CACHEDIR/$filename
# Set "TERMUX_PKG_NO_SRC_CACHE=yes" in package to never cache packages, such as in git builds:
test -n ${TERMUX_PKG_NO_SRC_CACHE-""} -o ! -f $file && curl --retry 3 -o $file -L $TERMUX_PKG_SRCURL
if [ "x$TERMUX_PKG_FOLDERNAME" = "x" ]; then
folder=`basename $filename .tar.bz2` && folder=`basename $folder .tar.gz` && folder=`basename $folder .tar.xz` && folder=`basename $folder .tar.lz` && folder=`basename $folder .tgz` && folder=`basename $folder .zip`
folder=`echo $folder | sed 's/_/-/'` # dpkg uses _ in tar filename, but - in folder
else
folder=$TERMUX_PKG_FOLDERNAME
fi
rm -Rf $folder
if [ ${file##*.} = zip ]; then
unzip $file
else
$TERMUX_TAR xf $file
fi
mv $folder $TERMUX_PKG_SRCDIR
}
termux_step_post_extract_package () {
return
}
# Perform a host build. Will be called in $TERMUX_PKG_HOSTBUILD_DIR.
# After termux_step_post_extract_package() and before termux_step_patch_package()
termux_step_host_build () {
$TERMUX_PKG_SRCDIR/configure ${TERMUX_PKG_EXTRA_HOSTBUILD_CONFIGURE_ARGS}
make
}
# This should not be overridden
termux_step_patch_package () {
cd $TERMUX_PKG_SRCDIR
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch; do
test -f $patch && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $patch | patch -p1
done
find . -name config.sub -exec chmod u+w '{}' \; -exec cp $TERMUX_COMMON_CACHEDIR/config.sub '{}' \;
find . -name config.guess -exec chmod u+w '{}' \; -exec cp $TERMUX_COMMON_CACHEDIR/config.guess '{}' \;
}
termux_step_pre_configure () {
return
}
termux_step_configure () {
if [ ! -e $TERMUX_PKG_SRCDIR/configure ]; then
return
fi
DISABLE_STATIC="--disable-static"
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-static/}" ]; then
# Do not --disable-static if package explicitly enables it (e.g. gdb needs enable-static to build)
DISABLE_STATIC=""
fi
DISABLE_NLS="--disable-nls"
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-nls/}" ]; then
# Do not --disable-nls if package explicitly enables it (for gettext itself)
DISABLE_NLS=""
fi
ENABLE_SHARED="--enable-shared"
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--disable-shared/}" ]; then
ENABLE_SHARED=""
fi
HOST_FLAG="--host=$TERMUX_HOST_PLATFORM"
if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--host=/}" ]; then
HOST_FLAG=""
fi
# Some packages provides a $PKG-config script which some configure scripts pickup instead of pkg-config:
mkdir $TERMUX_PKG_TMPDIR/config-scripts
for f in $TERMUX_PREFIX/bin/*config; do
test -f $f && cp $f $TERMUX_PKG_TMPDIR/config-scripts
done
set +e +o pipefail
find $TERMUX_PKG_TMPDIR/config-scripts | xargs file | grep -F " script" | cut -f 1 -d : | xargs sed -i -E "s@^#\!/system/bin/sh@#\!/bin/sh@"
set -e -o pipefail
export PATH=$TERMUX_PKG_TMPDIR/config-scripts:$PATH
$TERMUX_PKG_SRCDIR/configure \
--disable-dependency-tracking \
--prefix=$TERMUX_PREFIX \
--disable-rpath --disable-rpath-hack \
$HOST_FLAG \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS \
$DISABLE_NLS \
$ENABLE_SHARED \
$DISABLE_STATIC \
--libexecdir=$TERMUX_PREFIX/libexec
}
termux_step_post_configure () {
return
}
termux_step_pre_make () {
return
}
termux_step_make () {
if ls *akefile &> /dev/null; then
if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
make -j $TERMUX_MAKE_PROCESSES
else
make -j $TERMUX_MAKE_PROCESSES ${TERMUX_PKG_EXTRA_MAKE_ARGS}
fi
fi
}
termux_step_make_install () {
if ls *akefile &> /dev/null; then
: ${TERMUX_PKG_MAKE_INSTALL_TARGET:="install"}:
# Some packages have problem with parallell install, and it does not buy much, so use -j 1.
if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
make -j 1 ${TERMUX_PKG_MAKE_INSTALL_TARGET}
else
make -j 1 ${TERMUX_PKG_EXTRA_MAKE_ARGS} ${TERMUX_PKG_MAKE_INSTALL_TARGET}
fi
fi
}
termux_step_post_make_install () {
return
}
termux_step_extract_into_massagedir () {
TARBALL_ORIG=$TERMUX_PKG_PACKAGEDIR/${TERMUX_PKG_NAME}_orig.tar.gz
# Build diff tar with what has changed during the build:
cd $TERMUX_PREFIX
$TERMUX_TAR -N $TERMUX_BUILD_TS_FILE -czf $TARBALL_ORIG .
# Extract tar in order to massage it
mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX
cd $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX
$TERMUX_TAR xf $TARBALL_ORIG
}
termux_step_massage () {
cd $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX
# Remove lib/charset.alias which is installed by gettext-using packages:
rm -f lib/charset.alias
# Remove non-english man pages:
test -d share/man && (cd share/man; for f in `ls | grep -v man`; do rm -Rf $f; done )
# Remove info pages and other docs:
rm -Rf share/info share/doc share/locale
# Remove old kept libraries (readline):
find . -name '*.old' -delete
# .. remove static libraries:
if [ $TERMUX_PKG_KEEP_STATIC_LIBRARIES = "false" ]; then
find . -name '*.a' -delete
find . -name '*.la' -delete
fi
# .. move over sbin to bin
for file in sbin/*; do if test -f $file; then mv $file bin/; fi; done
# file(1) may fail for certain unusual files, so disable pipefail
set +e +o pipefail
# Remove world permissions and add write permissions:
find . -exec chmod u+w,o-rwx \{\} \;
# .. strip binaries (setting them as writeable first)
if [ "$TERMUX_DEBUG" = "" ]; then
find . -type f | xargs file | grep -E "(executable|shared object)" | grep ELF | cut -f 1 -d : | xargs $STRIP --strip-unneeded --preserve-dates -R '.gnu.version*'
fi
# Remove DT_ entries which the android 5.1 linker warns about:
find . -type f | xargs $TERMUX_ELF_CLEANER
# Fix shebang paths:
for file in `find . -type f`; do
head -c 100 $file | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && sed --follow-symlinks -i -E "s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" $file
done
set -e -o pipefail
test ! -z "$TERMUX_PKG_RM_AFTER_INSTALL" && rm -Rf $TERMUX_PKG_RM_AFTER_INSTALL
find . -type d -empty -delete # Remove empty directories
# Sub packages:
if [ -d include -a -z "${TERMUX_PKG_NO_DEVELSPLIT}" ]; then
# Add virtual -dev sub package if there are include files:
_DEVEL_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-dev.subpackage.sh
echo TERMUX_SUBPKG_INCLUDE=\"include share/man/man3 lib/pkgconfig share/aclocal\" > $_DEVEL_SUBPACKAGE_FILE
echo TERMUX_SUBPKG_DESCRIPTION=\"Development files for ${TERMUX_PKG_NAME}\" >> $_DEVEL_SUBPACKAGE_FILE
echo TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME\" >> $_DEVEL_SUBPACKAGE_FILE
fi
# Now build all sub packages
rm -Rf $TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages
for subpackage in $TERMUX_PKG_BUILDER_DIR/*.subpackage.sh $TERMUX_PKG_TMPDIR/*subpackage.sh; do
test ! -f $subpackage && continue
SUB_PKG_NAME=`basename $subpackage .subpackage.sh`
# Default value is same as main package, but sub package may override:
TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT
echo "$SUB_PKG_NAME => $subpackage"
SUB_PKG_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages/$SUB_PKG_NAME
TERMUX_SUBPKG_DEPENDS=""
SUB_PKG_MASSAGE_DIR=$SUB_PKG_DIR/massage/$TERMUX_PREFIX
SUB_PKG_PACKAGE_DIR=$SUB_PKG_DIR/package
mkdir -p $SUB_PKG_MASSAGE_DIR $SUB_PKG_PACKAGE_DIR
. $subpackage
for includeset in $TERMUX_SUBPKG_INCLUDE; do
_INCLUDE_DIRSET=`dirname $includeset`
test "$_INCLUDE_DIRSET" = "." && _INCLUDE_DIRSET=""
if [ -e $includeset ]; then
mkdir -p $SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET
mv $includeset $SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET
fi
done
SUB_PKG_ARCH=$TERMUX_ARCH
test -n "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" && SUB_PKG_ARCH=all
cd $SUB_PKG_DIR/massage
SUB_PKG_INSTALLSIZE=`du -sk . | cut -f 1`
$TERMUX_TAR --xz -cf $SUB_PKG_PACKAGE_DIR/data.tar.xz .
mkdir -p DEBIAN
cd DEBIAN
cat > control <<HERE
Package: $SUB_PKG_NAME
Architecture: ${SUB_PKG_ARCH}
Installed-Size: ${SUB_PKG_INSTALLSIZE}
Maintainer: $TERMUX_PKG_MAINTAINER
Version: $TERMUX_PKG_FULLVERSION
Description: $TERMUX_SUBPKG_DESCRIPTION
Homepage: $TERMUX_PKG_HOMEPAGE
HERE
test ! -z "$TERMUX_SUBPKG_DEPENDS" && echo "Depends: $TERMUX_SUBPKG_DEPENDS" >> control
$TERMUX_TAR -czf $SUB_PKG_PACKAGE_DIR/control.tar.gz .
# Create the actual .deb file:
TERMUX_SUBPKG_DEBFILE=$TERMUX_COMMON_DEBDIR/${SUB_PKG_NAME}-${TERMUX_PKG_FULLVERSION}_${SUB_PKG_ARCH}.deb
ar cr $TERMUX_SUBPKG_DEBFILE \
$TERMUX_COMMON_CACHEDIR/debian-binary \
$SUB_PKG_PACKAGE_DIR/control.tar.gz \
$SUB_PKG_PACKAGE_DIR/data.tar.xz
if [ "$TERMUX_PROCESS_DEB" != "" ]; then
$TERMUX_PROCESS_DEB $TERMUX_SUBPKG_DEBFILE
fi
# Go back to main package:
cd $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX
done
# .. remove empty directories (NOTE: keep this last):
find . -type d -empty -delete
# Make sure user can read and write all files (problem with dpkg otherwise):
chmod -R u+rw .
}
termux_step_post_massage () {
return
}
termux_step_create_debscripts () {
return
}
source $TERMUX_PKG_BUILDER_SCRIPT
# Compute full version:
TERMUX_PKG_FULLVERSION=$TERMUX_PKG_VERSION
if [ "$TERMUX_PKG_BUILD_REVISION" != "0" -o "$TERMUX_PKG_FULLVERSION" != "${TERMUX_PKG_FULLVERSION/-/}" ]; then
# "0" is the default revision, so only include it if the upstream versions contains "-" itself
TERMUX_PKG_FULLVERSION+="-$TERMUX_PKG_BUILD_REVISION"
fi
# Start by extracting the package src into $TERMUX_PKG_SRCURL:
termux_step_extract_package
# Optional post processing:
termux_step_post_extract_package
# Optional host build:
if [ "x$TERMUX_PKG_HOSTBUILD" != "x" ]; then
cd $TERMUX_PKG_SRCDIR
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch.beforehostbuild; do
test -f $patch && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $patch | patch -p1
done
if [ -f "$TERMUX_PKG_HOSTBUILD_DIR/TERMUX_BUILT_FOR_$TERMUX_PKG_VERSION" ]; then
echo "Using already built host build"
else
mkdir -p $TERMUX_PKG_HOSTBUILD_DIR
cd $TERMUX_PKG_HOSTBUILD_DIR
ORIG_AR=$AR; unset AR
ORIG_AS=$AS; unset AS
ORIG_CC=$CC; unset CC
ORIG_CXX=$CXX; unset CXX
ORIG_CPP=$CPP; unset CPP
ORIG_CFLAGS=$CFLAGS; unset CFLAGS
ORIG_CPPFLAGS=$CPPFLAGS; unset CPPFLAGS
ORIG_CXXFLAGS=$CXXFLAGS; unset CXXFLAGS
ORIG_LDFLAGS=$LDFLAGS; unset LDFLAGS
ORIG_RANLIB=$RANLIB; unset RANLIB
ORIG_LD=$LD; unset LD
ORIG_PKG_CONFIG=$PKG_CONFIG; unset PKG_CONFIG
ORIG_PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR; unset PKG_CONFIG_LIBDIR
ORIG_STRIP=$STRIP; unset STRIP
termux_step_host_build
touch $TERMUX_PKG_HOSTBUILD_DIR/TERMUX_BUILT_FOR_$TERMUX_PKG_VERSION
export AR=$ORIG_AR
export AS=$ORIG_AS
export CC=$ORIG_CC
export CXX=$ORIG_CXX
export CPP=$ORIG_CPP
export CFLAGS=$ORIG_CFLAGS
export CPPFLAGS=$ORIG_CPPFLAGS
export CXXFLAGS=$ORIG_CXXFLAGS
export LDFLAGS=$ORIG_LDFLAGS
export RANLIB=$ORIG_RANLIB
export LD=$ORIG_LD
export PKG_CONFIG=$ORIG_PKG_CONFIG
export PKG_CONFIG_LIBDIR=$ORIG_PKG_CONFIG_LIBDIR
export STRIP=$ORIG_STRIP
fi
fi
if [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libandroid-support/}" ]; then
# If using the android support library, link to it and include its headers as system headers:
export CPPFLAGS="$CPPFLAGS -isystem $TERMUX_PREFIX/include/libandroid-support"
export LDFLAGS="$LDFLAGS -landroid-support"
fi
if [ -n "$TERMUX_PKG_BUILD_IN_SRC" ]; then
echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set" >> $TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR
fi
cd $TERMUX_PKG_BUILDDIR
termux_step_patch_package
cd $TERMUX_PKG_BUILDDIR
termux_step_pre_configure
cd $TERMUX_PKG_BUILDDIR
termux_step_configure
cd $TERMUX_PKG_BUILDDIR
termux_step_post_configure
cd $TERMUX_PKG_BUILDDIR
termux_step_pre_make
cd $TERMUX_PKG_BUILDDIR
termux_step_make
cd $TERMUX_PKG_BUILDDIR
termux_step_make_install
cd $TERMUX_PKG_BUILDDIR
termux_step_post_make_install
cd $TERMUX_PKG_MASSAGEDIR
termux_step_extract_into_massagedir
termux_step_massage
termux_step_post_massage
# Create data tarball containing files to package:
cd $TERMUX_PKG_MASSAGEDIR
if [ "`find . -type f`" = "" ]; then
echo "ERROR: No files in package"
exit 1
fi
$TERMUX_TAR --xz -cf $TERMUX_PKG_PACKAGEDIR/data.tar.xz .
# Get install size. This will be written as the "Installed-Size" deb field so is measured in 1024-byte blocks:
TERMUX_PKG_INSTALLSIZE=`du -sk . | cut -f 1`
# Create deb package:
# NOTE: From here on TERMUX_ARCH is set to "all" if TERMUX_PKG_PLATFORM_INDEPENDENT is set by the package
test -n "$TERMUX_PKG_PLATFORM_INDEPENDENT" && TERMUX_ARCH=all
cd $TERMUX_PKG_MASSAGEDIR
mkdir -p DEBIAN
cat > DEBIAN/control <<HERE
Package: $TERMUX_PKG_NAME
Architecture: ${TERMUX_ARCH}
Installed-Size: ${TERMUX_PKG_INSTALLSIZE}
Maintainer: $TERMUX_PKG_MAINTAINER
Version: $TERMUX_PKG_FULLVERSION
Description: $TERMUX_PKG_DESCRIPTION
Homepage: $TERMUX_PKG_HOMEPAGE
HERE
test ! -z "$TERMUX_PKG_DEPENDS" && echo "Depends: $TERMUX_PKG_DEPENDS" >> DEBIAN/control
test ! -z "$TERMUX_PKG_ESSENTIAL" && echo "Essential: yes" >> DEBIAN/control
# Create DEBIAN/conffiles (see https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html):
for f in $TERMUX_PKG_CONFFILES; do echo $TERMUX_PREFIX/$f >> DEBIAN/conffiles; done
# Allow packages to create arbitrary control files:
cd DEBIAN
termux_step_create_debscripts
# Create control.tar.gz
$TERMUX_TAR -czf $TERMUX_PKG_PACKAGEDIR/control.tar.gz .
# In the .deb ar file there should be a file "debian-binary" with "2.0" as the content:
TERMUX_PKG_DEBFILE=$TERMUX_COMMON_DEBDIR/${TERMUX_PKG_NAME}-${TERMUX_PKG_FULLVERSION}_${TERMUX_ARCH}.deb
# Create the actual .deb file:
ar cr $TERMUX_PKG_DEBFILE \
$TERMUX_COMMON_CACHEDIR/debian-binary \
$TERMUX_PKG_PACKAGEDIR/control.tar.gz \
$TERMUX_PKG_PACKAGEDIR/data.tar.xz
if [ "$TERMUX_PROCESS_DEB" != "" ]; then
$TERMUX_PROCESS_DEB $TERMUX_PKG_DEBFILE
fi
echo "termux - build of '$1' done"
test -t 1 && printf "\033]0;$1 - DONE\007"
exit 0

88
buildorder.py

@ -0,0 +1,88 @@
#!/usr/bin/env python3
# buildorder.py - script to generate a build order respecting package dependencies
import os, sys
def die(msg):
print('ERROR: ' + msg)
sys.exit(1)
if len(sys.argv) != 2: die("Supply path to packages directory as first and only argument")
packages_dir = sys.argv[1]
if not os.path.isdir(packages_dir): die(packages_dir + ' is not a directory')
class DebianPackage:
def __init__(self, name):
self.name = name
self.remaining_dependencies = set() # String
self.sub_packages = set() # String
self.prerequisite_for = set() # Packages that needs this package
all_packages = [] # List of all DebianPackage:s
packages_map = {} # Mapping from package name to DebianPackage (if subpackage, mapping from subpackage name to parent package)
for subdir_name in sorted(os.listdir(packages_dir)):
subdir_path = packages_dir + '/' + subdir_name
if os.path.exists(subdir_path + '/BROKEN.txt'): continue
build_sh_path = subdir_path + '/build.sh'
this_package = DebianPackage(subdir_name)
all_packages.append(this_package)
packages_map[this_package.name] = this_package
if not os.path.isfile(build_sh_path): die('The directory ' + subdir_name + ' does not contain build.sh')
with open(build_sh_path) as build_sh_file:
for line in build_sh_file:
if line.startswith('TERMUX_PKG_DEPENDS='):
deps_comma_separated = line[(line.index('=')+2):(len(line)-2)]
for dep in deps_comma_separated.split(','):
dep = dep.strip()
this_package.remaining_dependencies.add(dep)
for file_in_subdir_name in sorted(os.listdir(subdir_path)):
if file_in_subdir_name.endswith('.subpackage.sh'):
subpackage_name = file_in_subdir_name[0:-len(".subpackage.sh"):]
this_package.sub_packages.add(subpackage_name)
packages_map[subpackage_name] = this_package
with open(subdir_path + '/' + file_in_subdir_name) as subpackage_sh_file:
for line in subpackage_sh_file:
if line.startswith('TERMUX_SUBPKG_DEPENDS='):
deps_comma_separated = line[(line.index('=')+2):(len(line)-2)]
for dep in deps_comma_separated.split(','):
dep = dep.strip()
this_package.remaining_dependencies.add(dep)
this_package.remaining_dependencies.discard(this_package.name) # Do not depend on itself
this_package.remaining_dependencies.difference_update(this_package.sub_packages) # Do not depend on any sub package
for package in all_packages:
for remaining in package.remaining_dependencies:
if not remaining in packages_map: die('Package ' + package.name + ' depends on non-existing package "' + remaining + '"')
packages_map[remaining].prerequisite_for.add(package)
# List of all DebianPackage:s without dependencies
packages_without_deps = [p for p in all_packages if not p.remaining_dependencies]
if not packages_without_deps: die('No package without dependency - where to start?')
# Sort alphabetically, but with libandroid-support first (since dependency on libandroid-support
# does not need to be declared explicitly, so anything might in theory depend on it to build):
packages_without_deps.sort(key=lambda p: 'aaaa' if p.name == 'libandroid-support' else p.name, reverse=True)
# Topological sorting
build_order = []
while packages_without_deps:
pkg = packages_without_deps.pop()
build_order.append(pkg)
for other_package in pkg.prerequisite_for:
other_package.remaining_dependencies.discard(pkg.name) # Remove this package
other_package.remaining_dependencies.difference_update(pkg.sub_packages) # .. and all its subpackages
if not other_package.remaining_dependencies:
# Check if the other package is ready to build now
packages_without_deps.append(other_package)
if len(all_packages) != len(build_order):
print("ERROR: Cycle exists. Remaining: ");
for pkg in all_packages:
if pkg not in build_order: print(pkg.name)
sys.exit(1)
for pkg in build_order: print(pkg.name)

9
check-pie.sh

@ -0,0 +1,9 @@
#!/bin/sh
# check-pie.sh - script to detect non-PIE binaries (which does not work on Android)
cd /data/data/com.termux/files/usr/bin/
for file in *; do
if readelf -h $file 2>/dev/null | grep -q 'Type:[[:space:]]*EXEC'; then
echo $file
fi
done

16
check-versions.sh

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# check-versions.sh - script to open packages in a browser for checking their versions
OPEN=xdg-open
if [ `uname` = Darwin ]; then OPEN=open; fi
# Run each package in separate process since we include their environment variables:
for path in packages/*; do
(
pkg=`basename $path`
. $path/build.sh
echo -n "$pkg - $TERMUX_PKG_VERSION - press Return to check homepage"
read
$OPEN $TERMUX_PKG_HOMEPAGE
)
done

5
clean-rebuild-all.sh

@ -0,0 +1,5 @@
#!/bin/sh
# clean-rebuild-all.sh - clean everything and rebuild
rm -Rf /data/data $HOME/termux $HOME/lib/android-standalone-toolchain-*
bash -x build-all.sh

3
install-sdk.sh

@ -0,0 +1,3 @@
#!/bin/sh
android update sdk --all --no-https --no-ui --filter build-tools-22.0.1,android-21

9
list-packages.sh

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# list-packages.sh - tool to list all package with home pages and descriptions
for path in packages/*; do (
pkg=`basename $path`
. $path/build.sh
echo "$pkg($TERMUX_PKG_VERSION): $TERMUX_PKG_HOMEPAGE"
echo " $TERMUX_PKG_DESCRIPTION"
) done

120
ndk_patches/JNIHelp.h

@ -0,0 +1,120 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* JNI helper functions.
*
* This file may be included by C or C++ code, which is trouble because jni.h
* uses different typedefs for JNIEnv in each language.
*/
#ifndef _NATIVEHELPER_JNIHELP_H
#define _NATIVEHELPER_JNIHELP_H
#include "jni.h"
#include "utils/Log.h"
#ifndef NELEM
# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Register one or more native methods with a particular class.
*/
int jniRegisterNativeMethods(C_JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods);
/*
* Throw an exception with the specified class and an optional message.
* The "className" argument will be passed directly to FindClass, which
* takes strings with slashes (e.g. "java/lang/Object").
*
* Returns 0 on success, nonzero if something failed (e.g. the exception
* class couldn't be found).
*
* Currently aborts the VM if it can't throw the exception.
*/
int jniThrowException(C_JNIEnv* env, const char* className, const char* msg);
/*
* Throw a java.lang.RuntimeException, with an optional message.
*/
int jniThrowRuntimeException(JNIEnv* env, const char* msg);
/*
* Throw a java.io.IOException, generating the message from errno.
*/
int jniThrowIOException(C_JNIEnv* env, int errnum);
/*
* Create a java.io.FileDescriptor given an integer fd
*/
jobject jniCreateFileDescriptor(C_JNIEnv* env, int fd);
/*
* Get an int file descriptor from a java.io.FileDescriptor
*/
int jniGetFDFromFileDescriptor(C_JNIEnv* env, jobject fileDescriptor);
/*
* Set an int file descriptor to a java.io.FileDescriptor
*/
void jniSetFileDescriptorOfFD(C_JNIEnv* env, jobject fileDescriptor, int value);
#ifdef __cplusplus
}
#endif
/*
* For C++ code, we provide inlines that map to the C functions. g++ always
* inlines these, even on non-optimized builds.
*/
#if defined(__cplusplus) && !defined(JNI_FORCE_C)
inline int jniRegisterNativeMethods(JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods)
{
return jniRegisterNativeMethods(&env->functions, className, gMethods,
numMethods);
}
inline int jniThrowException(JNIEnv* env, const char* className,
const char* msg)
{
return jniThrowException(&env->functions, className, msg);
}
inline int jniThrowIOException(JNIEnv* env, int errnum)
{
return jniThrowIOException(&env->functions, errnum);
}
inline jobject jniCreateFileDescriptor(JNIEnv* env, int fd)
{
return jniCreateFileDescriptor(&env->functions, fd);
}
inline int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor)
{
return jniGetFDFromFileDescriptor(&env->functions, fileDescriptor);
}
inline void jniSetFileDescriptorOfFD(JNIEnv* env, jobject fileDescriptor,
int value)
{
return jniSetFileDescriptorOfFD(&env->functions, fileDescriptor, value);
}
#endif
#endif /*_NATIVEHELPER_JNIHELP_H*/

111
ndk_patches/arpa-ftp.patch

@ -0,0 +1,111 @@
Add <arpa/ftp.h> for some ftp defines which some packages needs.
diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h ./usr/include/arpa/ftp.h
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h 1970-01-01 01:00:00.000000000 +0100
+++ ./usr/include/arpa/ftp.h 2014-02-07 02:07:52.000000000 +0100
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ftp.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _ARPA_FTP_H
+#define _ARPA_FTP_H 1
+
+/* Definitions for FTP; see RFC-765. */
+
+/*
+ * Reply codes.
+ */
+#define PRELIM 1 /* positive preliminary */
+#define COMPLETE 2 /* positive completion */
+#define CONTINUE 3 /* positive intermediate */
+#define TRANSIENT 4 /* transient negative completion */
+#define ERROR 5 /* permanent negative completion */
+
+/*
+ * Type codes
+ */
+#define TYPE_A 1 /* ASCII */
+#define TYPE_E 2 /* EBCDIC */
+#define TYPE_I 3 /* image */
+#define TYPE_L 4 /* local byte size */
+
+#ifdef FTP_NAMES
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
+#endif
+
+/*
+ * Form codes
+ */
+#define FORM_N 1 /* non-print */
+#define FORM_T 2 /* telnet format effectors */
+#define FORM_C 3 /* carriage control (ASA) */
+#ifdef FTP_NAMES
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+
+/*
+ * Structure codes
+ */
+#define STRU_F 1 /* file (no record structure) */
+#define STRU_R 2 /* record structure */
+#define STRU_P 3 /* page structure */
+#ifdef FTP_NAMES
+char *strunames[] = {"0", "File", "Record", "Page" };
+#endif
+
+/*
+ * Mode types
+ */
+#define MODE_S 1 /* stream */
+#define MODE_B 2 /* block */
+#define MODE_C 3 /* compressed */
+#ifdef FTP_NAMES
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
+#endif
+
+/*
+ * Record Tokens
+ */
+#define REC_ESC '\377' /* Record-mode Escape */
+#define REC_EOR '\001' /* Record-mode End-of-Record */
+#define REC_EOF '\002' /* Record-mode End-of-File */
+
+/*
+ * Block Header
+ */
+#define BLK_EOR 0x80 /* Block is End-of-Record */
+#define BLK_EOF 0x40 /* Block is End-of-File */
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
+
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
+
+#endif /* arpa/ftp.h */

88
ndk_patches/arpa-tftp.patch

@ -0,0 +1,88 @@
The <arpa/tftp.h> header is needed by inetutils.
diff -N -a -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/arpa/tftp.h ./usr/include/arpa/tftp.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/arpa/tftp.h 1969-12-31 19:00:00.000000000 -0500
+++ ./usr/include/arpa/tftp.h 2015-05-12 15:40:31.648145474 -0400
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tftp.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _ARPA_TFTP_H
+#define _ARPA_TFTP_H 1
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+#define SEGSIZE 512 /* data segment size */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define ERROR 05 /* error code */
+
+struct tftphdr {
+ short th_opcode; /* packet type */
+ union {
+ char tu_padding[3]; /* sizeof() compat */
+ struct {
+ union {
+ unsigned short tu_block; /* block # */
+ short tu_code; /* error code */
+ } __attribute__ ((__packed__)) th_u3;
+ char tu_data[0]; /* data or error string */
+ } __attribute__ ((__packed__)) th_u2;
+ char tu_stuff[0]; /* request packet stuff */
+ } __attribute__ ((__packed__)) th_u1;
+} __attribute__ ((__packed__));
+
+#define th_block th_u1.th_u2.th_u3.tu_block
+#define th_code th_u1.th_u2.th_u3.tu_code
+#define th_stuff th_u1.tu_stuff
+#define th_data th_u1.th_u2.tu_data
+#define th_msg th_u1.th_u2.tu_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+
+#endif /* arpa/tftp.h */

17
ndk_patches/fcntl.h.patch

@ -0,0 +1,17 @@
Avoid defining constants which causes at least dpkg build to think that
sync_file_range(2) is available - which it is not.
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/fcntl.h ./usr/include/fcntl.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/fcntl.h 2014-10-14 22:53:49.000000000 -0400
+++ ./usr/include/fcntl.h 2014-12-16 05:51:38.371338608 -0500
@@ -59,10 +59,6 @@
#define SPLICE_F_MORE 4
#define SPLICE_F_GIFT 8
-#define SYNC_FILE_RANGE_WAIT_BEFORE 1
-#define SYNC_FILE_RANGE_WRITE 2
-#define SYNC_FILE_RANGE_WAIT_AFTER 4
-
extern int creat(const char*, mode_t);
extern int creat64(const char*, mode_t);
extern int fallocate64(int, int, off64_t, off64_t);

24
ndk_patches/grp.h.patch

@ -0,0 +1,24 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/grp.h ./usr/include/grp.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/grp.h 2014-10-14 22:53:49.000000000 -0400
+++ ./usr/include/grp.h 2014-12-14 15:33:15.715243224 -0500
@@ -54,13 +54,13 @@
struct group *getgrgid(gid_t);
struct group *getgrnam(const char *);
#if __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE
-struct group *getgrent(void);
-void setgrent(void);
-void endgrent(void);
-int getgrgid_r(gid_t, struct group *, char *,
- size_t, struct group **);
-int getgrnam_r(const char *, struct group *, char *,
- size_t, struct group **);
+static struct group *getgrent(void) { return 0; }
+static void setgrent(void) {}
+static void endgrent(void) {}
+static int getgrgid_r(gid_t gid, struct group * grp, char * buf,
+ size_t buflen, struct group ** result) { *result = 0; return 0; }
+static int getgrnam_r(const char * name, struct group * grp, char * buf,
+ size_t buflen, struct group ** result) { *result = 0; return 0; }
#endif
int getgrouplist (const char *user, gid_t group,

18
ndk_patches/in.h.patch

@ -0,0 +1,18 @@
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netinet/in.h.html:
"The <netinet/in.h> header shall define the following types:
in_port_t
Equivalent to the type uint16_t as defined in <inttypes.h>"
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/netinet/in.h ./usr/include/netinet/in.h
--- /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/netinet/in.h 2012-08-21 07:23:12.000000000 +0200
+++ ./usr/include/netinet/in.h 2014-07-06 04:31:37.563233271 +0200
@@ -41,6 +41,8 @@
#define INET_ADDRSTRLEN 16
+typedef uint16_t in_port_t;
+
extern int bindresvport (int sd, struct sockaddr_in *sin);
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;

47
ndk_patches/pwd.patch

@ -0,0 +1,47 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/pwd.h ./usr/include/pwd.h
--- /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/pwd.h 2012-08-21 07:23:12.000000000 +0200
+++ ./usr/include/pwd.h 2014-07-06 04:39:02.731221101 +0200
@@ -114,6 +114,43 @@
struct passwd* getpwnam(const char*);
struct passwd* getpwuid(uid_t);
+extern char *realpath(const char *path, char *resolved_path);
+extern void free(void *ptr);
+extern void *memcpy(void *dest, const void *src, size_t n);
+extern size_t strlen(const char *s);
+
+static void android_setup_pwd(struct passwd* pw) {
+ static char realpath_buffer[255];
+ size_t allocated_realpath_len;
+ char* allocated_realpath = realpath("@TERMUX_HOME@/.termux/shell", NULL);
+ if (allocated_realpath == NULL || (allocated_realpath_len = strlen(allocated_realpath)) >= sizeof(realpath_buffer)) {
+ pw->pw_shell = "@TERMUX_PREFIX@/bin/ash";
+ } else {
+ memcpy(realpath_buffer, allocated_realpath, allocated_realpath_len);
+ realpath_buffer[allocated_realpath_len] = 0;
+ pw->pw_shell = realpath_buffer;
+ }
+ free(allocated_realpath);
+ pw->pw_dir = "@TERMUX_HOME@";
+ pw->pw_passwd = "*";
+}
+
+static struct passwd* android_polyfill_getpwuid(uid_t t) {
+ struct passwd* pw = getpwuid(t);
+ if (pw == NULL) return NULL;
+ android_setup_pwd(pw);
+ return pw;
+}
+
+static struct passwd* android_polyfill_getpwnam(const char* name) {
+ struct passwd* pw = getpwnam(name);
+ if (pw == NULL) return NULL;
+ android_setup_pwd(pw);
+ return pw;
+}
+
+#define getpwnam android_polyfill_getpwnam
+#define getpwuid android_polyfill_getpwuid
void endpwent(void);
#if 0 /* MISSING FROM BIONIC */

13
ndk_patches/route.h.patch

@ -0,0 +1,13 @@
Fix problem where <linux/route.h> needed <sys/socket.h> to compile.
diff -u -r /Users/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/linux/route.h ./usr/include/linux/route.h
--- /Users/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/linux/route.h 2014-10-15 04:53:49.000000000 +0200
+++ ./usr/include/linux/route.h 2014-12-14 20:10:13.000000000 +0100
@@ -18,6 +18,7 @@
****************************************************************************/
#ifndef _LINUX_ROUTE_H
#define _LINUX_ROUTE_H
+#include <sys/socket.h> /* for struct sockaddr */
#include <linux/if.h>
#include <linux/compiler.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */

31
ndk_patches/sha1.h

@ -0,0 +1,31 @@
/* $NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $ */
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*/
#ifndef _SYS_SHA1_H_
#define _SYS_SHA1_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH 41
typedef struct {
uint32_t state[5];
uint32_t count[2];
u_char buffer[64];
} SHA1_CTX;
__BEGIN_DECLS
void SHA1Transform(uint32_t[5], const u_char[64]);
void SHA1Init(SHA1_CTX *);
void SHA1Update(SHA1_CTX *, const u_char *, u_int);
void SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *);
__END_DECLS
#endif /* _SYS_SHA1_H_ */

22
ndk_patches/stdio.h.patch

@ -0,0 +1,22 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h ./usr/include/stdio.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h 2014-10-14 22:53:49.000000000 -0400
+++ ./usr/include/stdio.h 2014-12-14 15:11:46.007242332 -0500
@@ -193,7 +193,7 @@
/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
#if __BSD_VISIBLE || __XPG_VISIBLE
-#define P_tmpdir "/tmp/"
+#define P_tmpdir "@TERMUX_PREFIX@/tmp/"
#endif
#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
#define TMP_MAX 308915776
@@ -371,6 +371,9 @@
#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
#endif /* __BSD_VISIBLE */
+/* Needed by gnulibs freading() */
+#define __sferror(p) (((p)->_flags & __SERR) != 0)
+
#if defined(__BIONIC_FORTIFY)
__BEGIN_DECLS

18
ndk_patches/string.h.patch

@ -0,0 +1,18 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/string.h ./usr/include/string.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/string.h 2014-12-02 22:38:31.000000000 -0500
+++ ./usr/include/string.h 2015-05-08 23:00:18.591924680 -0400
@@ -289,6 +289,14 @@
#endif /* defined(__BIONIC_FORTIFY) */
+/* Termux: Patched support for GNU extension function mempcpy(3): */
+#if defined(_GNU_SOURCE) && defined(TERMUX_EXPOSE_MEMPCPY)
+static void* mempcpy(void* dest, void const* src, size_t n)
+{
+ return memcpy(dest, src, n) + n;
+}
+#endif
+
__END_DECLS
#endif /* _STRING_H_ */

5
ndk_patches/sys-fcntl.patch

@ -0,0 +1,5 @@
diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/sys/fcntl.h ./usr/include/sys/fcntl.h
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/sys/fcntl.h 1970-01-01 01:00:00.000000000 +0100
+++ ./usr/include/sys/fcntl.h 2014-01-27 08:44:34.000000000 +0100
@@ -0,0 +1 @@
+#include <fcntl.h>

11
ndk_patches/sys-wait.h.patch

@ -0,0 +1,11 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/sys/wait.h ./usr/include/sys/wait.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/sys/wait.h 2014-10-14 22:53:49.000000000 -0400
+++ ./usr/include/sys/wait.h 2015-05-15 18:28:58.428331748 -0400
@@ -44,6 +44,7 @@
#define WIFEXITED(s) (WTERMSIG(s) == 0)
#define WIFSTOPPED(s) (WTERMSIG(s) == 0x7f)
#define WIFSIGNALED(s) (WTERMSIG((s)+1) >= 2)
+#define WIFCONTINUED(x) (WIFSTOPPED(x) && WSTOPSIG(x) == 0x13)
extern pid_t wait(int *);
extern pid_t waitpid(pid_t, int *, int);

114
ndk_patches/sysexits.h

@ -0,0 +1,114 @@
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)sysexits.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _SYSEXITS_H
#define _SYSEXITS_H 1
/*
* SYSEXITS.H -- Exit status codes for system programs.
*
* This include file attempts to categorize possible error
* exit statuses for system programs, notably delivermail
* and the Berkeley network.
*
* Error numbers begin at EX__BASE to reduce the possibility of
* clashing with other exit statuses that random programs may
* already return. The meaning of the codes is approximately
* as follows:
*
* EX_USAGE -- The command was used incorrectly, e.g., with
* the wrong number of arguments, a bad flag, a bad
* syntax in a parameter, or whatever.
* EX_DATAERR -- The input data was incorrect in some way.
* This should only be used for user's data & not
* system files.
* EX_NOINPUT -- An input file (not a system file) did not
* exist or was not readable. This could also include
* errors like "No message" to a mailer (if it cared
* to catch it).
* EX_NOUSER -- The user specified did not exist. This might
* be used for mail addresses or remote logins.
* EX_NOHOST -- The host specified did not exist. This is used
* in mail addresses or network requests.
* EX_UNAVAILABLE -- A service is unavailable. This can occur
* if a support program or file does not exist. This
* can also be used as a catchall message when something
* you wanted to do doesn't work, but you don't know
* why.
* EX_SOFTWARE -- An internal software error has been detected.
* This should be limited to non-operating system related
* errors as possible.
* EX_OSERR -- An operating system error has been detected.
* This is intended to be used for such things as "cannot
* fork", "cannot create pipe", or the like. It includes
* things like getuid returning a user that does not
* exist in the passwd file.
* EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
* etc.) does not exist, cannot be opened, or has some
* sort of error (e.g., syntax error).
* EX_CANTCREAT -- A (user specified) output file cannot be
* created.
* EX_IOERR -- An error occurred while doing I/O on some file.
* EX_TEMPFAIL -- temporary failure, indicating something that
* is not really an error. In sendmail, this means
* that a mailer (e.g.) could not create a connection,
* and the request should be reattempted later.
* EX_PROTOCOL -- the remote system returned something that
* was "not possible" during a protocol exchange.
* EX_NOPERM -- You did not have sufficient permission to
* perform the operation. This is not intended for
* file system problems, which should use NOINPUT or
* CANTCREAT, but rather for higher level permissions.
*/
#define EX_OK 0 /* successful termination */
#define EX__BASE 64 /* base value for error messages */
#define EX_USAGE 64 /* command line usage error */
#define EX_DATAERR 65 /* data format error */
#define EX_NOINPUT 66 /* cannot open input */
#define EX_NOUSER 67 /* addressee unknown */
#define EX_NOHOST 68 /* host name unknown */
#define EX_UNAVAILABLE 69 /* service unavailable */
#define EX_SOFTWARE 70 /* internal software error */
#define EX_OSERR 71 /* system error (e.g., can't fork) */
#define EX_OSFILE 72 /* critical OS file missing */
#define EX_CANTCREAT 73 /* can't create (user) output file */
#define EX_IOERR 74 /* input/output error */
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
#define EX_PROTOCOL 76 /* remote error in protocol */
#define EX_NOPERM 77 /* permission denied */
#define EX_CONFIG 78 /* configuration error */
#define EX__MAX 78 /* maximum listed value */
#endif /* sysexits.h */

78
ndk_patches/syslog.patch

@ -0,0 +1,78 @@
diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h ./usr/include/syslog.h
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h 2012-08-21 07:23:12.000000000 +0200
+++ ./usr/include/syslog.h 2014-01-29 17:51:55.000000000 +0100
@@ -31,6 +31,8 @@
#include <stdio.h>
#include <sys/cdefs.h>
#include <stdarg.h>
+#include <android/log.h> /* for __android_log_vprint() */
+#include <unistd.h> /* for getpid() */
__BEGIN_DECLS
@@ -111,6 +112,65 @@
extern void syslog_r(int, struct syslog_data *, const char *, ...);
extern void vsyslog_r(int, struct syslog_data *, const char *, va_list);
+extern /*const*/ char* __progname;
+static void android_polyfill_openlog(const char* a, int b, int c) {
+ (void) a;
+ (void) b;
+ (void) c;
+}
+static void android_polyfill_closelog() {}
+
+static void android_polyfill_vsyslog(int syslog_priority, char const* format, va_list ap)
+{
+ android_LogPriority a = ANDROID_LOG_FATAL;
+ switch (syslog_priority) {
+ case LOG_INFO : a = ANDROID_LOG_SILENT ; break;
+ case LOG_EMERG : a = ANDROID_LOG_FATAL ; break;
+ case LOG_ERR : a = ANDROID_LOG_ERROR ; break;
+ case LOG_WARNING : a = ANDROID_LOG_WARN ; break;
+ case LOG_DEBUG : a = ANDROID_LOG_VERBOSE ; break;
+ }
+ char* syslog_text;
+ if (vasprintf(&syslog_text, format, ap) == -1) {
+ __android_log_vprint(a, "syslog", format, ap);
+ return;
+ }
+ __android_log_print(a, "syslog", "%s - %s", __progname, syslog_text);
+ free(syslog_text);
+}
+
+static void android_polyfill_syslog(int priority, const char* format, ...)
+{
+ va_list myargs;
+ va_start(myargs, format);
+ android_polyfill_vsyslog(priority, format, myargs);
+ va_end(myargs);
+}
+
+static void android_polyfill_syslog_r(int syslog_priority, struct syslog_data* d, const char* format, ...)
+{
+ (void) d;
+ va_list myargs;
+ va_start(myargs, format);
+ android_polyfill_vsyslog(syslog_priority, format, myargs);
+ va_end(myargs);
+}
+
+static void android_polyfill_vsyslog_r(int syslog_priority, struct syslog_data* d, const char* fmt, va_list ap)
+{
+ (void) d;
+ android_polyfill_vsyslog(syslog_priority, fmt, ap);
+}
+
+#define openlog android_polyfill_openlog
+#define closelog android_polyfill_closelog
+
+#define syslog android_polyfill_syslog
+#define syslog_r android_polyfill_syslog_r
+
+#define vsyslog android_polyfill_vsyslog
+#define vsyslog_r android_polyfill_vsyslog_r
+
__END_DECLS
#endif /* _SYSLOG_H */

12
ndk_patches/termios.h.patch

@ -0,0 +1,12 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/termios.h ./usr/include/termios.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/termios.h 2014-10-14 22:53:49.000000000 -0400
+++ ./usr/include/termios.h 2015-05-15 18:23:49.264331535 -0400
@@ -49,6 +49,8 @@
int tcsendbreak(int, int);
int tcsetattr(int, int, const struct termios*);
+#define _POSIX_VDISABLE 0
+
__END_DECLS
#endif /* _TERMIOS_H_ */

55
ndk_patches/unistd.patch

@ -0,0 +1,55 @@
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/unistd.h ./usr/include/unistd.h
--- /home/fornwall/lib/android-ndk/platforms/android-19/arch-arm/usr/include/unistd.h 2012-08-21 07:23:12.000000000 +0200
+++ ./usr/include/unistd.h 2014-07-09 09:55:58.443639544 +0200
@@ -35,6 +35,7 @@
#include <sys/sysconf.h>
#include <linux/capability.h>
#include <pathconf.h>
+#include <asm/unistd.h>
__BEGIN_DECLS
@@ -166,6 +174,43 @@
extern char* ttyname(int);
extern int ttyname_r(int, char*, size_t);
+/* start android polyfill of ttyname(3) and ttyname_r(3) */
+#define ttyname(a) android_polyfill_ttyname(a)
+#define ttyname_r(a, b, c) android_polyfill_ttyname_r(a, b, c)
+
+static int android_polyfill_ttyname_r(int fd, char* buf, size_t buflen)
+{
+ char symlink_path[32] = "/proc/self/fd/";
+ ssize_t siz;
+
+ if (!isatty(fd)) return -1;
+
+ /* Would like to do sprintf(symlink_path, "/proc/self/fd/%d", fd), but stdio.h may not be included. */
+ int shifter = fd;
+ char* p = symlink_path + 14;
+ do {
+ p++;
+ shifter = shifter / 10;
+ } while(shifter);
+ *p = '\0';
+ do {
+ *--p = (fd % 10) + '0';
+ fd = fd / 10;
+ } while (fd);
+
+ siz = readlink(symlink_path, buf, buflen);
+ if (siz < 0 || siz == buflen) return -1;
+ buf[siz] = '\0';
+ return 0;
+}
+
+static char* android_polyfill_ttyname(int fd)
+{
+ static char buf[32];
+ return (ttyname_r(fd, buf, sizeof(buf)) == 0) ? buf : NULL;
+}
+/* end android polyfill of ttyname(3) and ttyname_r(3) */
+
extern int acct(const char* filepath);
static __inline__ int getpagesize(void) {

18
ndk_patches/user.h.patch

@ -0,0 +1,18 @@
Needed for binutils on x86.
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-x86/usr/include/sys/user.h ./usr/include/sys/user.h
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-x86/usr/include/sys/user.h 2014-12-01 19:05:05.000000000 -0500
+++ ./usr/include/sys/user.h 2014-12-23 10:31:31.343768553 -0500
@@ -99,6 +99,12 @@
int u_debugreg[8];
};
+/* http://osxr.org/android/source/bionic/libc/kernel/arch-x86/asm/user_32.h#0089 */
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
#elif defined(__x86_64__)
struct user_fpregs_struct {

93
packages/aapt/build.sh

@ -0,0 +1,93 @@
TERMUX_PKG_HOMEPAGE=https://android.googlesource.com/platform/system/core/+/android-4.4.4_r2/libutils
TERMUX_PKG_DESCRIPTION="Android Asset Packaging Tool"
TERMUX_PKG_VERSION=5.1.0
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_DEPENDS="libexpat, libpng, libgnustl"
termux_step_make_install () {
local _TAGNAME=${TERMUX_PKG_VERSION}_r1
LIBCUTILS_TARFILE=$TERMUX_PKG_CACHEDIR/libcutils_${_TAGNAME}.tar.gz
LIBUTILS_TARFILE=$TERMUX_PKG_CACHEDIR/libutils_${_TAGNAME}.tar.gz
ANDROIDFW_TARFILE=$TERMUX_PKG_CACHEDIR/androidfw_${_TAGNAME}.tar.gz
AAPT_TARFILE=$TERMUX_PKG_CACHEDIR/aapt_${_TAGNAME}.tar.gz
LIBZIPARCHIVE_TARFILE=$TERMUX_PKG_CACHEDIR/libziparchive_${_TAGNAME}.tar.gz
ZIPALIGN_TARFILE=$TERMUX_PKG_CACHEDIR/zipalign_${_TAGNAME}.tar.gz
test ! -f $LIBCUTILS_TARFILE && curl -o $LIBCUTILS_TARFILE "https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/libcutils.tar.gz"
test ! -f $LIBUTILS_TARFILE && curl -o $LIBUTILS_TARFILE "https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/libutils.tar.gz"
test ! -f $ANDROIDFW_TARFILE && curl -o $ANDROIDFW_TARFILE "https://android.googlesource.com/platform/frameworks/base/+archive/android-$_TAGNAME/libs/androidfw.tar.gz"
test ! -f $AAPT_TARFILE && curl -o $AAPT_TARFILE "https://android.googlesource.com/platform/frameworks/base/+archive/android-$_TAGNAME/tools/aapt.tar.gz"
test ! -f $ZIPALIGN_TARFILE && curl -o $ZIPALIGN_TARFILE "https://android.googlesource.com/platform/build.git/+archive/android-$_TAGNAME/tools/zipalign.tar.gz"
test ! -f $LIBZIPARCHIVE_TARFILE && curl -o $LIBZIPARCHIVE_TARFILE "https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/libziparchive.tar.gz"
# https://android.googlesource.com/platform/system/core/+/android-4.4.4_r2/include/cutils/
LIBCUTILS_INCLUDE_TARFILE=$TERMUX_PKG_CACHEDIR/libcutils_include_${_TAGNAME}.tar.gz
test ! -f $LIBCUTILS_INCLUDE_TARFILE && curl -o $LIBCUTILS_INCLUDE_TARFILE \
"https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/include/cutils.tar.gz"
# https://android.googlesource.com/platform/system/core/+/android-4.4.4_r2/include/utils/
LIBUTILS_INCLUDE_TARFILE=$TERMUX_PKG_CACHEDIR/libutils_include_${_TAGNAME}.tar.gz
test ! -f $LIBUTILS_INCLUDE_TARFILE && curl -o $LIBUTILS_INCLUDE_TARFILE \
"https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/include/utils.tar.gz"
# https://android.googlesource.com/platform/frameworks/base/+/android-4.4.4_r2/include/androidfw/
ANDROIDFW_INCLUDE_TARFILE=$TERMUX_PKG_CACHEDIR/androidfw_include_${_TAGNAME}.tar.gz
test ! -f $ANDROIDFW_INCLUDE_TARFILE && curl -o $ANDROIDFW_INCLUDE_TARFILE \
"https://android.googlesource.com/platform/frameworks/base/+archive/android-$_TAGNAME/include/androidfw.tar.gz"
LIBZIPARCHIVE_INCLUDE_TARFILE=$TERMUX_PKG_CACHEDIR/libziparchive_include_${_TAGNAME}.tar.gz
test ! -f $LIBZIPARCHIVE_INCLUDE_TARFILE && curl -o $LIBZIPARCHIVE_INCLUDE_TARFILE \
"https://android.googlesource.com/platform/system/core/+archive/android-$_TAGNAME/include/ziparchive.tar.gz"
mkdir -p include/{cutils,utils,androidfw,log,system,ziparchive} libcutils libutils androidfw aapt zipalign ziparchive
(cd include/cutils; tar xf $LIBCUTILS_INCLUDE_TARFILE)
(cd include/utils; tar xf $LIBUTILS_INCLUDE_TARFILE; rm CallStack.h; touch CallStack.h)
(cd include/androidfw; tar xf $ANDROIDFW_INCLUDE_TARFILE)
(cd include/ziparchive; tar xf $LIBZIPARCHIVE_INCLUDE_TARFILE)
touch include/system/graphics.h
cp $TERMUX_PKG_BUILDER_DIR/log.h include/log/
cp $TERMUX_PKG_BUILDER_DIR/thread_defs.h include/system/
# to satisfy <libexpat/expat.h> include:
ln -s "$TERMUX_PREFIX/include" include/libexpat
cd libcutils
tar xf $LIBCUTILS_TARFILE
rm trace.c dlmalloc_stubs.c ashmem-host.c
cd ../libutils
tar xf $LIBUTILS_TARFILE
rm CallStack.cpp ProcessCallStack.cpp Trace.cpp
perl -p -i -e 's/__android_log_print\(mPriority, mLogTag,/printf(/' Printer.cpp
cd ../androidfw
tar xf $ANDROIDFW_TARFILE
rm BackupData.cpp BackupHelpers.cpp CursorWindow.cpp
cd ../ziparchive
tar xf $LIBZIPARCHIVE_TARFILE
rm zip_archive_test.cc
# png_set_expand_gray_1_2_4_to_8(png_ptr) is the newer name instead of png_set_gray_1_2_4_to_8(png_ptr):
# libpng no longer defines "#define png_sizeof(x) (sizeof (x))"
# -include <zlib.h> since png.h no longer includes zlib.h
COMPILE_FLAGS="$CC $CFLAGS \
-DANDROID_SMP=1 \
-DHAVE_ENDIAN_H=1 -DHAVE_POSIX_FILEMAP=1 -DHAVE_OFF64_T=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_PTHREADS=1 \
-DNDEBUG=1 \
-Dpng_set_gray_1_2_4_to_8=png_set_expand_gray_1_2_4_to_8 -Dpng_sizeof=sizeof -include zlib.h \
-I $TERMUX_PKG_SRCDIR/include \
-I $TERMUX_PREFIX/include \
$LDFLAGS \
-lm -lz -lpng -lexpat -lgnustl_shared \
../libcutils/*.c ../ziparchive/*.cc ../libutils/*.cpp ../androidfw/*.cpp *.cpp"
cd ../aapt
tar xf $AAPT_TARFILE
rm printapk.cpp
perl -p -i -e 's/png_ptr->io_ptr/png_get_io_ptr(png_ptr)/' Images.cpp
$COMPILE_FLAGS *.c -o $TERMUX_PREFIX/bin/aapt
# zipalign needs "zopfli/deflate.h", so disable for now:
#cd ../zipalign
#tar xf $ZIPALIGN_TARFILE
#$COMPILE_FLAGS -o $TERMUX_PREFIX/bin/zipalign
}

31
packages/aapt/log.h

@ -0,0 +1,31 @@
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <android/log.h>
/* https://android.googlesource.com/platform/system/core/+/android-4.4.4_r2/include/log/log.h */
#define QUOTEME_(x) #x
#define QUOTEME(x) QUOTEME_(x)
#define ALOGV(...) printf("VERBOSE (" __FILE__ ":" QUOTEME(__LINE__) "): " __VA_ARGS__)
#define ALOGD(...) printf("DEBUG (" __FILE__ ":" QUOTEME(__LINE__) "): " __VA_ARGS__)
#define ALOGI(...) printf("INFO (" __FILE__ ":" QUOTEME(__LINE__) "): " __VA_ARGS__)
#define ALOGW(...) printf("WARNING (" __FILE__ ":" QUOTEME(__LINE__) "): " __VA_ARGS__)
#define ALOGE(...) printf("ERROR (" __FILE__ ":" QUOTEME(__LINE__) "): " __VA_ARGS__)
#define HAL_PRIORITY_URGENT_DISPLAY ANDROID_LOG_INFO
#define LOG_FATAL_IF(...)
#define LOG_ALWAYS_FATAL(...)
#define LOG_ALWAYS_FATAL_IF(...)
#define LOG_PRI(...)
#define ALOGW_IF(...)
#define android_printAssert(cond, tag, fmt...)
#define ALOG_ASSERT(...)
#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
#define OS_PATH_SEPARATOR '/'

78
packages/aapt/thread_defs.h

@ -0,0 +1,78 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_THREAD_DEFS_H
#define ANDROID_THREAD_DEFS_H
/* FREDRIK */
/* #include "graphics.h" */
#if defined(__cplusplus)
extern "C" {
#endif
enum {
/*
* ***********************************************
* ** Keep in sync with android.os.Process.java **
* ***********************************************
*
* This maps directly to the "nice" priorities we use in Android.
* A thread priority should be chosen inverse-proportionally to
* the amount of work the thread is expected to do. The more work
* a thread will do, the less favorable priority it should get so that
* it doesn't starve the system. Threads not behaving properly might
* be "punished" by the kernel.
* Use the levels below when appropriate. Intermediate values are
* acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
*/
ANDROID_PRIORITY_LOWEST = 19,
/* use for background tasks */
ANDROID_PRIORITY_BACKGROUND = 10,
/* most threads run at normal priority */
ANDROID_PRIORITY_NORMAL = 0,
/* threads currently running a UI that the user is interacting with */
ANDROID_PRIORITY_FOREGROUND = -2,
/* the main UI thread has a slightly more favorable priority */
ANDROID_PRIORITY_DISPLAY = -4,
/* ui service treads might want to run at a urgent display (uncommon) */
ANDROID_PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_DISPLAY /* FREDRIK */,
/* all normal audio threads */
ANDROID_PRIORITY_AUDIO = -16,
/* service audio threads (uncommon) */
ANDROID_PRIORITY_URGENT_AUDIO = -19,
/* should never be used in practice. regular process might not
* be allowed to use this level */
ANDROID_PRIORITY_HIGHEST = -20,
ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL,
ANDROID_PRIORITY_MORE_FAVORABLE = -1,
ANDROID_PRIORITY_LESS_FAVORABLE = +1,
};
#if defined(__cplusplus)
}
#endif
#endif /* ANDROID_THREAD_DEFS_H */

9
packages/angband/build.sh

@ -0,0 +1,9 @@
TERMUX_PKG_VERSION=3.5.1
TERMUX_PKG_SRCURL=http://rephial.org/downloads/3.5/angband-v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_FOLDERNAME=angband-$TERMUX_PKG_VERSION
TERMUX_PKG_HOMEPAGE=http://rephial.org/
TERMUX_PKG_DESCRIPTION="Dungeon exploration game where you play an adventurer seeking riches, fighting monsters and preparing for a final battle with Morgoth, the Lord of Darkness"
TERMUX_PKG_DEPENDS="libandroid-support, ncurses"
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--without-x --bindir=$TERMUX_PREFIX/bin --sysconfdir=$TERMUX_PREFIX/share/angband"
TERMUX_PKG_RM_AFTER_INSTALL="share/angband/xtra"

26
packages/angband/configure.patch

@ -0,0 +1,26 @@
diff -u -r ../angband-v3.5.0/configure ./configure
--- ../angband-v3.5.0/configure 2013-12-24 16:56:55.000000000 +0100
+++ ./configure 2014-03-10 01:27:04.085884186 +0100
@@ -4879,18 +4879,18 @@
if test x$ncurses_exec_prefix != x ; then
ncurses_args="$ncurses_args --exec-prefix=$ncurses_exec_prefix"
if test x${NCURSES_CONFIG+set} != xset ; then
- NCURSES_CONFIG=$ncurses_exec_prefix/bin/ncursesw5-config
+ NCURSES_CONFIG=$ncurses_exec_prefix/bin/ncursesw6-config
fi
fi
if test x$ncurses_prefix != x ; then
ncurses_args="$ncurses_args --prefix=$ncurses_prefix"
if test x${NCURSES_CONFIG+set} != xset ; then
- NCURSES_CONFIG=$ncurses_prefix/bin/ncursesw5-config
+ NCURSES_CONFIG=$ncurses_prefix/bin/ncursesw6-config
fi
fi
- # Extract the first word of "ncursesw5-config", so it can be a program name with args.
-set dummy ncursesw5-config; ac_word=$2
+ # Extract the first word of "ncursesw6-config", so it can be a program name with args.
+set dummy ncursesw6-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_NCURSES_CONFIG+:} false; then :

28
packages/angband/no_langinfo.patch

@ -0,0 +1,28 @@
diff -u -r ../angband-v3.5.0/src/main.c ./src/main.c
--- ../angband-v3.5.0/src/main.c 2013-12-24 16:56:52.000000000 +0100
+++ ./src/main.c 2014-02-06 03:15:12.000000000 +0100
@@ -23,8 +23,10 @@
#include "savefile.h"
/* locale junk */
+#ifndef __ANDROID__
#include "locale.h"
#include "langinfo.h"
+#endif
/*
* Some machines have a "main()" function in their "main-xxx.c" file,
@@ -555,11 +557,13 @@
if (mstr)
ANGBAND_SYS = mstr;
+#ifndef __ANDROID__
if (setlocale(LC_CTYPE, "")) {
/* Require UTF-8 */
if (strcmp(nl_langinfo(CODESET), "UTF-8") != 0)
quit("Angband requires UTF-8 support");
}
+#endif
/* Try the modules in the order specified by modules[] */
for (i = 0; i < (int)N_ELEMENTS(modules); i++)

81
packages/ant/ant

@ -0,0 +1,81 @@
#!@TERMUX_PREFIX@/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e -u
# Extract launch and ant arguments, (see details below).
ant_exec_args=
no_config=false
ant_exec_debug=false
show_help=false
for arg in "$@" ; do
if [ "$arg" = "--noconfig" ] ; then
no_config=true
elif [ "$arg" = "--execdebug" ] ; then
ant_exec_debug=true
elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
show_help=true
ant_exec_args="$ant_exec_args -h"
else
if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
show_help=true
fi
ant_exec_args="$ant_exec_args \"$arg\""
fi
done
if [ -z "$ANT_HOME" ]; then
ANT_HOME=@TERMUX_PREFIX@/share/ant
fi
if ! $no_config ; then
if [ -f "$HOME/.ant/ant.conf" ] ; then
. $HOME/.ant/ant.conf
fi
if [ -f "$HOME/.antrc" ] ; then
. "$HOME/.antrc"
fi
fi
ANT_LIB="${ANT_HOME}/lib"
if [ -z "$LOCALCLASSPATH" ] ; then
LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
else
LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
fi
# Show script help if requested
if $show_help ; then
echo $0 '[script options] [options] [target [target2 [target3] ..]]'
echo 'Script Options:'
echo ' --help, --h print this message and ant help'
echo ' --noconfig suppress sourcing of /etc/ant.conf,'
echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'
echo ' configuration files'
echo ' --execdebug print ant exec line generated by this'
echo ' launch script'
echo ' '
fi
# Execute ant using eval/exec to preserve spaces in paths, java options, and ant args
ant_sys_opts=
ant_exec_command="exec dalvikvm $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\""
if $ant_exec_debug ; then
echo $ant_exec_command $ant_exec_args
fi
eval $ant_exec_command "$ant_exec_args"

21
packages/ant/build.sh

@ -0,0 +1,21 @@
TERMUX_PKG_HOMEPAGE=http://ant.apache.org/
TERMUX_PKG_DESCRIPTION="Java based build tool like make"
TERMUX_PKG_VERSION=1.9.5
TERMUX_PKG_SRCURL=http://apache.mirrors.spacedump.net//ant/binaries/apache-ant-${TERMUX_PKG_VERSION}-bin.tar.bz2
TERMUX_PKG_FOLDERNAME=apache-ant-${TERMUX_PKG_VERSION}
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_PLATFORM_INDEPENDENT=true
termux_step_make_install () {
mkdir -p $TERMUX_PREFIX/share/ant/lib
for jar in ant ant-launcher; do
$TERMUX_DX \
--dex \
--output=$TERMUX_PREFIX/share/ant/lib/${jar}.jar \
lib/${jar}.jar
done
install $TERMUX_PKG_BUILDER_DIR/ant $TERMUX_PREFIX/bin/ant
perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/ant
}

7
packages/apr-util/build.sh

@ -0,0 +1,7 @@
TERMUX_PKG_VERSION=1.5.4
TERMUX_PKG_DEPENDS="apr, libexpat"
TERMUX_PKG_HOMEPAGE=https://apr.apache.org/
TERMUX_PKG_DESCRIPTION="Apache Portable Runtime - library providing a predictable and consistent interface to underlying platform-specific implementations"
TERMUX_PKG_SRCURL=http://apache.mirrors.spacedump.net/apr/apr-util-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-apr=$TERMUX_PREFIX --without-sqlite3"
TERMUX_PKG_RM_AFTER_INSTALL="bin/apu-1-config lib/aprutil.exp"

15
packages/apr/Makefile.in.patch

@ -0,0 +1,15 @@
diff -u -r ../apr-1.5.2/Makefile.in ./Makefile.in
--- ../apr-1.5.2/Makefile.in 2014-04-25 06:51:11.000000000 -0400
+++ ./Makefile.in 2015-05-03 19:04:44.159616097 -0400
@@ -134,8 +134,9 @@
$(APR_MKDIR) tools
$(LT_COMPILE)
-tools/gen_test_char@EXEEXT@: $(OBJECTS_gen_test_char)
- $(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS)
+tools/gen_test_char@EXEEXT@: tools/gen_test_char.c
+ $(CC_FOR_BUILD) -DCROSS_COMPILE -o $@ $<
+
include/private/apr_escape_test_char.h: tools/gen_test_char@EXEEXT@
$(APR_MKDIR) include/private

7
packages/apr/build.sh

@ -0,0 +1,7 @@
TERMUX_PKG_VERSION=1.5.2
TERMUX_PKG_SRCURL=http://archive.apache.org/dist/apr/apr-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_HOMEPAGE=https://apr.apache.org/
TERMUX_PKG_DESCRIPTION="Apache Portable Runtime - library providing a predictable and consistent interface to underlying platform-specific implementations"
TERMUX_PKG_BUILD_IN_SRC="yes"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-installbuilddir=$TERMUX_PKG_TMPDIR ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_process_shared_works=no apr_cv_tcp_nodelay_with_cork=yes ac_cv_sizeof_struct_iovec=8"
TERMUX_PKG_RM_AFTER_INSTALL="bin/apr-1-config lib/apr.exp"

11
packages/apt/Makefile.patch

@ -0,0 +1,11 @@
diff -u -r ../upstream.git/Makefile ./Makefile
--- ../upstream.git/Makefile 2013-12-07 14:12:14.000000000 +0100
+++ ./Makefile 2014-05-03 23:46:58.870093099 +0200
@@ -21,7 +21,6 @@
$(MAKE) -C dselect $@
$(MAKE) -C doc $@
$(MAKE) -C po $@
- $(MAKE) -C test $@
all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs

35
packages/apt/apt-get.patch

@ -0,0 +1,35 @@
diff -u -r ../upstream.git/cmdline/apt-get.cc ./cmdline/apt-get.cc
--- ../upstream.git/cmdline/apt-get.cc 2014-03-14 09:05:18.000000000 +0100
+++ ./cmdline/apt-get.cc 2014-04-15 21:01:01.072700439 +0200
@@ -79,8 +79,11 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/statfs.h>
-#include <sys/statvfs.h>
+#ifndef __ANDROID__
+# include <sys/statvfs.h>
+#endif
#include <sys/wait.h>
+#include <termios.h>
#include <unistd.h>
#include <algorithm>
#include <fstream>
@@ -854,14 +857,14 @@
unsigned long long DebBytes = Fetcher.TotalNeeded();
// Check for enough free space
- struct statvfs Buf;
+ struct statfs Buf;
string OutputDir = ".";
- if (statvfs(OutputDir.c_str(),&Buf) != 0) {
+ if (statfs(OutputDir.c_str(),&Buf) != 0) {
if (errno == EOVERFLOW)
- return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
+ return _error->WarningE("statfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
else
- return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
+ return _error->Errno("statfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
} else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{

46
packages/apt/apt-key.patch

@ -0,0 +1,46 @@
diff -u -r ../upstream.git/cmdline/apt-key.in ./cmdline/apt-key.in
--- ../upstream.git/cmdline/apt-key.in 2014-04-25 13:39:00.000000000 +0200
+++ ./cmdline/apt-key.in 2014-06-03 11:55:07.623749140 +0200
@@ -40,10 +40,7 @@
TMP_KEYRING=${APT_DIR}/var/lib/apt/keyrings/maybe-import-keyring.gpg
requires_root() {
- if [ "$(id -u)" -ne 0 ]; then
- echo >&1 "ERROR: This command can only be used by root."
- exit 1
- fi
+ # We do not require root
}
# gpg defaults to mode 0600 for new keyrings. Create one with 0644 instead.
@@ -216,11 +213,11 @@
remove_key_from_keyring "$FORCED_KEYRING" "$1"
else
# otherwise all known keyrings are up for inspection
- local TRUSTEDFILE="/etc/apt/trusted.gpg"
+ local TRUSTEDFILE="@TERMUX_PREFIX@/etc/apt/trusted.gpg"
eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring)
eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f)
remove_key_from_keyring "$TRUSTEDFILE" "$1"
- TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
+ TRUSTEDPARTS="@TERMUX_PREFIX@/etc/apt/trusted.gpg.d"
eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)
if [ -d "$TRUSTEDPARTS" ]; then
for trusted in $(run-parts --list "$TRUSTEDPARTS" --regex '^.*\.gpg$'); do
@@ -278,14 +275,14 @@
done
if [ -z "$TRUSTEDFILE" ]; then
- TRUSTEDFILE="/etc/apt/trusted.gpg"
+ TRUSTEDFILE="@TERMUX_PREFIX@/etc/apt/trusted.gpg"
eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring)
eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f)
if [ -r "$TRUSTEDFILE" ]; then
GPG="$GPG --keyring $TRUSTEDFILE"
fi
GPG="$GPG --primary-keyring $TRUSTEDFILE"
- TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
+ TRUSTEDPARTS="@TERMUX_PREFIX@/etc/apt/trusted.gpg.d"
eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)
if [ -d "$TRUSTEDPARTS" ]; then
# strip / suffix as gpg will double-slash in that case (#665411)

26
packages/apt/apt-pkg-init-dir.patch

@ -0,0 +1,26 @@
diff -u -r ../upstream.git/apt-pkg/init.cc ./apt-pkg/init.cc
--- ../upstream.git/apt-pkg/init.cc 2014-05-05 14:01:59.000000000 +0200
+++ ./apt-pkg/init.cc 2014-06-04 13:57:49.848604233 +0200
@@ -44,7 +44,8 @@
Cnf.Set("APT::Build-Essential::", "build-essential");
Cnf.CndSet("APT::Install-Recommends", true);
Cnf.CndSet("APT::Install-Suggests", false);
- Cnf.CndSet("Dir","/");
+ Cnf.CndSet("Dir","@TERMUX_PREFIX@/");
+ Cnf.CndSet("Acquire::Languages", "none");
// State
Cnf.CndSet("Dir::State","var/lib/apt/");
@@ -71,9 +72,9 @@
Cnf.CndSet("Dir::Etc::preferencesparts","preferences.d");
Cnf.CndSet("Dir::Etc::trusted", "trusted.gpg");
Cnf.CndSet("Dir::Etc::trustedparts","trusted.gpg.d");
- Cnf.CndSet("Dir::Bin::methods","/usr/lib/apt/methods");
- Cnf.CndSet("Dir::Bin::solvers::","/usr/lib/apt/solvers");
- Cnf.CndSet("Dir::Media::MountPath","/media/apt");
+ Cnf.CndSet("Dir::Bin::methods","lib/apt/methods");
+ Cnf.CndSet("Dir::Bin::solvers::","lib/apt/solvers");
+ Cnf.CndSet("Dir::Media::MountPath","media/apt");
// State
Cnf.CndSet("Dir::Log","var/log/apt");

12
packages/apt/apt-pkg-makefile-no-libutil.patch

@ -0,0 +1,12 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/makefile ./apt-pkg/makefile
--- ../apt-0.9.16.1/apt-pkg/makefile 2014-03-15 17:59:06.000000000 +0100
+++ ./apt-pkg/makefile 2014-03-25 01:26:00.600685588 +0100
@@ -14,7 +14,7 @@
LIBRARY=apt-pkg
MAJOR=$(LIBAPTPKG_MAJOR)
MINOR=$(LIBAPTPKG_RELEASE)
-SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl
+SLIBS=$(PTHREADLIB) $(INTLLIBS) -ldl
ifeq ($(HAVE_ZLIB),yes)
SLIBS+= -lz
endif

3
packages/apt/apt-transport-https.subpackage.sh

@ -0,0 +1,3 @@
TERMUX_SUBPKG_INCLUDE="lib/apt/methods/https"
TERMUX_SUBPKG_DESCRIPTION="Https download support for APT"
TERMUX_SUBPKG_DEPENDS="apt, libcurl"

32
packages/apt/aptconfiguration.patch

@ -0,0 +1,32 @@
diff -u -r ../upstream.git/apt-pkg/aptconfiguration.cc ./apt-pkg/aptconfiguration.cc
--- ../upstream.git/apt-pkg/aptconfiguration.cc 2014-04-25 13:39:00.000000000 +0200
+++ ./apt-pkg/aptconfiguration.cc 2014-06-03 11:39:43.931774391 +0200
@@ -193,7 +193,7 @@
// get the environment language codes: LC_MESSAGES (and later LANGUAGE)
// we extract both, a long and a short code and then we will
// check if we actually need both (rare) or if the short is enough
- string const envMsg = string(Locale == 0 ? std::setlocale(LC_MESSAGES, NULL) : *Locale);
+ string const envMsg = "en_US.UTF-8"; // string(Locale == 0 ? std::setlocale(LC_MESSAGES, NULL) : *Locale);
size_t const lenShort = (envMsg.find('_') != string::npos) ? envMsg.find('_') : 2;
size_t const lenLong = (envMsg.find_first_of(".@") != string::npos) ? envMsg.find_first_of(".@") : (lenShort + 3);
@@ -405,8 +405,8 @@
// setDefaultConfigurationForCompressors /*{{{*/
void Configuration::setDefaultConfigurationForCompressors() {
// Set default application paths to check for optional compression types
- _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
- _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
+ _config->CndSet("Dir::Bin::bzip2", "bin/bzip2");
+ _config->CndSet("Dir::Bin::xz", "bin/xz");
if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
_config->Set("Dir::Bin::lzma", _config->FindFile("Dir::Bin::xz"));
_config->Set("APT::Compressor::lzma::Binary", "xz");
@@ -419,7 +419,7 @@
_config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
}
} else {
- _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
+ _config->CndSet("Dir::Bin::lzma", "bin/lzma");
if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
_config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
_config->Set("APT::Compressor::lzma::CompressArg::", "-9");

47
packages/apt/build.sh

@ -0,0 +1,47 @@
TERMUX_PKG_HOMEPAGE=https://packages.debian.org/apt
TERMUX_PKG_DESCRIPTION="Front-end for the dpkg package manager"
TERMUX_PKG_DEPENDS="libbz2, liblzma, libgnustl, dpkg, gnupg"
TERMUX_PKG_VERSION=1.0.9.10
TERMUX_PKG_SRCURL=http://ftp.debian.org/debian/pool/main/a/apt/apt_${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--host=${TERMUX_ARCH}-linux --disable-rpath acl_cv_rpath=$TERMUX_PREFIX/lib gt_cv_func_CFPreferencesCopyAppValue=no gt_cv_func_CFLocaleCopyCurrent=no ac_cv_c_bigendian=no --no-create"
TERMUX_PKG_FOLDERNAME=apt-${TERMUX_PKG_VERSION}
TERMUX_PKG_ESSENTIAL=yes
# $NDK/docs/STANDALONE-TOOLCHAIN.html: "If you use the GNU libstdc++, you will need to explicitly link with libsupc++ if you use these features"
export LDFLAGS="$LDFLAGS -lgnustl_shared" # -lsupc++"
termux_step_pre_configure () {
cp $TERMUX_COMMON_CACHEDIR/config.{guess,sub} $TERMUX_PKG_SRCDIR/buildlib
perl -p -i -e "s/TERMUX_ARCH/$TERMUX_ARCH/" $TERMUX_PKG_SRCDIR/configure
}
termux_step_post_configure () {
# This is needed to generate makefile, but does not work due to configure arguments not being remembered
./config.status
}
termux_step_make () {
unset CC
unset CFLAGS
unset LDFLAGS
unset CXX
unset CXXFLAGS
make
}
termux_step_make_install () {
cp $TERMUX_PKG_BUILDDIR/bin/apt{,-get,-cache,-config,-key} $TERMUX_PREFIX/bin/
cp $TERMUX_PKG_BUILDDIR/bin/libapt-{pkg.so.4.12,private.so.0.0} $TERMUX_PREFIX/lib/
(cd $TERMUX_PREFIX/lib; rm -f libapt-pkg.so; ln -s libapt-pkg.so.4.12 libapt-pkg.so) # used by python-apt
mkdir -p $TERMUX_PREFIX/lib/apt/methods $TERMUX_PREFIX/share/man/man{5,8}
cp $TERMUX_PKG_BUILDDIR/docs/apt{,-cache,-get}.8 $TERMUX_PREFIX/share/man/man8/
cp $TERMUX_PKG_BUILDDIR/docs/{apt.conf,sources.list}.5 $TERMUX_PREFIX/share/man/man5/
cp $TERMUX_PKG_BUILDDIR/bin/methods/{copy,file,gpgv,gzip,http,https} $TERMUX_PREFIX/lib/apt/methods
(cd $TERMUX_PREFIX/lib/apt/methods; ln -f -s gzip bzip2)
mkdir -p $TERMUX_PREFIX/etc/apt
printf "# The main termux repository:\ndeb [arch=all,${TERMUX_ARCH}] http://apt.termux.com stable main\n" > $TERMUX_PREFIX/etc/apt/sources.list
# The trusted.gpg was created with "apt-key add public-key.key":
cp $TERMUX_PKG_BUILDER_DIR/trusted.gpg $TERMUX_PREFIX/etc/apt/
}

44
packages/apt/cdrumtl.patch

@ -0,0 +1,44 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/contrib/cdromutl.cc ./apt-pkg/contrib/cdromutl.cc
--- ../apt-0.9.16.1/apt-pkg/contrib/cdromutl.cc 2014-03-15 17:26:21.000000000 +0100
+++ ./apt-pkg/contrib/cdromutl.cc 2014-03-25 00:58:55.948730001 +0100
@@ -24,7 +24,6 @@
#include <iostream>
#include <string>
#include <vector>
-#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -239,6 +238,7 @@
closedir(D);
// Some stats from the fsys
+#ifndef __ANDROID__
if (_config->FindB("Debug::identcdrom",false) == false)
{
struct statvfs Buf;
@@ -258,6 +258,7 @@
}
else
sprintf(S,"-%u.debug",Version);
+#endif
Res = Hash.Result().Value() + S;
return true;
@@ -266,6 +267,7 @@
// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
string FindMountPointForDevice(const char *devnode)
{
+#ifndef __ANDROID__
// this is the order that mount uses as well
std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount");
@@ -290,7 +292,7 @@
}
fclose(f);
}
-
+#endif
return string();
}
/*}}}*/

18
packages/apt/cmndline-no-strchrnul.patch

@ -0,0 +1,18 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/contrib/cmndline.cc ./apt-pkg/contrib/cmndline.cc
--- ../apt-0.9.16.1/apt-pkg/contrib/cmndline.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./apt-pkg/contrib/cmndline.cc 2014-03-25 01:10:30.764711007 +0100
@@ -27,6 +27,14 @@
/*}}}*/
using namespace std;
+#if defined(__ANDROID__)
+static char* strchrnul(char const* s, int c)
+{
+ char* result = strchr(s, c);
+ return (result == NULL) ? const_cast<char*>(s + strlen(s)) : result;
+}
+#endif
+
// CommandLine::CommandLine - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */

15
packages/apt/configure.ac.patch

@ -0,0 +1,15 @@
diff -u -r ../upstream.git/configure.ac ./configure.ac
--- ../upstream.git/configure.ac 2014-06-18 14:12:32.000000000 +0200
+++ ./configure.ac 2014-06-18 23:18:51.219899072 +0200
@@ -89,11 +89,6 @@
AC_MSG_ERROR([failed: I need CURL due https support]),
)
-AC_LANG_PUSH([C++])
-AC_CHECK_HEADER(gtest/gtest.h,,
- AC_MSG_ERROR([failed: I need gtest to build tests]),
-)
-AC_LANG_POP([C++])
AC_SUBST(BDBLIB)

24
packages/apt/configure.patch

@ -0,0 +1,24 @@
diff -u -r ../upstream.git/configure ./configure
--- ../upstream.git/configure 2014-06-18 14:12:34.000000000 +0200
+++ ./configure 2014-06-18 23:09:25.315914542 +0200
@@ -4807,11 +4807,6 @@
ac_fn_cxx_check_header_mongrel "$LINENO" "gtest/gtest.h" "ac_cv_header_gtest_gtest_h" "$ac_includes_default"
-if test "x$ac_cv_header_gtest_gtest_h" = xyes; then :
-
-else
- as_fn_error $? "failed: I need gtest to build tests" "$LINENO" 5
-fi
ac_ext=c
@@ -4986,7 +4981,7 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking debian architecture" >&5
$as_echo_n "checking debian architecture... " >&6; }
-archset="`dpkg-architecture -qDEB_HOST_ARCH`"
+archset=TERMUX_ARCH
if test "x$archset" = "x"; then
as_fn_error $? "failed: use --host= or output from dpkg-architecture" "$LINENO" 5
fi

12
packages/apt/connect-use-socklen_t.patch

@ -0,0 +1,12 @@
diff -u -r ../apt-0.9.16.1/methods/connect.cc ./methods/connect.cc
--- ../apt-0.9.16.1/methods/connect.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./methods/connect.cc 2014-03-25 01:30:10.924678745 +0100
@@ -111,7 +111,7 @@
// Check the socket for an error condition
unsigned int Err;
- unsigned int Len = sizeof(Err);
+ socklen_t Len = sizeof(Err);
if (getsockopt(Fd,SOL_SOCKET,SO_ERROR,&Err,&Len) != 0)
return _error->Errno("getsockopt",_("Failed"));

27
packages/apt/debrecords-cc-no-langinfo.patch

@ -0,0 +1,27 @@
diff -u -r ../upstream.git/apt-pkg/deb/debrecords.cc ./apt-pkg/deb/debrecords.cc
--- ../upstream.git/apt-pkg/deb/debrecords.cc 2014-04-25 13:39:00.000000000 +0200
+++ ./apt-pkg/deb/debrecords.cc 2014-07-01 16:47:41.913835586 +0200
@@ -22,7 +22,9 @@
#include <algorithm>
#include <string>
#include <vector>
+#ifndef __ANDROID__
#include <langinfo.h>
+#endif
/*}}}*/
using std::string;
@@ -151,11 +153,13 @@
orig = Section.FindS(string("Description-").append(*l).c_str());
}
+#ifndef __ANDROID__
char const * const codeset = nl_langinfo(CODESET);
if (strcmp(codeset,"UTF-8") != 0) {
UTF8ToCodeset(codeset, orig, &dest);
orig = dest;
}
+#endif
return orig;
}

18
packages/apt/debsrcrecords.patch

@ -0,0 +1,18 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/deb/debsrcrecords.cc ./apt-pkg/deb/debsrcrecords.cc
--- ../apt-0.9.16.1/apt-pkg/deb/debsrcrecords.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./apt-pkg/deb/debsrcrecords.cc 2014-03-25 01:23:30.652689687 +0100
@@ -26,6 +26,14 @@
#include <string>
#include <vector>
/*}}}*/
+#if defined(__ANDROID__)
+static char* strchrnul(char const* s, int c)
+{
+ char* result = strchr(s, c);
+ return (result == NULL) ? const_cast<char*>(s + strlen(s)) : result;
+}
+#endif
+
using std::max;
using std::string;

26
packages/apt/debsystem-paths.patch

@ -0,0 +1,26 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/deb/debsystem.cc ./apt-pkg/deb/debsystem.cc
--- ../apt-0.9.16.1/apt-pkg/deb/debsystem.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./apt-pkg/deb/debsystem.cc 2014-03-27 13:39:56.648378401 +0100
@@ -187,8 +187,8 @@
which is yet to be determined. The functions in pkgcachegen should
be the only users of these */
Cnf.CndSet("Dir::State::extended_states", "extended_states");
- Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status");
- Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
+ Cnf.CndSet("Dir::State::status","@TERMUX_PREFIX@/var/lib/dpkg/status");
+ Cnf.CndSet("Dir::Bin::dpkg","@TERMUX_PREFIX@/bin/dpkg");
if (d->StatusFile) {
delete d->StatusFile;
@@ -216,9 +216,9 @@
signed debSystem::Score(Configuration const &Cnf)
{
signed Score = 0;
- if (FileExists(Cnf.FindFile("Dir::State::status","/var/lib/dpkg/status")) == true)
+ if (FileExists(Cnf.FindFile("Dir::State::status","@TERMUX_PREFIX@/var/lib/dpkg/status")) == true)
Score += 10;
- if (FileExists(Cnf.FindFile("Dir::Bin::dpkg","/usr/bin/dpkg")) == true)
+ if (FileExists(Cnf.FindFile("Dir::Bin::dpkg","@TERMUX_PREFIX@/bin/dpkg")) == true)
Score += 10;
if (FileExists("/etc/debian_version") == true)
Score += 10;

26
packages/apt/dpkgpm.cc.patch

@ -0,0 +1,26 @@
diff -u -r ../apt-1.0.9.4/apt-pkg/deb/dpkgpm.cc ./apt-pkg/deb/dpkgpm.cc
--- ../apt-1.0.9.4/apt-pkg/deb/dpkgpm.cc 2014-12-03 10:06:58.000000000 -0500
+++ ./apt-pkg/deb/dpkgpm.cc 2014-12-07 07:17:09.210804305 -0500
@@ -27,7 +27,9 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
-#include <pty.h>
+#ifndef __ANDROID__
+# include <pty.h>
+#endif
#include <pwd.h>
#include <signal.h>
#include <stddef.h>
@@ -1075,7 +1077,11 @@
_error->PushToStack();
+#ifdef __ANDROID__
+ d->master = open("/dev/ptmx", O_RDWR | O_NOCTTY);
+# else
d->master = posix_openpt(O_RDWR | O_NOCTTY);
+#endif
if (d->master == -1)
_error->Errno("posix_openpt", _("Can not write log (%s)"), _("Is /dev/pts mounted?"));
else if (unlockpt(d->master) == -1)

67
packages/apt/fileutl.patch

@ -0,0 +1,67 @@
diff -u -r ../upstream.git/apt-pkg/contrib/fileutl.cc ./apt-pkg/contrib/fileutl.cc
--- ../upstream.git/apt-pkg/contrib/fileutl.cc 2014-05-05 14:01:59.000000000 +0200
+++ ./apt-pkg/contrib/fileutl.cc 2014-06-06 00:09:17.233239376 +0200
@@ -46,7 +46,9 @@
#include <dirent.h>
#include <signal.h>
#include <errno.h>
+#ifndef __ANDROID__
#include <glob.h>
+#endif
#include <set>
#include <algorithm>
@@ -93,7 +95,7 @@
_exit(100);
}
- if (chdir("/tmp/") != 0)
+ if (chdir("@TERMUX_PREFIX@/tmp/") != 0)
_exit(100);
unsigned int Count = 1;
@@ -1883,7 +1885,11 @@
FileFdErrno("read","Unable to read original size of gzipped file");
return 0;
}
+#ifdef __ANDROID__
+ size = letoh32(size);
+#else
size = le32toh(size);
+#endif
if (lseek(iFd, oldPos, SEEK_SET) < 0)
{
@@ -1998,6 +2004,7 @@
std::vector<std::string> Glob(std::string const &pattern, int flags)
{
std::vector<std::string> result;
+#ifndef __ANDROID__
glob_t globbuf;
int glob_res;
unsigned int i;
@@ -2017,6 +2024,7 @@
result.push_back(string(globbuf.gl_pathv[i]));
globfree(&globbuf);
+#endif
return result;
}
/*}}}*/
@@ -2025,15 +2033,10 @@
{
const char *tmpdir = getenv("TMPDIR");
-#ifdef P_tmpdir
- if (!tmpdir)
- tmpdir = P_tmpdir;
-#endif
-
// check that tmpdir is set and exists
struct stat st;
if (!tmpdir || strlen(tmpdir) == 0 || stat(tmpdir, &st) != 0)
- tmpdir = "/tmp";
+ tmpdir = "@TERMUX_PREFIX@/tmp";
return string(tmpdir);
}

12
packages/apt/ftp-use-socklen_t.patch

@ -0,0 +1,12 @@
diff -u -r ../apt-0.9.16.1/methods/ftp.cc ./methods/ftp.cc
--- ../apt-0.9.16.1/methods/ftp.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./methods/ftp.cc 2014-03-25 01:31:05.464677254 +0100
@@ -711,7 +711,7 @@
if (WaitFd(DataFd,true,TimeOut) == false)
return _error->Error(_("Could not connect data socket, connection timed out"));
unsigned int Err;
- unsigned int Len = sizeof(Err);
+ socklen_t Len = sizeof(Err);
if (getsockopt(DataFd,SOL_SOCKET,SO_ERROR,&Err,&Len) != 0)
return _error->Errno("getsockopt",_("Failed"));
if (Err != 0)

12
packages/apt/gpgv.patch

@ -0,0 +1,12 @@
diff -u -r ../upstream.git/apt-pkg/contrib/gpgv.cc ./apt-pkg/contrib/gpgv.cc
--- ../upstream.git/apt-pkg/contrib/gpgv.cc 2014-04-25 13:39:00.000000000 +0200
+++ ./apt-pkg/contrib/gpgv.cc 2014-06-06 00:18:13.209224724 +0200
@@ -43,7 +84,7 @@
int const &statusfd, int fd[2])
{
#define EINTERNAL 111
- std::string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
+ std::string const gpgvpath = _config->Find("Dir::Bin::gpg", "@TERMUX_PREFIX@/bin/gpgv");
// FIXME: remove support for deprecated APT::GPGV setting
std::string const trustedFile = _config->Find("APT::GPGV::TrustedKeyring", _config->FindFile("Dir::Etc::Trusted"));
std::string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts");

11
packages/apt/install-progress-cc-include-termios-h.patch

@ -0,0 +1,11 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/install-progress.cc ./apt-pkg/install-progress.cc
--- ../apt-0.9.16.1/apt-pkg/install-progress.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./apt-pkg/install-progress.cc 2014-03-25 01:16:03.436701913 +0100
@@ -15,6 +15,7 @@
#include <fcntl.h>
#include <algorithm>
#include <stdio.h>
+#include <termios.h>
#include <apti18n.h>

19
packages/apt/netrc.patch

@ -0,0 +1,19 @@
diff -u -r ../apt-0.9.16.1/apt-pkg/contrib/netrc.cc ./apt-pkg/contrib/netrc.cc
--- ../apt-0.9.16.1/apt-pkg/contrib/netrc.cc 2014-03-15 17:23:45.000000000 +0100
+++ ./apt-pkg/contrib/netrc.cc 2014-03-25 01:01:34.692725662 +0100
@@ -84,6 +84,7 @@
int state_our_login = false; /* With specific_login,
found *our* login name */
+#ifndef __ANDROID__
while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) {
tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
while (!done && tok) {
@@ -142,6 +143,7 @@
tok = strtok_r (NULL, " \t\n", &tok_buf);
} /* while(tok) */
} /* while getline() */
+#endif
free(netrcbuffer);
fclose(file);

12
packages/apt/no-usr-bin-test.patch

@ -0,0 +1,12 @@
diff -u -r ../upstream.git/buildlib/configure.mak ./buildlib/configure.mak
--- ../upstream.git/buildlib/configure.mak 2013-12-07 14:12:14.000000000 +0100
+++ ./buildlib/configure.mak 2014-03-11 15:33:01.000000000 +0100
@@ -55,7 +55,7 @@
aclocal -I buildlib
$(BUILDDIR)/config.status: configure
- /usr/bin/test -e $(BUILDDIR) || mkdir $(BUILDDIR)
+ test -e $(BUILDDIR) || mkdir $(BUILDDIR)
(HERE=`pwd`; cd $(BUILDDIR) && $$HERE/configure)
$(addprefix $(BUILDDIR)/,$(CONVERTED)): $(BUILDDIR)/config.status

33
packages/apt/private-install-no-statvfs.patch

@ -0,0 +1,33 @@
diff -u -r ../upstream.git/apt-private/private-install.cc ./apt-private/private-install.cc
--- ../upstream.git/apt-private/private-install.cc 2014-03-14 09:05:18.000000000 +0100
+++ ./apt-private/private-install.cc 2014-04-15 20:58:34.416703941 +0200
@@ -24,7 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/statfs.h>
-#include <sys/statvfs.h>
+#ifndef __ANDROID__
+# include <sys/statvfs.h>
+#endif
#include <algorithm>
#include <iostream>
#include <set>
@@ -179,14 +181,14 @@
if (_config->FindB("APT::Get::Print-URIs") == false &&
_config->FindB("APT::Get::Download",true) == true)
{
- struct statvfs Buf;
+ struct statfs Buf;
std::string OutputDir = _config->FindDir("Dir::Cache::Archives");
- if (statvfs(OutputDir.c_str(),&Buf) != 0) {
+ if (statfs(OutputDir.c_str(),&Buf) != 0) {
if (errno == EOVERFLOW)
- return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
+ return _error->WarningE("statfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
else
- return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
+ return _error->Errno("statfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
} else if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{

25
packages/apt/private-output-no-langinfo.patch

@ -0,0 +1,25 @@
diff -u -r ../upstream.git/apt-private/private-output.cc ./apt-private/private-output.cc
--- ../upstream.git/apt-private/private-output.cc 2014-06-10 15:24:50.000000000 +0200
+++ ./apt-private/private-output.cc 2014-06-15 02:40:10.539223656 +0200
@@ -20,7 +20,11 @@
#include <string.h>
#include <iomanip>
#include <iostream>
-#include <langinfo.h>
+#ifdef __ANDROID__
+# include <termios.h>
+# else
+# include <langinfo.h>
+#endif
#include <unistd.h>
#include <signal.h>
#include <sys/ioctl.h>
@@ -764,7 +768,7 @@
regex_t Pattern;
int Res;
- Res = regcomp(&Pattern, nl_langinfo(YESEXPR),
+ Res = regcomp(&Pattern, "^[yY]",
REG_EXTENDED|REG_ICASE|REG_NOSUB);
if (Res != 0) {

65
packages/apt/strutl.c.patch

@ -0,0 +1,65 @@
diff -u -r ../upstream.git/apt-pkg/contrib/strutl.cc ./apt-pkg/contrib/strutl.cc
--- ../upstream.git/apt-pkg/contrib/strutl.cc 2014-06-18 13:17:17.000000000 +0200
+++ ./apt-pkg/contrib/strutl.cc 2014-07-01 16:49:25.305832759 +0200
@@ -35,7 +35,9 @@
#include <regex.h>
#include <errno.h>
#include <stdarg.h>
+#ifndef __ANDROID__
#include <iconv.h>
+#endif
#include <apti18n.h>
/*}}}*/
@@ -68,6 +70,7 @@
// UTF8ToCodeset - Convert some UTF-8 string for some codeset /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use before display some information for enduser */
+#ifndef __ANDROID__
bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest)
{
iconv_t cd;
@@ -134,6 +137,7 @@
return true;
}
+#endif
/*}}}*/
// strstrip - Remove white space from the front and back of a string /*{{{*/
// ---------------------------------------------------------------------
@@ -375,13 +379,13 @@
{
if (ASize < 100 && I != 0)
{
- sprintf(S,"%'.1f %c",ASize,Ext[I]);
+ sprintf(S,"%.1f %c",ASize,Ext[I]);
break;
}
if (ASize < 10000)
{
- sprintf(S,"%'.0f %c",ASize,Ext[I]);
+ sprintf(S,"%.0f %c",ASize,Ext[I]);
break;
}
ASize /= 1000.0;
@@ -909,14 +913,16 @@
setlocale (LC_ALL,"C");
bool const invalid =
// Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
- (strptime(str, "%a, %d %b %Y %H:%M:%S %Z", &Tm) == NULL &&
+ (strptime(str, "%a, %d %b %Y %H:%M:%S", &Tm) == NULL &&
// Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- strptime(str, "%A, %d-%b-%y %H:%M:%S %Z", &Tm) == NULL &&
+ strptime(str, "%A, %d-%b-%y %H:%M:%S", &Tm) == NULL &&
// Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
strptime(str, "%a %b %d %H:%M:%S %Y", &Tm) == NULL);
setlocale (LC_ALL,"");
- if (invalid == true)
+ if (invalid == true) {
+ if (str != NULL && strlen(str) > 1) printf("Invalid time str '%s'\n", str);
return false;
+ }
time = timegm(&Tm);
return true;

12
packages/apt/test-interactive-helper-makefile-no-libpthread.patch

@ -0,0 +1,12 @@
diff -u -r ../apt-0.9.16.1/test/interactive-helper/makefile ./test/interactive-helper/makefile
--- ../apt-0.9.16.1/test/interactive-helper/makefile 2014-01-05 20:06:21.000000000 +0100
+++ ./test/interactive-helper/makefile 2014-03-25 01:33:54.600672630 +0100
@@ -41,7 +41,7 @@
# Program for testing udevcdrom
PROGRAM=aptwebserver
-SLIBS = -lapt-pkg -lpthread
+SLIBS = -lapt-pkg
LIB_MAKES = apt-pkg/makefile
SOURCE = aptwebserver.cc
include $(PROGRAM_H)

BIN
packages/apt/trusted.gpg

Binary file not shown.

16
packages/apt/vendor.patch

@ -0,0 +1,16 @@
diff -u -r ../upstream.git/vendor/ubuntu/apt-vendor.ent ./vendor/ubuntu/apt-vendor.ent
--- ../upstream.git/vendor/ubuntu/apt-vendor.ent 2014-04-25 13:39:00.000000000 +0200
+++ ./vendor/ubuntu/apt-vendor.ent 2014-06-03 11:53:11.535752314 +0200
@@ -1,7 +1,7 @@
<!-- details about the keys used by the distribution -->
-<!ENTITY keyring-distro "Ubuntu">
-<!ENTITY keyring-package "<package>ubuntu-keyring</package>">
-<!ENTITY keyring-filename "<filename>/usr/share/keyrings/ubuntu-archive-keyring.gpg</filename>">
-<!ENTITY keyring-removed-filename "<filename>/usr/share/keyrings/ubuntu-archive-removed-keys.gpg</filename>">
-<!ENTITY keyring-master-filename "/usr/share/keyrings/ubuntu-master-keyring.gpg">
+<!ENTITY keyring-distro "Termux">
+<!ENTITY keyring-package "<package>termux-keyring</package>">
+<!ENTITY keyring-filename "<filename>@TERMUX_PREFIX@/share/keyrings/termux-archive-keyring.gpg</filename>">
+<!ENTITY keyring-removed-filename "<filename>@TERMUX_PREFIX@/share/keyrings/termux-archive-removed-keys.gpg</filename>">
+<!ENTITY keyring-master-filename "@TERMUX_PREFIX@/share/keyrings/termux-master-keyring.gpg">
<!ENTITY keyring-uri "http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg">

57
packages/aria2/Makefile.in.patch

@ -0,0 +1,57 @@
diff -u -r ../aria2-1.18.8/src/Makefile.in ./src/Makefile.in
--- ../aria2-1.18.8/src/Makefile.in 2014-09-11 12:24:36.000000000 -0400
+++ ./src/Makefile.in 2014-12-21 13:24:10.507656196 -0500
@@ -84,11 +84,6 @@
bin_PROGRAMS = aria2c$(EXEEXT)
@ANDROID_TRUE@am__append_1 = android/android.c
-# Android NDK R8e does not provide ftruncate64. Use assembly code from
-# android source code and link it.
-@ANDROID_ARM_TRUE@am__append_2 = android/arm-ftruncate64.S
-@ANDROID_MIPS_TRUE@am__append_3 = android/mips-ftruncate64.S
-@ANDROID_X86_TRUE@am__append_4 = android/x86-ftruncate64.S android/x86-asm.h
@MINGW_BUILD_TRUE@am__append_5 = WinConsoleFile.cc WinConsoleFile.h
@ENABLE_WEBSOCKET_TRUE@am__append_6 = \
@ENABLE_WEBSOCKET_TRUE@ WebSocketInteractionCommand.cc WebSocketInteractionCommand.h\
@@ -602,8 +597,6 @@
XmlRpcRequestParserController.cc \
XmlRpcRequestParserController.h OpenedFileCounter.cc \
OpenedFileCounter.h android/android.c \
- android/arm-ftruncate64.S android/mips-ftruncate64.S \
- android/x86-ftruncate64.S android/x86-asm.h WinConsoleFile.cc \
WinConsoleFile.h WebSocketInteractionCommand.cc \
WebSocketInteractionCommand.h WebSocketResponseCommand.cc \
WebSocketResponseCommand.h WebSocketSession.cc \
@@ -801,9 +794,6 @@
KeepRunningCommand.cc KeepRunningCommand.h
am__dirstamp = $(am__leading_dot)dirstamp
@ANDROID_TRUE@am__objects_1 = android/android.lo
-@ANDROID_ARM_TRUE@am__objects_2 = android/arm-ftruncate64.lo
-@ANDROID_MIPS_TRUE@am__objects_3 = android/mips-ftruncate64.lo
-@ANDROID_X86_TRUE@am__objects_4 = android/x86-ftruncate64.lo
@MINGW_BUILD_TRUE@am__objects_5 = WinConsoleFile.lo
@ENABLE_WEBSOCKET_TRUE@am__objects_6 = WebSocketInteractionCommand.lo \
@ENABLE_WEBSOCKET_TRUE@ WebSocketResponseCommand.lo \
@@ -1708,12 +1698,6 @@
@: > android/$(DEPDIR)/$(am__dirstamp)
android/android.lo: android/$(am__dirstamp) \
android/$(DEPDIR)/$(am__dirstamp)
-android/arm-ftruncate64.lo: android/$(am__dirstamp) \
- android/$(DEPDIR)/$(am__dirstamp)
-android/mips-ftruncate64.lo: android/$(am__dirstamp) \
- android/$(DEPDIR)/$(am__dirstamp)
-android/x86-ftruncate64.lo: android/$(am__dirstamp) \
- android/$(DEPDIR)/$(am__dirstamp)
libaria2.la: $(libaria2_la_OBJECTS) $(libaria2_la_DEPENDENCIES) $(EXTRA_libaria2_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(am_libaria2_la_rpath) $(libaria2_la_OBJECTS) $(libaria2_la_LIBADD) $(LIBS)
@@ -2199,9 +2183,6 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version_usage.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wallclock.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@android/$(DEPDIR)/android.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@android/$(DEPDIR)/arm-ftruncate64.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@android/$(DEPDIR)/mips-ftruncate64.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@android/$(DEPDIR)/x86-ftruncate64.Plo@am__quote@
.S.o:
@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\

12
packages/aria2/a2io.h.patch

@ -0,0 +1,12 @@
diff -u -r ../aria2-1.18.8/src/a2io.h ./src/a2io.h
--- ../aria2-1.18.8/src/a2io.h 2014-09-11 12:24:10.000000000 -0400
+++ ./src/a2io.h 2014-12-21 13:11:23.147655665 -0500
@@ -149,7 +149,7 @@
# define a2fstat(fd, buf) fstat64(fd, buf)
// # define a2ftell(fd): No ftell64 and not used in aria2
# define a2_struct_stat struct stat
-# define a2stat(path, buf) stat64(path, buf)
+# define a2stat(path, buf) stat(path, buf)
# define a2mkdir(path, openMode) mkdir(path, openMode)
# define a2utimbuf utimbuf
# define a2utime(path, times) ::utime(path, times)

9
packages/aria2/build.sh

@ -0,0 +1,9 @@
TERMUX_PKG_HOMEPAGE=http://aria2.sourceforge.net/
TERMUX_PKG_DESCRIPTION="Multi-protocol & multi-source command-line download utility supporting HTTP/HTTPS, FTP, BitTorrent and Metalink"
TERMUX_PKG_VERSION=1.19.0
TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/aria2/stable/aria2-${TERMUX_PKG_VERSION}/aria2-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_DEPENDS="c-ares, openssl, libxml2, libgnustl"
# sqlite3 is only used for loading cookies from firefox or chrome:
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-openssl --without-gnutls --without-libuv --without-sqlite3 ac_cv_search_getaddrinfo=no ac_cv_func_getaddrinfo=yes ac_cv_func_gettimeofday=yes ac_cv_func_sleep=yes ac_cv_func_usleep=yes ac_cv_func_basename=yes"
export CXXFLAGS="$CXXFLAGS -lgnustl_shared"

12
packages/autoconf/General.pm.patch

@ -0,0 +1,12 @@
diff -u -r ../autoconf-2.69/lib/Autom4te/General.pm ./lib/Autom4te/General.pm
--- ../autoconf-2.69/lib/Autom4te/General.pm 2012-04-24 16:44:15.000000000 -0400
+++ ./lib/Autom4te/General.pm 2015-05-17 16:11:45.492445577 -0400
@@ -300,7 +300,7 @@
sub mktmpdir ($)
{
my ($signature) = @_;
- my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
+ my $TMPDIR = $ENV{'TMPDIR'} || '@TERMUX_PREFIX@/tmp';
my $quoted_tmpdir = shell_quote ($TMPDIR);
# If mktemp supports dirs, use it.

15
packages/autoconf/build.sh

@ -0,0 +1,15 @@
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/autoconf/autoconf.html
TERMUX_PKG_DESCRIPTION="Creator of shell scripts to configure source code packages"
TERMUX_PKG_VERSION=2.69
TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/autoconf/autoconf-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_DEPENDS="m4, make, perl"
termux_step_post_extract_package () {
cd $TERMUX_PKG_SRCDIR
perl -p -i -e "s|/bin/sh|$TERMUX_PREFIX/bin/sh|" lib/*/*.m4
}
termux_step_post_massage () {
perl -p -i -e "s|/usr/bin/m4|$TERMUX_PREFIX/bin/m4|" bin/*
perl -p -i -e "s|CONFIG_SHELL-/bin/sh|CONFIG_SHELL-$TERMUX_PREFIX/bin/sh|" bin/autoconf
}

5
packages/automake/build.sh

@ -0,0 +1,5 @@
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/automake/
TERMUX_PKG_DESCRIPTION="Tool for automatically generating Makefile.in files"
TERMUX_PKG_VERSION=1.15
TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/automake/automake-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_DEPENDS="autoconf"

12
packages/bash/bash.patch

@ -0,0 +1,12 @@
diff -u -r ../bash-4.2/lib/readline/complete.c ./lib/readline/complete.c
--- ../bash-4.2/lib/readline/complete.c 2011-01-16 21:32:57.000000000 +0100
+++ ./lib/readline/complete.c 2014-01-13 12:28:56.338866643 +0100
@@ -2021,7 +2021,7 @@
const char *text;
int state;
{
-#if defined (__WIN32__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT) || defined (__ANDROID__)
return (char *)NULL;
#else /* !__WIN32__ && !__OPENNT) */
static char *username = (char *)NULL;

19
packages/bash/build.sh

@ -0,0 +1,19 @@
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/bash/
TERMUX_PKG_DESCRIPTION="A sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh)"
TERMUX_PKG_DEPENDS="ncurses, readline, libandroid-support"
_MAIN_VERSION=4.3
_PATCH_VERSION=39
TERMUX_PKG_VERSION=${_MAIN_VERSION}.${_PATCH_VERSION}
TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/bash/bash-${_MAIN_VERSION}.tar.gz
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--enable-multibyte --without-bash-malloc --with-installed-readline ac_cv_header_grp_h=no ac_cv_header_pwd_h=no ac_cv_rl_version=6.3"
TERMUX_PKG_RM_AFTER_INSTALL="share/man/man1/bashbug.1 bin/bashbug"
termux_step_pre_configure () {
cd $TERMUX_PKG_SRCDIR
for patch_number in `seq -f '%03g' ${_PATCH_VERSION}`; do
PATCHFILE=$TERMUX_PKG_CACHEDIR/bash_patch_${patch_number}.patch
test ! -f $PATCHFILE && curl "http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$patch_number" > $PATCHFILE
patch -p0 -i $PATCHFILE
done
}

13
packages/bash/dont_endpwent_in_shell_c.patch

@ -0,0 +1,13 @@
diff -u -r ../bash-4.2/shell.c ./shell.c
--- ../bash-4.2/shell.c 2011-01-02 22:04:51.000000000 +0100
+++ ./shell.c 2014-02-11 11:20:46.000000000 +0100
@@ -1654,7 +1654,9 @@
current_user.shell = savestring ("/bin/sh");
current_user.home_dir = savestring ("/");
}
+#ifndef __ANDROID__
endpwent ();
+#endif
}
}

15
packages/bash/etc_hosts_and_profile_path.patch

@ -0,0 +1,15 @@
--- ../bash-4.2/pathnames.h.in 2009-01-04 20:32:40.000000000 +0100
+++ ./pathnames.h.in 2014-02-04 18:34:17.000000000 +0100
@@ -22,10 +22,10 @@
#define _PATHNAMES_H_
/* The default file for hostname completion. */
-#define DEFAULT_HOSTS_FILE "/etc/hosts"
+#define DEFAULT_HOSTS_FILE "@TERMUX_PREFIX@/etc/hosts"
/* The default login shell startup file. */
-#define SYS_PROFILE "/etc/profile"
+#define SYS_PROFILE "@TERMUX_PREFIX@/etc/profile"
/* The default location of the bash debugger initialization/startup file. */
#define DEBUGGER_START_FILE "@DEBUGGER_START_FILE@"

39
packages/bash/getpwd.patch.disabled

@ -0,0 +1,39 @@
diff -u -r ../bash-4.2/lib/readline/complete.c ./lib/readline/complete.c
--- ../bash-4.2/lib/readline/complete.c 2011-01-16 21:32:57.000000000 +0100
+++ ./lib/readline/complete.c 2014-01-13 12:28:56.338866643 +0100
@@ -2021,7 +2021,7 @@
const char *text;
int state;
{
-#if defined (__WIN32__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT) || defined (__ANDROID__)
return (char *)NULL;
#else /* !__WIN32__ && !__OPENNT) */
static char *username = (char *)NULL;
diff -u -r ../bash-4.2/shell.c ./shell.c
--- ../bash-4.2/shell.c 2011-01-02 22:04:51.000000000 +0100
+++ ./shell.c 2014-01-13 12:43:01.070846472 +0100
@@ -1638,6 +1638,7 @@
/* Don't fetch this more than once. */
if (current_user.user_name == 0)
{
+#ifndef __ANDROID__
entry = getpwuid (current_user.uid);
if (entry)
{
@@ -1649,12 +1650,15 @@
}
else
{
+#endif
current_user.user_name = _("I have no name!");
current_user.user_name = savestring (current_user.user_name);
current_user.shell = savestring ("/bin/sh");
current_user.home_dir = savestring ("/");
+#ifndef __ANDROID__
}
endpwent ();
+#endif
}
}

13
packages/bash/y.tab.c.patch

@ -0,0 +1,13 @@
Fix breakage on android-21 due "conflicting type for '__errno'"
diff -u -r ../bash-4.3/y.tab.c ./y.tab.c
--- ../bash-4.3/y.tab.c 2014-02-11 10:57:47.000000000 -0500
+++ ./y.tab.c 2014-12-16 05:39:58.047338124 -0500
@@ -280,7 +280,6 @@
extern int bash_input_fd_changed;
#endif
-extern int errno;
/* **************************************************************** */
/* */
/* "Forward" declarations */

6
packages/bc/build.sh

@ -0,0 +1,6 @@
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/bc/
TERMUX_PKG_DESCRIPTION="Arbitrary precision numeric processing language"
TERMUX_PKG_VERSION=1.06.95
TERMUX_PKG_SRCURL=http://alpha.gnu.org/gnu/bc/bc-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_DEPENDS="readline,flex"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-readline --mandir=$TERMUX_PREFIX/share/man"

13
packages/binutils/binutils.patch

@ -0,0 +1,13 @@
diff -u -r ../binutils-2.24/bfd/archive.c ./bfd/archive.c
--- ../binutils-2.24/bfd/archive.c 2013-11-04 16:33:37.000000000 +0100
+++ ./bfd/archive.c 2014-01-01 14:44:49.000000000 +0100
@@ -1880,7 +1880,8 @@
{
/* Assume we just "made" the member, and fake it. */
struct bfd_in_memory *bim = (struct bfd_in_memory *) member->iostream;
- time (&status.st_mtime);
+ /* termux diff: explicit cast */
+ time ((time_t*) &status.st_mtime);
status.st_uid = getuid ();
status.st_gid = getgid ();
status.st_mode = 0644;

11
packages/binutils/build.sh

@ -0,0 +1,11 @@
TERMUX_PKG_VERSION=2.25
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/binutils/
TERMUX_PKG_DESCRIPTION="Collection of binary tools, the main ones being ld, the GNU linker, and as, the GNU assembler"
TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/binutils/binutils-${TERMUX_PKG_VERSION}.tar.gz
# TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--enable-gold"
TERMUX_PKG_EXTRA_MAKE_ARGS="tooldir=$TERMUX_PREFIX"
TERMUX_PKG_RM_AFTER_INSTALL="share/man/man1/windmc.1 share/man/man1/windres.1 bin/ld.bfd"
termux_step_post_make_install () {
cp $TERMUX_PKG_BUILDER_DIR/ldd $TERMUX_PREFIX/bin/ldd
}

12
packages/binutils/gold_layout_printf_cast.patch

@ -0,0 +1,12 @@
diff -u -r ../binutils-2.24/gold/layout.cc ./gold/layout.cc
--- ../binutils-2.24/gold/layout.cc 2013-11-04 16:33:39.000000000 +0100
+++ ./gold/layout.cc 2014-02-12 18:03:07.000000000 +0100
@@ -3031,7 +3031,7 @@
gold_error(_("/dev/urandom: read failed: %s"), strerror(errno));
else if (static_cast<size_t>(got) != uuidsz)
gold_error(_("/dev/urandom: expected %zu bytes, got %zd bytes"),
- uuidsz, got);
+ uuidsz, (signed size_t) got);
}
desc.assign(buffer, uuidsz);

12
packages/binutils/gold_printf_cast.patch

@ -0,0 +1,12 @@
diff -u -r ../binutils-2.24/gold/fileread.cc ./gold/fileread.cc
--- ../binutils-2.24/gold/fileread.cc 2013-11-04 16:33:39.000000000 +0100
+++ ./gold/fileread.cc 2014-02-12 18:00:06.000000000 +0100
@@ -686,7 +686,7 @@
if (got != want)
gold_fatal(_("%s: file too short: read only %zd of %zd bytes at %lld"),
this->filename().c_str(),
- got, want, static_cast<long long>(base + first_offset));
+ (signed size_t) got, (signed size_t) want, static_cast<long long>(base + first_offset));
}
// Portable IOV_MAX.

3
packages/binutils/ldd

@ -0,0 +1,3 @@
#!/system/bin/sh
objdump -p $@ | grep NEEDED | cut -d ' ' -f 18

18
packages/binutils/ldmain.c.patch

@ -0,0 +1,18 @@
diff -u -r ../binutils-2.24/ld/ldmain.c ./ld/ldmain.c
--- ../binutils-2.24/ld/ldmain.c 2013-11-08 11:13:48.000000000 +0100
+++ ./ld/ldmain.c 2014-06-18 08:16:53.945378483 +0200
@@ -263,7 +263,13 @@
config.text_read_only = TRUE;
link_info.disable_target_specific_optimizations = -1;
- command_line.warn_mismatch = TRUE;
+ command_line.warn_mismatch =
+#if defined(__ANDROID__) && defined(__arm__)
+ /* --no-warn-mismatch is needed to suppress linker errors about not all functions using VFP register to pass arguments: */
+ FALSE;
+# else
+ TRUE;
+#endif
command_line.warn_search_mismatch = TRUE;
command_line.check_section_addresses = -1;

12
packages/binutils/native_lib_dirs.patch

@ -0,0 +1,12 @@
diff -r -u ../binutils-2.24/ld/configure.tgt ./ld/configure.tgt
--- ../binutils-2.24/ld/configure.tgt 2013-11-26 12:37:33.000000000 +0100
+++ ./ld/configure.tgt 2014-02-12 18:06:26.000000000 +0100
@@ -769,7 +769,7 @@
esac
-NATIVE_LIB_DIRS='/usr/local/lib /lib /usr/lib'
+NATIVE_LIB_DIRS='/system/lib'
case "${target}" in
*-*-dragonfly*)

7
packages/bison/build.sh

@ -0,0 +1,7 @@
TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/bison/
TERMUX_PKG_DESCRIPTION="General-purpose parser generator"
TERMUX_PKG_VERSION=3.0.4
TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/bison/bison-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
TERMUX_PKG_HOSTBUILD=true

19
packages/brogue/build.sh

@ -0,0 +1,19 @@
TERMUX_PKG_VERSION=1.7.4
TERMUX_PKG_HOMEPAGE=https://sites.google.com/site/broguegame/
TERMUX_PKG_DESCRIPTION="Roguelike dungeon crawling game"
TERMUX_PKG_DEPENDS="ncurses"
TERMUX_PKG_SRCURL=https://sites.google.com/site/broguegame/brogue-${TERMUX_PKG_VERSION}-linux-i386.tbz2
TERMUX_PKG_EXTRA_MAKE_ARGS="curses"
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_FOLDERNAME=brogue-${TERMUX_PKG_VERSION}
CC="$CC $CFLAGS $CPPFLAGS $LDFLAGS"
#termux_step_configure () {
# Tarball has an extra level of folders.
#TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR/brogue-${TERMUX_PKG_VERSION}
#}
termux_step_make_install () {
cp bin/brogue $TERMUX_PREFIX/bin
}

28
packages/brogue/curses-platform.c.patch

@ -0,0 +1,28 @@
In Android the <sys/timeb.h> header and associated ftime(3) has been
removed in android-21 since it is deprecated and removed from POSIX.
diff -u -r ../brogue-1.7.4/src/platform/curses-platform.c ./src/platform/curses-platform.c
--- ../brogue-1.7.4/src/platform/curses-platform.c 2014-07-03 15:19:10.000000000 -0400
+++ ./src/platform/curses-platform.c 2014-12-20 03:47:20.303572495 -0500
@@ -3,7 +3,7 @@
#include <string.h>
#include <time.h>
#include "term.h"
-#include <sys/timeb.h>
+#include <sys/time.h>
#include <stdint.h>
#include <signal.h>
#include "platform.h"
@@ -109,9 +109,9 @@
#define PAUSE_BETWEEN_EVENT_POLLING 34//17
static uint32_t getTime() {
- struct timeb time;
- ftime(&time);
- return 1000 * time.time + time.millitm;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return 1000 * tv.tv_sec + tv.tv_usec / 1000;
}
static boolean curses_pauseForMilliseconds(short milliseconds) {

12
packages/brogue/no_i586.patch

@ -0,0 +1,12 @@
--- ../brogue-linux-1.7.3/brogue-1.7.3/Makefile 2013-09-11 07:38:48.000000000 +0200
+++ ./Makefile 2014-01-28 07:57:06.000000000 +0100
@@ -81,7 +81,7 @@
.PHONY : clean both curses tcod tar
bin/brogue : ${DEPENDENCIES} ${BROGUEFILES}
- $(CC) -O2 -march=i586 -o bin/brogue ${BROGUEFILES} ${LIBRARIES} -Wl,-rpath,.
+ $(CC) -o bin/brogue ${BROGUEFILES} ${LIBRARIES} -Wl,-rpath,.
clean :
rm -f src/brogue/*.o src/platform/*.o bin/brogue

12
packages/busybox/ash.patch

@ -0,0 +1,12 @@
diff -u -r ../busybox-1.22.1/shell/ash.c ./shell/ash.c
--- ../busybox-1.22.1/shell/ash.c 2014-01-20 03:38:10.000000000 +0100
+++ ./shell/ash.c 2014-01-20 08:47:37.000000000 +0100
@@ -13225,7 +13225,7 @@
const char *hp;
state = 1;
- read_profile("/etc/profile");
+ read_profile("@TERMUX_PREFIX@/etc/profile");
state1:
state = 2;
hp = lookupvar("HOME");

41
packages/busybox/build.sh

@ -0,0 +1,41 @@
TERMUX_PKG_HOMEPAGE=http://www.busybox.net/
TERMUX_PKG_DESCRIPTION="Tiny versions of many common UNIX utilities into a single small executable"
TERMUX_PKG_ESSENTIAL=yes
TERMUX_PKG_VERSION=1.23.2
TERMUX_PKG_SRCURL=http://www.busybox.net/downloads/busybox-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_BUILD_IN_SRC=yes
# NOTE: sed on mac does not work for building busybox, install gsed and symlink sed => gsed
CFLAGS+=" -llog -DTERMUX_EXPOSE_MEMPCPY=1" # Android system liblog.so for syslog
termux_step_configure () {
# Bug in gold linker with busybox in android r10e:
# https://sourceware.org/ml/binutils/2015-02/msg00386.html
CFLAGS+=" -fuse-ld=bfd"
LD+=.bfd
cp $TERMUX_PKG_BUILDER_DIR/busybox.config .config
echo "CONFIG_SYSROOT=\"$TERMUX_STANDALONE_TOOLCHAIN/sysroot\"" >> .config
echo "CONFIG_PREFIX=\"$TERMUX_PREFIX\"" >> .config
echo "CONFIG_CROSS_COMPILER_PREFIX=\"${TERMUX_HOST_PLATFORM}-\"" >> .config
echo "CONFIG_FEATURE_CROND_DIR=\"$TERMUX_PREFIX/var/spool/cron\"" >> .config
make oldconfig
}
termux_step_post_make_install () {
# Create symlinks in $PREFIX/bin/applets to $PREFIX/bin/busybox
rm -Rf $TERMUX_PREFIX/bin/applets
mkdir -p $TERMUX_PREFIX/bin/applets
cd $TERMUX_PREFIX/bin/applets
for f in `cat $TERMUX_PKG_SRCDIR/busybox.links`; do ln -s ../busybox `basename $f`; done
cd $TERMUX_PREFIX/bin
rm -f ash
ln busybox ash
# Install busybox man page
mkdir -p $TERMUX_PREFIX/share/man/man1
cp $TERMUX_PKG_SRCDIR/docs/busybox.1 $TERMUX_PREFIX/share/man/man1
}

1033
packages/busybox/busybox.config

File diff suppressed because it is too large

15
packages/busybox/change_identity.c.patch

@ -0,0 +1,15 @@
diff -u -r ../busybox-1.22.1/libbb/change_identity.c ./libbb/change_identity.c
--- ../busybox-1.22.1/libbb/change_identity.c 2014-01-09 19:15:44.000000000 +0100
+++ ./libbb/change_identity.c 2014-07-01 09:57:10.000000000 +0200
@@ -33,9 +33,11 @@
/* Become the user and group(s) specified by PW. */
void FAST_FUNC change_identity(const struct passwd *pw)
{
+#ifndef __ANDROID__
if (initgroups(pw->pw_name, pw->pw_gid) == -1)
bb_perror_msg_and_die("can't set groups");
endgrent(); /* helps to close a fd used internally by libc */
xsetgid(pw->pw_gid);
xsetuid(pw->pw_uid);
+#endif
}

28
packages/busybox/crond.c.patch

@ -0,0 +1,28 @@
diff -u -r ../busybox-1.23.1/miscutils/crond.c ./miscutils/crond.c
--- ../busybox-1.23.1/miscutils/crond.c 2015-01-27 03:48:58.000000000 -0500
+++ ./miscutils/crond.c 2015-02-06 16:43:24.238473247 -0500
@@ -415,7 +415,7 @@
maxLines = (strcmp(fileName, "root") == 0) ? 65535 : MAXLINES;
- if (fstat(fileno(parser->fp), &sbuf) == 0 && sbuf.st_uid == DAEMON_UID) {
+ if (fstat(fileno(parser->fp), &sbuf) == 0) {
CronFile *file = xzalloc(sizeof(CronFile));
CronLine **pline;
int n;
@@ -571,6 +571,7 @@
static void set_env_vars(struct passwd *pas, const char *shell)
{
+#ifndef __ANDROID__
/* POSIX requires crond to set up at least HOME, LOGNAME, PATH, SHELL.
* We assume crond inherited suitable PATH.
*/
@@ -585,6 +586,7 @@
xsetenv("HOME", pas->pw_dir);
xsetenv("SHELL", shell);
#endif
+#endif
}
static void change_user(struct passwd *pas)

16
packages/busybox/crontab.c.patch

@ -0,0 +1,16 @@
diff -u -r ../busybox-1.22.1/miscutils/crontab.c ./miscutils/crontab.c
--- ../busybox-1.22.1/miscutils/crontab.c 2014-01-09 19:15:44.000000000 +0100
+++ ./miscutils/crontab.c 2014-07-01 09:47:30.000000000 +0200
@@ -40,10 +40,12 @@
/* CHILD - change user and run editor */
/* initgroups, setgid, setuid */
+#ifndef __ANDROID__
change_identity(pas);
setup_environment(pas->pw_shell,
SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP,
pas);
+#endif
ptr = getenv("VISUAL");
if (!ptr) {
ptr = getenv("EDITOR");

146
packages/busybox/dpkg.patch

@ -0,0 +1,146 @@
diff -u -r ../busybox-1.22.1/archival/dpkg.c ./archival/dpkg.c
--- ../busybox-1.22.1/archival/dpkg.c 2014-01-09 19:15:44.000000000 +0100
+++ ./archival/dpkg.c 2014-01-20 08:52:03.000000000 +0100
@@ -813,8 +813,8 @@
/* This could do with a cleanup */
static void write_status_file(deb_file_t **deb_file)
{
- FILE *old_status_file = xfopen_for_read("/var/lib/dpkg/status");
- FILE *new_status_file = xfopen_for_write("/var/lib/dpkg/status.udeb");
+ FILE *old_status_file = xfopen_for_read("@TERMUX_PREFIX@/var/lib/dpkg/status");
+ FILE *new_status_file = xfopen_for_write("@TERMUX_PREFIX@/var/lib/dpkg/status.udeb");
char *package_name;
char *status_from_file;
char *control_buffer = NULL;
@@ -942,7 +942,7 @@
fclose(new_status_file);
/* Create a separate backfile to dpkg */
- if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
+ if (rename("@TERMUX_PREFIX@/var/lib/dpkg/status", "@TERMUX_PREFIX@/var/lib/dpkg/status.udeb.bak") == -1) {
if (errno != ENOENT)
bb_error_msg_and_die("can't create backup status file");
/* Its ok if renaming the status file fails because status
@@ -950,7 +950,7 @@
bb_error_msg("no status file found, creating new one");
}
- xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
+ xrename("@TERMUX_PREFIX@/var/lib/dpkg/status.udeb", "@TERMUX_PREFIX@/var/lib/dpkg/status");
}
/* This function returns TRUE if the given package can satisfy a
@@ -1242,7 +1242,7 @@
char *script_path;
int result;
- script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
+ script_path = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt fatal */
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
@@ -1295,7 +1295,7 @@
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
while (i < ARRAY_SIZE(all_control_files)) {
- remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
+ remove_files[i] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s",
package_name, all_control_files[i]);
i++;
}
@@ -1366,8 +1366,8 @@
const int package_name_length = strlen(package_name);
char **remove_files;
char **exclude_files;
- char list_name[package_name_length + 25];
- char conffile_name[package_name_length + 30];
+ char list_name[package_name_length + 100];
+ char conffile_name[package_name_length + 100];
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
@@ -1376,10 +1376,10 @@
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove, and a separate list of those to keep */
- sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
+ sprintf(list_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
- sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
+ sprintf(conffile_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
exclude_files = create_list(conffile_name);
/* Some directories can't be removed straight away, so do multiple passes */
@@ -1391,7 +1391,7 @@
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 3);
exclude_files[0] = xstrdup(conffile_name);
- exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
+ exclude_files[1] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "postrm");
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1416,7 +1416,7 @@
const unsigned status_num = search_status_hashtable(package_name);
char **remove_files;
char **exclude_files;
- char list_name[strlen(package_name) + 25];
+ char list_name[strlen(package_name) + 100];
printf("Purging %s (%s)...\n", package_name, package_version);
@@ -1424,7 +1424,7 @@
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove */
- sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
+ sprintf(list_name, "@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
/* Some directories cant be removed straight away, so do multiple passes */
@@ -1437,7 +1437,7 @@
/* Delete all of them except the postrm script */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 2);
- exclude_files[0] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
+ exclude_files[0] = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "postrm");
remove_file_array(remove_files, exclude_files);
free_array(exclude_files);
@@ -1528,7 +1528,7 @@
FILE *fp;
char *filename, *line;
- filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, control_name);
+ filename = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, control_name);
fp = fopen_for_read(filename);
free(filename);
if (fp != NULL) {
@@ -1648,7 +1648,7 @@
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
- info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
+ info_prefix = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "");
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
@@ -1688,7 +1688,7 @@
unpack_ar_archive(archive_handle);
/* Create the list file */
- list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
+ list_filename = xasprintf("@TERMUX_PREFIX@/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen_for_write(list_filename);
archive_handle->dpkg__sub_archive->passed = llist_rev(archive_handle->dpkg__sub_archive->passed);
while (archive_handle->dpkg__sub_archive->passed) {
@@ -1782,7 +1782,7 @@
}
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
- index_status_file("/var/lib/dpkg/status");
+ index_status_file("@TERMUX_PREFIX@/var/lib/dpkg/status");
/* if the list action was given print the installed packages and exit */
if (opt & OPT_list_installed) {

17
packages/busybox/ftpd.c.patch

@ -0,0 +1,17 @@
We disable security, because chroot() does not work with our non-root usage.
With chdir() it's unsafe as a general network service,
but can be used for bootstrapping on a local network.
diff -u -r ../busybox-1.23.1/networking/ftpd.c ./networking/ftpd.c
--- ../busybox-1.23.1/networking/ftpd.c 2015-01-27 03:51:46.000000000 -0500
+++ ./networking/ftpd.c 2015-02-06 16:38:33.202473045 -0500
@@ -1230,7 +1230,7 @@
G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
close_on_exec_on(G.root_fd);
#endif
- xchroot(argv[0]);
+ xchdir(argv[0]);
}
/* RFC-959 Section 5.1

39
packages/busybox/httpd.patch

@ -0,0 +1,39 @@
diff -u -r ../busybox-1.22.1/networking/httpd.c ./networking/httpd.c
--- ../busybox-1.22.1/networking/httpd.c 2014-01-09 19:15:44.000000000 +0100
+++ ./networking/httpd.c 2014-01-20 08:47:37.000000000 +0100
@@ -112,7 +112,7 @@
//usage: "\n -i Inetd mode"
//usage: "\n -f Don't daemonize"
//usage: "\n -v[v] Verbose"
-//usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:80)"
+//usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:8080)"
//usage: IF_FEATURE_HTTPD_SETUID(
//usage: "\n -u USER[:GRP] Set uid/gid after binding to port")
//usage: IF_FEATURE_HTTPD_BASIC_AUTH(
@@ -371,7 +371,7 @@
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
- bind_addr_or_port = "80"; \
+ bind_addr_or_port = "8080"; \
index_page = index_html; \
file_size = -1; \
} while (0)
@@ -887,7 +887,7 @@
if (!errno && n && n <= 0xffff)
n = create_and_bind_stream_or_die(NULL, n);
else
- n = create_and_bind_stream_or_die(bind_addr_or_port, 80);
+ n = create_and_bind_stream_or_die(bind_addr_or_port, 8080);
xlisten(n, 9);
return n;
}
@@ -2245,7 +2245,7 @@
proxy_fd = socket(AF_INET, SOCK_STREAM, 0);
if (proxy_fd < 0)
send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);
- lsa = host2sockaddr(proxy_entry->host_port, 80);
+ lsa = host2sockaddr(proxy_entry->host_port, 8080);
if (lsa == NULL)
send_headers_and_exit(HTTP_INTERNAL_SERVER_ERROR);
if (connect(proxy_fd, &lsa->u.sa, lsa->len) < 0)

35
packages/busybox/iplink.patch

@ -0,0 +1,35 @@
diff -u -r ../busybox-1.22.1/networking/libiproute/iplink.c ./networking/libiproute/iplink.c
--- ../busybox-1.22.1/networking/libiproute/iplink.c 2014-01-09 19:15:44.000000000 +0100
+++ ./networking/libiproute/iplink.c 2014-01-20 08:47:37.000000000 +0100
@@ -11,6 +11,31 @@
#include <netinet/if_ether.h>
#include <linux/if_vlan.h>
+#ifdef __ANDROID__
+enum {
+ IFLA_INFO_UNSPEC,
+ IFLA_INFO_KIND,
+ IFLA_INFO_DATA,
+ IFLA_INFO_XSTATS,
+ __IFLA_INFO_MAX,
+};
+
+#define IFLA_INFO_MAX (__IFLA_INFO_MAX - 1)
+enum {
+ IFLA_VLAN_UNSPEC,
+ IFLA_VLAN_ID,
+ IFLA_VLAN_FLAGS,
+ IFLA_VLAN_EGRESS_QOS,
+ IFLA_VLAN_INGRESS_QOS,
+ IFLA_VLAN_PROTOCOL,
+ __IFLA_VLAN_MAX,
+};
+#define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
+struct ifla_vlan_flags {
+ __u32 flags;
+ __u32 mask;
+};
+#endif
#include "ip_common.h" /* #include "libbb.h" is inside */
#include "rt_names.h"
#include "utils.h"

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save