From a94f48bb07b1adba907b97db504166e7793709ff Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Thu, 5 Dec 2019 20:34:50 -0500 Subject: [PATCH] Add readme/license, tweak build --- .travis.yml | 25 ++++++++------------ LICENSE.txt | 21 +++++++++++++++++ README.md | 19 +++++++++++++++ build.sh | 20 +++++++++++----- docker_build.sh | 22 +++++++++++++----- static-curl.svg | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 140 insertions(+), 28 deletions(-) create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 static-curl.svg diff --git a/.travis.yml b/.travis.yml index 51b0185..8c0e7a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,26 @@ -dist: trusty language: minimal services: docker -sudo: required env: global: - CURL_VERSION='7.67.0' +matrix: + include: + - env: ARCH='amd64' DOCKER_IMAGE='alpine' + - env: ARCH='i386' DOCKER_IMAGE='i386/alpine' + - env: ARCH='aarch64' DOCKER_IMAGE='alpine' + arch: arm64 + script: - - bash docker_build.sh "$CURL_VERSION" + - ./docker_build.sh "$DOCKER_IMAGE" "$ARCH" "$CURL_VERSION" deploy: - # TODO update `api_key.secure` - # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new - # - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789 - # - Paste the output down here api_key: secure: $GITHUB_OAUTH file_glob: true - file: curl + file: curl* on: tags: true provider: releases skip_cleanup: true - -branches: - only: - # release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - - travis - - ci diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..33b781c --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Travis Burtrum + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d72662 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +no not that kind Static curl no not that kind +----------- +[![Travis-CI Build Status](https://api.travis-ci.org/moparisthebest/static-curl.svg?branch=master)](https://travis-ci.org/moparisthebest/static-curl) + +These are a couple simple scripts to build a fully static curl binary using an alpine linux docker container. Currently it is a minimal build with OpenSSL and only supporting HTTP and FTP. Tweak configure options in [build.sh](build.sh#L33) if you need something else (and/or suggest or PR). + +Grab the latest release (curl 7.67.0) from one of these links, by CPU architecture: + - [curl-amd64](https://github.com/moparisthebest/static-curl/releases/download/v7.67.0/curl-amd64) + - [curl-i386](https://github.com/moparisthebest/static-curl/releases/download/v7.67.0/curl-i386) + - [curl-aarch64](https://github.com/moparisthebest/static-curl/releases/download/v7.67.0/curl-aarch64) + +Development +----------- + +File explanation: + - [build.sh](build.sh) - runs inside an alpine docker container, downloads curl, verifies it with gpg, and builds it + - [docker_build.sh](docker_build.sh) - runs build.sh inside docker + - [mykey.asc](mykey.asc) - Daniel Stenberg's [GPG key](https://daniel.haxx.se/address.html) used for signing/verifying curl releases + - [bicep curl](https://thenounproject.com/term/curl/499187) by Laymik from [the Noun Project](https://thenounproject.com) diff --git a/build.sh b/build.sh index 098fb22..a9a7610 100755 --- a/build.sh +++ b/build.sh @@ -6,35 +6,43 @@ CURL_VERSION='7.67.0' set -exu +# change to the directory this script is in, we assume mykey.asc is there cd "$(dirname "$0")" +# 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 +# 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 tar xzf curl-${CURL_VERSION}.tar.gz cd curl-${CURL_VERSION}/ +# dependencies to build curl apk add build-base clang openssl-dev +# gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang export CC=clang -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 +# 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 make -j4 V=1 curl_LDFLAGS=-all-static +# binary is ~13M before stripping, 2.6M after strip src/curl -ls -lah src/curl; file src/curl +# print out some info about this, size, and to ensure it's actually fully static +ls -lah src/curl +file src/curl ldd src/curl || true #./src/curl -v http://www.moparisthebest.com/; ./src/curl -v https://www.moparisthebest.com/ip -cp src/curl /tmp/ - -cd .. -rm -rf curl-${CURL_VERSION}/ +# we only want to save curl here, by moving it to /tmp/ for now +mv src/curl /tmp/ diff --git a/docker_build.sh b/docker_build.sh index 18a318a..a6ccb27 100755 --- a/docker_build.sh +++ b/docker_build.sh @@ -1,10 +1,20 @@ #!/bin/sh -rm -rf /tmp/static-curl/ -mkdir -p /tmp/static-curl/ -cp build.sh mykey.asc /tmp/static-curl/ +DOCKER_IMAGE="$1" +shift +ARCH="$1" +shift +CURL_VERSION="$1" -docker run -it --rm -v /tmp/static-curl:/tmp alpine /tmp/build.sh +BUILD_DIR=/tmp/static-curl/ -mv /tmp/static-curl/curl . -rm -rf /tmp/static-curl/ +rm -rf "$BUILD_DIR" +mkdir -p "$BUILD_DIR" +cp build.sh mykey.asc "$BUILD_DIR" + +docker run --rm -v "$BUILD_DIR":/tmp "$DOCKER_IMAGE" /tmp/build.sh "$CURL_VERSION" || exit 1 + +mv "$BUILD_DIR"curl "./curl-$ARCH" +rm -rf "$BUILD_DIR" 2>/dev/null + +exit 0 diff --git a/static-curl.svg b/static-curl.svg new file mode 100644 index 0000000..56fafbf --- /dev/null +++ b/static-curl.svg @@ -0,0 +1,61 @@ + +image/svg+xml \ No newline at end of file