Files
reactos/boot/boot_images.cmake
Hermès Bélusca-Maïto b2e33f26eb [REACTOS] Merge our bootcd and livecd into an all-in-one ReactOS BootCD (#7313)
CORE-9069, CORE-13525, RELEASE-11

This new BootCD contains the functionality of both the original bootcd
(text-mode 1st-stage installer) and the livecd (that will include the
1st-stage GUI installer later).
Our separate livecd ISOs become obsolete, and this completely removes
the need for the so-called "hybridcd" ISO.

Some details:

- The "hybridcd" build target is completely removed, since now the new
  BootCD *is* basically what we used to call "hybridcd".

- The "livecd" build target is kept so far (to minimize the code changes),
  but internally I start to refer to it as "LiveImage", and is reduced
  to a minimum.

  A minimal non-bootable "liveimg.iso" is built (but currently not
  included within the BootCD). Its purpose will be to implement the
  "ReactOS Live" functionality as a RAMDISK.
  (We currently don't support other file formats apart from ISO and
  flat disk for a RAMDISK).

  The "ReactOS Live" (non-RAMDISK) is implemented by adding to the
  BootCD file tree the files from the LiveImage.
  These files add two root directories, "Profiles" and "reactos"
  (which is the SystemRoot for the non-ramdisk LiveImage).

- The minimal text-mode ReactOS installation used for the 1st-stage
  installer, including USETUP itself, and the executable for the
  1st-stage GUI installer and the reactos.cab (installation source),
  are moved to the root directory called "i386" (ideally, one directory
  per architecture).

- The "bootcdregtest" target, i.e. the ISOs we feed our testbots with,
  are left untouched, i.e. they are only constituted of the 1st-stage
  text-mode installation only, but placed in a per-architecture root
  directory ("i386", etc. as for the bootcd).

- Remove the ACPI APIC/SMP entries from bootcd.ini. They will be made
  available via the Advanced Boot Options F8 menu in Debug builds, for
  testing purposes only, in a subsequent commit.

This commit is based upon an older SVN one:
svn path=/branches/setup_improvements/; revision=75273
2026-04-28 23:11:10 +02:00

188 lines
10 KiB
CMake

# EFI platform ID - Used for naming the EFI boot image on supported platforms.
if(ARCH STREQUAL "i386")
if(NOT (SARCH STREQUAL "pc98" OR SARCH STREQUAL "xbox"))
set(EFI_PLATFORM_ID "ia32")
endif()
elseif(ARCH STREQUAL "amd64")
set(EFI_PLATFORM_ID "x64")
elseif(ARCH STREQUAL "ia64")
set(EFI_PLATFORM_ID "ia64")
elseif(ARCH STREQUAL "arm")
set(EFI_PLATFORM_ID "arm")
elseif(ARCH STREQUAL "arm64")
set(EFI_PLATFORM_ID "aa64")
else()
message(FATAL_ERROR "Unknown ARCH '" ${ARCH} "', cannot generate a valid UEFI boot image filename.")
endif()
## efisys.bin
if(DEFINED EFI_PLATFORM_ID)
add_custom_target(efisys
COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT
-boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin
-mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:uefildr> EFI/BOOT/boot${EFI_PLATFORM_ID}.efi
DEPENDS native-fatten fat uefildr
VERBATIM)
endif()
# Create an 'empty' directory (guaranteed to be empty) to be able to add
# arbitrary empty directories to the ISO image using mkisofs.
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty)
# Retrieve the full paths to the generated files of the 'isombr', 'isoboot', 'isobtrt' and 'efisys' targets
set(_isombr_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isombr.bin) # get_target_property(_isombr_file isombr LOCATION)
set(_isoboot_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin) # get_target_property(_isoboot_file isoboot LOCATION)
set(_isobtrt_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin) # get_target_property(_isobtrt_file isobtrt LOCATION)
if(DEFINED EFI_PLATFORM_ID)
set(_efisys_file ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin) # get_target_property(_efisys_file efisys LOCATION)
endif()
# Create an mkisofs sort file that defines an explicit ordering to place the
# boot files at the beginning of the ISO image, making its analysis easier.
# See mkisofs/schilytools/mkisofs/README.sort for more details.
#
# As the default file sort weight is '0', give the boot files sort weights >= 1.
# Note that, sadly, '-sort' does not work using grafted points. As a result, we
# need in particular to use the boot catalog file "path" that mkisofs expects.
# Indeed, the boot catalog file name is appended to the first host-system path
# listed in the file list (whatever it is), and this does not work well if the
# first item is a graft point, especially if it's a file and not a directory.
#
# To fix that, the trick is to use, as the first file item, the empty directory
# created earlier. This ensures that:
# - the boot catalog file path is meaningful;
# - since its contents are included by mkisofs at the root of the ISO image,
# using the empty directory ensures that no extra unwanted files are added.
#
set(ISO_SORT_FILE_DATA "\
${CMAKE_CURRENT_BINARY_DIR}/empty/boot.catalog 4
${_isoboot_file} 3
${_isobtrt_file} 2
")
if(DEFINED EFI_PLATFORM_ID)
string(APPEND ISO_SORT_FILE_DATA "${_efisys_file} 1\n")
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort ${ISO_SORT_FILE_DATA})
# ISO image identifier names
set(ISO_MANUFACTURER "ReactOS Project") # For both the publisher and the preparer
set(ISO_VOLNAME "ReactOS") # For both the Volume ID and the Volume set ID
# ISO image options
set(ISO_COMMON_OPTIONS
-iso-level 4 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME})
set(ISO_LAYOUT_OPTIONS
-duplicates-once -no-cache-inodes -graft-points)
# Boot catalog and sorting files options
set(ISO_BOOT_FILES_OPTIONS
-hide boot.catalog -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort)
## "El Torito" ISO boot options
# ISO_BOOT_OPTIONS; ISO_BOOT_OPTIONS_REGTEST (only for BootCDRegTest)
# BIOS-based PC boot entry (x86/x64 only)
if(ARCH STREQUAL "i386" OR ARCH STREQUAL "amd64")
set(ISO_BOOT_OPTIONS
-eltorito-platform x86 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4)
set(ISO_BOOT_OPTIONS_REGTEST
-eltorito-platform x86 -eltorito-boot loader/isobtrt.bin -no-emul-boot -boot-load-size 4)
endif()
# EFI boot entry
if(DEFINED EFI_PLATFORM_ID)
set(ISO_BOOT_EFI_OPTIONS
-eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot)
if(DEFINED ISO_BOOT_OPTIONS)
list(APPEND ISO_BOOT_OPTIONS -eltorito-alt-boot)
list(APPEND ISO_BOOT_OPTIONS_REGTEST -eltorito-alt-boot)
endif()
list(APPEND ISO_BOOT_OPTIONS ${ISO_BOOT_EFI_OPTIONS})
list(APPEND ISO_BOOT_OPTIONS_REGTEST ${ISO_BOOT_EFI_OPTIONS})
endif()
# Create user profile directories in the LiveImage
function(add_allusers_profile_dirs _image_filelist _rootdir)
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Music=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Pictures=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Videos=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/My Documents=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Start Menu/Programs/StartUp=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/All Users/Templates=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
endfunction()
function(add_user_profile_dirs _image_filelist _rootdir _username)
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Application Data/Microsoft/Internet Explorer/Quick Launch=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Cookies=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Desktop=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/History=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/Temporary Internet Files=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Music=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Pictures=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Videos=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/NetHood=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/PrintHood=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Recent=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/SendTo=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs/Administrative Tools=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs/StartUp=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Templates=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
endfunction()
## BootCD
# Create the file list
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
add_custom_target(bootcd
COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/bootcd.iso
${ISO_COMMON_OPTIONS} ${ISO_BOOT_OPTIONS} ${ISO_BOOT_FILES_OPTIONS} ${ISO_LAYOUT_OPTIONS}
-path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcd.$<CONFIG>.lst
COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/bootcd.iso
DEPENDS isombr native-isohybrid native-mkisofs livecd
VERBATIM)
## BootCDRegTest
# Create the file list
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
add_custom_target(bootcdregtest
COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/bootcdregtest.iso
${ISO_COMMON_OPTIONS} ${ISO_BOOT_OPTIONS_REGTEST} ${ISO_BOOT_FILES_OPTIONS} ${ISO_LAYOUT_OPTIONS}
-path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.$<CONFIG>.lst
COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/bootcdregtest.iso
DEPENDS isombr native-isohybrid native-mkisofs
VERBATIM)
## LiveImage -- Constitutes a small RAMDISK ISO, and is also merged with the BootCD
# Create the file list
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
# Create TEMP directory
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "reactos/TEMP=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
# Create user profile directories
add_allusers_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "Profiles")
add_user_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "Profiles" "Default User")
add_custom_target(livecd
COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/liveimg.iso
${ISO_COMMON_OPTIONS} ${ISO_LAYOUT_OPTIONS}
-path-list ${CMAKE_CURRENT_BINARY_DIR}/livecd.$<CONFIG>.lst
DEPENDS native-mkisofs
VERBATIM)
if(DEFINED EFI_PLATFORM_ID)
# For devices such as USB drives, add also the EFI boot image into efi/boot.
add_cd_file(TARGET efisys FILE ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin DESTINATION loader NO_CAB FOR bootcd regtest)
add_cd_file(TARGET uefildr DESTINATION efi/boot NO_CAB NAME_ON_CD boot${EFI_PLATFORM_ID}.efi FOR bootcd regtest)
endif()