2021-11-07 20:37:56 +00:00
|
|
|
#!/bin/sh -eu
|
|
|
|
# vim: ts=4 et:
|
|
|
|
|
2021-11-23 06:09:18 +00:00
|
|
|
[ -z "$DEBUG" ] || [ "$DEBUG" = 0 ] || set -x
|
2021-11-07 20:37:56 +00:00
|
|
|
|
|
|
|
export \
|
|
|
|
TARGET=/mnt
|
|
|
|
|
|
|
|
|
|
|
|
die() {
|
|
|
|
printf '\033[1;7;31m FATAL: %s \033[0m\n' "$@" >&2 # bold reversed red
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
einfo() {
|
|
|
|
printf '\n\033[1;7;36m> %s <\033[0m\n' "$@" >&2 # bold reversed cyan
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
# Sweep cruft out of the image that doesn't need to ship or will be
|
|
|
|
# re-generated when the image boots
|
|
|
|
rm -f \
|
|
|
|
"$TARGET/var/cache/apk/"* \
|
|
|
|
"$TARGET/etc/resolv.conf" \
|
|
|
|
"$TARGET/root/.ash_history" \
|
|
|
|
"$TARGET/etc/"*-
|
|
|
|
|
|
|
|
# unmount extra EFI mount
|
|
|
|
if [ "$FIRMWARE" = uefi ]; then
|
|
|
|
umount "$TARGET/boot/efi"
|
|
|
|
fi
|
|
|
|
|
|
|
|
umount \
|
|
|
|
"$TARGET/dev" \
|
|
|
|
"$TARGET/proc" \
|
|
|
|
"$TARGET/sys"
|
|
|
|
|
|
|
|
umount "$TARGET"
|
|
|
|
}
|
|
|
|
|
|
|
|
einfo "Cleaning up and unmounting image volume..."
|
|
|
|
cleanup
|
|
|
|
einfo "Done!"
|