From d19665e64d78f19f21eca841ce260b7df777cf95 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 3 Aug 2020 18:35:57 +0000 Subject: [PATCH 1/2] build: avoid errors when tar closes curl's pipe Release note: none. --- build/release/teamcity-make-and-publish-build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/release/teamcity-make-and-publish-build.sh b/build/release/teamcity-make-and-publish-build.sh index 8638a487a879..3d48ec25b345 100755 --- a/build/release/teamcity-make-and-publish-build.sh +++ b/build/release/teamcity-make-and-publish-build.sh @@ -45,7 +45,8 @@ docker_login_with_google gcr_repository="us.gcr.io/cockroach-cloud-images/cockroach" # TODO: update publish-provisional-artifacts with option to leave one or more cockroach binaries in the local filesystem -curl -f -s -S -o- "https://${bucket}.s3.amazonaws.com/cockroach-${build_name}.linux-amd64.tgz" | tar xfz - --strip-components 1 +# HACK: we pipe though tac twice to reverse/un-reverse since that will read the whole buffer and make curl happy, even if tar closes early. +curl -f -s -S -o- "https://${bucket}.s3.amazonaws.com/cockroach-${build_name}.linux-amd64.tgz" | tac | tac | tar xfz - --strip-components 1 cp cockroach build/deploy/cockroach docker build --no-cache --tag="${gcr_repository}:${build_name}" build/deploy From 14d8a7345fed2dddacfda926751b19808bd59d8f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 3 Aug 2020 23:52:14 +0000 Subject: [PATCH 2/2] build: ask tar to read to end tar typically stops reading as soon as it hits a zero block. This can mean it closes its input before EOF, but that can make the process sending that input, like curl, unhappy. Instead, the -i option to tar instructs it to read to end of file. Release note: none --- build/release/teamcity-make-and-publish-build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/release/teamcity-make-and-publish-build.sh b/build/release/teamcity-make-and-publish-build.sh index 3d48ec25b345..20b41ef01477 100755 --- a/build/release/teamcity-make-and-publish-build.sh +++ b/build/release/teamcity-make-and-publish-build.sh @@ -45,8 +45,9 @@ docker_login_with_google gcr_repository="us.gcr.io/cockroach-cloud-images/cockroach" # TODO: update publish-provisional-artifacts with option to leave one or more cockroach binaries in the local filesystem -# HACK: we pipe though tac twice to reverse/un-reverse since that will read the whole buffer and make curl happy, even if tar closes early. -curl -f -s -S -o- "https://${bucket}.s3.amazonaws.com/cockroach-${build_name}.linux-amd64.tgz" | tac | tac | tar xfz - --strip-components 1 +# NB: tar usually stops reading as soon as it sees an empty block but that makes +# curl unhappy, so passing `i` will cause it to read to the end. +curl -f -s -S -o- "https://${bucket}.s3.amazonaws.com/cockroach-${build_name}.linux-amd64.tgz" | tar ixfz - --strip-components 1 cp cockroach build/deploy/cockroach docker build --no-cache --tag="${gcr_repository}:${build_name}" build/deploy