From 9081c6afbd1b59404901a4e6e004d6cfa3b2beb0 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sat, 20 Feb 2016 21:40:41 -0800 Subject: [PATCH 01/10] Replace non-standard `rename` in update.sh. A more standard and widely available alternative implementation created by @dominikh in https://github.com/gopherjs/gopherjs.github.io/issues/43#issuecomment-186747811. Fixes #43. --- playground/update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playground/update.sh b/playground/update.sh index 188aeb8d..f6d8f003 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -36,4 +36,5 @@ cp -r $GOROOT/pkg/darwin_amd64_js_min/* $PKG rm -r /tmp/gopherjsplayground_goroot rm -r /tmp/gopherjsplayground_gopath -rename 's/\.a/\.a.js/' $(find $PKG -name "*.a") +# Rename all *.a files in $PKG to *.a.js. +find "$PKG" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; From 88daf49aa1bcc4f89164c35a97df11907a7a0076 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 08:22:54 +0100 Subject: [PATCH 02/10] update.sh: split gopherjs install into multiple lines --- playground/update.sh | 100 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/playground/update.sh b/playground/update.sh index f6d8f003..d68eaa7e 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -29,7 +29,105 @@ cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.c # use it to build and copy out standard library packages. cp -r $(go env GOROOT) /tmp/gopherjsplayground_goroot export GOROOT=/tmp/gopherjsplayground_goroot -gopherjs install -m archive/tar archive/zip bufio bytes compress/bzip2 compress/flate compress/gzip compress/lzw compress/zlib container/heap container/list container/ring crypto/aes crypto/cipher crypto/des crypto/dsa crypto/ecdsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand crypto/rc4 crypto/rsa crypto/sha1 crypto/sha256 crypto/sha512 crypto/subtle database/sql/driver debug/gosym debug/pe encoding/ascii85 encoding/asn1 encoding/base32 encoding/base64 encoding/binary encoding/csv encoding/gob encoding/hex encoding/json encoding/pem encoding/xml errors fmt go/ast go/doc go/format go/printer go/token hash/adler32 hash/crc32 hash/crc64 hash/fnv html html/template image image/color image/draw image/gif image/jpeg image/png index/suffixarray io io/ioutil math math/big math/cmplx math/rand mime net/http/cookiejar net/http/fcgi net/http/httptest net/http/httputil net/mail net/smtp net/textproto net/url path path/filepath reflect regexp regexp/syntax runtime/internal/sys sort strconv strings sync/atomic testing testing/iotest testing/quick text/scanner text/tabwriter text/template text/template/parse time unicode unicode/utf16 unicode/utf8 +gopherjs install -m \ + archive/tar \ + archive/zip \ + bufio \ + bytes \ + compress/bzip2 \ + compress/flate \ + compress/gzip \ + compress/lzw \ + compress/zlib \ + container/heap \ + container/list \ + container/ring \ + crypto/aes \ + crypto/cipher \ + crypto/des \ + crypto/dsa \ + crypto/ecdsa \ + crypto/elliptic \ + crypto/hmac \ + crypto/md5 \ + crypto/rand \ + crypto/rc4 \ + crypto/rsa \ + crypto/sha1 \ + crypto/sha256 \ + crypto/sha512 \ + crypto/subtle \ + database/sql/driver \ + debug/gosym \ + debug/pe \ + encoding/ascii85 \ + encoding/asn1 \ + encoding/base32 \ + encoding/base64 \ + encoding/binary \ + encoding/csv \ + encoding/gob \ + encoding/hex \ + encoding/json \ + encoding/pem \ + encoding/xml \ + errors \ + fmt \ + go/ast \ + go/doc \ + go/format \ + go/printer \ + go/token \ + hash/adler32 \ + hash/crc32 \ + hash/crc64 \ + hash/fnv \ + html \ + html/template \ + image \ + image/color \ + image/draw \ + image/gif \ + image/jpeg \ + image/png \ + index/suffixarray \ + io \ + io/ioutil \ + math \ + math/big \ + math/cmplx \ + math/rand \ + mime \ + net/http/cookiejar \ + net/http/fcgi \ + net/http/httptest \ + net/http/httputil \ + net/mail \ + net/smtp \ + net/textproto \ + net/url \ + path \ + path/filepath \ + reflect \ + regexp \ + regexp/syntax \ + runtime/internal/sys \ + sort \ + strconv \ + strings \ + sync/atomic \ + testing \ + testing/iotest \ + testing/quick \ + text/scanner \ + text/tabwriter \ + text/template \ + text/template/parse \ + time \ + unicode \ + unicode/utf16 \ + unicode/utf8 + cp -r $GOROOT/pkg/darwin_js_min/* $PKG cp -r $GOROOT/pkg/darwin_amd64_js_min/* $PKG From 96af71603e9ffb7a1313f7aad81e7b87d3917533 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 08:27:52 +0100 Subject: [PATCH 03/10] update.sh: don't assume we're running OS X --- playground/update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index d68eaa7e..69e3502e 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -22,8 +22,8 @@ cp -r $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/ gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync mkdir -p $PKG/github.com/gopherjs/gopherjs -cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/js.a $PKG/github.com/gopherjs/gopherjs/js.a -cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/gopherjs/gopherjs/nosync.a +cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a $PKG/github.com/gopherjs/gopherjs/js.a +cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/gopherjs/gopherjs/nosync.a # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. @@ -128,8 +128,8 @@ gopherjs install -m \ unicode/utf16 \ unicode/utf8 -cp -r $GOROOT/pkg/darwin_js_min/* $PKG -cp -r $GOROOT/pkg/darwin_amd64_js_min/* $PKG +cp -r $GOROOT/pkg/*_js_min/* $PKG +cp -r $GOROOT/pkg/*_amd64_js_min/* $PKG rm -r /tmp/gopherjsplayground_goroot rm -r /tmp/gopherjsplayground_gopath From 31bb2762ca13af3219e02025ab696e4082bf68dc Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 08:41:33 +0100 Subject: [PATCH 04/10] update.sh: remove temporary files even on ^C or errors --- playground/update.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index 69e3502e..0a253489 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -1,6 +1,14 @@ #!/bin/sh set -e +cleanup() { + rm -rf /tmp/gopherjsplayground_gopath + rm -rf /tmp/gopherjsplayground_goroot + exit +} + +trap cleanup EXIT SIGHUP SIGINT SIGTERM + go install github.com/gopherjs/gopherjs/... go generate github.com/gopherjs/gopherjs.github.io/playground/internal/imports @@ -131,8 +139,5 @@ gopherjs install -m \ cp -r $GOROOT/pkg/*_js_min/* $PKG cp -r $GOROOT/pkg/*_amd64_js_min/* $PKG -rm -r /tmp/gopherjsplayground_goroot -rm -r /tmp/gopherjsplayground_gopath - # Rename all *.a files in $PKG to *.a.js. find "$PKG" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; From 57a5c6bb6d6b07687ab2d1ebc38d726486bb25fd Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 08:52:06 +0100 Subject: [PATCH 05/10] update.sh: use mktemp Using mktemp solves two issues: - it allows running multiple instances of update.sh in parallel. For example, someone might have two separate checkouts of the playground and intent to build them with different versions of Go. They might run both instances of update.sh in parallel to save time. - it works correctly when someone has set their TMPDIR to something other than /tmp --- playground/update.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index 0a253489..4c928d1d 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -1,9 +1,12 @@ #!/bin/sh set -e +tmp_gopath=$(mktemp -d --suffix _play_gopath) +tmp_goroot=$(mktemp -d --suffix _play_goroot) + cleanup() { - rm -rf /tmp/gopherjsplayground_gopath - rm -rf /tmp/gopherjsplayground_goroot + rm -rf "$tmp_gopath" + rm -rf "$tmp_goroot" exit } @@ -24,7 +27,7 @@ rm -r $PKG # Use an empty GOPATH workspace with just gopherjs, # so that all the standard library packages get written to GOROOT/pkg. -export GOPATH=/tmp/gopherjsplayground_gopath +export GOPATH="$tmp_gopath" mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs cp -r $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs @@ -35,8 +38,8 @@ cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/go # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. -cp -r $(go env GOROOT) /tmp/gopherjsplayground_goroot -export GOROOT=/tmp/gopherjsplayground_goroot +cp -r $(go env GOROOT)/. "$tmp_goroot" +export GOROOT="$tmp_goroot" gopherjs install -m \ archive/tar \ archive/zip \ From 71b5c54bf2e3d7b401fdb5f9e7e0f4308f2078d9 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 08:55:23 +0100 Subject: [PATCH 06/10] update.sh: use cp -a instead of cp -r for more accurate copies --- playground/update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index 4c928d1d..28e8c169 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -29,7 +29,7 @@ rm -r $PKG # so that all the standard library packages get written to GOROOT/pkg. export GOPATH="$tmp_gopath" mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs -cp -r $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs +cp -a $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync mkdir -p $PKG/github.com/gopherjs/gopherjs @@ -38,7 +38,7 @@ cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/go # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. -cp -r $(go env GOROOT)/. "$tmp_goroot" +cp -a $(go env GOROOT)/. "$tmp_goroot" export GOROOT="$tmp_goroot" gopherjs install -m \ archive/tar \ @@ -139,8 +139,8 @@ gopherjs install -m \ unicode/utf16 \ unicode/utf8 -cp -r $GOROOT/pkg/*_js_min/* $PKG -cp -r $GOROOT/pkg/*_amd64_js_min/* $PKG +cp -a $GOROOT/pkg/*_js_min/* $PKG +cp -a $GOROOT/pkg/*_amd64_js_min/* $PKG # Rename all *.a files in $PKG to *.a.js. find "$PKG" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; From 29f4fefc84ecb3fed894076383af2a7e99042a4b Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sun, 21 Feb 2016 09:17:20 +0100 Subject: [PATCH 07/10] update.sh: quote all relevant variable uses Even quote the use of PKG. While not necessary right now, it protects us from future code breakage. --- playground/update.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index 28e8c169..af83aea3 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -23,22 +23,22 @@ gopherjs build -m GOPHERJSGOPATH=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs) PKG=pkg -rm -r $PKG +rm -r "$PKG" # Use an empty GOPATH workspace with just gopherjs, # so that all the standard library packages get written to GOROOT/pkg. export GOPATH="$tmp_gopath" -mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs -cp -a $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs +mkdir -p "$GOPATH"/src/github.com/gopherjs/gopherjs +cp -a "$GOPHERJSGOPATH"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync -mkdir -p $PKG/github.com/gopherjs/gopherjs -cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a $PKG/github.com/gopherjs/gopherjs/js.a -cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/gopherjs/gopherjs/nosync.a +mkdir -p "$PKG"/github.com/gopherjs/gopherjs +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a "$PKG"/github.com/gopherjs/gopherjs/js.a +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a "$PKG"/github.com/gopherjs/gopherjs/nosync.a # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. -cp -a $(go env GOROOT)/. "$tmp_goroot" +cp -a "$(go env GOROOT)" "$tmp_goroot" export GOROOT="$tmp_goroot" gopherjs install -m \ archive/tar \ @@ -139,8 +139,8 @@ gopherjs install -m \ unicode/utf16 \ unicode/utf8 -cp -a $GOROOT/pkg/*_js_min/* $PKG -cp -a $GOROOT/pkg/*_amd64_js_min/* $PKG +cp -a "$GOROOT"/pkg/*_js_min/* $PKG +cp -a "$GOROOT"/pkg/*_amd64_js_min/* $PKG # Rename all *.a files in $PKG to *.a.js. find "$PKG" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; From 78f89bcbe0b2cad824cd46b1fc6fae0f79f98ae7 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Mon, 22 Feb 2016 02:43:40 +0100 Subject: [PATCH 08/10] update.sh: fix mktemp on BSD/OS X, only use one directory --- playground/update.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index af83aea3..3309fd0a 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -1,12 +1,10 @@ #!/bin/sh set -e -tmp_gopath=$(mktemp -d --suffix _play_gopath) -tmp_goroot=$(mktemp -d --suffix _play_goroot) +tmp=$(mktemp -d "${TMPDIR:-/tmp}/gopherjs_playground.XXXXXXXXXX") cleanup() { - rm -rf "$tmp_gopath" - rm -rf "$tmp_goroot" + rm -rf "$tmp" exit } @@ -27,7 +25,7 @@ rm -r "$PKG" # Use an empty GOPATH workspace with just gopherjs, # so that all the standard library packages get written to GOROOT/pkg. -export GOPATH="$tmp_gopath" +export GOPATH="$tmp/gopath" mkdir -p "$GOPATH"/src/github.com/gopherjs/gopherjs cp -a "$GOPHERJSGOPATH"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs @@ -38,8 +36,8 @@ cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a "$PKG"/github.co # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. -cp -a "$(go env GOROOT)" "$tmp_goroot" -export GOROOT="$tmp_goroot" +cp -a "$(go env GOROOT)" "$tmp/goroot" +export GOROOT="$tmp/goroot" gopherjs install -m \ archive/tar \ archive/zip \ From 825a4b39146172dd962e6d7976fdec570fd5f0ee Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Mon, 22 Feb 2016 03:02:13 +0100 Subject: [PATCH 09/10] update.sh: consistent variable naming --- playground/update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index 3309fd0a..bdbba4cf 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -18,21 +18,21 @@ go generate github.com/gopherjs/gopherjs.github.io/playground/internal/imports gopherjs build -m # The GOPATH workspace where the GopherJS project is. -GOPHERJSGOPATH=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs) +gopherjsgopath=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs) -PKG=pkg -rm -r "$PKG" +pkg=pkg +rm -r "$pkg" # Use an empty GOPATH workspace with just gopherjs, # so that all the standard library packages get written to GOROOT/pkg. export GOPATH="$tmp/gopath" mkdir -p "$GOPATH"/src/github.com/gopherjs/gopherjs -cp -a "$GOPHERJSGOPATH"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs +cp -a "$gopherjsgopath"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync -mkdir -p "$PKG"/github.com/gopherjs/gopherjs -cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a "$PKG"/github.com/gopherjs/gopherjs/js.a -cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a "$PKG"/github.com/gopherjs/gopherjs/nosync.a +mkdir -p "$pkg"/github.com/gopherjs/gopherjs +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a "$pkg"/github.com/gopherjs/gopherjs/js.a +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a "$pkg"/github.com/gopherjs/gopherjs/nosync.a # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. @@ -137,8 +137,8 @@ gopherjs install -m \ unicode/utf16 \ unicode/utf8 -cp -a "$GOROOT"/pkg/*_js_min/* $PKG -cp -a "$GOROOT"/pkg/*_amd64_js_min/* $PKG +cp -a "$GOROOT"/pkg/*_js_min/* $pkg +cp -a "$GOROOT"/pkg/*_amd64_js_min/* $pkg -# Rename all *.a files in $PKG to *.a.js. -find "$PKG" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; +# Rename all *.a files in $pkg to *.a.js. +find "$pkg" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; From 97f92c7429676d0e5f8a50a814fd0bece8d244c4 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Mon, 22 Feb 2016 03:27:50 +0100 Subject: [PATCH 10/10] update.sh: eliminate $pkg variable --- playground/update.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/playground/update.sh b/playground/update.sh index bdbba4cf..5d62c702 100755 --- a/playground/update.sh +++ b/playground/update.sh @@ -20,8 +20,7 @@ gopherjs build -m # The GOPATH workspace where the GopherJS project is. gopherjsgopath=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs) -pkg=pkg -rm -r "$pkg" +rm -r pkg/ # Use an empty GOPATH workspace with just gopherjs, # so that all the standard library packages get written to GOROOT/pkg. @@ -30,9 +29,9 @@ mkdir -p "$GOPATH"/src/github.com/gopherjs/gopherjs cp -a "$gopherjsgopath"/src/github.com/gopherjs/gopherjs/* "$GOPATH"/src/github.com/gopherjs/gopherjs gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync -mkdir -p "$pkg"/github.com/gopherjs/gopherjs -cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a "$pkg"/github.com/gopherjs/gopherjs/js.a -cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a "$pkg"/github.com/gopherjs/gopherjs/nosync.a +mkdir -p pkg/github.com/gopherjs/gopherjs +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/js.a pkg/github.com/gopherjs/gopherjs/js.a +cp "$GOPATH"/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a pkg/github.com/gopherjs/gopherjs/nosync.a # Make a copy of GOROOT that is user-writeable, # use it to build and copy out standard library packages. @@ -137,8 +136,8 @@ gopherjs install -m \ unicode/utf16 \ unicode/utf8 -cp -a "$GOROOT"/pkg/*_js_min/* $pkg -cp -a "$GOROOT"/pkg/*_amd64_js_min/* $pkg +cp -a "$GOROOT"/pkg/*_js_min/* pkg/ +cp -a "$GOROOT"/pkg/*_amd64_js_min/* pkg/ -# Rename all *.a files in $pkg to *.a.js. -find "$pkg" -name "*.a" -exec sh -c 'mv $0 $0.js' {} \; +# Rename all *.a files in pkg/ to *.a.js. +find pkg -name "*.a" -exec sh -c 'mv $0 $0.js' {} \;