From 4ee7d7aec94d00b2c9f1aca5707b877710b7ac6e Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 31 Aug 2023 13:55:45 +0200 Subject: [PATCH] deploy: Verify that `jazzer.jar` is a valid Jazzer jar Release v0.20.0 failed because the zip containing the Jazzer jar was passed in instead of the Jazzer jar itself. --- deploy/BUILD.bazel | 4 ++++ deploy/deploy.sh | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deploy/BUILD.bazel b/deploy/BUILD.bazel index d5e572a61..a598fd7eb 100644 --- a/deploy/BUILD.bazel +++ b/deploy/BUILD.bazel @@ -20,6 +20,10 @@ sh_binary( name = "deploy", srcs = ["deploy.sh"], args = [JAZZER_COORDINATES], + data = ["@bazel_tools//tools/jdk:current_host_java_runtime"], + env = {"JAVA_EXECPATH": "$(JAVA)"}, + toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"], + deps = ["@bazel_tools//tools/bash/runfiles"], ) java_export( diff --git a/deploy/deploy.sh b/deploy/deploy.sh index edf8b4071..ffd45455f 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # Copyright 2022 Code Intelligence GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,6 +33,24 @@ JAZZER_COORDINATES=$1 [ ! -f "${JAZZER_JAR_PATH}" ] && \ fail "JAZZER_JAR_PATH does not exist at '$JAZZER_JAR_PATH'" +# --- begin runfiles.bash initialization v3 --- +# Copy-pasted from the Bazel Bash runfiles library v3. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v3 --- + +# JAZZER_EXECPATH is a path of the form "external/remotejdk_17/bin/java". We need to strip of the +# leading external to get a path we can pass to rlocation. +java_rlocationpath=$(echo "$JAVA_EXECPATH" | cut -d/ -f2-) +java=$(rlocation "$java_rlocationpath") +"$java" -jar "${JAZZER_JAR_PATH}" --version 2>&1 | grep '^Jazzer v' || \ + fail "JAZZER_JAR_PATH is not a valid jazzer.jar" + MAVEN_REPO=https://oss.sonatype.org/service/local/staging/deploy/maven2 # The Jazzer jar itself bundles native libraries for multiple architectures and thus can't be built