forked from squillace/sysext-bakery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_nerdctl_sysext.sh
executable file
·45 lines (34 loc) · 1.58 KB
/
create_nerdctl_sysext.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/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 nerdctl release tar ball (e.g., for 4.0.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=aarch64' as environment variable (current value is '${ARCH}')."
"${SCRIPTFOLDER}"/bake.sh --help
exit 1
fi
VERSION="$1"
SYSEXTNAME="$2"
# clean and obtain the specified version
rm -f "wasmtime-${VERSION}.tar.xz"
curl -o "wasmtime-${VERSION}.tar.xz" -fsSL "https://github.com/bytecodealliance/wasmtime/releases/download/v${VERSION}/wasmtime-v${VERSION}-${ARCH}-linux.tar.xz"
# clean earlier SYSEXTNAME directory and recreate
rm -rf "${SYSEXTNAME}"
mkdir -p "${SYSEXTNAME}"
# extract wasmtime into SYSEXTNAME/
tar --force-local -xf "wasmtime-${VERSION}.tar.xz" -C "${SYSEXTNAME}"
# clean downloaded tarball
rm "wasmtime-${VERSION}.tar.xz"
# create deployment directory in SYSEXTNAME/ and move wasmtime into it
mkdir -p "${SYSEXTNAME}"/usr/bin
mv "${SYSEXTNAME}"/"wasmtime-v${VERSION}-${ARCH}-linux"/wasmtime "${SYSEXTNAME}"/usr/bin/
# clean up any extracted mess
rm -r "${SYSEXTNAME}"/"wasmtime-v${VERSION}-${ARCH}-linux"
# bake the .raw
"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}"
# clean again just in case
rm -rf "${SYSEXTNAME}"