|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euxo pipefail |
| 4 | + |
| 5 | +ENV_YAML="$SRCDIR/l2-builder/mkosi.extra/usr/flashbots/env.yaml" |
| 6 | +BPROXY_VERSION=$(mkosi-chroot yq -r .bproxy.version < "$ENV_YAML") |
| 7 | +BPROXY_CHECKSUM=$(mkosi-chroot yq -r .bproxy.checksum < "$ENV_YAML") |
| 8 | +NODE_HEALTHCHECKER_VERSION=$(mkosi-chroot yq -r .node_healthchecker.version < "$ENV_YAML") |
| 9 | +NODE_HEALTHCHECKER_CHECKSUM=$(mkosi-chroot yq -r .node_healthchecker.checksum < "$ENV_YAML") |
| 10 | +VAULT_VERSION=$(mkosi-chroot yq -r .vault.version < "$ENV_YAML") |
| 11 | +GOMPLATE_VERSION=$(mkosi-chroot yq -r .deps.gomplate_version < "$ENV_YAML") |
| 12 | +RUST_VERSION=$(mkosi-chroot yq -r .deps.rust_version < "$ENV_YAML") |
| 13 | +OPS_AGENT_VERSION=$(mkosi-chroot yq -r .deps.ops_agent_version < "$ENV_YAML") |
| 14 | + |
| 15 | +export RUSTUP_HOME="/rustup" |
| 16 | +export CARGO_HOME="/cargo" |
| 17 | +mkosi-chroot rustup toolchain install $RUST_VERSION |
| 18 | +mkosi-chroot rustup default $RUST_VERSION |
| 19 | +export PATH="$CARGO_HOME/bin:$PATH" |
| 20 | + |
| 21 | +source scripts/make_git_package.sh |
| 22 | +source scripts/build_rust_package.sh |
| 23 | + |
| 24 | +# build/re-use op-rbuilder |
| 25 | +if [ -f "l2-builder/mkosi.extra/usr/bin/op-rbuilder" ]; then |
| 26 | + echo "Using pre-built op-rbuilder binary" |
| 27 | +else |
| 28 | + build_rust_package \ |
| 29 | + "op-rbuilder" \ |
| 30 | + "main" \ |
| 31 | + "https://github.com/flashbots/op-rbuilder.git" \ |
| 32 | + "" "" "-g" |
| 33 | +fi |
| 34 | + |
| 35 | +# build/re-use tdx-quote-provider |
| 36 | +if [ -f "l2-builder/mkosi.extra/usr/bin/tdx-quote-provider" ]; then |
| 37 | + echo "Using pre-built tdx-quote-provider binary" |
| 38 | +else |
| 39 | +build_rust_package \ |
| 40 | + "tdx-quote-provider" \ |
| 41 | + "main" \ |
| 42 | + "https://github.com/flashbots/op-rbuilder.git" \ |
| 43 | + "" "" "-g" |
| 44 | +fi |
| 45 | + |
| 46 | +# build gomplate |
| 47 | +make_git_package \ |
| 48 | + "gomplate" \ |
| 49 | + "v${GOMPLATE_VERSION}" \ |
| 50 | + "https://github.com/hairyhenderson/gomplate" \ |
| 51 | + 'go build -trimpath -ldflags "-s -w -buildid=" -o ./build/gomplate ./cmd/gomplate' \ |
| 52 | + "build/gomplate:/usr/bin/gomplate" |
| 53 | +chmod +x $DESTDIR/usr/bin/gomplate |
| 54 | + |
| 55 | +# build vault |
| 56 | +make_git_package \ |
| 57 | + "vault" \ |
| 58 | + "v${VAULT_VERSION}" \ |
| 59 | + "https://github.com/hashicorp/vault.git" \ |
| 60 | + 'go build -trimpath -ldflags "-s -w -buildid=" -o ./bin/vault .' \ |
| 61 | + "bin/vault:/usr/bin/vault" |
| 62 | +chmod +x $DESTDIR/usr/bin/vault |
| 63 | + |
| 64 | +cd "$BUILDROOT" |
| 65 | + |
| 66 | +if [ -f "l2-builder/mkosi.extra/usr/bin/bproxy" ]; then |
| 67 | + echo "Using pre-built bproxy binary" |
| 68 | +else |
| 69 | + curl -L -o bproxy.zip "https://github.com/flashbots/bproxy/releases/download/v${BPROXY_VERSION}/bproxy_linux_amd64.zip" |
| 70 | + echo "${BPROXY_CHECKSUM} bproxy.zip" | sha256sum -c |
| 71 | + unzip bproxy.zip |
| 72 | + install -m 755 bproxy "$DESTDIR/usr/bin/bproxy" |
| 73 | + rm -f bproxy bproxy.zip |
| 74 | +fi |
| 75 | + |
| 76 | +if [ -f "l2-builder/mkosi.extra/usr/bin/node-healthchecker" ]; then |
| 77 | + echo "Using pre-built node-healthchecker binary" |
| 78 | +else |
| 79 | + # Download and install node-healthchecker |
| 80 | + curl -L -o node-healthchecker.zip "https://github.com/flashbots/node-healthchecker/releases/download/v${NODE_HEALTHCHECKER_VERSION}/node-healthchecker_linux_amd64.zip" |
| 81 | + echo "${NODE_HEALTHCHECKER_CHECKSUM} node-healthchecker.zip" | sha256sum -c |
| 82 | + unzip node-healthchecker.zip |
| 83 | + install -m 755 node-healthchecker "$DESTDIR/usr/bin/node-healthchecker" |
| 84 | + rm -f node-healthchecker node-healthchecker.zip |
| 85 | +fi |
| 86 | + |
| 87 | +# Build Google Cloud Ops Agent |
| 88 | +IMPORT_PATH="github.com/GoogleCloudPlatform/ops-agent" |
| 89 | +BUILD_CMD=" |
| 90 | + # Fluentbit |
| 91 | + export SOURCE_DATE_EPOCH=0 PATH=/usr/local/go/bin:\$PATH |
| 92 | + export CFLAGS='-fno-ident -Wno-date-time' CXXFLAGS='-fno-ident -Wno-date-time' |
| 93 | + git submodule update --init --depth 1 submodules/fluent-bit |
| 94 | + ./builds/fluent_bit.sh \$(pwd)/out |
| 95 | +
|
| 96 | + # Main gcs agent binaries |
| 97 | + mkdir -p out/libexec |
| 98 | + LDFLAGS='-s -w -buildid=' |
| 99 | + go build -buildvcs=false -trimpath -ldflags \"\$LDFLAGS \\ |
| 100 | + -X $IMPORT_PATH/internal/version.BuildDistro=debian13 \\ |
| 101 | + -X $IMPORT_PATH/internal/version.Version=$OPS_AGENT_VERSION\" \\ |
| 102 | + -o out/libexec/google_cloud_ops_agent_engine \\ |
| 103 | + $IMPORT_PATH/cmd/google_cloud_ops_agent_engine |
| 104 | +
|
| 105 | + go build -buildvcs=false -trimpath -ldflags \"\$LDFLAGS\" \\ |
| 106 | + -o out/libexec/google_cloud_ops_agent_wrapper \\ |
| 107 | + $IMPORT_PATH/cmd/agent_wrapper |
| 108 | +" |
| 109 | + |
| 110 | +make_git_package \ |
| 111 | + "google-cloud-ops-agent" \ |
| 112 | + "$OPS_AGENT_VERSION" \ |
| 113 | + "https://github.com/GoogleCloudPlatform/ops-agent" \ |
| 114 | + "$BUILD_CMD" \ |
| 115 | + "out/libexec:/opt/google-cloud-ops-agent/libexec" \ |
| 116 | + "out/opt/google-cloud-ops-agent/subagents/fluent-bit:/opt/google-cloud-ops-agent/subagents/fluent-bit" \ |
| 117 | + "systemd/google-cloud-ops-agent-fluent-bit.service:/usr/lib/systemd/system/google-cloud-ops-agent-fluent-bit.service" \ |
| 118 | + "systemd/google-cloud-ops-agent.service:/usr/lib/systemd/system/google-cloud-ops-agent.service" |
| 119 | + |
| 120 | +sed -i 's|@PREFIX@|/opt/google-cloud-ops-agent|g; s|@SYSCONFDIR@|/etc|g' "$DESTDIR/usr/lib/systemd/system/google-cloud-ops-agent"*.service |
0 commit comments