Skip to content

Commit bddb191

Browse files
meteorcloudycopybara-github
authored andcommitted
Fix race condition in package-bazel.sh
`bazel build -c //src:bazel.exe //src:bazel_nojdk.exe` sometimes output corrupted binaries on Windows. The reason is when we are executing the genrule for packaging the bazel zip files, we are writing a "file.list" file into the execroot, however there is no sandbox on Windows. So two actions are actually sharing the same path for the "file.list", this PR fixes the issue by writing the "file.list" file under the tmp dir. Fixes bazelbuild#16613 Closes bazelbuild#16614. PiperOrigin-RevId: 485578533 Change-Id: I74b69e58919a463d5cc40abaa6ae4ca36251cdac
1 parent 9296068 commit bddb191

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/package-bazel.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ ROOT="$(mktemp -d ${TMP_DIR%%/}/bazel.XXXXXXXX)"
3737
RECOMP="$ROOT/recomp"
3838
PACKAGE_DIR="$ROOT/pkg"
3939
DEPLOY_UNCOMP="$ROOT/deploy-uncompressed.jar"
40+
FILE_LIST="$ROOT/file.list"
4041
mkdir -p "${PACKAGE_DIR}"
4142
trap "rm -fr ${ROOT}" EXIT
4243

@@ -101,14 +102,14 @@ fi
101102
find . -type f | sort
102103
# And install_base_key must be last.
103104
echo install_base_key
104-
) > files.list
105+
) > $FILE_LIST
105106

106107
# Move these after the 'find' above.
107108
cp $DEPLOY_JAR $PACKAGE_DIR/A-server.jar
108109
cp $INSTALL_BASE_KEY $PACKAGE_DIR/install_base_key
109110

110111
# Zero timestamps.
111-
(cd $PACKAGE_DIR; xargs touch -t 198001010000.00) < files.list
112+
(cd $PACKAGE_DIR; xargs touch -t 198001010000.00) < $FILE_LIST
112113

113114
if [[ "$DEV_BUILD" -eq 1 ]]; then
114115
# Create output zip with lowest compression, but fast.
@@ -117,6 +118,6 @@ else
117118
# Create output zip with highest compression, but slow.
118119
ZIP_ARGS="-q9DX@"
119120
fi
120-
(cd $PACKAGE_DIR; zip $ZIP_ARGS $WORKDIR/$OUT) < files.list
121+
(cd $PACKAGE_DIR; zip $ZIP_ARGS $WORKDIR/$OUT) < $FILE_LIST
121122

122123

0 commit comments

Comments
 (0)