1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 ###############################################################################
21 ###############################################################################
23 ###############################################################################
30 TARGET = $(DIR_INFO)/$(THISAPP)
32 # Fail when there is an error in the tar pipe
33 SHELL=/bin/bash -o pipefail
39 ifeq "$(BUILD_PLATFORM)" "x86"
46 -A "$(NAME) $(VERSION) $(BUILD_ARCH)" \
47 -V "$(NAME) $(VERSION) $(BUILD_ARCH)"
51 ifeq "$(HAS_ISOLINUX)" "1"
56 -b boot/isolinux/isolinux.bin \
57 -c boot/isolinux/boot.catalog
63 -e boot/isolinux/efiboot.img \
66 ISOHYBRID_ARGS += --uefi
121 ISO_FILE = $(IMAGES_DIR)/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).iso
123 ###############################################################################
125 ###############################################################################
135 ###############################################################################
136 # Installation Details
137 ###############################################################################
139 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
140 # Update /etc/system-release, because the string might have changed
141 # since stage2 has been executed..
142 echo "$(SYSTEM_RELEASE)" > /etc/system-release
144 # Create a directory to authorise the CDROM in
145 rm -rf $(DIR_TMP)/cdrom && mkdir -p $(DIR_TMP)/cdrom
147 # Create the target directory
148 rm -rf $(DIR_TMP)/root && mkdir -p $(DIR_TMP)/root
150 # Copy all files that we want
151 $(call COPY_FILES,$(DIR_SRC)/config/rootfiles/common,$(DIR_TMP)/root,)
153 # Create mount points
154 $(call CREATE_MOUNTPOINTS,$(DIR_TMP)/root)
157 $(call COMPRESS_ZSTD,$(DIR_TMP)/root,$(DIR_TMP)/cdrom/distro.img)
159 # Remove the raw files
160 rm -rf $(DIR_TMP)/root
163 touch $(DIR_TMP)/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
164 sed 's/VERSION/$(VERSION)/' $(DIR_SRC)/config/cdrom/README.txt > $(DIR_TMP)/cdrom/README.txt
165 cp $(DIR_SRC)/doc/COPYING $(DIR_TMP)/cdrom/
167 mkdir -p $(DIR_TMP)/cdrom/boot/isolinux
169 cp /boot/vmlinuz-$(KVER) $(DIR_TMP)/cdrom/boot/isolinux/vmlinuz
170 dracut --force -a "installer" --strip $(DIR_TMP)/cdrom/boot/isolinux/instroot $(KVER)
172 ifeq "$(HAS_ISOLINUX)" "1"
173 dd if=/dev/zero bs=1k count=2 > $(DIR_TMP)/cdrom/boot/isolinux/boot.catalog
174 cp $(DIR_SRC)/config/syslinux/boot.png $(DIR_TMP)/cdrom/boot/isolinux/boot.png
175 cp /usr/share/syslinux/isolinux.bin $(DIR_TMP)/cdrom/boot/isolinux/isolinux.bin
176 cp /usr/share/hwdata/pci.ids $(DIR_TMP)/cdrom/boot/isolinux/pci.ids
177 cp -vf /usr/share/syslinux/*.c32 $(DIR_TMP)/cdrom/boot/isolinux/
178 sed -e "s/VERSION/$(VERSION) - Core $(CORE)/g" \
179 $(DIR_SRC)/config/syslinux/syslinux.cfg \
180 > $(DIR_TMP)/cdrom/boot/isolinux/isolinux.cfg
183 ifeq "$(HAS_MEMTEST)" "1"
185 cp /usr/lib/memtest86+/memtest.efi $(DIR_TMP)/cdrom/boot/isolinux/memtest
188 ifeq "$(HAS_IPXE)" "1"
189 cp /usr/share/ipfire-netboot/ipxe.lkrn $(DIR_TMP)/cdrom/boot/isolinux/netboot
193 # Generate embedded GRUB configuration
194 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
195 $(DIR_SRC)/config/cdrom/grub-efi.cfg > /tmp/grub-efi.cfg
197 # Build a GRUB EFI image
198 mkdir -pv $(DIR_TMP)/cdrom/EFI/BOOT
200 --format=$(GRUB_ARCH)-efi \
201 --output=$(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
202 --config=$(DIR_TMP)/grub-efi.cfg \
205 $$(for mod in $(GRUB_EFI_MODULES); do [ -f "/usr/lib/grub/$(GRUB_ARCH)-efi/$${mod}.mod" ] && echo "$${mod}"; done)
207 # Install GRUB configuration
208 mkdir -pv $(DIR_TMP)/cdrom/EFI/BOOT
209 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
210 < $(DIR_SRC)/config/cdrom/grub.cfg > $(DIR_TMP)/cdrom/EFI/BOOT/grub.cfg
212 # Create the EFI Eltorito image
213 dd if=/dev/zero of=$(DIR_TMP)/cdrom/boot/isolinux/efiboot.img bs=1k count=2880
214 mkdosfs -F 12 -n "IPFIRE_EFI" $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img
216 # Mount the EFI image
217 mkdir -pv $(DIR_TMP)/efiboot.img
218 mount -o loop $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img $(DIR_TMP)/efiboot.img
220 # Copy the bootloader into the image
221 mkdir -p $(DIR_TMP)/efiboot.img/EFI/BOOT
222 cp -a $(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
223 $(DIR_TMP)/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
226 umount $(DIR_TMP)/efiboot.img
227 rm -rf $(DIR_TMP)/efiboot.img $(DIR_TMP)/grub-efi.cfg
230 cd $(DIR_TMP)/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
231 xargs md5sum > md5sum.txt
233 # Master the ISO file
234 cd $(DIR_TMP)/cdrom && mkisofs $(ISO_ARGS) -o $(ISO_FILE) .
236 ifeq "$(HAS_ISOLINUX)" "1"
237 isohybrid $(ISOHYBRID_ARGS) $(ISO_FILE)
240 # Create checksum file
241 cd $(IMAGES_DIR) && b2sum "$(notdir $(ISO_FILE))" > "$(notdir $(ISO_FILE)).b2"