Build environment for making Devuan installer ISOs for i386 and amd64.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
4.2 KiB

  1. # Makefile fragment for preparing an EFI boot into build/${ARCH}/efi
  2. # and installing into
  3. # a FAT disk image = ${ISOTREE}/boot/efi.img
  4. # a GRUB boot config = ${ISOTREE}/boot/grub/${ARCH}/grub.cfg
  5. #
  6. # Note: EFI boot set up is the same for all ISO's within an architecture
  7. # Relative path for the boot loader, used by xorriso
  8. EFIGRUB = /boot/grub
  9. EGTHEME = beowulf.theme
  10. EFIGRUBS = grub.cfg font.pf2 efi.img themes/${EGTHEME}
  11. EFIIMG = ${EFIGRUB}/efi.img
  12. ${warning ${ISOTREE}${EFIGRUB}/}
  13. # Define a work area for boot partition packaging
  14. ifeq (${ARCH},i386)
  15. FMT = i386-efi
  16. EFI = bootia32.efi
  17. else ifeq (${ARCH},amd64)
  18. FMT = x86_64-efi
  19. EFI = bootx64.efi
  20. else
  21. $(error "unknown EFI architecture ${ARCH}")
  22. endif
  23. # Temporary directory for packaging the boot loader config file
  24. WORK = build/${ARCH}/efi
  25. # Path for the boot loader configuration file, which must be named "grub.cfg"
  26. EFILOAD = /boot/grub
  27. EFILOADCFG = ${WORK}${EFILOAD}/grub.cfg
  28. EFILOADTAR = ${WORK}/grubloader.tar
  29. EFILOADBIN = ${WORK}/grubloader.bin
  30. # Prepare the efi grub config which is included in the efi boot bin-file
  31. #.INTERMEDIATE: ${EFILOADCFG} | ${dir ${EFILOADCFG}}
  32. ${EFILOADCFG}: ${dir ${EFILOADCFG}}
  33. echo 'search --file --set=root /.disk/info' > $@
  34. echo 'set prefix=($$root)${EFIGRUB}' >> $@
  35. echo 'source $$prefix/${FMT}/grub.cfg' >> $@
  36. #.INTERMEDIATE: ${EFILOADTAR}
  37. ${EFILOADTAR}: ROOT = ${word 1,${subst /, ,${EFILOAD}}}
  38. ${EFILOADTAR}: ${EFILOADCFG} | ${dir ${EFILOADTAR}}
  39. tar cf $@ -C ${WORK} ${ROOT}
  40. # Prepare the grub boot loader in work area
  41. #.INTERMEDIATE: ${EFILOADBIN}
  42. ${EFILOADBIN}: ${EFILOADTAR} | ${dir ${EFILOADBIN}}
  43. grub-mkimage -O ${FMT} -m $< -o $@ -p '(memdisk)${EFILOAD}' \
  44. search iso9660 configfile normal memdisk tar part_msdos part_gpt fat
  45. # Compute FAT size from grubby master rounded up as the size of a
  46. # number of 32k blocks
  47. GRUBBINSZ = $(shell stat -c %s "${EFILOADBIN}")
  48. FATSZ = $(shell echo $$(( ( ( $(GRUBBINSZ) / 32768 + 2 ) * 32) )) )
  49. # Pick grub font
  50. ${ISOTREE}${EFIGRUB}/font.pf2: /usr/share/grub/ascii.pf2
  51. @cp $< $@
  52. # Pack the boot loader into a FAT partition in the work area
  53. ${ISOTREE}${EFIGRUB}/efi.img: ${EFILOADBIN} | ${ISOTREE}${EFIGRUB}/
  54. /sbin/mkfs.msdos -v -C "$@" ${FATSZ}
  55. mmd -i "$@" ::efi
  56. mmd -i "$@" ::efi/boot
  57. mcopy -i "$@" "${EFILOADBIN}" "::efi/boot/${EFI}"
  58. # Generic rules for populating target ${EFIGRUB} from templates
  59. ${ISOTREE}${EFIGRUB}/themes/${EGTHEME}: | ${ISOTREE}${EFIGRUB}/themes/
  60. ${ISOTREE}${EFIGRUB}/themes/${EGTHEME}: boot/grub/${EGTHEME}.tmpl
  61. env KERNEL=${KERNEL} INITRD=${INITRD} VIDEO_MODE="vga=788 nomodeset" \
  62. envsubst '$$KERNEL $$INITRD $$VIDEO_MODE' < $< > $@
  63. ${ISOTREE}${EFIGRUB}/%: boot/grub/%.tmpl | ${ISOTREE}${EFIGRUB}/
  64. env KERNEL=${KERNEL} INITRD=${INITRD} VIDEO_MODE="vga=788 nomodeset" \
  65. envsubst '$$KERNEL $$INITRD $$VIDEO_MODE' < $< > $@
  66. # Handle grub modules (.mod and .lst files)
  67. GRUBMODSRCDIR = /usr/lib/grub/${FMT}
  68. GRUBMODDSTDIR = ${ISOTREE}${EFIGRUB}/${FMT}
  69. GRUBMOD_LOAD = ${patsubst %.mod,%,${filter part_%.mod,${GRUBMODS}}}
  70. # grub module files to install
  71. GRUBMODS = ${sort ${notdir ${wildcard ${GRUBMODSRCDIR}/*.mod}}}
  72. GRUBMODSKIP = configfile fshelp iso9660 memdisk
  73. GRUBMODSKIP += search search_fs_file search_fs_uuid search_label tar
  74. GRUBMODSKIP += affs afs afs_be befs befs_be minix nilfs2 sfs zfs zfsinfo
  75. GRUBMODSKIP += example_functional_test functional_test hello
  76. GRUBMOD_INSTALL = ${filter-out ${addsuffix .mod,${GRUBMODSKIP}},${GRUBMODS}}
  77. GRUBMOD_INSTALL += ${sort ${notdir ${wildcard ${GRUBMODSRCDIR}/*.lst}}}
  78. # install a grub .lst file
  79. ${GRUBMODDSTDIR}/%.lst: ${GRUBMODSRCDIR}/%.lst | ${GRUBMODDSTDIR}/
  80. @cp $< $@
  81. # install a grub .mod file
  82. ${GRUBMODDSTDIR}/%.mod: ${GRUBMODSRCDIR}/%.mod | ${GRUBMODDSTDIR}/
  83. @cp $< $@
  84. # prepare a grub.cfg file for module dir
  85. ${GRUBMODDSTDIR}/grub.cfg: ${GRUBMODDSTDIR}/
  86. for i in ${GRUBMOD_LOAD} ; do echo "insmod $${i%.mod}" ; done > $@
  87. echo 'source $$prefix/grub.cfg' >> $@
  88. # EFI boot with grub needs a FAT and grub modules in the output tree
  89. .PHONY: boot-efi-grub
  90. boot-efi-grub: ${addprefix ${ISOTREE}${EFIGRUB}/,${EFIGRUBS}}
  91. boot-efi-grub: ${addprefix ${GRUBMODDSTDIR}/,${GRUBMOD_INSTALL}}
  92. boot-efi-grub: ${GRUBMODDSTDIR}/grub.cfg
  93. boot-efi-grub: ${ISOTREE}${INITRD} ${ISOTREE}${KERNEL}
  94. # Install the boot option
  95. BOOTOPTIONS += boot-efi-grub