Make sure the staging dir in OSS-Fuzz packaging rule is cleaned up, to permit non-sandboxed runs. (#134)
diff --git a/fuzzing/private/oss_fuzz/package.bzl b/fuzzing/private/oss_fuzz/package.bzl
index f514b69..75b2e09 100644
--- a/fuzzing/private/oss_fuzz/package.bzl
+++ b/fuzzing/private/oss_fuzz/package.bzl
@@ -29,8 +29,11 @@
outputs = [output_archive],
inputs = action_inputs,
command = """
- declare -r STAGING_DIR="$(pwd)/{output}.staging"
- mkdir "$STAGING_DIR"
+ declare -r STAGING_DIR="$(mktemp --directory -t oss-fuzz-pkg.XXXXXXXXXX)"
+ function cleanup() {{
+ rm -rf "$STAGING_DIR"
+ }}
+ trap cleanup EXIT
ln -s "$(pwd)/{binary_path}" "$STAGING_DIR/{base_name}"
if [[ -n "{corpus_dir}" ]]; then
pushd "{corpus_dir}" >/dev/null