Skip to content

Commit a2995ec

Browse files
heschigopherbot
authored andcommitted
internal/relui: fix tar commands to work on Mac
Mac tar doesn't support --mtime. Use touch everywhere. Also, when it creates a tgz, it puts a timestamp in the header. Do the gzipping oureslves to avoid that. Also remove some stray -x's that were cluttering the test output. Change-Id: Ifccd887b94018bb22850ebd85a354e07d850fbbd Reviewed-on: https://go-review.googlesource.com/c/build/+/491017 Reviewed-by: Carlos Amedee <[email protected]> Auto-Submit: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Heschi Kreinick <[email protected]>
1 parent 5235360 commit a2995ec

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

internal/relui/buildrelease_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func newReleaseTestDeps(t *testing.T, previousTag, wantVersion string) *releaseT
113113
bootstrapServer := httptest.NewServer(http.HandlerFunc(serveBootstrap))
114114
t.Cleanup(bootstrapServer.Close)
115115
fakeBuildlets := task.NewFakeBuildlets(t, bootstrapServer.URL, map[string]string{
116-
"pkgbuild": `#!/bin/bash -eux
116+
"pkgbuild": `#!/bin/bash -eu
117117
case "$@" in
118118
"--identifier=org.golang.go --version ` + wantVersion + ` --scripts=pkg-scripts --root=pkg-root pkg-intermediate/org.golang.go.pkg")
119119
# We're doing an intermediate step in building a PKG.
@@ -126,7 +126,7 @@ case "$@" in
126126
;;
127127
esac
128128
`,
129-
"productbuild": `#!/bin/bash -eux
129+
"productbuild": `#!/bin/bash -eu
130130
case "$@" in
131131
"--distribution=pkg-distribution --resources=pkg-resources --package-path=pkg-intermediate pkg-out/` + wantVersion + `.pkg")
132132
# We're building a PKG.
@@ -140,7 +140,7 @@ case "$@" in
140140
;;
141141
esac
142142
`,
143-
"pkgutil": `#!/bin/bash -eux
143+
"pkgutil": `#!/bin/bash -eu
144144
case "$@" in
145145
"--expand-full go.pkg pkg-expanded")
146146
# We're expanding a PKG.
@@ -485,9 +485,11 @@ VERSION=$(head -n 1 $GO/VERSION)
485485
486486
if [[ $# >0 && $1 == "-distpack" ]]; then
487487
mkdir -p $GO/pkg/distpack
488-
tmp=$(mktemp).tar.gz
489-
tar czf $tmp --mtime 2023-01-01 -C $GO/.. go
490-
mv $tmp $GO/pkg/distpack/$VERSION.src.tar.gz
488+
tmp=$(mktemp).tar
489+
(cd $GO/.. && find . | xargs touch -t 202301010000 && tar cf $tmp go)
490+
# On macOS, tar -czf puts a timestamp in the gzip header. Do it ourselves with --no-name to suppress it.
491+
gzip --no-name $tmp
492+
mv $tmp.gz $GO/pkg/distpack/$VERSION.src.tar.gz
491493
fi
492494
493495
mkdir -p $GO/bin
@@ -525,13 +527,15 @@ if [[ $# >0 && $1 == "-distpack" ]]; then
525527
"windows")
526528
tmp=$(mktemp).zip
527529
# The zip command isn't installed on our buildlets. Python is.
528-
(cd $GO/.. && find . | xargs touch -d 2023-01-01 && python3 -m zipfile -c $tmp go/)
530+
(cd $GO/.. && find . | xargs touch -t 202301010000 && python3 -m zipfile -c $tmp go/)
529531
mv $tmp $GO/pkg/distpack/$VERSION-$GOOS-$GOARCH.zip
530532
;;
531533
*)
532-
tmp=$(mktemp).tar.gz
533-
tar czf $tmp --mtime 2023-01-01 -C $GO/.. go
534-
mv $tmp $GO/pkg/distpack/$VERSION-$GOOS-$GOARCH.tar.gz
534+
tmp=$(mktemp).tar
535+
(cd $GO/.. && find . | xargs touch -t 202301010000 && tar cf $tmp go)
536+
# On macOS, tar -czf puts a timestamp in the gzip header. Do it ourselves with --no-name to suppress it.
537+
gzip --no-name $tmp
538+
mv $tmp.gz $GO/pkg/distpack/$VERSION-$GOOS-$GOARCH.tar.gz
535539
;;
536540
esac
537541
@@ -543,7 +547,7 @@ if [[ $# >0 && $1 == "-distpack" ]]; then
543547
mkdir -p $MODDIR
544548
cp -r $GO $MODDIR
545549
tmp=$(mktemp).zip
546-
(cd $MODTMP && find . | xargs touch -d 2023-01-01 && python3 -m zipfile -c $tmp .)
550+
(cd $MODTMP && find . | xargs touch -t 202301010000 && python3 -m zipfile -c $tmp .)
547551
mv $tmp $GO/pkg/distpack/$MODVER.zip
548552
fi
549553
`

0 commit comments

Comments
 (0)