This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.sh
executable file
·70 lines (62 loc) · 2.13 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
#!/bin/bash
set -e
# Note the hashes here are the git SHAs that correspond to the given tags. This
# lets us make sure the tags don't change on us.
DUMB_INIT_TAG=v1.0.0
DUMB_INIT_HASH=a9eadb580c0d234fc4090c1bf3f19f8d87bff76b
GOSU_TAG=1.7
GOSU_HASH=6908f86c7e0bf676b27b9237c41ca40719d4b9cb
# Get the version from the command line.
VERSION=$1
if [ -z $VERSION ]; then
echo "Please specify a version."
exit 1
fi
# Clear out the working folder and make the initial structure.
rm -rf pkg
mkdir -p pkg/dist
mkdir -p pkg/build
mkdir -p pkg/rootfs/bin
# Generate the tag.
if [ -z $NOTAG ]; then
git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION"
git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master
fi
# Create the Debian build box. We don't use this to package anything
# directly, but it's used as a scratch build environment.
docker build -t hashicorp/builder-debian images/builder-debian
# Build dumb-init.
git clone -b "$DUMB_INIT_TAG" https://github.com/Yelp/dumb-init.git pkg/build/dumb-init
pushd pkg/build/dumb-init
if $(git show-ref --verify refs/tags/${DUMB_INIT_TAG} | grep --quiet "$DUMB_INIT_HASH") ; then
echo "Verified dumb-init git repository state"
else
echo "Could not verify dumb-init git repository state"
exit 1
fi
docker run --rm -v "$(pwd):/build" -w /build hashicorp/builder-debian make
popd
cp pkg/build/dumb-init/dumb-init pkg/rootfs/bin
# Build gosu.
git clone -b "$GOSU_TAG" https://github.com/tianon/gosu.git pkg/build/gosu
pushd pkg/build/gosu
if $(git show-ref --verify refs/tags/${GOSU_TAG} | grep --quiet "$GOSU_HASH") ; then
echo "Verified gosu git repository state"
else
echo "Could not verify gosu git repository state"
exit 1
fi
docker build --no-cache --pull -t gosu .
docker run --rm gosu bash -c 'cd /go/bin && tar -c gosu*' | tar -xv
popd
cp pkg/build/gosu/gosu-amd64 pkg/rootfs/bin/gosu
# Prep the release.
pushd pkg/rootfs
zip -r ../dist/docker-base_${VERSION}_linux_amd64.zip *
popd
pushd pkg/dist
shasum -a256 * > ./docker-base_${VERSION}_SHA256SUMS
if [ -z $NOSIGN ]; then
gpg --default-key 348FFC4C --detach-sig ./docker-base_${VERSION}_SHA256SUMS
fi
popd