From 248c602faf570d8c711bb76b493c9dbc69849f4b Mon Sep 17 00:00:00 2001 From: Douglas Reis Date: Wed, 1 Jul 2026 16:26:08 +0000 Subject: [PATCH 1/6] [bazel-airgapped] Update shebang Signed-off-by: Douglas Reis #!/usr/bin/env bash is more portable --- util/prep-bazel-airgapped-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index f453529a9273a..ca6ea4af9c967 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright lowRISC contributors (OpenTitan project). # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 From 936c51d8321f19b0da56e4d2c0ccaf04899db73b Mon Sep 17 00:00:00 2001 From: Douglas Reis Date: Wed, 1 Jul 2026 16:27:15 +0000 Subject: [PATCH 2/6] [bazel-airgapped] Use downloaded bazel to fetch it's dependencies Signed-off-by: Douglas Reis --- util/prep-bazel-airgapped-build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index ca6ea4af9c967..d00b82d64dd9e 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -109,12 +109,13 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ ${AIRGAPPED_DIR_CONTENTS} == "DISTDIR" ]]; then echo $LINE_SEP echo "Preparing bazel offline distdir ..." - mkdir -p ${BAZEL_AIRGAPPED_DIR}/${BAZEL_DISTDIR} - cd ${BAZEL_AIRGAPPED_DIR} + mkdir -p ${BAZEL_DISTDIR} + pushd ${BAZEL_AIRGAPPED_DIR} curl --silent --location \ https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-linux-x86_64 \ --output bazel chmod +x bazel + popd # Make Bazel fetch its own dependencies to the repository cache: # https://bazel.build/run/build#repository_cache_with_bazel_7_or_later @@ -122,7 +123,7 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ pushd "${BAZEL_AIRGAPPED_DIR}/empty_workspace" touch MODULE.bazel cp "${REPO_TOP}/.bazelversion" . - "$BAZELISK" fetch --repository_cache="${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR}" + ../bazel fetch --repository_cache="${BAZEL_CACHEDIR}" popd rm -rf "${BAZEL_AIRGAPPED_DIR}/empty_workspace" fi From 480638bd144bfcbf3da5ff856a4cb35cba7544a4 Mon Sep 17 00:00:00 2001 From: Douglas Reis Date: Wed, 1 Jul 2026 16:28:13 +0000 Subject: [PATCH 3/6] [bazel-airgapped] Use absolut paths Signed-off-by: Douglas Reis --- util/prep-bazel-airgapped-build.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/util/prep-bazel-airgapped-build.sh b/util/prep-bazel-airgapped-build.sh index d00b82d64dd9e..c6d549adfb9d6 100755 --- a/util/prep-bazel-airgapped-build.sh +++ b/util/prep-bazel-airgapped-build.sh @@ -10,11 +10,11 @@ set -euo pipefail : "${BAZELISK:=${REPO_TOP}/bazelisk.sh}" : "${BAZEL_VERSION:=$(cat "${REPO_TOP}/.bazelversion")}" -: "${BAZEL_AIRGAPPED_DIR:=bazel-airgapped}" -: "${BAZEL_DISTDIR:=bazel-distdir}" -: "${BAZEL_CACHEDIR:=bazel-cache}" -: "${BAZEL_VENDORDIR:=bazel-vendor}" -: "${BAZEL_BITSTREAMS_CACHE:=bitstreams-cache}" +: "${BAZEL_AIRGAPPED_DIR:=${REPO_TOP}/bazel-airgapped}" +: "${BAZEL_DISTDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-distdir}" +: "${BAZEL_CACHEDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-cache}" +: "${BAZEL_VENDORDIR:=${BAZEL_AIRGAPPED_DIR}/bazel-vendor}" +: "${BAZEL_BITSTREAMS_CACHE:=${BAZEL_AIRGAPPED_DIR}/bitstreams-cache}" : "${BAZEL_BITSTREAMS_CACHEDIR:=${BAZEL_BITSTREAMS_CACHE}/cache}" : "${BAZEL_BITSTREAMS_REPO:=bitstreams}" @@ -136,13 +136,13 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ echo $LINE_SEP echo "Preparing bazel offline cachedir ..." cd ${REPO_TOP} - mkdir -p ${BAZEL_AIRGAPPED_DIR}/${BAZEL_CACHEDIR} + mkdir -p ${BAZEL_CACHEDIR} # Make bazel forget everything it knows, then download everything. ${BAZELISK} clean --expunge - ${BAZELISK} vendor --vendor_dir="${BAZEL_AIRGAPPED_DIR}/${BAZEL_VENDORDIR}" //... + ${BAZELISK} vendor --vendor_dir="${BAZEL_VENDORDIR}" //... # We don't need all bitstreams in the cache, we just need the latest one so # that the cache is "initialized" and "offline" mode will work correctly. - mkdir -p ${BAZEL_AIRGAPPED_DIR}/${BAZEL_BITSTREAMS_CACHEDIR} + mkdir -p ${BAZEL_BITSTREAMS_CACHEDIR} readonly SYSTEM_BITSTREAM_CACHE="${HOME}/.cache/opentitan-bitstreams" readonly SYSTEM_BITSTREAM_CACHEDIR="${SYSTEM_BITSTREAM_CACHE}/cache" readonly LATEST_BISTREAM_HASH_FILE="${SYSTEM_BITSTREAM_CACHE}/latest.txt" @@ -150,10 +150,10 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" || \ # cache backend to fetch the latest bitstreams. BITSTREAM="latest" ${BAZELISK} fetch @bitstreams//... cp "${LATEST_BISTREAM_HASH_FILE}" \ - "${BAZEL_AIRGAPPED_DIR}/${BAZEL_BITSTREAMS_CACHE}/" + "${BAZEL_BITSTREAMS_CACHE}/" LATEST_BISTREAM_HASH=$(cat "${LATEST_BISTREAM_HASH_FILE}") cp -r "${SYSTEM_BITSTREAM_CACHEDIR}/${LATEST_BISTREAM_HASH}" \ - "${BAZEL_AIRGAPPED_DIR}/${BAZEL_BITSTREAMS_CACHEDIR}" + "${BAZEL_BITSTREAMS_CACHEDIR}" echo "Done." fi @@ -164,5 +164,5 @@ if [[ ${AIRGAPPED_DIR_CONTENTS} == "ALL" ]]; then echo $LINE_SEP echo "To perform an airgapped build, ship the contents of ${BAZEL_AIRGAPPED_DIR} to your airgapped environment and then:" echo "" - echo "bazel build --distdir=${BAZEL_AIRGAPPED_DIR}/${BAZEL_DISTDIR} --vendor_dir=${BAZEL_AIRGAPPED_DIR}/${BAZEL_VENDORDIR}