mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Ripunzip: provide installer
This commit is contained in:
@@ -7,3 +7,10 @@ buildifier(
|
||||
],
|
||||
lint_mode = "fix",
|
||||
)
|
||||
|
||||
sh_library(
|
||||
name = "sh_runfiles",
|
||||
srcs = ["runfiles.sh"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@bazel_tools//tools/bash/runfiles"],
|
||||
)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
|
||||
|
||||
native_binary(
|
||||
name = "ripunzip",
|
||||
src = select({"@platforms//os:" + os: "@ripunzip-" + os for os in ("linux", "windows", "macos")}),
|
||||
out = "ripunzip.exe",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -1,2 +0,0 @@
|
||||
These LFS files are distributions of [ripunzip](https://github.com/google/ripunzip), compiled with this [workflow](https://github.com/github/codeql/actions/workflows/build-ripunzip.yml).
|
||||
A [copy](./LICENSE.txt) of the ripunzip license is included.
|
||||
@@ -364,7 +364,7 @@ def codeql_pack(
|
||||
internal("script"),
|
||||
] + ([
|
||||
internal("zip-manifest"),
|
||||
Label("//misc/bazel/internal/ripunzip"),
|
||||
Label("//misc/ripunzip"),
|
||||
] if zips else []),
|
||||
deps = ["@rules_python//python/runfiles"],
|
||||
args = [
|
||||
@@ -373,7 +373,7 @@ def codeql_pack(
|
||||
"--destdir",
|
||||
install_dest,
|
||||
] + ([
|
||||
"--ripunzip=$(rlocationpath %s)" % Label("//misc/bazel/internal/ripunzip"),
|
||||
"--ripunzip=$(rlocationpath %s)" % Label("//misc/ripunzip"),
|
||||
"--zip-manifest=$(rlocationpath %s)" % internal("zip-manifest"),
|
||||
] if zips else []),
|
||||
visibility = visibility,
|
||||
|
||||
10
misc/bazel/runfiles.sh
Normal file
10
misc/bazel/runfiles.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
# --- 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 ---
|
||||
13
misc/ripunzip/BUILD.bazel
Normal file
13
misc/ripunzip/BUILD.bazel
Normal file
@@ -0,0 +1,13 @@
|
||||
alias(
|
||||
name = "ripunzip",
|
||||
actual = select({"@platforms//os:" + os: "@ripunzip-" + os for os in ("linux", "windows", "macos")}),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
sh_binary(
|
||||
name = "install",
|
||||
srcs = ["install.sh"],
|
||||
args = ["$(rlocationpath :ripunzip)"],
|
||||
data = [":ripunzip"],
|
||||
deps = ["//misc/bazel:sh_runfiles"],
|
||||
)
|
||||
11
misc/ripunzip/README.md
Normal file
11
misc/ripunzip/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
These LFS files are distributions of [ripunzip](https://github.com/google/ripunzip), compiled with this [workflow](https://github.com/github/codeql/actions/workflows/build-ripunzip.yml).
|
||||
A [copy](./LICENSE.txt) of the ripunzip license is included.
|
||||
|
||||
`ripunzip` can easily be made available on the system by running
|
||||
```bash
|
||||
bazel run //misc/ripunzip:install
|
||||
```
|
||||
By default, it will be installed in `~/.local/bin`. The target can be changed with
|
||||
```bash
|
||||
bazel run //misc/ripunzip:install -- /path/to/installation/dir
|
||||
```
|
||||
24
misc/ripunzip/install.sh
Executable file
24
misc/ripunzip/install.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
. misc/bazel/runfiles.sh
|
||||
|
||||
dest="${2:-$HOME/.local/bin}"
|
||||
|
||||
if [ ! -d "$dest" ]; then
|
||||
echo "$dest: not a directory. Provide a valid installation target." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source="$(rlocation "$1")"
|
||||
|
||||
dest+="/ripunzip"
|
||||
|
||||
if [[ "$source" = *.exe ]]; then
|
||||
dest+=".exe"
|
||||
fi
|
||||
|
||||
cp "$source" "$dest"
|
||||
|
||||
echo "installed $("$dest" --version) in $(dirname "$dest")"
|
||||
Reference in New Issue
Block a user