-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
02_build_image.sh
executable file
·49 lines (40 loc) · 1.71 KB
/
02_build_image.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
#!/bin/bash
set -eu -o pipefail
echo >&2 "===]> Info: Create image directory and populate it... "
cd "${WORKING_PATH}"
if [ -d "${IMAGE_PATH}" ]; then
rm -rf "${IMAGE_PATH}"
fi
mkdir -p "${IMAGE_PATH}"/{casper,install,isolinux}
cp "${CHROOT_PATH}"/boot/vmlinuz-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/vmlinuz
cp "${CHROOT_PATH}"/boot/initrd.img-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/initrd
echo >&2 "===]> Info: Grub configuration... "
# we add an empty file to use it with the search command in grub later on.
touch "${IMAGE_PATH}"/ubuntu
cp -r "${ROOT_PATH}"/files/preseed "${IMAGE_PATH}"/preseed
cp "${ROOT_PATH}/files/grub/grub.cfg" "${IMAGE_PATH}"/isolinux/grub.cfg
echo >&2 "===]> Info: Compress the chroot... "
cd "${WORKING_PATH}"
mksquashfs "${CHROOT_PATH}" "${IMAGE_PATH}"/casper/filesystem.squashfs
printf "%s" "$(du -sx --block-size=1 "${CHROOT_PATH}" | cut -f1)" >"${IMAGE_PATH}"/casper/filesystem.size
echo >&2 "===]> Info: Create manifest... "
# shellcheck disable=SC2016
chroot "${CHROOT_PATH}" dpkg-query -W --showformat='${Package} ${Version}\n' |
tee "${IMAGE_PATH}"/casper/filesystem.manifest
cp -v "${IMAGE_PATH}"/casper/filesystem.manifest "${IMAGE_PATH}"/casper/filesystem.manifest-desktop
REMOVE='ubiquity casper lupin-casper user-setup discover discover-data os-prober laptop-detect'
for i in $REMOVE; do
sed -i "/${i}/d" "${IMAGE_PATH}"/casper/filesystem.manifest-desktop
done
echo >&2 "===]> Info: Create diskdefines... "
cat <<EOF >"${IMAGE_PATH}"/README.diskdefines
#define DISKNAME Ubuntu MBP 24.04 LTS "Noble Numbat" - amd64
#define TYPE binary
#define TYPEbinary 1
#define ARCH amd64
#define ARCHamd64 1
#define DISKNUM 1
#define DISKNUM1 1
#define TOTALNUM 0
#define TOTALNUM0 1
EOF