blob: 811c5cb719f73e766f528cc3c454c13f25084e9d (
plain)
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
|
#!/bin/bash -xe
IMAGE_VERSION=$( date +%Y%m%d.%H%M%S )
function unmount_pseudo_filesystems(){
set +e
for dir in dev sys proc; do umount -v "$root"/"$dir"; done
set -e
}
function on_exit(){
set +e
unmount_pseudo_filesystems
umount -v "$root"
}
trap on_exit EXIT
root=rootfs/"$IMAGE_VERSION"
mkdir -p "$root"
# bootstrap the OS
debootstrap noble "$root"
for dir in /proc /sys /dev; do
mount --bind "$dir" "$root"/"$dir"
done
export DEBIAN_FRONTEND=noninteractive
chroot "$root" locale-gen en_US.UTF-8
chroot "$root" apt-get update
# Install a kernel and bootloader
chroot "$root" apt-get -y --no-install-recommends install linux-generic-hwe-24.04 grub-efi
if [ "$1" == "with-app" ]; then
# Install an application
chroot "$root" apt-get update
chroot "$root" apt-get install -y software-properties-common
chroot "$root" add-apt-repository -y universe
chroot "$root" apt-get update
chroot "$root" apt-get -y install nethack-console
fi
# Cleanup
chroot "$root" apt-get clean
unmount_pseudo_filesystems
rm -rf "$root"/dev/*
rm -rf "$root"/var/lib/apt/lists/*
|