Philipp Schrader | 8ac22f3 | 2023-12-30 17:37:15 -0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o errexit |
| 4 | set -o nounset |
| 5 | set -o pipefail |
| 6 | |
| 7 | # --- begin runfiles.bash initialization v2 --- |
| 8 | # Copy-pasted from the Bazel Bash runfiles library v2. |
| 9 | set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 10 | source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 11 | source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 12 | source "$0.runfiles/$f" 2>/dev/null || \ |
| 13 | source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 14 | source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 15 | { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 16 | # --- end runfiles.bash initialization v2 --- |
| 17 | |
| 18 | DOCKERFILE="$(rlocation org_frc971/tools/python/update_helper_files/Dockerfile)" |
| 19 | CONTEXT_DIR="$(dirname "${DOCKERFILE}")" |
| 20 | CONTAINER_TAG="pip-lock:${USER}" |
| 21 | |
| 22 | # Build the container that has the bare minimum to run the various setup.py |
| 23 | # scripts from our dependencies. |
| 24 | docker build \ |
| 25 | --file="${DOCKERFILE}" \ |
| 26 | --tag="${CONTAINER_TAG}" \ |
| 27 | "${CONTEXT_DIR}" |
| 28 | |
| 29 | # Run the actual update. The assumption here is that mounting the user's home |
| 30 | # directory is sufficient to allow the tool to run inside the container without |
| 31 | # any issues. I.e. the cache and the source tree are available in the |
| 32 | # container. |
| 33 | docker run \ |
| 34 | --rm \ |
| 35 | --tty \ |
| 36 | --env BUILD_WORKSPACE_DIRECTORY="${BUILD_WORKSPACE_DIRECTORY}" \ |
| 37 | --workdir "${PWD}" \ |
| 38 | --volume "${HOME}:${HOME}" \ |
| 39 | "${CONTAINER_TAG}" \ |
| 40 | "$@" |