-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxbuild-alpine.sh
56 lines (45 loc) · 998 Bytes
/
xbuild-alpine.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
#!/bin/bash
# netmill: cross-build on Linux for Alpine
IMAGE_NAME=netmill-alpine-builder
CONTAINER_NAME=netmill_alpine_build
ARGS=${@@Q}
set -xe
if ! test -d "../netmill" ; then
exit 1
fi
if ! podman container exists $CONTAINER_NAME ; then
if ! podman image exists $IMAGE_NAME ; then
# Create builder image
cat <<EOF | podman build -t $IMAGE_NAME -f - .
FROM alpine:3.18
RUN apk add \
build-base \
linux-headers
RUN apk add \
openssl openssl-dev
EOF
fi
# Create builder container
podman create --attach --tty \
-v `pwd`/..:/src \
--name $CONTAINER_NAME \
$IMAGE_NAME \
sh -c 'cd /src/netmill && source ./build_linux.sh'
fi
# Prepare build script
cat >build_linux.sh <<EOF
set -xe
make -j8 zlib \
-C ../ffpack \
BINDIR=_linux-musl-amd64
mkdir -p _linux-musl-amd64
make -j8 \
-C _linux-musl-amd64 \
-f ../Makefile \
ROOT_DIR=../.. \
CFLAGS_USER=-DFF_MUSL \
BINDIR=_linux-musl-amd64 \
$ARGS
EOF
# Build inside the container
podman start --attach $CONTAINER_NAME