forked from ppc64le-cloud/docker-ce-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-static.sh
executable file
·98 lines (79 loc) · 2.57 KB
/
build-static.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
#!/bin/bash
# Script building the static docker binaries in a docker container
set -u
set -o allexport
source env.list
${PATH_SCRIPTS}/dockerctl.sh start
DIR_LOGS="/workspace/logs"
STATIC_LOG="static.log"
# Get the latest version of runc
if [[ ! -z ${RUNC_VERS} ]]
then
echo "~ Get the latest version of runc ~"
RUNC_VERS=$(eval "git ls-remote --refs --tags https://github.com/opencontainers/runc.git | cut --delimiter='/' --fields=3 | sort --version-sort | tail --lines=1")
echo "RUNC_VERS = ${RUNC_VERS}"
fi
##
# Patch GO image so that we use bullseye instead of buster which is EOL
##
patchGoVersion() {
MKFILE_PATH=$1/Makefile
echo "Patching GO image from buster to bullseye for $MKFILE_PATH"
sed -ri 's/GO_VERSION\)\-buster/GO_VERSION\)\-bullseye/' $MKFILE_PATH
}
patchGoVersion docker-ce-packaging/deb
patchGoVersion docker-ce-packaging/rpm
echo "Search for buster anywhere"
grep -r buster *
echo "~~ Building static binaries ~~"
pushd docker-ce-packaging/static
echo " make static-linux"
echo " DOCKER_TAG : ${DOCKER_TAG}"
echo " CONTAINERD_TAG: ${CONTAINERD_TAG}"
echo " RUNC_VERS : ${RUNC_VERS}"
DEBUG="-d"
echo " DEBUG : ${DEBUG}"
# Launch the build:
VERSION=${DOCKER_TAG} CONTAINERD_VERSION=${CONTAINERD_TAG} RUNC_VERSION=${RUNC_VERS} make ${DEBUG} static-linux > ${DIR_LOGS}/${STATIC_LOG} 2>&1
RC=$?
if [[ $RC -ne 0 ]]
then
echo " make static-linux : RC: $RC"
echo "ERROR: Static binaries not built ('make static-linux' failed and build/linux has not been created)"
exit 1
fi
mkdir build/linux/tmp
echo "~~~ Renaming the static binaries ~~~"
# Copy the packages in a tmp directory
cp build/linux/*.tgz build/linux/tmp
popd # docker-ce-packaging/static
# Rename the static binaries (replace the version with ppc64le)
pushd docker-ce-packaging/static/build/linux/tmp
FILES="*"
# A "tag" is identical to the version, plus a "v" at first.
DOCKER_VERSION=`echo $DOCKER_TAG | sed "s/^v//"`
for f in $FILES
do
mv $f "${f//${DOCKER_VERSION}/ppc64le}"
done
popd
# Check if the binaries have been built and renamed
ls docker-ce-packaging/static/build/linux/tmp/*.tgz
if [[ $? -ne 0 ]]
then
# No static binaries built
echo "ERROR: Static binaries not built or not renamed"
exit 1
else
# Static binaries built
ls docker-ce-packaging/static/build/linux/tmp/docker*ppc64le.tgz
if [[ $? -ne 0 ]]
then
# Static binaries built but not renamed
echo "ERROR: Static binaries built but not renamed"
exit 1
fi
# Static binaries built and renamed
echo "Static binaries built and renamed"
exit 0
fi