forked from squillace/sysext-bakery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_slight_sysext.sh
executable file
·51 lines (38 loc) · 1.64 KB
/
create_slight_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
46
47
48
49
50
51
#!/bin/bash
set -euo pipefail
export ARCH="${ARCH-x86_64}"
export FILE_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 slight 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
SLIGHT_VERSION="$1"
SYSEXTNAME="$2"
# clean and download x86 first
rm -f "slight.tgz"
curl -L -s https://github.com/deislabs/spiderlightning/releases/download/v${SLIGHT_VERSION}/slight-linux-x86_64.tar.gz -o slight.tgz
#clean old sysextname directory and remake it
rm -rf "${SYSEXTNAME}"
mkdir -p "${SYSEXTNAME}"
# tar into systextname directory the slight binary
tar --force-local -xf "slight.tgz" -C "${SYSEXTNAME}"
#clean up remaining local slight
rm "slight.tgz"
# make a /usr/bin in sysextname directory
mkdir -p "${SYSEXTNAME}"/usr/bin
# move slight into sysextname/usr/bin/
mv "${SYSEXTNAME}"/release/slight "${SYSEXTNAME}/usr/bin"
# clean up temp directory for slight
rm -r "${SYSEXTNAME}"/"release"
# bake the image
"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}"
# rename the file to the specific version and arch.
mv "./${SYSEXTNAME}.raw" "./${SYSEXTNAME}-v${SLIGHT_VERSION}-${FILE_ARCH}.raw"
#clean up the sysextname directory
rm -rf "${SYSEXTNAME}"