]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - lfs/cdrom
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / lfs / cdrom
index 8c0eb1bc01bc1df5e698f38e600c5fbcc87132f6..fed69f171539731ebdabf381ae499af3ce5d68a5 100644 (file)
--- a/lfs/cdrom
+++ b/lfs/cdrom
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2013  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2021  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -29,14 +29,96 @@ VER = ipfire
 THISAPP    = cdrom
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(BUILD_PLATFORM)" "arm"
-       TAR_OPTIONS =
-else
-       TAR_OPTIONS = --xz
+# Fail when there is an error in the tar pipe
+SHELL=/bin/bash -o pipefail
+
+HAS_MEMTEST = 0
+HAS_IPXE = 0
+HAS_ISOLINUX = 0
+
+ifeq "$(BUILD_PLATFORM)" "x86"
+       HAS_MEMTEST = 1
+       HAS_IPXE = 1
+       HAS_ISOLINUX = 1
+endif
+
+ISO_ARGS = -J -r -v \
+       -A "$(NAME) $(VERSION) $(BUILD_ARCH)" \
+       -V "$(NAME) $(VERSION) $(BUILD_ARCH)"
+
+ISOHYBRID_ARGS =
+
+ifeq "$(HAS_ISOLINUX)" "1"
+       ISO_ARGS += \
+               -no-emul-boot \
+               -boot-load-size 4 \
+               -boot-info-table \
+               -b boot/isolinux/isolinux.bin \
+               -c boot/isolinux/boot.catalog
 endif
 
-# Enable multi-threaded compression for LZMA
-export XZ_OPT = --threads=0 -8
+ifeq "$(EFI)" "1"
+       ISO_ARGS += \
+               -eltorito-alt-boot \
+               -e boot/isolinux/efiboot.img \
+               -no-emul-boot
+
+       ISOHYBRID_ARGS += --uefi
+endif
+
+GRUB_EFI_MODULES = \
+       all_video \
+       at_keyboard \
+       boot \
+       bitmap_scale \
+       cat \
+       chain \
+       configfile \
+       disk \
+       echo \
+       efi_gop \
+       efi_uga \
+       ext2 \
+       extcmd \
+       fat \
+       file \
+       font \
+       fxterm_menu \
+       gfxterm \
+       gfxmenu \
+       gfxterm_background \
+       gzio \
+       halt \
+       help \
+       iso9660 \
+       jpeg \
+       loadbios \
+       loadenv \
+       loopback \
+       linux \
+       ls \
+       memdisk \
+       minicmd \
+       nativedisk \
+       normal \
+       ntfs \
+       part_gpt \
+       part_msdos \
+       png \
+       probe \
+       reboot \
+       regexp \
+       search \
+       search_fs_file \
+       search_fs_uuid \
+       search_label \
+       tar \
+       test \
+       tga \
+       true \
+       usb_keyboard
+
+ISO_FILE = /install/images/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).iso
 
 ###############################################################################
 # Top-level Rules
@@ -48,7 +130,7 @@ check :
 
 download :
 
-md5 :
+b2 :
 
 ###############################################################################
 # Installation Details
@@ -59,62 +141,108 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # since stage2 has been executed..
        echo "$(SYSTEM_RELEASE)" > /etc/system-release
 
-       rm -rf /install/cdrom /tmp/*
-       mkdir -p /install/cdrom/doc
+       # Create a directory to authorise the CDROM in
+       rm -rf $(DIR_TMP)/cdrom && mkdir -p $(DIR_TMP)/cdrom
 
        # Clear mtab (prevents .journal problems)
        rm -vf /etc/mtab
-       echo > /etc/mtab
+       ln -s /proc/self/mounts /etc/mtab
 
        # Create filelist for packaging.
        BUILDTARGET="$(BUILDTARGET)" BUILD_ARCH="$(BUILD_ARCH)" KVER="$(KVER)" \
                $(DIR_SRC)/src/scripts/archive.files \
                $(DIR_SRC)/config/rootfiles/common \
-               > /tmp/ROOTFILES
+               > $(DIR_TMP)/ROOTFILES
 
        # 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'
-       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 *
+       rm -rf $(DIR_TMP)/root && mkdir -p $(DIR_TMP)/root
+       tar $(TAR_OPTIONS) -c --exclude='#*' --exclude='proc/*' --exclude='dev/pts/*' --exclude='tmp/*' \
+               --exclude='__pycache__' \
+               -C / --files-from=$(DIR_TMP)/ROOTFILES | tar $(TAR_OPTIONS) -x -C $(DIR_TMP)/root
+       rm -f $(DIR_TMP)/ROOTFILES
+       mkdir $(DIR_TMP)/root/sys
+       cd $(DIR_TMP)/root && tar $(TAR_OPTIONS) -cf - * | zstd $(ZSTD_OPTIONS) > $(DIR_TMP)/cdrom/distro.img
+       rm -rf $(DIR_TMP)/root
 
        # Other files
-       touch /install/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
-       sed 's/VERSION/$(VERSION)/' $(DIR_SRC)/config/cdrom/README.txt > /install/cdrom/README.txt
-       cp $(DIR_SRC)/doc/COPYING                               /install/cdrom/
-       cp $(DIR_SRC)/doc/{ChangeLog,packages-list.txt} /install/cdrom/doc
-
-       # Make the ISO
-       mkdir -p /install/cdrom/boot/isolinux
-       dd if=/dev/zero  bs=1k count=2            > /install/cdrom/boot/isolinux/boot.catalog
-ifneq "$(BUILD_PLATFORM)" "arm"
-       cp /boot/vmlinuz-$(KVER)-ipfire             /install/cdrom/boot/isolinux/vmlinuz
-       dracut --force -a "installer" --strip --xz /install/cdrom/boot/isolinux/instroot $(KVER)-ipfire
-       cp $(DIR_SRC)/config/syslinux/boot.png      /install/cdrom/boot/isolinux/boot.png
-       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
-       cp /usr/share/hwdata/pci.ids                /install/cdrom/boot/isolinux/pci.ids
-       cp -vf /usr/share/syslinux/*.c32            /install/cdrom/boot/isolinux/
+       touch $(DIR_TMP)/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
+       sed 's/VERSION/$(VERSION)/' $(DIR_SRC)/config/cdrom/README.txt > $(DIR_TMP)/cdrom/README.txt
+       cp $(DIR_SRC)/doc/COPYING $(DIR_TMP)/cdrom/
+
+       # Install documentation
+       -mkdir -pv $(DIR_TMP)/cdrom/doc
+       cp $(DIR_SRC)/doc/{ChangeLog,packages-list.txt} $(DIR_TMP)/cdrom/doc
+
+       mkdir -p $(DIR_TMP)/cdrom/boot/isolinux
+
+       cp /boot/vmlinuz-$(KVER)-ipfire $(DIR_TMP)/cdrom/boot/isolinux/vmlinuz
+       dracut --force -a "installer" --strip $(DIR_TMP)/cdrom/boot/isolinux/instroot $(KVER)-ipfire
+
+ifeq "$(HAS_ISOLINUX)" "1"
+       dd if=/dev/zero  bs=1k count=2            > $(DIR_TMP)/cdrom/boot/isolinux/boot.catalog
+       cp $(DIR_SRC)/config/syslinux/boot.png      $(DIR_TMP)/cdrom/boot/isolinux/boot.png
+       cp /usr/share/syslinux/isolinux.bin         $(DIR_TMP)/cdrom/boot/isolinux/isolinux.bin
+       cp /usr/share/hwdata/pci.ids                $(DIR_TMP)/cdrom/boot/isolinux/pci.ids
+       cp -vf /usr/share/syslinux/*.c32            $(DIR_TMP)/cdrom/boot/isolinux/
        sed -e "s/VERSION/$(VERSION) - Core $(CORE)/g" \
                $(DIR_SRC)/config/syslinux/syslinux.cfg \
-               > /install/cdrom/boot/isolinux/isolinux.cfg
+               > $(DIR_TMP)/cdrom/boot/isolinux/isolinux.cfg
+endif
+
+ifeq "$(HAS_MEMTEST)" "1"
+       # Install memtest
+       cp /usr/lib/memtest86+/memtest.efi $(DIR_TMP)/cdrom/boot/isolinux/memtest
+endif
+
+ifeq "$(HAS_IPXE)" "1"
+       cp /usr/share/ipfire-netboot/ipxe.lkrn $(DIR_TMP)/cdrom/boot/isolinux/netboot
+endif
+
+ifeq "$(EFI)" "1"
+       # 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
+       mkdir -pv $(DIR_TMP)/cdrom/EFI/BOOT
+       grub-mkimage \
+               --format=$(GRUB_ARCH)-efi \
+               --output=$(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
+               --config=$(DIR_TMP)/grub-efi.cfg \
+               --compression=xz \
+               --prefix=/EFI/BOOT \
+               $$(for mod in $(GRUB_EFI_MODULES); do [ -f "/usr/lib/grub/$(GRUB_ARCH)-efi/$${mod}.mod" ] && echo "$${mod}"; done)
+
+       # Install GRUB configuration
+       mkdir -pv $(DIR_TMP)/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 > $(DIR_TMP)/cdrom/EFI/BOOT/grub.cfg
+
+       # Create the EFI Eltorito image
+       dd if=/dev/zero of=$(DIR_TMP)/cdrom/boot/isolinux/efiboot.img bs=1k count=2880
+       mkdosfs -F 12 -n "IPFIRE_EFI" $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img
+
+       # Mount the EFI image
+       mkdir -pv $(DIR_TMP)/efiboot.img
+       mount -o loop $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img $(DIR_TMP)/efiboot.img
+
+       # Copy the bootloader into the image
+       mkdir -p $(DIR_TMP)/efiboot.img/EFI/BOOT
+       cp -a $(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
+               $(DIR_TMP)/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
+
+       # Cleanup
+       umount $(DIR_TMP)/efiboot.img
+       rm -rf $(DIR_TMP)/efiboot.img $(DIR_TMP)/grub-efi.cfg
 endif
-       cd /install/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
+
+       cd $(DIR_TMP)/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
                                                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
+       cd $(DIR_TMP)/cdrom && mkisofs $(ISO_ARGS) -o $(ISO_FILE) .
+
+ifeq "$(HAS_ISOLINUX)" "1"
+       isohybrid $(ISOHYBRID_ARGS) $(ISO_FILE)
 endif