forked from charmed-kubernetes/charm-flannel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-flannel-resources.sh
executable file
·55 lines (47 loc) · 1.47 KB
/
build-flannel-resources.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
#!/usr/bin/env bash
set -eux
FLANNEL_VERSION=${FLANNEL_VERSION:-"v0.11.0"}
ETCD_VERSION=${ETCD_VERSION:-"v2.3.7"}
ARCH=${ARCH:-"amd64 arm64 s390x"}
build_script_commit="$(git show --oneline -q)"
temp_dir="$(readlink -f build-flannel-resources.tmp)"
rm -rf "$temp_dir"
mkdir "$temp_dir"
(cd "$temp_dir"
git clone https://github.com/coreos/flannel.git flannel \
--branch "$FLANNEL_VERSION" \
--depth 1
git clone https://github.com/coreos/etcd.git etcd \
--branch "$ETCD_VERSION" \
--depth 1
# Grab the user id and group id of this current user.
GROUP_ID=$(id -g)
USER_ID=$(id -u)
for arch in $ARCH; do
echo "Building flannel $FLANNEL_VERSION for $arch"
(cd flannel
ARCH=$arch make dist/flanneld-$arch
)
echo "Building etcd $ETCD_VERSION for $arch"
docker run \
--rm \
-e GOOS=linux \
-e GOARCH="$arch" \
-v $temp_dir/etcd:/etcd \
golang \
/bin/bash -c "cd /etcd && ./build && chown -R ${USER_ID}:${GROUP_ID} /etcd"
rm -rf contents
mkdir contents
(cd contents
echo "flannel-$arch $FLANNEL_VERSION" >> BUILD_INFO
echo "etcdctl version $ETCD_VERSION" >> BUILD_INFO
echo "built $(date)" >> BUILD_INFO
echo "build script commit: $build_script_commit" >> BUILD_INFO
cp "$temp_dir"/etcd/bin/etcdctl .
cp "$temp_dir"/flannel/dist/flanneld-$arch ./flanneld
tar -caf "$temp_dir/flannel-$arch.tar.gz" .
)
done
)
mv "$temp_dir"/flannel-*.tar.gz .
rm -rf "$temp_dir"