Add readme/license, tweak build

This commit is contained in:
Travis Burtrum 2019-12-05 20:34:50 -05:00
parent 4cefaa2b00
commit a94f48bb07
6 changed files with 140 additions and 28 deletions

View File

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

21
LICENSE.txt Normal file
View File

@ -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.

19
README.md Normal file
View File

@ -0,0 +1,19 @@
<img src="https://raw.githubusercontent.com/moparisthebest/static-curl/master/static-curl.svg?sanitize=true" alt="no not that kind" width="32" /> Static curl <img src="https://raw.githubusercontent.com/moparisthebest/static-curl/master/static-curl.svg?sanitize=true" alt="no not that kind" width="32" />
-----------
[![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)

View File

@ -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/

View File

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

61
static-curl.svg Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
x="0px"
y="0px"
viewBox="0 0 87.596748 89.035118"
xml:space="preserve"
id="svg16"
sodipodi:docname="static-curl.svg"
width="87.596748"
height="89.035118"
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
id="metadata22"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs20" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1013"
id="namedview18"
showgrid="false"
inkscape:zoom="1.888"
inkscape:cx="-48.686715"
inkscape:cy="35.735117"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg16"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" /><path
d="m 86.933624,66.6 c 0.9,-5.6 0.8,-11.9 0.2,-15.1 -0.3,-1.4 -0.6,-3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2 -3.3,-1.6 -6.6,-4.1 -9.3,-7.8 -0.2,-0.2 -0.1,-0.5 0.1,-0.7 0.2,-0.2 0.5,-0.1 0.7,0.1 9.8,13.8 27.7,9.5 27.9,9.5 0.3,-0.1 0.5,0.1 0.6,0.4 0.1,0.2 -0.1,0.4 -0.3,0.5 z m 16.3,-0.7 c -0.1,0.2 -0.4,0.2 -0.6,0.1 0,0 -0.1,0 -0.1,-0.1 -5.4,-4.3 -2.9,-11.4 -2.1,-13.8 0.1,-0.2 0.1,-0.4 0.2,-0.6 0.5,-1.7 7.6,-17.3 7.9,-18 0.1,-0.3 0.4,-0.4 0.7,-0.2 0.2,0.1 0.4,0.4 0.2,0.7 -0.1,0.2 -7.4,16.2 -7.8,17.8 -0.1,0.2 -0.1,0.4 -0.2,0.6 -0.9,2.4 -3.1,8.8 1.7,12.7 0.2,0.3 0.3,0.6 0.1,0.8 z"
id="path2"
inkscape:connector-curvature="0" /><path
d="m 76.733624,2.3 c -0.7,-0.8 -1.7,-1.1 -2.7,-0.8 -0.5,0.1 -1,0.3 -1.6,0.4 l 8.1,4.9 c -1.3,-1.7 -2.8,-3.4 -3.8,-4.5 z"
id="path4"
inkscape:connector-curvature="0" /><path
d="m 69.433624,17.2 c -0.3,0.6 -0.8,1 -1.4,1.2 -0.6,0.2 -1.3,0.2 -1.8,-0.1 -0.6,-0.3 -1,-0.8 -1.2,-1.4 -0.2,-0.6 -0.2,-1.3 0.1,-1.8 0.3,-0.6 0.8,-1 1.4,-1.2 0.4,-0.2 0.9,-0.2 1.3,-0.1 0.2,0 0.3,0.1 0.5,0.2 0.6,0.3 1,0.8 1.2,1.4 0.2,0.6 0.2,1.3 -0.1,1.8 z"
id="path6"
inkscape:connector-curvature="0" /><path
d="m 72.033624,13.6 -4.7,-2.8 -4.8,2.6 v 5.4 l 4.6,2.8 4.8,-2.6 z m -1.7,4.1 c -0.4,0.8 -1.1,1.4 -1.9,1.7 -0.6,0.2 -1.3,0.3 -1.9,0.1 -0.2,-0.1 -0.5,-0.1 -0.7,-0.3 -0.8,-0.4 -1.4,-1.1 -1.7,-1.9 -0.3,-0.9 -0.3,-1.8 0.1,-2.6 0.4,-0.8 1.1,-1.4 1.9,-1.7 0.9,-0.3 1.8,-0.3 2.6,0.1 0.8,0.4 1.4,1.1 1.7,1.9 0.3,0.9 0.3,1.9 -0.1,2.7 z"
id="path8"
inkscape:connector-curvature="0" /><path
d="m 81.433624,8.4 -13.9,-8.4 -14.1,7.8 -0.3,16.2 13.8,8.4 14.2,-7.8 z m -14.3,14.4 -5.6,-3.4 0.1,-6.6 5.8,-3.2 5.6,3.4 -0.1,6.6 z"
id="path10"
inkscape:connector-curvature="0" /></svg>

After

Width:  |  Height:  |  Size: 4.3 KiB