2017-08-22 16:22:12 -06:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2017 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# build.docker builds and publishes a Docker image for
|
|
|
|
# a given Go+BoringCrypto release.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2017-09-28 10:18:54 -06:00
|
|
|
# With no arguments, use the most recent linux-amd64 release in the RELEASES file.
|
2017-08-22 16:22:12 -06:00
|
|
|
case "$#" in
|
|
|
|
0)
|
2017-09-28 10:18:54 -06:00
|
|
|
version=$(grep linux-amd64 RELEASES | tail -1 | awk '{print $1}');;
|
2017-08-22 16:22:12 -06:00
|
|
|
1)
|
|
|
|
version="$1";;
|
|
|
|
*)
|
|
|
|
echo 'usage: build.docker [version]' >&2
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
|
2017-09-28 10:18:54 -06:00
|
|
|
url="$(grep "^$version .* linux-amd64 " RELEASES | awk '{print $4}')"
|
|
|
|
sha256="$(grep "^$version .* linux-amd64 " RELEASES | awk '{print $5}')"
|
2017-08-22 16:22:12 -06:00
|
|
|
if [ "$sha256" = "" ]; then
|
|
|
|
echo "cannot find $version in RELEASES file" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build a temporary directory with a Dockerfile.
|
|
|
|
dir=$(mktemp -d)
|
|
|
|
trap "rm -rf $dir" EXIT
|
|
|
|
|
|
|
|
if echo "$url" | grep '!' >/dev/null; then
|
|
|
|
# ! is sed delimiter below. Should never happen.
|
|
|
|
echo "URL contains an exclamation mark!" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed "s!UUU!$url!; s/SSS/$sha256/" dockerfile.in >$dir/Dockerfile
|
|
|
|
cp go-wrapper $dir/go-wrapper
|
|
|
|
|
|
|
|
dversion=$(echo "$version" | sed 's/^go//')
|
2018-12-06 10:16:43 -07:00
|
|
|
docker build --pull -t goboring/golang:$dversion $dir
|
2017-08-22 16:22:12 -06:00
|
|
|
docker run goboring/golang:$dversion go version
|
|
|
|
docker run goboring/golang:$dversion go tool nm /usr/local/go/bin/go >$dir/nm
|
2019-03-26 18:26:53 -06:00
|
|
|
if ! grep crypto/internal/boring/sig.BoringCrypto $dir/nm >/dev/null; then
|
|
|
|
echo 'built docker image but did NOT find sig.BoringCrypto in go command!' >&2
|
2017-08-22 16:22:12 -06:00
|
|
|
exit 2
|
|
|
|
fi
|
2019-03-26 18:26:53 -06:00
|
|
|
if egrep 'crypto/sha256\.\(\*digest\)' $dir/nm >/dev/null; then
|
|
|
|
echo 'built docker image but DID find sha256.(*digest) in go command unexpectedly!' >&2
|
2017-08-22 16:22:12 -06:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
docker push goboring/golang:$dversion
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo published as goboring/golang:$dversion
|