-
Notifications
You must be signed in to change notification settings - Fork 3
/
build
executable file
·71 lines (58 loc) · 1.92 KB
/
build
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -euxo pipefail
scriptdir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
distdir="${scriptdir}/dist"
workdir="${scriptdir}/workdir"
iconsdir="${workdir}/icons"
outdir="${workdir}/out"
rootfsdir="${workdir}/rootfs"
mkdir -p "${workdir}"
# Download Alma cloud init image
image="AlmaLinux-8-GenericCloud-latest.x86_64.qcow2"
url="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/${image}"
image_path="${workdir}/${image}"
if [ -f "${image_path}" ]; then
echo "Alma cloud-init image exists in workdir. Skipping download."
else
echo "Downloading ${url}"
curl --silent --output "${image_path}" "${url}"
fi
# Download WSLDL
url="https://github.com/yuk7/wsldl/releases/latest/download/icons.zip"
wsldl_path="${workdir}/Alma-8.exe"
if [ -f "${wsldl_path}" ]; then
echo "WSLDL exists in workdir. Skipping download."
else
echo "Downloading ${url}"
rm -rf "${iconsdir}"
mkdir -p "${iconsdir}"
curl --silent --location --output "${iconsdir}/icons.zip" "${url}"
unzip -d "${iconsdir}" "${iconsdir}/icons.zip"
mv "${iconsdir}/Alma.exe" "${wsldl_path}"
fi
# Extract rootfs from image
sudo rm -rf "${rootfsdir}"
sudo mkdir -p "${rootfsdir}"
echo "Extracting rootfs"
# Unmount and remount the image
sudo guestunmount --quiet --no-retry "${rootfsdir}" || true
sudo guestmount --add "${image_path}" --inspector --ro "${rootfsdir}"
# Archive the rootfs
echo "Compressing rootfs"
rootfs_tar="${workdir}/install.tar.gz"
sudo tar -zcpf ${rootfs_tar} -C "${rootfsdir}" .
sudo chown "$(id -un)" "${rootfs_tar}"
# Unmount the image
sudo guestunmount "${rootfsdir}"
# Create the download bundle
echo "Creating the download bundle"
rm -rf "${outdir}"
mkdir -p "${outdir}"
mv "${rootfs_tar}" "${wsldl_path}" "${outdir}"
dist_file="${distdir}/Alma-8.zip"
rm -rf "${distdir}"
mkdir -p "${distdir}"
# quirk with zip where in -j doesn't always exclude absolute paths
pushd "${outdir}"
zip "${dist_file}" ./*
popd