From c71fa89a0d9917f1c04413f6ee3fcd244a640273 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Mon, 6 Mar 2023 19:00:13 -0500 Subject: [PATCH] [buildomat] Package all global zone tarballs into single tarball (#2475) My expectation is that we'll: 1. Download `global-zone-packages.tar.gz` in the `helios` repo 2. Unpack the contents into a staging directory 3. Use [image builder to copy the contents of these services into the host OS image](https://github.com/illumos/image-builder/pull/4) Additionally, I made the list of artifacts a bit more explicit. *Eventually* we could parse the package manifest to access this info, but for now, I don't want to include any "intermediate" artifacts that shouldn't be installed on a system. --- .github/buildomat/jobs/package.sh | 65 +++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) mode change 100644 => 100755 .github/buildomat/jobs/package.sh diff --git a/.github/buildomat/jobs/package.sh b/.github/buildomat/jobs/package.sh old mode 100644 new mode 100755 index 79250e9115..b5eee62705 --- a/.github/buildomat/jobs/package.sh +++ b/.github/buildomat/jobs/package.sh @@ -6,9 +6,14 @@ #: rust_toolchain = "1.66.1" #: output_rules = [ #: "=/work/package.tar.gz", +#: "=/work/global-zone-packages.tar.gz", #: "=/work/zones/*.tar.gz", #: ] #: +#: [[publish]] +#: series = "image" +#: name = "global-zone-packages" +#: from_output = "/out/global-zone-packages.tar.gz" set -o errexit set -o pipefail @@ -17,10 +22,15 @@ set -o xtrace cargo --version rustc --version +# Build ptime -m ./tools/install_builder_prerequisites.sh -yp -ptime -m ./tools/create_self_signed_cert.sh -yp +ptime -m cargo run --locked --release --bin omicron-package -- -t 'image_type=standard switch_variant=asic' package +ptime -m cargo run --locked --release --bin omicron-package -- -t 'image_type=standard switch_variant=stub' package -ptime -m cargo run --locked --release --bin omicron-package -- package +tarball_src_dir="$(pwd)/out" + +# Assemble some utilities into a tarball that can be used by deployment +# phases of buildomat. files=( out/*.tar @@ -29,6 +39,55 @@ files=( target/release/omicron-package tools/create_virtual_hardware.sh ) + ptime -m tar cvzf /work/package.tar.gz "${files[@]}" + +# Assemble global zone files in a temporary directory. +if ! tmp=$(mktemp -d); then + exit 1 +fi +trap 'cd /; rm -rf "$tmp"' EXIT + +# Header file, identifying this is intended to be layered in the global zone. +# Within the ramdisk, this means that all files under "root/foo" should appear +# in the global zone as "/foo". +echo '{"v":"1","t":"layer"}' > "$tmp/oxide.json" + +# Extract the sled-agent tarball for re-packaging into the layered GZ archive. +pkg_dir="$tmp/root/opt/oxide/sled-agent" +mkdir -p "$pkg_dir" +cd "$pkg_dir" +tar -xvfz "$tarball_src_dir/omicron-sled-agent.tar" +# Ensure that the manifest for the sled agent exists in a location where it may +# be automatically initialized. +mkdir -p "$tmp/root/lib/svc/manifest/site/" +mv pkg/manifest.xml "$tmp/root/lib/svc/manifest/site/sled-agent.xml" +cd - + +# Extract the mg-ddm tarball for re-packaging into the layered GZ archive. +pkg_dir="$tmp/root/opt/oxide/mg-ddm" +mkdir -p "$pkg_dir" +cd "$pkg_dir" +tar -xvfz "$tarball_src_dir/maghemite.tar" +cd - + +mkdir -p /work +cd "$tmp" && tar cvfz /work/global-zone-packages.tar.gz oxide.json root +cd - + +# Assemble Zone Images into their respective output locations. mkdir -p /work/zones -mv out/*.tar.gz /work/zones/ +zones=( + out/clickhouse.tar.gz + out/cockroachdb.tar.gz + out/crucible-pantry.tar.gz + out/crucible.tar.gz + out/external-dns.tar.gz + out/internal-dns.tar.gz + out/omicron-nexus.tar.gz + out/oximeter-collector.tar.gz + out/propolis-server.tar.gz + out/switch-asic.tar.gz + out/switch-stub.tar.gz +) +cp "${zones[@]}" /work/zones/