1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:30:03 -07:00
go/misc/boring/build.docker
Filippo Valsorda 347af7f060 [dev.boringcrypto] misc/boring: add go1.12.1b4 and update build scripts
The inliner seems to have gotten a bit too smart in 1.12 and it made
sha1.boringNewSHA1 disappear. Replace it with the proper
crypto/internal/boring/sig.BoringCrypto signature. Also, switch the
negative signature to sha256.(*digest), since SHA-256 is used for sure
by cmd/go. Not using crypto/internal/boring/sig.StandardCrypto just to
be safe, in case the crypto/internal/boring/sig mechanism breaks.

Also, had to fight #30833 and #30515 to get
golang.org/x/build/cmd/release to build in modules mode.

Change-Id: I46f1471582fd77daae47d00baab975109902052d
Reviewed-on: https://go-review.googlesource.com/c/go/+/169517
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-28 18:21:20 +00:00

58 lines
1.7 KiB
Bash
Executable File

#!/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
# With no arguments, use the most recent linux-amd64 release in the RELEASES file.
case "$#" in
0)
version=$(grep linux-amd64 RELEASES | tail -1 | awk '{print $1}');;
1)
version="$1";;
*)
echo 'usage: build.docker [version]' >&2
exit 2
esac
url="$(grep "^$version .* linux-amd64 " RELEASES | awk '{print $4}')"
sha256="$(grep "^$version .* linux-amd64 " RELEASES | awk '{print $5}')"
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//')
docker build --pull -t goboring/golang:$dversion $dir
docker run goboring/golang:$dversion go version
docker run goboring/golang:$dversion go tool nm /usr/local/go/bin/go >$dir/nm
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
exit 2
fi
if egrep 'crypto/sha256\.\(\*digest\)' $dir/nm >/dev/null; then
echo 'built docker image but DID find sha256.(*digest) in go command unexpectedly!' >&2
exit 2
fi
docker push goboring/golang:$dversion
echo
echo published as goboring/golang:$dversion