From f401413ea99f7c1a899e7337afb0bc28db082a8e Mon Sep 17 00:00:00 2001 From: Joonas Bergius Date: Mon, 8 Apr 2024 21:03:01 -0500 Subject: [PATCH] Add wasmCloud sysext image Signed-off-by: Joonas Bergius --- create_wasmcloud_sysext.sh | 57 ++++++++++++++++++++++++++++++++++++++ release_build_versions.txt | 2 ++ 2 files changed, 59 insertions(+) create mode 100755 create_wasmcloud_sysext.sh diff --git a/create_wasmcloud_sysext.sh b/create_wasmcloud_sysext.sh new file mode 100755 index 0000000..e27c971 --- /dev/null +++ b/create_wasmcloud_sysext.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -euo pipefail + +export ARCH="${ARCH-x86-64}" +SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")" + +if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "Usage: $0 VERSION SYSEXTNAME [NATS_VERSION]" + echo "The script will download the wasmcloud release (e.g. 0.82.0) and create a sysext squashfs image with the name SYSEXTNAME.raw in the current folder." + echo "A temporary directory named SYSEXTNAME in the current folder will be created and deleted again." + echo "All files in the sysext image will be owned by root." + echo "To use arm64 pass 'ARCH=arm64' as environment variable (current value is '${ARCH}')." + "${SCRIPTFOLDER}"/bake.sh --help + exit 1 +fi + +VERSION="$1" +SYSEXTNAME="$2" +NATS_VERSION="${3-latest}" + +# The github release uses different arch identifiers, we map them here +# and rely on bake.sh to map them back to what systemd expects +if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "x86-64" ]; then + ARCH="x86_64" + GOARCH="amd64" +elif [ "${ARCH}" = "arm64" ]; then + ARCH="aarch64" + GOARCH="arm64" +else + echo "Unknown architecture ('${ARCH}') provided, supported values are 'amd64', 'arm64'." + exit 1 +fi + +rm -rf "${SYSEXTNAME}" +mkdir -p "${SYSEXTNAME}"/usr/bin + +VERSION="v${VERSION#v}" +curl -o "${SYSEXTNAME}"/usr/bin/wasmcloud -fvSL "https://github.com/wasmcloud/wasmcloud/releases/download/${VERSION}/wasmcloud-${ARCH}-unknown-linux-musl" +chmod +x "${SYSEXTNAME}"/usr/bin/wasmcloud + +# Install NATS +version="${NATS_VERSION}" +if [[ "${NATS_VERSION}" == "latest" ]]; then + version=$(curl -fvSL https://api.github.com/repos/nats-io/nats-server/releases/latest | jq -r .tag_name) + echo "Using latest version: ${version} for NATS Server" +fi +version="v${version#v}" + +rm -f "nats-server.tar.gz" +curl -o nats-server.tar.gz -fvSL "https://github.com/nats-io/nats-server/releases/download/${version}/nats-server-${version}-linux-${GOARCH}.tar.gz" +tar -xf "nats-server.tar.gz" -C "${SYSEXTNAME}" +mv "${SYSEXTNAME}/nats-server-${version}-linux-${GOARCH}/nats-server" "${SYSEXTNAME}/usr/bin/" +rm -r "${SYSEXTNAME}/nats-server-${version}-linux-${GOARCH}" +rm "nats-server.tar.gz" + +"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}" +rm -rf "${SYSEXTNAME}" diff --git a/release_build_versions.txt b/release_build_versions.txt index b95e362..222109b 100644 --- a/release_build_versions.txt +++ b/release_build_versions.txt @@ -17,3 +17,5 @@ wasmtime-12.0.0 wasmtime-13.0.0 # Used in Flatcar wasm OS demo wasmtime-17.0.1 # Used in README.md. Update readme when version changes. wasmtime-18.0.1 + +wasmcloud-0.82.0 \ No newline at end of file