2019-12-04 22:33:05 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
# to test locally, run one of:
|
2020-11-24 00:21:25 -05:00
|
|
|
# docker run --rm -v $(pwd):/tmp -w /tmp -e ARCH=amd64 alpine /tmp/build.sh
|
|
|
|
# docker run --rm -v $(pwd):/tmp -w /tmp -e ARCH=aarch64 multiarch/alpine:aarch64-latest-stable /tmp/build.sh
|
|
|
|
# docker run --rm -v $(pwd):/tmp -w /tmp -e ARCH=ARCH_HERE ALPINE_IMAGE_HERE /tmp/build.sh
|
2020-01-09 22:41:05 -05:00
|
|
|
|
2021-02-03 10:39:54 -05:00
|
|
|
CURL_VERSION='7.75.0'
|
2019-12-04 22:33:05 -05:00
|
|
|
|
2020-11-24 00:21:25 -05:00
|
|
|
[ "$1" != "" ] && CURL_VERSION="$1"
|
2019-12-04 22:33:05 -05:00
|
|
|
|
|
|
|
set -exu
|
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
if [ ! -f curl-${CURL_VERSION}.tar.gz ]
|
|
|
|
then
|
|
|
|
|
|
|
|
# for gpg verification of the curl download below
|
|
|
|
apk add gnupg
|
|
|
|
|
|
|
|
wget https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz.asc
|
2019-12-04 22:33:05 -05:00
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
# convert mykey.asc to a .pgp file to use in verification
|
|
|
|
gpg --no-default-keyring --yes -o ./curl.gpg --dearmor mykey.asc
|
|
|
|
# this has a non-zero exit code if it fails, which will halt the script
|
|
|
|
gpg --no-default-keyring --keyring ./curl.gpg --verify curl-${CURL_VERSION}.tar.gz.asc
|
2019-12-04 22:33:05 -05:00
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
fi
|
2019-12-04 22:33:05 -05:00
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
rm -rf "curl-${CURL_VERSION}/"
|
2019-12-04 22:33:05 -05:00
|
|
|
tar xzf curl-${CURL_VERSION}.tar.gz
|
|
|
|
|
|
|
|
cd curl-${CURL_VERSION}/
|
|
|
|
|
2019-12-05 20:34:50 -05:00
|
|
|
# dependencies to build curl
|
2020-01-09 22:41:05 -05:00
|
|
|
apk add build-base clang openssl-dev nghttp2-dev nghttp2-static libssh2-dev libssh2-static
|
|
|
|
|
|
|
|
# these are missing on at least armhf
|
|
|
|
apk add openssl-libs-static zlib-static || true
|
2019-12-04 22:33:05 -05:00
|
|
|
|
2019-12-05 20:34:50 -05:00
|
|
|
# gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang
|
2019-12-04 22:33:05 -05:00
|
|
|
export CC=clang
|
|
|
|
|
2019-12-05 20:34:50 -05:00
|
|
|
# set up any required curl options here
|
2020-01-09 22:41:05 -05:00
|
|
|
#LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-libcurl-option --without-brotli --disable-manual --disable-unix-sockets --disable-dict --disable-file --disable-gopher --disable-imap --disable-smtp --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --without-zlib --disable-threaded-resolver --disable-ipv6 --disable-smb --disable-ntlm-wb --disable-tls-srp --disable-crypto-auth --with-ssl
|
|
|
|
|
|
|
|
LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-ldap --enable-ipv6 --enable-unix-sockets --with-ssl --with-libssh2
|
2019-12-04 22:33:05 -05:00
|
|
|
|
|
|
|
make -j4 V=1 curl_LDFLAGS=-all-static
|
|
|
|
|
2019-12-05 20:34:50 -05:00
|
|
|
# binary is ~13M before stripping, 2.6M after
|
2019-12-04 22:33:05 -05:00
|
|
|
strip src/curl
|
|
|
|
|
2019-12-05 20:34:50 -05:00
|
|
|
# print out some info about this, size, and to ensure it's actually fully static
|
|
|
|
ls -lah src/curl
|
|
|
|
file src/curl
|
2019-12-04 22:33:05 -05:00
|
|
|
ldd src/curl || true
|
|
|
|
|
2020-01-09 22:41:05 -05:00
|
|
|
./src/curl -V
|
|
|
|
|
2019-12-04 22:33:05 -05:00
|
|
|
#./src/curl -v http://www.moparisthebest.com/; ./src/curl -v https://www.moparisthebest.com/ip
|
|
|
|
|
2020-11-24 00:21:25 -05:00
|
|
|
# we only want to save curl here
|
|
|
|
mkdir -p /tmp/release/
|
|
|
|
mv src/curl "/tmp/release/curl-$ARCH"
|
|
|
|
cd ..
|
|
|
|
rm -rf "curl-${CURL_VERSION}/"
|