From 8f743213aad3ee13cf10d7512cace9913f287feb Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Thu, 8 Oct 2020 13:53:48 +0200 Subject: [PATCH] Add my helper build scripts for building custom binaries. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows building Kore with several different component versions. Eg: $ ./build-kore.sh 1.1.1h 3.9.0 7.72.0 1.41.0 Will build Kore with OpenSSL 1.1.1h, Python 3.9.0, Curl 7.72.0 and nghttp2 (for curl) 1.41.0 --- misc/kore-build/build-curl.sh | 19 +++++++++ misc/kore-build/build-kodev.sh | 16 +++++++ misc/kore-build/build-kore.sh | 67 +++++++++++++++++++++++++++++ misc/kore-build/build-nghttp2.sh | 16 +++++++ misc/kore-build/build-openssl.sh | 16 +++++++ misc/kore-build/build-python.sh | 17 ++++++++ misc/kore-build/helpers.sh | 72 ++++++++++++++++++++++++++++++++ 7 files changed, 223 insertions(+) create mode 100755 misc/kore-build/build-curl.sh create mode 100755 misc/kore-build/build-kodev.sh create mode 100755 misc/kore-build/build-kore.sh create mode 100755 misc/kore-build/build-nghttp2.sh create mode 100755 misc/kore-build/build-openssl.sh create mode 100755 misc/kore-build/build-python.sh create mode 100644 misc/kore-build/helpers.sh diff --git a/misc/kore-build/build-curl.sh b/misc/kore-build/build-curl.sh new file mode 100755 index 0000000..a0234c2 --- /dev/null +++ b/misc/kore-build/build-curl.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +. ./env.sh + +if [ $# -ne 3 ]; then + echo "Usage: build-curl.sh [release] [openssl] [nghttp2]" + exit 1 +fi + +export PKG_CONFIG="pkg-config --static" +export PKG_CONFIG_PATH="$FAKEROOT/openssl-$2/lib/pkgconfig:$FAKEROOT/nghttp2-$3/lib/pkgconfig" + +NAME=curl-$1 + +fetch "https://curl.haxx.se/download/$NAME.tar.gz" $NAME + +default_build $NAME --enable-shared=no diff --git a/misc/kore-build/build-kodev.sh b/misc/kore-build/build-kodev.sh new file mode 100755 index 0000000..80c0cd8 --- /dev/null +++ b/misc/kore-build/build-kodev.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +. /home/build/env.sh + +if [ $# -ne 4 ]; then + echo "Usage: build-kore.sh [openssl] [python] [curl] [nghttp2]" + exit 1 +fi + +export PATH=$FAKEROOT/Python-$2/bin:$FAKEROOT/curl-$3/bin:$PATH +export OPENSSL_PATH=$FAKEROOT/openssl-$1 + +kodev clean +kodev build diff --git a/misc/kore-build/build-kore.sh b/misc/kore-build/build-kore.sh new file mode 100755 index 0000000..cfd2db4 --- /dev/null +++ b/misc/kore-build/build-kore.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +set -e + +if [ $# -ne 4 ]; then + echo "Usage: build-kore.sh [openssl] [python] [curl] [nghttp2]" + exit 1 +fi + +# Set ROOT based on the versions given. +VERSION=kore_ossl-$1_python-$2_curl-$3_nghttp2-$4 +ROOT=`pwd`/$VERSION + +# Pull in the rest of the functions. +. ./helpers.sh + +OPENSSL=openssl-$1 +PYTHON=Python-$2 +CURL=curl-$3 +NGHTTP2=nghttp2-$4 + +# Build OpenSSL +echo "Building $OPENSSL" +fetch "https://www.openssl.org/source/$OPENSSL.tar.gz" $OPENSSL +build $OPENSSL ./config no-shared --prefix=$FAKEROOT/$OPENSSL + +# Build Python +echo "Building $PYTHON" +fetch "https://www.python.org/ftp/python/$2/$PYTHON.tgz" $PYTHON +default_build $PYTHON + +# Build nghttp2 +echo "Building $NGHTTP2" +fetch \ + "https://github.com/nghttp2/nghttp2/releases/download/v$4/$NGHTTP2.tar.gz" \ + $NGHTTP2 + +default_build $NGHTTP2 --enable-lib-only --prefix=$FAKEROOT/$NGHTTP2 \ + --enable-shared=no + +# Build curl +echo "Building $CURL" +export PKG_CONFIG="pkg-config --static" +export PKG_CONFIG_PATH="$FAKEROOT/$OPENSSL/lib/pkgconfig:$FAKEROOT/$NGHTTP2/lib/pkgconfig" + +fetch "https://curl.haxx.se/download/$CURL.tar.gz" $CURL +default_build $CURL --enable-shared=no + +# Now we can build kore. +unset PKG_CONFIG +unset PKG_CONFIG_PATH + +export PATH=$FAKEROOT/bin:$PATH +export OPENSSL_PATH=$FAKEROOT/$OPENSSL + +cd $ROOT + +if [ ! -d kore ]; then + git clone https://git.kore.io/kore.git +fi + +pushd kore +make clean +LDFLAGS=-L$FAKEROOT/$NGHTTP2/lib make PYTHON=1 CURL=1 ACME=1 + +mv kore $ROOT/kore.bin +popd diff --git a/misc/kore-build/build-nghttp2.sh b/misc/kore-build/build-nghttp2.sh new file mode 100755 index 0000000..040a125 --- /dev/null +++ b/misc/kore-build/build-nghttp2.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +. ./env.sh + +if [ $# -ne 1 ]; then + echo "Usage: build-nghttp2.sh [release]" + exit 1 +fi + +NAME=nghttp2-$1 + +fetch "https://github.com/nghttp2/nghttp2/releases/download/v$1/$NAME.tar.gz" $NAME + +default_build $NAME --enable-lib-only --prefix=$FAKEROOT/$NAME --enable-shared=no diff --git a/misc/kore-build/build-openssl.sh b/misc/kore-build/build-openssl.sh new file mode 100755 index 0000000..82f4093 --- /dev/null +++ b/misc/kore-build/build-openssl.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +. ./env.sh + +if [ $# -ne 1 ]; then + echo "Usage: build-openssl.sh [release]" + exit 1 +fi + +NAME=openssl-$1 + +fetch "https://www.openssl.org/source/$NAME.tar.gz" $NAME + +build $NAME ./config no-shared --prefix=$FAKEROOT/$NAME diff --git a/misc/kore-build/build-python.sh b/misc/kore-build/build-python.sh new file mode 100755 index 0000000..e2fb1af --- /dev/null +++ b/misc/kore-build/build-python.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e +set -x + +. ./env.sh + +if [ $# -ne 1 ]; then + echo "Usage: build-python.sh [release]" + exit 1 +fi + +NAME=Python-$1 + +fetch "https://www.python.org/ftp/python/$1/$NAME.tgz" $NAME + +default_build $NAME diff --git a/misc/kore-build/helpers.sh b/misc/kore-build/helpers.sh new file mode 100644 index 0000000..c424908 --- /dev/null +++ b/misc/kore-build/helpers.sh @@ -0,0 +1,72 @@ +if [ -z "$ROOT" ]; then + echo "No ROOT set" + exit 1 +fi + +SOURCES=sources +BUILD=$ROOT/build +FAKEROOT=$ROOT/fakeroot + +LASTDIR=`pwd` + +pushd() { + LASTDIR=`pwd` + cd $1 +} + +popd() { + cd $LASTDIR +} + +fetch() { + url=$1 + name=$2 + + if [ -f $SOURCES/$name.tar.gz ]; then + return + fi + + curl -L "$url" > $SOURCES/$name.tar.gz +} + +default_build() { + name=$1 + shift + config=$* + + build $name ./configure --prefix=$FAKEROOT/$NAME $config +} + +build() { + name=$1 + shift + configcmd=$* + + if [ -f $BUILD/$name/.built ]; then + return + fi + + rm -rf $BUILD/$name + rm -rf $FAKEROOT/$name + + tar -zvxf $SOURCES/$name.tar.gz -C $BUILD + + pushd $BUILD/$name + mkdir -p $FAKEROOT/$name + + $configcmd + + make -j + make install + popd + + touch $BUILD/$name/.built +} + +setup() { + mkdir -p $BUILD + mkdir -p $SOURCES + mkdir -p $FAKEROOT +} + +setup