iso9660.mk 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ################################################################################
  2. #
  3. # Build the iso96600 root filesystem image
  4. #
  5. ################################################################################
  6. #
  7. # We need to handle three cases:
  8. #
  9. # 1. The ISO9660 filesystem will really be the real root filesystem
  10. # itself. This is when BR2_TARGET_ROOTFS_ISO9660_INITRD is
  11. # disabled.
  12. #
  13. # 2. The ISO9660 filesystem will be a filesystem with just a kernel
  14. # image, initrd and grub. This is when
  15. # BR2_TARGET_ROOTFS_ISO9660_INITRD is enabled, but
  16. # BR2_TARGET_ROOTFS_INITRAMFS is disabled.
  17. #
  18. # 3. The ISO9660 filesystem will be a filesystem with just a kernel
  19. # image and grub. This is like (2), except that the initrd is
  20. # built into the kernel image. This is when
  21. # BR2_TARGET_ROOTFS_INITRAMFS is enabled (regardless of the value
  22. # of BR2_TARGET_ROOTFS_ISO9660_INITRD).
  23. ROOTFS_ISO9660_BOOT_MENU = $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU))
  24. ROOTFS_ISO9660_DEPENDENCIES = host-cdrkit linux
  25. ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
  26. ROOTFS_ISO9660_USE_INITRD = YES
  27. endif
  28. ifeq ($(BR2_TARGET_ROOTFS_ISO9660_INITRD),y)
  29. ROOTFS_ISO9660_USE_INITRD = YES
  30. endif
  31. ifeq ($(ROOTFS_ISO9660_USE_INITRD),YES)
  32. ROOTFS_ISO9660_TMP_TARGET_DIR = $(FS_DIR)/rootfs.iso9660.tmp
  33. define ROOTFS_ISO9660_CREATE_TEMPDIR
  34. $(RM) -rf $(ROOTFS_ISO9660_TMP_TARGET_DIR)
  35. mkdir -p $(ROOTFS_ISO9660_TMP_TARGET_DIR)
  36. endef
  37. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_CREATE_TEMPDIR
  38. else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION),y)
  39. ROOTFS_ISO9660_DEPENDENCIES += host-zisofs-tools
  40. ROOTFS_ISO9660_TMP_TARGET_DIR = $(FS_DIR)/rootfs.iso9660.tmp
  41. # This must be early, before we copy the bootloader files.
  42. define ROOTFS_ISO9660_MKZFTREE
  43. $(RM) -rf $(ROOTFS_ISO9660_TMP_TARGET_DIR)
  44. $(HOST_DIR)/bin/mkzftree -X -z 9 -p $(PARALLEL_JOBS) \
  45. $(TARGET_DIR) \
  46. $(ROOTFS_ISO9660_TMP_TARGET_DIR)
  47. endef
  48. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_MKZFTREE
  49. ROOTFS_ISO9660_GENISOIMAGE_OPTS += -z
  50. else
  51. ROOTFS_ISO9660_TMP_TARGET_DIR = $(TARGET_DIR)
  52. endif
  53. ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2),y)
  54. ROOTFS_ISO9660_DEPENDENCIES += grub2
  55. ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
  56. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
  57. ROOTFS_ISO9660_BOOT_IMAGE = boot/grub/grub-eltorito.img
  58. define ROOTFS_ISO9660_INSTALL_BOOTLOADER
  59. $(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \
  60. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img
  61. endef
  62. else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
  63. ROOTFS_ISO9660_DEPENDENCIES += syslinux
  64. ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
  65. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
  66. ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin
  67. define ROOTFS_ISO9660_INSTALL_BOOTLOADER
  68. $(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \
  69. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/
  70. $(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
  71. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/ldlinux.c32
  72. endef
  73. endif
  74. define ROOTFS_ISO9660_PREPARATION
  75. $(INSTALL) -D -m 0644 $(ROOTFS_ISO9660_BOOT_MENU) \
  76. $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
  77. $(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
  78. $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
  79. $(ROOTFS_ISO9660_INSTALL_BOOTLOADER)
  80. endef
  81. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_PREPARATION
  82. define ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
  83. $(SED) '/__INITRD_PATH__/d' $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
  84. endef
  85. # Copy the kernel to temporary filesystem
  86. define ROOTFS_ISO9660_COPY_KERNEL
  87. $(INSTALL) -D -m 0644 $(LINUX_IMAGE_PATH) \
  88. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/$(LINUX_IMAGE_NAME)
  89. endef
  90. ifeq ($(ROOTFS_ISO9660_USE_INITRD),YES)
  91. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_KERNEL
  92. # If initramfs is used, disable loading the initrd as the rootfs is
  93. # already inside the kernel image. Otherwise, make sure a cpio is
  94. # generated and use it as the initrd.
  95. ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
  96. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
  97. else
  98. ROOTFS_ISO9660_DEPENDENCIES += rootfs-cpio
  99. define ROOTFS_ISO9660_COPY_INITRD
  100. $(INSTALL) -D -m 0644 $(BINARIES_DIR)/rootfs.cpio$(ROOTFS_CPIO_COMPRESS_EXT) \
  101. $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/initrd
  102. $(SED) "s%__INITRD_PATH__%/boot/initrd%" \
  103. $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
  104. endef
  105. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_INITRD
  106. endif
  107. else # ROOTFS_ISO9660_USE_INITRD
  108. ifeq ($(BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION),y)
  109. # We must use the uncompressed kernel image
  110. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_COPY_KERNEL
  111. endif
  112. ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD
  113. endif # ROOTFS_ISO9660_USE_INITRD
  114. define ROOTFS_ISO9660_CMD
  115. $(HOST_DIR)/bin/genisoimage -J -R -b $(ROOTFS_ISO9660_BOOT_IMAGE) \
  116. -no-emul-boot -boot-load-size 4 -boot-info-table \
  117. $(ROOTFS_ISO9660_GENISOIMAGE_OPTS) \
  118. -o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR)
  119. endef
  120. ifeq ($(BR2_TARGET_ROOTFS_ISO9660_HYBRID),y)
  121. define ROOTFS_ISO9660_GEN_HYBRID
  122. $(HOST_DIR)/bin/isohybrid -t 0x96 $@
  123. endef
  124. ROOTFS_ISO9660_POST_GEN_HOOKS += ROOTFS_ISO9660_GEN_HYBRID
  125. endif
  126. $(eval $(rootfs))