# Create an empty zeroed-out 64MiB image file.
dd if=/dev/zero bs=1M count=0 seek=64 of=image.hdd

# Create a partition table.
sgdisk image.hdd -n 1:2048 -t 1:ef00 -m 1


#rm -rf limine
# If first time: Download the latest Limine binary release for the 10.x branch.
#git clone https://codeberg.org/Limine/Limine.git limine --branch=v10.x-binary --depth=1

# Build "limine" utility.
make -C limine

# Install the Limine BIOS stages onto the image.
./limine/limine bios-install image.hdd

# Format the image as fat32.
mformat -i image.hdd@@1M -F

# Make relevant subdirectories.
mmd -i image.hdd@@1M ::/EFI ::/EFI/BOOT ::/boot ::/boot/limine ::/fort

# Copy over the relevant files.
mcopy -i image.hdd@@1M bin/os ::/boot
mcopy -i image.hdd@@1M limine.conf limine/limine-bios.sys ::/boot/limine
mcopy -i image.hdd@@1M limine/BOOTX64.EFI ::/EFI/BOOT
mcopy -i image.hdd@@1M limine/BOOTIA32.EFI ::/EFI/BOOT
mcopy -i image.hdd@@1M fortune ::/fort/fortu.ne
