Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
leleliu008 committed Sep 30, 2024
1 parent 67bf675 commit e75d4e0
Showing 1 changed file with 43 additions and 82 deletions.
125 changes: 43 additions & 82 deletions ndk-pkg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)"

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

##################################################################################

Expand Down Expand Up @@ -9265,7 +9226,7 @@ fi
fi
}

NDKPKG_VERSION=0.17.0
NDKPKG_VERSION=0.18.0

NDKPKG_ARG0="$0"
NDKPKG_ARG1="$1"
Expand Down

0 comments on commit e75d4e0

Please sign in to comment.