From ea35dce43c9a2c73a997afdb7a3066086b5c67ee Mon Sep 17 00:00:00 2001 From: hydai Date: Tue, 26 Nov 2024 10:43:56 +0800 Subject: [PATCH] sysext: add wasmedge recipe Signed-off-by: hydai --- README.md | 20 +++++++++++++++++++ create_wasmedge_sysext.sh | 40 ++++++++++++++++++++++++++++++++++++++ release_build_versions.txt | 2 ++ 3 files changed, 62 insertions(+) create mode 100755 create_wasmedge_sysext.sh diff --git a/README.md b/README.md index 9bb71a8..65c0757 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ For extensions that are not part of the GitHub Release or which you want to cust | `rke2` | released | | `keepalived` | build script | | `ollama` | released | +| `wasmedge` | released | ### Consuming the published images @@ -440,6 +441,25 @@ Note that this configuration can be customized in terms of where Ollama is confi Please refer to the [Ollama documentation for further details](https://github.com/ollama/ollama/tree/main/docs). +#### WasmEdge + +The wasmedge sysext can be configured by using the following snippet: + +``` +variant: flatcar +version: 1.0.0 +storage: + files: + - path: /opt/extensions/wasmedge-0.14.1-x86-64.raw + mode: 0420 + contents: + source: https://github.com/flatcar/sysext-bakery/releases/download/wasmedge-0.14.1-x86-64.raw + links: + - target: /opt/extensions/wasmedge-0.14.1-x86-64.raw + path: /etc/extensions/wasmedge.raw + hard: false +``` + ### Building sysext images To use the build scripts in this repository, the following packages are required: diff --git a/create_wasmedge_sysext.sh b/create_wasmedge_sysext.sh new file mode 100755 index 0000000..32e83ac --- /dev/null +++ b/create_wasmedge_sysext.sh @@ -0,0 +1,40 @@ +#!/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" + echo "The script will download the WasmEdge release tar ball (e.g., for 0.14.1) 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" + +# 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" +elif [ "${ARCH}" = "arm64" ]; then + ARCH="aarch64" +fi + +rm -f "WasmEdge-${VERSION}.tar.gz" +curl -o "WasmEdge-${VERSION}.tar.gz" -fsSL "https://github.com/WasmEdge/WasmEdge/releases/download/${VERSION}/WasmEdge-${VERSION}-ubuntu20.04_${ARCH}.tar.gz" +rm -rf "${SYSEXTNAME}" +mkdir -p "${SYSEXTNAME}" +tar --force-local -xvf "WasmEdge-${VERSION}.tar.gz" -C "${SYSEXTNAME}" +rm "WasmEdge-${VERSION}.tar.gz" +mkdir -p "${SYSEXTNAME}"/usr/bin +mkdir -p "${SYSEXTNAME}"/usr/lib # for .so files +mv "${SYSEXTNAME}"/"WasmEdge-${VERSION}-Linux"/bin/wasmedge "${SYSEXTNAME}"/usr/bin/ +mv "${SYSEXTNAME}"/"WasmEdge-${VERSION}-Linux"/lib/* "${SYSEXTNAME}"/usr/lib/ +rm -r "${SYSEXTNAME}"/"WasmEdge-${VERSION}-Linux" +"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}" +rm -rf "${SYSEXTNAME}" diff --git a/release_build_versions.txt b/release_build_versions.txt index 91bd3ee..7716281 100644 --- a/release_build_versions.txt +++ b/release_build_versions.txt @@ -30,3 +30,5 @@ nvidia_runtime-v1.16.2 ollama-0.3.9 containerd-2.0.0 + +wasmedge-0.14.1