forked from crosscloudci/cross-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
118 lines (93 loc) · 2.69 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
set -o pipefail
set -x
MUSL_VERSION=1.1.15
SOCAT_VERSION=1.7.3.0
NCURSES_VERSION=5.9
READLINE_VERSION=7.0
OPENSSL_VERSION=1.0.2j
function build_musl() {
cd /build
# Download
curl -LO http://www.musl-libc.org/releases/musl-${MUSL_VERSION}.tar.gz
tar zxvf musl-${MUSL_VERSION}.tar.gz
cd musl-${MUSL_VERSION}
# Build
./configure
make -j4
make install
}
function build_ncurses() {
cd /build
# Download
curl -LO https://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
tar zxvf ncurses-5.9.tar.gz
cd ncurses-${NCURSES_VERSION}
# Build
CC='/usr/local/musl/bin/musl-gcc -static' CFLAGS='-fPIC' ./configure \
--disable-shared \
--enable-static
}
function build_readline() {
cd /build
# Download
curl -LO ftp://ftp.gnu.org/gnu/readline/readline-${READLINE_VERSION}.tar.gz
tar xzvf readline-${READLINE_VERSION}.tar.gz
cd readline-${READLINE_VERSION}
# Build
CC='/usr/local/musl/bin/musl-gcc -static' CFLAGS='-fPIC' ./configure \
--disable-shared \
--enable-static
make -j4
# Note that socat looks for readline in <readline/readline.h>, so we need
# that directory to exist.
ln -s /build/readline-${READLINE_VERSION} /build/readline
}
function build_openssl() {
cd /build
# Download
curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar zxvf openssl-${OPENSSL_VERSION}.tar.gz
cd openssl-${OPENSSL_VERSION}
# Configure
CC='/usr/local/musl/bin/musl-gcc -static' ./Configure no-shared linux-x86_64
# Build
make
echo "** Finished building OpenSSL"
}
function build_socat() {
cd /build
# Download
curl -LO http://www.dest-unreach.org/socat/download/socat-${SOCAT_VERSION}.tar.gz
tar xzvf socat-${SOCAT_VERSION}.tar.gz
cd socat-${SOCAT_VERSION}
# Build
# NOTE: `NETDB_INTERNAL` is non-POSIX, and thus not defined by MUSL.
# We define it this way manually.
CC='/usr/local/musl/bin/musl-gcc -static' \
CFLAGS='-fPIC' \
CPPFLAGS='-I/build -I/build/openssl-1.0.2/include -DNETDB_INTERNAL=-1' \
LDFLAGS="-L/build/readline-${READLINE_VERSION} -L/build/ncurses-${NCURSES_VERSION}/lib -L/build/openssl-${OPENSSL_VERSION}" \
./configure
make -j4
strip socat
}
function doit() {
build_musl
build_ncurses
build_readline
build_openssl
build_socat
# Copy to output
if [ -d /output ]
then
OUT_DIR=/output/`uname | tr 'A-Z' 'a-z'`/`uname -m`
mkdir -p $OUT_DIR
cp /build/socat-${SOCAT_VERSION}/socat $OUT_DIR/
echo "** Finished **"
else
echo "** /output does not exist **"
fi
}
doit