diff --git a/ndk-pkg b/ndk-pkg index 1280aaf..f86f5df 100755 --- a/ndk-pkg +++ b/ndk-pkg @@ -320,7 +320,7 @@ wfetch() { fi fi - for FETCH_TOOL in curl wget http lynx aria2c axel + for FETCH_TOOL in curl wget http lynx aria2c axel python3 do if command -v "$FETCH_TOOL" > /dev/null ; then break @@ -329,6 +329,10 @@ wfetch() { fi done + if [ "$FETCH_TOOL" = python3 ] ; then + python3 -c 'import requests' 2> /dev/null || unset FETCH_TOOL + fi + if [ -z "$FETCH_TOOL" ] ; then abort 1 "no fetch tool found, please install one of curl wget http lynx aria2c axel, then try again." fi @@ -378,6 +382,17 @@ wfetch() { run "axel -o '$FETCH_BUFFER_FILEPATH' '$FETCH_URL'" || run "axel -o '$FETCH_BUFFER_FILEPATH' '$FETCH_URI'" ;; + python3) + python3 -c " + import requests + + response = requests.get('$FETCH_URL') + + if response.status_code == 200: + with open('$FETCH_BUFFER_FILEPATH', 'wb') as f: + f.write(response.content) + " + ;; *) abort 1 "wfetch() unimplementation: $FETCH_TOOL" ;; esac @@ -5124,9 +5139,9 @@ $PACKAGE_ONSTART CCFLAGS_FOR_BUILD="-isysroot $SYSROOT_FOR_BUILD -mmacosx-version-min=$NATIVE_OS_VERS -arch $NATIVE_OS_ARCH -Qunused-arguments" LDFLAGS_FOR_BUILD='-Wl,-search_paths_first' else - CC_FOR_BUILD="$(command -v cc || command -v clang || command -v gcc)" || abort 1 "C Compiler for native not found." - OBJC_FOR_BUILD="$(command -v cc || command -v clang || command -v gcc)" || abort 1 "C Compiler for native not found." - CXX_FOR_BUILD="$(command -v c++ || command -v clang++ || command -v g++)" || abort 1 "C++ Compiler for native not found." + CC_FOR_BUILD="$(command -v gcc || command -v clang || command -v cc)" || abort 1 "C Compiler for native not found." + OBJC_FOR_BUILD="$(command -v gcc || command -v clang || command -v cc)" || abort 1 "C Compiler for native not found." + CXX_FOR_BUILD="$(command -v g++ || command -v clang++ || command -v c++)" || abort 1 "C++ Compiler for native not found." AS_FOR_BUILD="$(command -v as)" || abort 1 "command not found: as" AR_FOR_BUILD="$(command -v ar)" || abort 1 "command not found: ar" RANLIB_FOR_BUILD="$(command -v ranlib)" || abort 1 "command not found: ranlib" @@ -8554,78 +8569,14 @@ EOF ############################################################################## # {{{ ndk-pkg setup -__setup_debian() { - $sudo apt-get -y update - $sudo apt-get -y install curl tar xz-utils g++ -} - -__setup_ubuntu() { - $sudo apt-get -y update - $sudo apt-get -y install curl tar xz-utils g++ -} - -__setup_linuxmint() { - $sudo apt-get -y update - $sudo apt-get -y install curl tar xz-utils g++ -} - -__setup_rocky() { - $sudo dnf -y update - $sudo dnf -y install tar xz gcc-c++ - - # https://bugs.launchpad.net/tripleo/+bug/1953156 - command -v curl > /dev/null || dnf -y install curl -} - -__setup_centos() { - $sudo dnf -y update - $sudo dnf -y install curl tar xz gcc-c++ -} - -__setup_fedora() { - $sudo dnf -y update - $sudo dnf -y install curl tar xz g++ -} - -__setup_rhel() { -: -} - -__setup_opensuse_leap() { - $sudo zypper update -y - $sudo zypper install -y curl tar xz gcc-c++ -} - -__setup_gentoo() { - $sudo emerge net-misc/curl sys-devel/gcc -} - -__setup_manjaro() { - $sudo pacman -Syyuu --noconfirm - $sudo pacman -S --noconfirm curl gcc -} - -__setup_arch() { - $sudo pacman -Syyuu --noconfirm - $sudo pacman -S --noconfirm curl gcc -} - -__setup_void() { - $sudo xbps-install -Syu xbps - $sudo xbps-install -S - $sudo xbps-install -Syu curl tar xz gcc -} - -__setup_alpine() { - $sudo apk update - $sudo apk add gcompat g++ linux-headers -} - __setup() { + unset NATIVE_OS_KIND unset NATIVE_OS_ARCH unset NATIVE_OS_VERS - case "$(uname -s)" in + NATIVE_OS_KIND="$(uname -s)" + + case $NATIVE_OS_KIND in Darwin) NATIVE_OS_VERS_MAJOR="$(sw_vers -productVersion | cut -d. -f1)" @@ -8651,15 +8602,11 @@ __setup() { if [ -f /etc/os-release ] ; then . /etc/os-release - if [ "$ID" = 'opensuse-leap' ] ; then - ID='opensuse_leap' - fi - - if [ "$(id -u)" -ne 0 ] ; then - sudo=sudo + if [ "$ID" = alpine ] ; then + if [ "$(id -u)" -ne 0 ] ; then + sudo=sudo + fi fi - - __setup_$ID fi fi esac @@ -8674,6 +8621,20 @@ __setup() { ################################################################################## + if [ "$NATIVE_OS_KIND" = Linux ] ; then + wfetch 'https://github.com/leleliu008/test/releases/download/2023.10.08/bsdtar-3.7.2-linux-x86_64.exe' -o bsdtar --no-buffer + chmod +x bsdtar + export PATH="$PWD:$PATH" + + wfetch 'https://github.com/leleliu008/test/releases/download/2023.10.08/gcc-13.1.0-linux-glibc-x86_64.tar.xz' --no-buffer + run ./bsdtar xvf gcc-13.1.0-linux-glibc-x86_64.tar.xz --strip-components=1 --no-same-owner + + wfetch 'https://github.com/leleliu008/test/releases/download/2023.10.08/binutils-2.41-linux-glibc-x86_64.tar.xz' --no-buffer + run ./bsdtar xvf binutils-2.41-linux-glibc-x86_64.tar.xz --strip-components=1 --no-same-owner + fi + + ################################################################################## + # https://curl.se/docs/caextract.html wfetch 'https://curl.se/ca/cacert.pem' --no-buffer @@ -8695,7 +8656,7 @@ __setup() { wfetch "$NDKPKG_CORE_LATEST_RELEASE_TARBALL_URL" --no-buffer - run tar xvf "$NDKPKG_CORE_LATEST_RELEASE_TARBALL_FILENAME" --strip-components=1 --no-same-owner + run bsdtar xvf "$NDKPKG_CORE_LATEST_RELEASE_TARBALL_FILENAME" --strip-components=1 --no-same-owner ################################################################################## @@ -9265,7 +9226,7 @@ fi fi } -NDKPKG_VERSION=0.17.0 +NDKPKG_VERSION=0.18.0 NDKPKG_ARG0="$0" NDKPKG_ARG1="$1"