Skip to content

Commit 57a5c6b

Browse files
committed
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
1 parent 31bb276 commit 57a5c6b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

playground/update.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/sh
22
set -e
33

4+
tmp_gopath=$(mktemp -d --suffix _play_gopath)
5+
tmp_goroot=$(mktemp -d --suffix _play_goroot)
6+
47
cleanup() {
5-
rm -rf /tmp/gopherjsplayground_gopath
6-
rm -rf /tmp/gopherjsplayground_goroot
8+
rm -rf "$tmp_gopath"
9+
rm -rf "$tmp_goroot"
710
exit
811
}
912

@@ -24,7 +27,7 @@ rm -r $PKG
2427

2528
# Use an empty GOPATH workspace with just gopherjs,
2629
# so that all the standard library packages get written to GOROOT/pkg.
27-
export GOPATH=/tmp/gopherjsplayground_gopath
30+
export GOPATH="$tmp_gopath"
2831
mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs
2932
cp -r $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs
3033

@@ -35,8 +38,8 @@ cp $GOPATH/pkg/*_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/go
3538

3639
# Make a copy of GOROOT that is user-writeable,
3740
# use it to build and copy out standard library packages.
38-
cp -r $(go env GOROOT) /tmp/gopherjsplayground_goroot
39-
export GOROOT=/tmp/gopherjsplayground_goroot
41+
cp -r $(go env GOROOT)/. "$tmp_goroot"
42+
export GOROOT="$tmp_goroot"
4043
gopherjs install -m \
4144
archive/tar \
4245
archive/zip \

0 commit comments

Comments
 (0)