]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - lfs/cdrom
cdrom: Add grub.cfg that allows to install IPFire
[ipfire-2.x.git] / lfs / cdrom
index 7a7fff166d752c051e76e22477858314cb9fd2fb..08cbcb772d416263762d8219bdf6fc36bee75523 100644 (file)
--- a/lfs/cdrom
+++ b/lfs/cdrom
@@ -32,11 +32,32 @@ TARGET     = $(DIR_INFO)/$(THISAPP)
 ifeq "$(BUILD_PLATFORM)" "arm"
        TAR_OPTIONS =
 else
-       TAR_OPTIONS = --xz
+       TAR_OPTIONS = --lzma
 endif
 
-# Enable multi-threaded compression for LZMA
-export XZ_OPT = --threads=0
+ISO_ARGS = -J -r -v \
+       -A "$(NAME) $(VERSION) $(BUILD_ARCH)" \
+       -V "$(NAME) $(VERSION) $(BUILD_ARCH)" \
+       -no-emul-boot \
+       -boot-load-size 4 \
+       -boot-info-table \
+       -b boot/isolinux/isolinux.bin \
+       -c boot/isolinux/boot.catalog
+
+# Only build a stub ISO for ARM
+ifeq "$(BUILD_PLATFORM)" "arm"
+       ISO_ARGS = -J -r -V "$(NAME) $(VERSION) $(BUILD_ARCH)"
+endif
+
+ISOHYBRID_ARGS =
+
+ifeq "$(EFI)" "1"
+       ISO_ARGS += \
+               -eltorito-alt-boot \
+               -e boot/isolinux/efiboot.img
+
+       ISOHYBRID_ARGS += --uefi
+endif
 
 ###############################################################################
 # Top-level Rules
@@ -74,14 +95,13 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 
        # Compress root filesystem
        # Reason for this tar+untar+tar is removing of entries listed two or more in src/ROOTFILES
-       tar -c -C / --files-from=/tmp/ROOTFILES \
-               -f /$(SNAME).tar --exclude='#*' --exclude='dev/pts/*' \
-               --exclude='proc/*' --exclude='tmp/ROOTFILES'
+       tar -c --exclude='#*' --exclude='proc/*' --exclude='dev/pts/*' --exclude='tmp/ROOTFILES' \
+               -C / --files-from=/tmp/ROOTFILES -f /$(SNAME).tar
        rm -f /tmp/ROOTFILES
        tar -x -C /tmp -f /$(SNAME).tar
        rm -f /$(SNAME).tar
        @mkdir /tmp/sys
-       cd /tmp && tar  cf /install/cdrom/distro.img $(TAR_OPTIONS) * && rm -rf *
+       cd /tmp && tar cf - * | xz $(XZ_OPT) > /install/cdrom/distro.img && rm -rf *
 
        # Other files
        touch /install/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
@@ -99,6 +119,43 @@ ifneq "$(BUILD_PLATFORM)" "arm"
        cp /usr/lib/memtest86+/memtest.bin          /install/cdrom/boot/isolinux/memtest
        cp /usr/share/ipfire-netboot/ipxe.lkrn      /install/cdrom/boot/isolinux/netboot
        cp /usr/share/syslinux/isolinux.bin         /install/cdrom/boot/isolinux/isolinux.bin
+
+ifeq "$(EFI)" "1"
+       # Create the EFI Eltorito image
+       dd if=/dev/zero of=/install/cdrom/boot/isolinux/efiboot.img bs=1k count=1440
+       mkdosfs -F 12 -n "IPFIRE_EFI" /install/cdrom/boot/isolinux/efiboot.img
+
+       # Generate embedded GRUB configuration
+       sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
+               $(DIR_SRC)/config/cdrom/grub-efi.cfg > /tmp/grub-efi.cfg
+
+       # Build a GRUB EFI image
+       grub-mkimage \
+               --format=$(BUILD_ARCH)-efi \
+               --output=/tmp/boot$(EFI_ARCH).efi \
+               --config=/tmp/grub-efi.cfg \
+               --compression=xz \
+               --prefix=/EFI/BOOT \
+               $(GRUB_EFI_MODULES)
+
+       # Mount the EFI image
+       mkdir -pv /install/efiboot.img
+       mount -o loop /install/cdrom/boot/isolinux/efiboot.img /install/efiboot.img
+
+       # Copy the bootloader into the image
+       mkdir -pv /install/efiboot.img/EFI/BOOT
+       cp -a /tmp/boot$(EFI_ARCH).efi /install/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
+
+       # Cleanup
+       umount /install/efiboot.img
+       rm -rf /install/efiboot.img /tmp/boot$(EFI_ARCH).efi /tmp/grub-efi.cfg
+
+       # Install GRUB configuration
+       mkdir -pv /install/cdrom/EFI/BOOT
+       sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
+               < $(DIR_SRC)/config/cdrom/grub.cfg > /install/cdrom/EFI/BOOT/grub.cfg
+endif
+
        cp /usr/share/hwdata/pci.ids                /install/cdrom/boot/isolinux/pci.ids
        cp -vf /usr/share/syslinux/*.c32            /install/cdrom/boot/isolinux/
        sed -e "s/VERSION/$(VERSION) - Core $(CORE)/g" \
@@ -109,12 +166,7 @@ endif
                                                xargs md5sum > md5sum.txt
 
        mkdir -p /install/images
-ifeq "$(BUILD_PLATFORM)" "arm"
-       cd /install/cdrom && mkisofs -J -r -V "$(NAME)_$(VERSION)" \
-               . > /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
-else
-       cd /install/cdrom && mkisofs -J -r -V "$(NAME)_$(VERSION)" \
-           -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
-           -c boot/isolinux/boot.catalog . > /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
-       isohybrid /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
-endif
+       cd /install/cdrom && mkisofs $(ISO_ARGS) \
+               -o /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso .
+
+       isohybrid $(ISOHYBRID_ARGS) /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso