feat(iso9660): complete refactor of filesystem

The entire iso9660 filesystem folder was restructured to replace partially unreadable legacy code with modern, readable and modular structures. Hardcoded paths were replaced with variables, as much as possible, to make the code work with different setups. A mode "both" was added, producing Debian-style hybrid ISOs for both BIOS and EFI usage, while still allowing for flashing to USB and/or burning to CD/DVD-ROM. The configuration GUI (via "make menuconfig") was also refactored and adapted to the new changes.

Signed-off-by: desertwitch <24509509+desertwitch@users.noreply.github.com>
This commit is contained in:
desertwitch
2025-11-18 07:23:00 +01:00
parent 4e544986c1
commit 554f1a965b
5 changed files with 431 additions and 93 deletions

View File

@@ -4,7 +4,7 @@ config BR2_TARGET_ROOTFS_ISO9660
depends on BR2_LINUX_KERNEL
depends on BR2_TARGET_GRUB2 || BR2_TARGET_SYSLINUX_ISOLINUX
select BR2_LINUX_KERNEL_INSTALL_TARGET \
if (!BR2_TARGET_ROOTFS_ISO9660_INITRD && !BR2_TARGET_ROOTFS_INITRAMFS)
if (!BR2_TARGET_ROOTFS_ISO9660_INITRD && !BR2_TARGET_ROOTFS_INITRAMFS)
help
Build a bootable ISO9660 image. By default, the root
filesystem is directly packed as the ISO9660 filesystem,
@@ -26,24 +26,46 @@ choice
config BR2_TARGET_ROOTFS_ISO9660_GRUB2
bool "grub2"
depends on BR2_TARGET_GRUB2
depends on BR2_TARGET_GRUB2 \
&& (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI)
select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER \
if BR2_TARGET_GRUB2_I386_PC
select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER \
if (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI)
help
Use Grub 2 as the bootloader for the ISO9660 image. Make
sure to enable the 'iso9660' module in
BR2_TARGET_GRUB2_BUILTIN_MODULES_PC or
BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI. Use 'cd' as the boot
partition in BR2_TARGET_GRUB2_BOOT_PARTITION= for GRUB on BIOS
or 'set root=(cd0)' in the configuration file passed to
BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI for GRUB on EFI.
Use Grub 2 as the bootloader for the ISO9660 image.
Make sure to enable the 'iso9660' module in
BR2_TARGET_GRUB2_BUILTIN_MODULES_PC and/or
BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI. For GRUB on BIOS, use 'cd'
as the boot partition in BR2_TARGET_GRUB2_BOOT_PARTITION setting.
For GRUB on EFI 'set root=(cd0)' in the configuration file passed
to BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU, although the
default configuration file contains a "search" directive using
BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE, which works too.
config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
bool "isolinux"
depends on BR2_TARGET_SYSLINUX_ISOLINUX
select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
help
Use ISOLINUX as the bootloader for the ISO9660 image.
ISOLINUX is a bootloader for BIOS systems that can boot
from CD-ROM or USB devices.
config BR2_TARGET_ROOTFS_ISO9660_BOTH
bool "both"
depends on BR2_TARGET_SYSLINUX_ISOLINUX
depends on BR2_TARGET_GRUB2 \
&& (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI)
select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
help
Use both ISOLINUX (for BIOS boot) and GRUB2 (for UEFI boot).
This creates an ISO that can boot on both legacy BIOS
systems and modern UEFI systems, combined with the hybrid
image option this will produce a Debian-style hybrid ISO,
as it is commonly shipped alongside modern Linux distros,
which can both be flashed to USB and burned to CD/DVD-ROM.
endchoice
@@ -53,20 +75,72 @@ config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
bool
config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU
string "Boot menu config file"
default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2
default "fs/iso9660/isolinux.cfg" if BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX_BOOT_MENU
string "Isolinux configuration file"
depends on BR2_TARGET_ROOTFS_ISO9660_ISOLINUX || BR2_TARGET_ROOTFS_ISO9660_BOTH
default "fs/iso9660/isolinux.cfg"
help
Use this option to provide a custom bootloader configuration
file (grub.cfg for Grub 2, isolinux.cfg for isolinux).
Use this option to provide a custom ISOLINUX configuration
file (isolinux.cfg).
Note that the strings __KERNEL_PATH__ and __INITRD_PATH__
will automatically be replaced by the path to the kernel and
initrd images respectively.
initrd images respectively (or removed, if not applicable).
config BR2_TARGET_ROOTFS_ISO9660_GRUB2_BOOT_MENU
string "Grub2 configuration file"
depends on BR2_TARGET_ROOTFS_ISO9660_GRUB2 || BR2_TARGET_ROOTFS_ISO9660_BOTH
default "fs/iso9660/grub.cfg"
help
Use this option to provide a custom GRUB2 configuration
file (grub.cfg).
Note that the strings __KERNEL_PATH__ and __INITRD_PATH__
will automatically be replaced by the path to the kernel and
initrd images respectively (or removed, if not applicable).
config BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE
string "Grub2 identification file (EFI)"
depends on (BR2_TARGET_ROOTFS_ISO9660_GRUB2 || BR2_TARGET_ROOTFS_ISO9660_BOTH) \
&& BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
default "buildroot"
help
Use this option to provide a custom name for the identification
file that is added to the ISO9660 filesystem, so the EFI bootloader
can better "search" it among possibly multiple attached boot devices.
config BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_PARTITION_SIZE
string "Grub2 partition size (EFI)"
depends on (BR2_TARGET_ROOTFS_ISO9660_GRUB2 || BR2_TARGET_ROOTFS_ISO9660_BOTH) \
&& BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
default "3M"
help
Use this option to increase the size of the EFI partition.
Embedding more GRUB2 modules may require a larger EFI partition size.
config BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU
string "Grub2 embedded configuration (EFI)"
depends on (BR2_TARGET_ROOTFS_ISO9660_GRUB2 || BR2_TARGET_ROOTFS_ISO9660_BOTH) \
&& BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
default "fs/iso9660/efigrub.cfg"
help
Use this option to provide a custom GRUB2 configuration
file (grub.cfg) that is embedded in the EFI paritition.
It will usually just contain a "search" directive to find the
ISO9660 filesystem containing the actual GRUB2 configuration file.
Alternatively, 'set root=(cd0)' could be directly set here also...
Note that the string __EFI_ID_FILE__ will automatically be
replaced with the BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE.
Do not mistake this for the regular GRUB2 configuration that is
eventually loaded by the EFI bootloader, this is just for systems
which need some extra help to locate the actual ISO9660 filesystem.
config BR2_TARGET_ROOTFS_ISO9660_INITRD
bool "Use initrd"
depends on !BR2_TARGET_ROOTFS_INITRAMFS
default y
select BR2_TARGET_ROOTFS_CPIO
help
@@ -81,18 +155,17 @@ config BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION
depends on !BR2_TARGET_ROOTFS_ISO9660_INITRD
depends on !BR2_TARGET_ROOTFS_INITRAMFS
help
Say 'y' to enable use of transparent (de)compression. Files
Enables the use of transparent (de)compression. All files
are stored compressed and will be decompressed on-the-fly
upon access at runtime.
config BR2_TARGET_ROOTFS_ISO9660_HYBRID
bool "Build hybrid image"
depends on BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
depends on BR2_TARGET_ROOTFS_ISO9660_ISOLINUX || BR2_TARGET_ROOTFS_ISO9660_BOTH
help
Enable this option to build an hybrid image, i.e an image
which can either be booted from a CD-ROM or from a device
which BIOS considers a hard disk or ZIP disk, e.g. a USB key
or similar.
Enable this option to build a hybrid image, which is an image
that can either be burned to CD/DVD-ROM or flashed onto a device
which the BIOS considers as HDD/removable device (e.g. USB stick)
endif

3
fs/iso9660/efigrub.cfg Normal file
View File

@@ -0,0 +1,3 @@
search --file --set=root __EFI_ID_FILE__
set prefix=($root)/boot/grub
source $prefix/grub.cfg

View File

@@ -1,7 +1,12 @@
set default="0"
set timeout="10"
set timeout="5"
menuentry "Buildroot" {
linux __KERNEL_PATH__ root=/dev/sr0
initrd __INITRD_PATH__
menuentry "ShredOS" {
linux __KERNEL_PATH__ console=tty3 loglevel=3
initrd __INITRD_PATH__
}
menuentry "ShredOS (nomodeset)" {
linux __KERNEL_PATH__ console=tty3 loglevel=3 nomodeset
initrd __INITRD_PATH__
}

View File

@@ -1,6 +1,6 @@
################################################################################
#
# Build the iso96600 root filesystem image
# Build the ISO9660 root filesystem image
#
################################################################################
@@ -21,11 +21,38 @@
# built into the kernel image. This is when
# BR2_TARGET_ROOTFS_INITRAMFS is enabled (regardless of the value
# of BR2_TARGET_ROOTFS_ISO9660_INITRD).
#
ROOTFS_ISO9660_BOOT_MENU = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU))
################################################################################
# Configuration Variables
################################################################################
ROOTFS_ISO9660_DEPENDENCIES = host-xorriso linux
ROOTFS_ISO9660_GRUB2_BOOT_MENU = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_GRUB2_BOOT_MENU))
ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU))
ROOTFS_ISO9660_GRUB2_EFI_PARTITION_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_PARTITION_SIZE))
ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE))
ROOTFS_ISO9660_ISOLINUX_BOOT_MENU = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX_BOOT_MENU))
################################################################################
# Architecture-specific variables
################################################################################
ifeq ($(BR2_ARCH_IS_64),y)
ROOTFS_ISO9660_EFI_NAME = bootx64.efi
ROOTFS_ISO9660_EFI_NOTNAME = bootia32.efi
ROOTFS_ISO9660_GRUB2_EFI_PREFIX = $(call qstrip,$(GRUB2_PREFIX_x86_64-efi))
else
ROOTFS_ISO9660_EFI_NAME = bootia32.efi
ROOTFS_ISO9660_EFI_NOTNAME = bootx64.efi
ROOTFS_ISO9660_GRUB2_EFI_PREFIX = $(call qstrip,$(GRUB2_PREFIX_i386-efi))
endif
################################################################################
# Determine if we're using initrd
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
ROOTFS_ISO9660_USE_INITRD = YES
endif
@@ -34,17 +61,23 @@ ifeq ($(BR2_TARGET_ROOTFS_ISO9660_INITRD),y)
ROOTFS_ISO9660_USE_INITRD = YES
endif
################################################################################
# Setup temporary target directory
################################################################################
ifeq ($(ROOTFS_ISO9660_USE_INITRD),YES)
# Using initrd: create minimal temporary directory
ROOTFS_ISO9660_TMP_TARGET_DIR = $(FS_DIR)/rootfs.iso9660.tmp
define ROOTFS_ISO9660_CREATE_TEMPDIR
$(RM) -rf $(ROOTFS_ISO9660_TMP_TARGET_DIR)
mkdir -p $(ROOTFS_ISO9660_TMP_TARGET_DIR)
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_CREATE_TEMPDIR
else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION),y)
# Using transparent compression: create compressed tree
ROOTFS_ISO9660_DEPENDENCIES += host-zisofs-tools
ROOTFS_ISO9660_TMP_TARGET_DIR = $(FS_DIR)/rootfs.iso9660.tmp
# This must be early, before we copy the bootloader files.
define ROOTFS_ISO9660_MKZFTREE
$(RM) -rf $(ROOTFS_ISO9660_TMP_TARGET_DIR)
$(HOST_DIR)/bin/mkzftree -X -z 9 -p $(PARALLEL_JOBS) \
@@ -53,10 +86,16 @@ define ROOTFS_ISO9660_MKZFTREE
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_MKZFTREE
ROOTFS_ISO9660_OPTS += -z
else
# Standard mode: use TARGET_DIR directly
ROOTFS_ISO9660_TMP_TARGET_DIR = $(TARGET_DIR)
endif
################################################################################
# Reproducible build support
################################################################################
ifeq ($(BR2_REPRODUCIBLE),y)
ROOTFS_ISO9660_VFAT_OPTS = --invariant
ROOTFS_ISO9660_FIX_TIME = touch -d @$(SOURCE_DATE_EPOCH)
@@ -64,100 +103,278 @@ else
ROOTFS_ISO9660_FIX_TIME = :
endif
################################################################################
# GRUB2 BIOS Bootloader Configuration
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),yy)
ROOTFS_ISO9660_DEPENDENCIES += grub2
ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
ROOTFS_ISO9660_GRUB2_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
ROOTFS_ISO9660_BOOT_IMAGE = boot/grub/grub-eltorito.img
define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
define ROOTFS_ISO9660_INSTALL_GRUB2_BIOS
$(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img
endef
endif
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools
ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi
ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part
ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
define ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI
rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH))
dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1
$(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_VFAT_OPTS) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/*
$(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
$(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
define ROOTFS_ISO9660_INSTALL_GRUB2_CONFIG
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_BOOT_MENU) \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
endef
endif
################################################################################
# GRUB2 EFI Bootloader Configuration
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools
ROOTFS_ISO9660_EFI_PARTITION = boot/efi.img
ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part
ROOTFS_ISO9660_GRUB2_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/efigrub.cfg
define ROOTFS_ISO9660_INSTALL_GRUB2_EFI
# Create identification file to better find ISO9660 filesystem
$(INSTALL) -D -m 0644 /dev/null \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE)
# Copy grub.cfg to ISO9660 filesystem where GRUB will find it
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_CONFIG_PATH) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/grub.cfg
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NAME) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NAME)
# Create EFI FAT partition
rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH))
dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=$(ROOTFS_ISO9660_GRUB2_EFI_PARTITION_SIZE) count=1
$(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_VFAT_OPTS) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
# Copy bootloader and modules to EFI partition
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/*
$(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
$(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
# Delete the EFI bootloader that is NOT for the platform we're building for
$(HOST_DIR)/bin/mdel -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) \
::$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NOTNAME) || true
# Copy efigrub.cfg to EFI partition (may be used to find ISO9660 filesystem)
$(HOST_DIR)/bin/mcopy -n -o -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH) ::$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/grub.cfg
# Remove efigrub.cfg from ISO9660 filesystem, it was just there for SED-ing
rm -f $(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
endef
define ROOTFS_ISO9660_INSTALL_GRUB2_CONFIG
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_BOOT_MENU) \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU) \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(SED) "s%__EFI_ID_FILE__%$(ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE)%" \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
endef
endif
################################################################################
# ISOLINUX Bootloader Configuration (BIOS only)
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
ROOTFS_ISO9660_DEPENDENCIES += syslinux
ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin
define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
define ROOTFS_ISO9660_INSTALL_ISOLINUX_BIOS
$(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/ldlinux.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/menu.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/menu.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/libutil.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/libutil.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/libcom32.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/libcom32.c32
endef
define ROOTFS_ISO9660_INSTALL_ISOLINUX_CONFIG
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_ISOLINUX_BOOT_MENU) \
$(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH)
endef
endif
define ROOTFS_ISO9660_PREPARATION
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_BOOT_MENU) \
$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
################################################################################
# BOTH Mode: ISOLINUX (BIOS) + GRUB2 (EFI)
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BOTH),y)
ROOTFS_ISO9660_DEPENDENCIES += syslinux grub2 host-dosfstools host-mtools
# ISOLINUX configuration
ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin
# GRUB2 EFI configuration
ROOTFS_ISO9660_GRUB2_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/efigrub.cfg
ROOTFS_ISO9660_EFI_PARTITION = boot/efi.img
ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part
define ROOTFS_ISO9660_INSTALL_ISOLINUX_BIOS
$(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/ldlinux.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/menu.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/menu.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/libutil.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/libutil.c32
$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/libcom32.c32 \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/libcom32.c32
endef
define ROOTFS_ISO9660_INSTALL_ISOLINUX_CONFIG
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_ISOLINUX_BOOT_MENU) \
$(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS)
$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI)
$(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH)
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_PREPARATION
define ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
$(SED) '/__INITRD_PATH__/d' $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
define ROOTFS_ISO9660_INSTALL_GRUB2_EFI
# Create identification file to better find ISO9660 filesystem
$(INSTALL) -D -m 0644 /dev/null \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE)
# Copy grub.cfg to ISO9660 filesystem where GRUB will find it
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_CONFIG_PATH) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/grub.cfg
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NAME) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NAME)
# Create EFI FAT partition
rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH))
dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=$(ROOTFS_ISO9660_GRUB2_EFI_PARTITION_SIZE) count=1
$(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_VFAT_OPTS) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
# Copy bootloader and modules to EFI partition
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/*
$(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
$(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
# Delete the EFI bootloader that is NOT for the platform we're building for
$(HOST_DIR)/bin/mdel -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) \
::$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/$(ROOTFS_ISO9660_EFI_NOTNAME) || true
# Copy efigrub.cfg to EFI partition (may be used to find ISO9660 filesystem)
$(HOST_DIR)/bin/mcopy -n -o -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH) ::$(ROOTFS_ISO9660_GRUB2_EFI_PREFIX)/grub.cfg
# Remove efigrub.cfg from ISO9660 filesystem, it was just there for SED-ing
rm -f $(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(ROOTFS_ISO9660_FIX_TIME) $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
endef
# Copy the kernel to temporary filesystem
define ROOTFS_ISO9660_INSTALL_GRUB2_CONFIG
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_BOOT_MENU) \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH)
$(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_GRUB2_EFI_BOOT_MENU) \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
$(SED) "s%__EFI_ID_FILE__%$(ROOTFS_ISO9660_GRUB2_EFI_IDENT_FILE)%" \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH)
endef
endif
################################################################################
# Bootloader Configuration Installation
################################################################################
define ROOTFS_ISO9660_INSTALL_BOOTLOADER_CONFIGS
$(ROOTFS_ISO9660_INSTALL_GRUB2_CONFIG)
$(ROOTFS_ISO9660_INSTALL_ISOLINUX_CONFIG)
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_INSTALL_BOOTLOADER_CONFIGS
################################################################################
# Initrd Handling
################################################################################
define ROOTFS_ISO9660_COPY_KERNEL
$(INSTALL) -D -m 0644 $(LINUX_IMAGE_PATH) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/$(LINUX_IMAGE_NAME)
endef
ifeq ($(ROOTFS_ISO9660_USE_INITRD),YES)
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_KERNEL
# If initramfs is used, disable loading the initrd as the rootfs is
# already inside the kernel image. Otherwise, make sure a cpio is
# generated and use it as the initrd.
ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
else
ROOTFS_ISO9660_DEPENDENCIES += rootfs-cpio
define ROOTFS_ISO9660_COPY_INITRD
define ROOTFS_ISO9660_ENABLE_EXTERNAL_INITRD
$(INSTALL) -D -m 0644 $(BINARIES_DIR)/rootfs.cpio$(ROOTFS_CPIO_COMPRESS_EXT) \
$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/initrd
$(SED) "s%__INITRD_PATH__%/boot/initrd%" \
$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
$(if $(ROOTFS_ISO9660_GRUB2_CONFIG_PATH), \
$(SED) "s%__INITRD_PATH__%/boot/initrd%" \
$(ROOTFS_ISO9660_GRUB2_CONFIG_PATH))
$(if $(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH), \
$(SED) "s%__INITRD_PATH__%/boot/initrd%" \
$(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH))
$(if $(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH), \
$(SED) "s%__INITRD_PATH__%/boot/initrd%" \
$(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH))
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_INITRD
define ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
$(if $(ROOTFS_ISO9660_GRUB2_CONFIG_PATH), \
$(SED) '/__INITRD_PATH__/d' $(ROOTFS_ISO9660_GRUB2_CONFIG_PATH))
$(if $(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH), \
$(SED) '/__INITRD_PATH__/d' $(ROOTFS_ISO9660_GRUB2_EFI_CONFIG_PATH))
$(if $(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH), \
$(SED) '/append[[:space:]]*initrd=__INITRD_PATH__[[:space:]]*$$/d' $(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH) && \
$(SED) 's/initrd=__INITRD_PATH__[[:space:]]*//' $(ROOTFS_ISO9660_ISOLINUX_CONFIG_PATH))
endef
ifeq ($(ROOTFS_ISO9660_USE_INITRD),YES)
# Copy kernel when using initrd
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_KERNEL
ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
# Initramfs is built into kernel - disable external initrd
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
else
# External initrd - copy it and update configs
ROOTFS_ISO9660_DEPENDENCIES += rootfs-cpio
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_ENABLE_EXTERNAL_INITRD
endif
else # ROOTFS_ISO9660_USE_INITRD
else # Not using initrd
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION),y)
# We must use the uncompressed kernel image
# Transparent compression requires uncompressed kernel
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_KERNEL
endif
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
endif
endif # ROOTFS_ISO9660_USE_INITRD
################################################################################
# Bootloader Installation
# This must happen last after all config files are prepared
################################################################################
ROOTFS_ISO9660_OPTS += -J -R
define ROOTFS_ISO9660_INSTALL_BOOTLOADERS
$(ROOTFS_ISO9660_INSTALL_GRUB2_BIOS)
$(ROOTFS_ISO9660_INSTALL_ISOLINUX_BIOS)
$(ROOTFS_ISO9660_INSTALL_GRUB2_EFI)
endef
ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_INSTALL_BOOTLOADERS
################################################################################
# ISO9660 Generation Options
################################################################################
ROOTFS_ISO9660_OPTS += -r -J -joliet-long -cache-inodes -V 'ISO9660'
ROOTFS_ISO9660_OPTS_BIOS = \
-b $(ROOTFS_ISO9660_BOOT_IMAGE) \
@@ -169,29 +386,59 @@ ROOTFS_ISO9660_OPTS_EFI = \
--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \
-no-emul-boot
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
ROOTFS_ISO9660_OPTS += -c isolinux/boot.cat
else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BOTH),y)
ROOTFS_ISO9660_OPTS += -c isolinux/boot.cat
endif
# Determine which boot options to use
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
# Both BIOS and EFI
ROOTFS_ISO9660_OPTS += \
$(ROOTFS_ISO9660_OPTS_BIOS) \
-eltorito-alt-boot \
$(ROOTFS_ISO9660_OPTS_EFI)
else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
# BIOS only
ROOTFS_ISO9660_OPTS += $(ROOTFS_ISO9660_OPTS_BIOS)
else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
# EFI only
ROOTFS_ISO9660_OPTS += $(ROOTFS_ISO9660_OPTS_EFI)
endif
################################################################################
# Hybrid Image Support (USB bootable)
################################################################################
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_HYBRID),y)
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BOTH),y)
ROOTFS_ISO9660_OPTS += \
-isohybrid-mbr $(HOST_DIR)/share/syslinux/isohdpfx.bin \
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus
else
define ROOTFS_ISO9660_GEN_HYBRID
$(HOST_DIR)/bin/isohybrid -t 0x96 $@
endef
ROOTFS_ISO9660_POST_GEN_HOOKS += ROOTFS_ISO9660_GEN_HYBRID
endif
endif
################################################################################
# ISO9660 Image Generation
################################################################################
define ROOTFS_ISO9660_CMD
$(HOST_DIR)/bin/xorriso -as mkisofs \
$(ROOTFS_ISO9660_OPTS) \
-o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR)
endef
ifeq ($(BR2_TARGET_ROOTFS_ISO9660_HYBRID),y)
define ROOTFS_ISO9660_GEN_HYBRID
$(HOST_DIR)/bin/isohybrid -t 0x96 $@
endef
ROOTFS_ISO9660_POST_GEN_HOOKS += ROOTFS_ISO9660_GEN_HYBRID
endif
################################################################################
# Register filesystem
################################################################################
$(eval $(rootfs))

View File

@@ -1,5 +1,15 @@
default 1
label 1
kernel __KERNEL_PATH__
initrd __INITRD_PATH__
append root=/dev/sr0
default menu.c32
prompt 0
timeout 50
menu title ShredOS
label shredos
menu label ShredOS
kernel __KERNEL_PATH__
append initrd=__INITRD_PATH__ console=tty3 loglevel=3
label shredos-nomodeset
menu label ShredOS (nomodeset)
kernel __KERNEL_PATH__
append initrd=__INITRD_PATH__ console=tty3 loglevel=3 nomodeset