mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
Initial list of changes required to build iso and flash image successfully: 1 softwares require config.guess and config.stub update with loongarch support 2 no rust build and no suricata which depends on rust 3 comment out python 3.10 lib-dynload and config-3.10-xxxMACHINExxx-linux-gnu 4 lfs/cdrom lfs/Config loongarch seems requiring capital EFI boot image name to boot properly 5 comment out a few softwares that are not needed for now iso can be installed to loongarch PC hard drive, but fail to boot. flash image can be dd to USB drive, then boot loongarch PC from USB drive, then dd from USB drive to loongarch PC hard drive Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
242 lines
7.0 KiB
Plaintext
242 lines
7.0 KiB
Plaintext
###############################################################################
|
|
# #
|
|
# IPFire.org - A linux based firewall #
|
|
# 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 #
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
# (at your option) any later version. #
|
|
# #
|
|
# This program is distributed in the hope that it will be useful, #
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
# GNU General Public License for more details. #
|
|
# #
|
|
# You should have received a copy of the GNU General Public License #
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
|
# #
|
|
###############################################################################
|
|
|
|
###############################################################################
|
|
# Definitions
|
|
###############################################################################
|
|
|
|
include Config
|
|
|
|
VER = ipfire
|
|
|
|
THISAPP = cdrom
|
|
TARGET = $(DIR_INFO)/$(THISAPP)
|
|
|
|
# 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
|
|
|
|
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 = $(IMAGES_DIR)/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).iso
|
|
|
|
###############################################################################
|
|
# Top-level Rules
|
|
###############################################################################
|
|
|
|
install : $(TARGET)
|
|
|
|
check :
|
|
|
|
download :
|
|
|
|
b2 :
|
|
|
|
###############################################################################
|
|
# Installation Details
|
|
###############################################################################
|
|
|
|
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
|
# Update /etc/system-release, because the string might have changed
|
|
# since stage2 has been executed..
|
|
echo "$(SYSTEM_RELEASE)" > /etc/system-release
|
|
|
|
# Create a directory to authorise the CDROM in
|
|
rm -rf $(DIR_TMP)/cdrom && mkdir -p $(DIR_TMP)/cdrom
|
|
|
|
# Create the target directory
|
|
rm -rf $(DIR_TMP)/root && mkdir -p $(DIR_TMP)/root
|
|
|
|
# Copy all files that we want
|
|
$(call COPY_FILES,$(DIR_SRC)/config/rootfiles/common,$(DIR_TMP)/root,,,)
|
|
|
|
# Create mount points
|
|
$(call CREATE_MOUNTPOINTS,$(DIR_TMP)/root)
|
|
|
|
# Create the archive
|
|
$(call COMPRESS_ZSTD,$(DIR_TMP)/root,$(DIR_TMP)/cdrom/distro.img)
|
|
|
|
# Remove the raw files
|
|
rm -rf $(DIR_TMP)/root
|
|
|
|
# Other files
|
|
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/
|
|
|
|
mkdir -p $(DIR_TMP)/cdrom/boot/isolinux
|
|
|
|
cp /boot/vmlinuz-$(KVER) $(DIR_TMP)/cdrom/boot/isolinux/vmlinuz
|
|
dracut --force -a "installer" --strip $(DIR_TMP)/cdrom/boot/isolinux/instroot $(KVER)
|
|
|
|
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 \
|
|
> $(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 $(DIR_TMP)/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
|
|
xargs md5sum > md5sum.txt
|
|
|
|
# Master the ISO file
|
|
cd $(DIR_TMP)/cdrom && mkisofs $(ISO_ARGS) -o $(ISO_FILE) .
|
|
|
|
ifeq "$(HAS_ISOLINUX)" "1"
|
|
isohybrid $(ISOHYBRID_ARGS) $(ISO_FILE)
|
|
endif
|
|
|
|
# Create checksum file
|
|
cd $(IMAGES_DIR) && b2sum "$(notdir $(ISO_FILE))" > "$(notdir $(ISO_FILE)).b2"
|