"kernel"
)
+BUILDSYSTEM_PACKAGES=(
+ "@Base"
+ "dracut"
+ "grub"
+)
+
# Compress as best as we can
ZSTD_COMPRESSION_LEVEL=22
dd if=/dev/zero of="${path}" bs=1k count="${size}"
}
+make_buildsystem() {
+ local path="${1}"
+
+ local packages=(
+ "${BUILDSYSTEM_PACKAGES[@]}"
+ )
+
+ # Install packages
+ if ! pakfire --config="${PAKFIRE_CONFIG}" --root="${path}" \
+ install --without-recommends "${packages[@]}"; then
+ echo "Could not install build system" >&2
+ return 1
+ fi
+}
+
+in_buildsystem() {
+ if [ -z "${buildsystem}" ]; then
+ echo "Build system isn't set up" >&2
+ return 1
+ fi
+
+ pakfire --config="${PAKFIRE_CONFIG}" --root="${buildsystem}" execute "$@"
+}
+
make_live_system_image() {
local filename="${1}"
make_grub_bios_image() {
local path="${1}"
- local core_img="$(mktemp)"
+ local tempdir="$(mktemp -d)"
# Create a standalone image
- if ! grub-mkstandalone \
- --format="${grub_arch}-pc" \
- --output="${core_img}" \
- --modules="${GRUB_MODULES[@]}" \
- --install-modules="${GRUB_MODULES[@]}" \
- --fonts="" --locales=""; then
- unlink "${core_img}"
+ if ! in_buildsystem --bind="${tempdir}" \
+ grub-mkstandalone \
+ --verbose \
+ --format="${grub_arch}-pc" \
+ --output="${tempdir}/core.img" \
+ --modules="${GRUB_MODULES[@]}" \
+ --install-modules="${GRUB_MODULES[@]}" \
+ --fonts="" --locales="" --themes=""; then
+ rm -rf "${tempdir}"
return 1
fi
# Append cdboot.img with the generated core.img
- if ! cat "/usr/lib/grub/${grub_arch}-pc/cdboot.img" "${core_img}" > "${path}"; then
- unlink "${core_img}" "${path}"
+ if ! cat "${buildsystem}/usr/lib/grub/${grub_arch}-pc/cdboot.img" "${tempdir}/core.img" \
+ > "${path}"; then
+ unlink "${tempdir}" "${path}"
return 1
fi
# Cleanup
- unlink "${core_img}"
+ rm -rf "${tempdir}"
return 0
}
make_grub_efi_image() {
local path="${1}"
+ local grub_efi_arch="${arch}"
+
+ case "${arch}" in
+ aarch64)
+ grub_efi_arch="a64"
+ ;;
+ x86_64)
+ grub_efi_arch="x64"
+ ;;
+ esac
+
# Allocate file
if ! allocate_file "${path}" 2880; then
return 1
mkdir -p "${tempdir}/EFI/BOOT"
# Generate a GRUB image
- if ! grub-mkstandalone \
- --format="${grub_arch}-efi" \
- --output="${tempdir}/EFI/BOOT/bootx64.efi" \
- --fonts="" --locales=""; then
+ if ! in_buildsystem --bind="${tempdir}" \
+ grub-mkstandalone \
+ --format="${arch}-efi" \
+ --output="${tempdir}/EFI/BOOT/boot${grub_efi_arch}.efi" \
+ --fonts="" --locales="" --themes=""; then
echo "Could not generate GRUB EFI image" >&2
umount "${tempdir}"
rm -rf "${tempdir}"
x86_64)
has_bios_boot="true"
- #has_efi_boot="true"
+ has_efi_boot="true"
;;
# Throw an error on unhandled architectures
;;
esac
+ local buildsystem="$(mktemp -d)"
+
+ # Install a system with all tools we need
+ if ! make_buildsystem "${buildsystem}"; then
+ return 1
+ fi
+
# Make image and delete it if something went wrong
- if ! mkimage "${filename}"; then
- rm -f "${filename}"
+ if ! mkimage "${buildsystem}" "${filename}"; then
+ rm -rf "${buildsystem}" "${filename}"
return 1
fi
+ # Remove temporary system
+ rm -rf "${buildsystem}"
+
return 0
}