aboutsummaryrefslogtreecommitdiff
path: root/src/bootstrap.bash
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-11-30 02:26:51 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2017-11-30 17:37:23 +0000
commitf0f62fcc46a714cf0f3305b7c02af885953fdae7 (patch)
tree13592c6a291464447f89e8e537b5fbac9ffac2f0 /src/bootstrap.bash
parent2708da0dc1537ad223e060a3aca78e984c79bc01 (diff)
downloadgo-f0f62fcc46a714cf0f3305b7c02af885953fdae7.tar.gz
go-f0f62fcc46a714cf0f3305b7c02af885953fdae7.zip
build: add alternate output format for bootstrap.bash, as used by builders
I've been doing these tweaks by hand. I was going to write a tool in Go for it, but it's not much additional shell here. Fixes #22912 Updates #9797 (already closed) Change-Id: Ia15bd9b6876e6f6a76aa9ca86b10f113095e96a3 Reviewed-on: https://go-review.googlesource.com/80895 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/bootstrap.bash')
-rwxr-xr-xsrc/bootstrap.bash42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/bootstrap.bash b/src/bootstrap.bash
index da3dff461f..7b4f57461f 100755
--- a/src/bootstrap.bash
+++ b/src/bootstrap.bash
@@ -14,6 +14,15 @@
#
# Only changes that have been committed to Git (at least locally,
# not necessary reviewed and submitted to master) are included in the tree.
+#
+# As a special case for Go's internal use only, if the
+# BOOTSTRAP_FORMAT environment variable is set to "mintgz", the
+# resulting archive is intended for use by the Go build system and
+# differs in that the mintgz file:
+# * is a tar.gz file instead of bz2
+# * has many unnecessary files deleted to reduce its size
+# * does not have a shared directory component for each tar entry
+# Do not depend on the mintgz format.
set -e
@@ -28,6 +37,11 @@ if [ -e $targ ]; then
exit 2
fi
+if [ "$BOOTSTRAP_FORMAT" != "mintgz" -a "$BOOTSTRAP_FORMAT" != "" ]; then
+ echo "unknown BOOTSTRAP_FORMAT format"
+ exit 2
+fi
+
unset GOROOT
src=$(cd .. && pwd)
echo "#### Copying to $targ"
@@ -62,8 +76,36 @@ else
rmdir bin/*_*
rm -rf "pkg/${gohostos}_${gohostarch}" "pkg/tool/${gohostos}_${gohostarch}"
fi
+
+GITREV=$(git rev-parse --short HEAD)
rm -rf pkg/bootstrap pkg/obj .git
+# Support for building minimal tar.gz for the builders.
+# The build system doesn't support bzip2, and by deleting more stuff,
+# they start faster, especially on machines without fast filesystems
+# and things like tmpfs configures.
+# Do not depend on this format. It's for internal use only.
+if [ "$BOOTSTRAP_FORMAT" = "mintgz" ]; then
+ OUTGZ="gobootstrap-${GOOS}-${GOARCH}-${GITREV}.tar.gz"
+ echo "Preparing to generate build system's ${OUTGZ}; cleaning ..."
+ rm -rf bin/gofmt
+ rm -rf src/runtime/race/race_*.syso
+ rm -rf api test doc misc/cgo/test misc/trace
+ rm -rf pkg/tool/*_*/{addr2line,api,cgo,cover,doc,fix,nm,objdump,pack,pprof,test2json,trace,vet}
+ rm -rf pkg/*_*/{image,database,cmd}
+ rm -rf $(find . -type d -name testdata)
+ find . -type f -name '*_test.go' -exec rm {} \;
+ # git clean doesn't clean symlinks apparently, and the buildlet
+ # rejects them, so:
+ find . -type l -exec rm {} \;
+
+ echo "Writing ${OUTGZ} ..."
+ tar cf - . | gzip -9 > ../$OUTGZ
+ cd ..
+ ls -l "$(pwd)/$OUTGZ"
+ exit 0
+fi
+
echo ----
echo Bootstrap toolchain for "$GOOS/$GOARCH" installed in "$(pwd)".
echo Building tbz.