static-curl/build.sh

49 lines
1.8 KiB
Bash
Raw Normal View History

2019-12-04 22:33:05 -05:00
#!/bin/sh
CURL_VERSION='7.67.0'
[ "$1" != ""] && CURL_VERSION="$1"
set -exu
2019-12-05 20:34:50 -05:00
# change to the directory this script is in, we assume mykey.asc is there
2019-12-04 22:33:05 -05:00
cd "$(dirname "$0")"
2019-12-05 20:34:50 -05:00
# for gpg verification of the curl download below
2019-12-04 22:33:05 -05:00
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-05 20:34:50 -05:00
# convert mykey.asc to a .pgp file to use in verification
2019-12-04 22:33:05 -05:00
gpg --no-default-keyring --yes -o ./curl.gpg --dearmor mykey.asc
2019-12-05 20:34:50 -05:00
# this has a non-zero exit code if it fails, which will halt the script
2019-12-04 22:33:05 -05:00
gpg --no-default-keyring --keyring ./curl.gpg --verify curl-${CURL_VERSION}.tar.gz.asc
tar xzf curl-${CURL_VERSION}.tar.gz
cd curl-${CURL_VERSION}/
2019-12-05 20:34:50 -05:00
# dependencies to build curl
2019-12-04 22:33:05 -05:00
apk add build-base clang openssl-dev
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
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
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
#./src/curl -v http://www.moparisthebest.com/; ./src/curl -v https://www.moparisthebest.com/ip
2019-12-05 20:34:50 -05:00
# we only want to save curl here, by moving it to /tmp/ for now
mv src/curl /tmp/