mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-19 04:24:39 -04:00
bazel: download pseudo-version tool instead of "go build" (#1629)
Required for bootstrapping bazel stamping since we cannot use "bazel build" during the workspace_status command. Adds a small script that builds the pseudo-version tool in bazel (without stamping) and uploads it to the mirror. On the first bazel build with stamping, the pseudo-version tool is downloaded.
This commit is contained in:
parent
1ae39703d1
commit
eb11e9ac8a
9 changed files with 153 additions and 2 deletions
|
@ -1,4 +1,12 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library")
|
||||
load("//bazel/sh:def.bzl", "sh_template")
|
||||
|
||||
platforms = [
|
||||
"darwin_amd64",
|
||||
"darwin_arm64",
|
||||
"linux_amd64",
|
||||
"linux_arm64",
|
||||
]
|
||||
|
||||
go_library(
|
||||
name = "pseudo-version_lib",
|
||||
|
@ -21,3 +29,27 @@ go_binary(
|
|||
pure = "on",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
[
|
||||
go_cross_binary(
|
||||
name = "pseudo_version_%s" % platform,
|
||||
platform = "@io_bazel_rules_go//go/toolchain:" + platform,
|
||||
target = ":pseudo-version",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
for platform in platforms
|
||||
]
|
||||
|
||||
sh_template(
|
||||
name = "pseudo_version_tool_freshness",
|
||||
data = [
|
||||
":pseudo_version_" + platform
|
||||
for platform in platforms
|
||||
],
|
||||
substitutions = {
|
||||
"@@PSEUDO_VERSION_%s@@" % platform: "$(rootpath :pseudo_version_%s)" % platform
|
||||
for platform in platforms
|
||||
},
|
||||
template = "pseudo_version_tool_freshness.sh.in",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
43
hack/pseudo-version/pseudo_version_tool_freshness.sh.in
Normal file
43
hack/pseudo-version/pseudo_version_tool_freshness.sh.in
Normal file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script checks if the pseudo-version tool hashes are up-to-date.
|
||||
|
||||
###### script header ######
|
||||
|
||||
lib=$(realpath @@BASE_LIB@@) || exit 1
|
||||
stat "${lib}" >> /dev/null || exit 1
|
||||
|
||||
# shellcheck source=../../bazel/sh/lib.bash
|
||||
if ! source "${lib}"; then
|
||||
echo "Error: could not find import"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -A pseudo_version_tools
|
||||
pseudo_version_tools["darwin_amd64"]="$(realpath @@PSEUDO_VERSION_darwin_amd64@@)"
|
||||
pseudo_version_tools["darwin_arm64"]="$(realpath @@PSEUDO_VERSION_darwin_arm64@@)"
|
||||
pseudo_version_tools["linux_amd64"]="$(realpath @@PSEUDO_VERSION_linux_amd64@@)"
|
||||
pseudo_version_tools["linux_arm64"]="$(realpath @@PSEUDO_VERSION_linux_arm64@@)"
|
||||
|
||||
cd "${BUILD_WORKING_DIRECTORY}"
|
||||
|
||||
###### script body ######
|
||||
|
||||
platforms=(
|
||||
darwin_amd64
|
||||
darwin_arm64
|
||||
linux_amd64
|
||||
linux_arm64
|
||||
)
|
||||
|
||||
for platform in "${platforms[@]}"; do
|
||||
computed_hash=$(sha256sum "${pseudo_version_tools[$platform]}" | cut -d' ' -f1)
|
||||
# compare hash to saved hash in ${BUILD_WORKSPACE_DIRECTORY}/tools/pseudo_version_${platform}.sha256
|
||||
saved_hash=$(cat "${BUILD_WORKSPACE_DIRECTORY}/tools/pseudo_version_${platform}.sha256")
|
||||
if [[ ${computed_hash} != "${saved_hash}" ]]; then
|
||||
echo "Error: pseudo-version tool hash for ${platform} does not match saved hash"
|
||||
echo "Computed hash: ${computed_hash}"
|
||||
echo "Saved hash: ${saved_hash}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue