Fix find: ./local-spawn-runner not found issue (#5793)

CWD will be set to the same execroot for all targets on Windows. While
this will contain the things we are searching for it contains a whole
bunch of other stuff and in particular it can also change during the
execution of `find`. This resulted in errors with temporary files such
as the local-spawn-runner-* stuff that appear and disappear while
find is running.

This PR switches it to a tmp dir which works around this issue and
makes more sense anyway since we clearly don’t want to search in the
whole execroot.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-04-30 15:09:04 +02:00 committed by GitHub
parent 32fbf040aa
commit 8c25bc4de5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,10 +159,16 @@ def _extract_main_dalf_impl(ctx):
outputs = [output_dalf],
progress_message = "Extract DALF from DAR (%s)" % project_name,
command = """
set -eou pipefail
{zipper} x {input_dar}
main_dalf=$({find} . -name '{project_name}-{project_version}-[a-z0-9]*.dalf')
cp $main_dalf {output_dalf}
set -eoux pipefail
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
# While zipper has a -d option, it insists on it
# being a relative path so we don't use it.
ZIPPER=$PWD/{zipper}
DAR=$PWD/{input_dar}
(cd $TMPDIR && $ZIPPER x $DAR)
main_dalf=$({find} $TMPDIR/ -name '{project_name}-{project_version}-[a-z0-9]*.dalf')
cp $main_dalf {output_dalf}
""".format(
zipper = zipper.path,
find = posix.commands["find"],