From d84e745ce9bc457ac7ed4afaa1403afbd277bcd4 Mon Sep 17 00:00:00 2001 From: Cornelius Riemenschneider Date: Fri, 23 Aug 2024 14:24:51 +0200 Subject: [PATCH] Make ripunzip installer accessible from outside this repo. * The relative path to misc doesn't work when running from another repo * The buildifier dependency is not available from other repos, therefore we can't pull in //misc/bazel without further refactoring. Therefore, inline the runfiles snippet here. --- misc/ripunzip/BUILD.bazel | 2 +- misc/ripunzip/install.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/misc/ripunzip/BUILD.bazel b/misc/ripunzip/BUILD.bazel index ea21e6b1c948..83317a74e011 100644 --- a/misc/ripunzip/BUILD.bazel +++ b/misc/ripunzip/BUILD.bazel @@ -9,5 +9,5 @@ sh_binary( srcs = ["install.sh"], args = ["$(rlocationpath :ripunzip)"], data = [":ripunzip"], - deps = ["//misc/bazel:sh_runfiles"], + deps = ["@bazel_tools//tools/bash/runfiles"], ) diff --git a/misc/ripunzip/install.sh b/misc/ripunzip/install.sh index 2fb4d48ed6c0..45b69f84f785 100755 --- a/misc/ripunzip/install.sh +++ b/misc/ripunzip/install.sh @@ -2,7 +2,16 @@ set -eu -. misc/bazel/runfiles.sh +# --- 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 --- dest="${2:-$HOME/.local/bin}"