]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - lfs/flash-images
core186: ship header.pl
[ipfire-2.x.git] / lfs / flash-images
index d3c8a7520a9efae3a9285c503da8abeb75bd6e81..464ad5edf56d55ab53eca841907ceef1ae263111 100644 (file)
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2018  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2022  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,6 @@ VER = ipfire
 THISAPP    = flash-image
 TARGET     = $(DIR_INFO)/$(THISAPP)
 
-ifeq "$(MACHINE)" "x86_64"
-       EFI = 1
-endif
-
-ifeq "$(MACHINE)" "i586"
-       EFI = 1
-endif
-
 DEVICE     = $(shell losetup -f)
 PART_BOOT  = /dev/mapper/$(patsubst /dev/%,%,$(DEVICE))p1
 ifeq "$(EFI)" "1"
@@ -44,7 +36,7 @@ ifeq "$(EFI)" "1"
 endif
 PART_ROOT  = /dev/mapper/$(patsubst /dev/%,%,$(DEVICE))p3
 
-IMAGE_FILE = /install/images/$(SNAME)-$(VERSION).2gb-ext4.$(BUILD_ARCH)-full-core$(CORE).img.xz
+IMAGE_FILE = /install/images/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).img.xz
 
 FSTAB_FMT = UUID=%s %-8s %-4s %-10s %d %d\n
 
@@ -58,13 +50,13 @@ check :
 
 download :
 
-md5 :
+b2 :
 
 ###############################################################################
 # Installation Details
 ###############################################################################
-MNThdd   := /install/harddisk
-IMG      := /install/images/image.img
+MNThdd   := $(DIR_TMP)/harddisk
+IMG      := $(DIR_TMP)/image.img
 
 # All sizes in blocks
 ifeq "$(BUILD_PLATFORM)" "arm"
@@ -73,48 +65,40 @@ ifeq "$(BUILD_PLATFORM)" "arm"
 
  # FAT32
  PART_TYPE = c
+ifeq "$(BUILD_ARCH)" "aarch64"
+ BOOTLOADER = grub
+ S_OFFSET = 32768
+endif
 else
  BOOTLOADER = grub
  S_OFFSET = 8192
 
- # Logical
+ # Linux
  PART_TYPE = L
 endif
 
-GRUB_CFGS = /boot/grub/grub.cfg
+# /boot:  512 MB - OFFSET
+# /    : 1800 MB
+S_BOOT := $(shell echo $$(( 1048576 - $(S_OFFSET) )))
+S_ROOT := 3773292
 
 ifeq "$(EFI)" "1"
- S_EFI = 204800
- GRUB_CFGS += /boot/efi/EFI/ipfire/grub-efi/grub.cfg
+ S_EFI = 65536 # 32 MB
 else
  S_EFI = 0
 endif
 
-# /boot:  128MB - OFFSET
-# /    : 1200 MB
-S_BOOT := $(shell echo $$(( 262144 - $(S_OFFSET) )))
-S_ROOT := 2477600
-
-ifeq "$(MACHINE)" "x86_64"
-       EFI_ARCH = x64
-endif
-
-ifeq "$(MACHINE)" "i586"
-       EFI_ARCH = ia32
-endif
-
 PADDING = 100 # MB
 
 ifeq "$(EFI)" "1"
- SFDISK_EFI  = $(S_OFFSET),$(S_EFI),c,*\n
  SFDISK      = $(SFDISK_BOOT)$(SFDISK_EFI)$(SFDISK_ROOT)
 else
- SFDISK_SWAP = ,0,0\n
- SFDISK      = $(SFDISK_BOOT)$(SFDISK_SWAP)$(SFDISK_ROOT)
+ SFDISK      = $(SFDISK_BOOT),0,0\n$(SFDISK_ROOT)
 endif
 
-SFDISK_BOOT = $(shell echo $$(( $(S_OFFSET) + $(S_EFI) ))),$(S_BOOT),$(PART_TYPE)\n
-SFDISK_ROOT = $(shell echo $$(( $(S_OFFSET) + $(S_EFI) + $(S_BOOT) ))),$(S_ROOT),L\n
+SFDISK_BOOT = $(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n
+SFDISK_EFI  = $(shell echo $$(( $(S_OFFSET) + $(S_BOOT) ))),$(S_EFI),U\n
+SFDISK_ROOT = $(shell echo $$(( $(S_OFFSET) + $(S_BOOT) + $(S_EFI) ))),$(S_ROOT),L\n
 
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # Stop if $(MNThdd) is still mounted
@@ -129,11 +113,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # Write Partition table
        echo -e "$(SFDISK)" | sfdisk -uS $(DEVICE)
 
-       # Remove 2nd empty partition
-ifneq "$(EFI)" "1"
-       -echo -e "d\n2\nw\n\q\n" | fdisk $(DEVICE)
-endif
-
        kpartx -v -a $(DEVICE)
 
        # Format them
@@ -163,20 +142,11 @@ ifeq "$(EFI)" "1"
        mount $(PART_EFI) $(MNThdd)/boot/efi
 endif
 
-       # Install Pandaboard MLO and uboot first
-ifeq "$(BUILD_ARCH)" "armv5tel"
-       cp -v /boot/MLO $(MNThdd)/boot/
-       cp -v /boot/u-boot.img $(MNThdd)/boot/
-       sync
-       umount $(MNThdd)/boot
-       mount $(PART_BOOT) $(MNThdd)/boot
-endif
-
        # Install IPFire
 ifneq "$(BUILD_PLATFORM)" "arm"
-       tar -x --xz -C $(MNThdd)/ -f /install/cdrom/distro.img
+       tar $(TAR_OPTIONS) -x --zstd -C $(MNThdd)/ -f $(DIR_TMP)/cdrom/distro.img
 else
-       tar -x -C $(MNThdd)/ -f /install/cdrom/distro.img
+       tar $(TAR_OPTIONS) -x -C $(MNThdd)/ -f $(DIR_TMP)/cdrom/distro.img
 endif
        -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
        mkdir $(MNThdd)/proc
@@ -188,7 +158,7 @@ endif
 
        # Create /etc/fstab
        printf "$(FSTAB_FMT)" "$$(blkid -o value -s UUID $(PART_BOOT))" "/boot" \
-               "auto" "defaults" 1 2 >  $(MNThdd)/etc/fstab
+               "auto" "defaults,nodev,noexec,nosuid" 1 2 >  $(MNThdd)/etc/fstab
 ifeq "$(EFI)" "1"
        printf "$(FSTAB_FMT)" "$$(blkid -o value -s UUID $(PART_EFI))" "/boot/efi" \
                "auto" "defaults" 1 2 >> $(MNThdd)/etc/fstab
@@ -209,33 +179,39 @@ ifeq "$(BOOTLOADER)" "grub"
                        $(MNThdd)/etc/grub.d/
 
        # Create configuration
-       for i in $(GRUB_CFGS); do \
-               mkdir -pv $$(dirname $(MNThdd)$(GRUB_CFG)); \
-               chroot $(MNThdd) grub-mkconfig -o $$i || exit 1; \
-       done
+       mkdir -pv $(MNThdd)/boot/grub
+       GRUB_FIRST_BOOT=true KERNEL_RELEASE="$(KVER)-ipfire" chroot $(MNThdd) \
+               grub-mkconfig -o /boot/grub/grub.cfg
 
        # Boot the first kernel by default
        chroot $(MNThdd) grub-set-default 0
 
        # Insert the UUID because grub-mkconfig often fails to
        # detect that correctly
-       sed -i $(addprefix $(MNThdd),$(GRUB_CFGS)) \
        sed -i $(MNThdd)/boot/grub/grub.cfg \
                -e "s/root=[A-Za-z0-9\/=-]*/root=UUID=$$(blkid -o value -s UUID $(PART_ROOT))/g"
 
+ifeq "$(BUILD_PLATFORM)" "x86"
        # Install GRUB
        grub-install --force --recheck --no-floppy --target=i386-pc \
                --root-directory=$(MNThdd) $(DEVICE)
+endif
+
+ifeq "$(EFI)" "1"
+       # Install GRUB for EFI
+       grub-install --target=$(GRUB_ARCH)-efi --removable --no-nvram \
+               --boot-directory=$(MNThdd)/boot --efi-directory=$(MNThdd)/boot/efi
+endif
 
        # restore orginal defaults
        mv -f $(MNThdd)/etc/default/grub.backup $(MNThdd)/etc/default/grub
        rm -f $(MNThdd)/etc/grub.d/11_linux_scon
-
-ifeq "$(EFI)" "1"
-       mkdir -pv $(MNThdd)/boot/efi/EFI/boot
-       cp -vf $(MNThdd)/boot/efi/EFI/ipfire/grub-efi/grub.efi \
-               $(MNThdd)/boot/efi/EFI/boot/boot$(EFI_ARCH).efi
 endif
+
+ifeq "$(BUILD_PLATFORM)" "arm"
+       # Insert the UUID to uENV.txt
+       sed -i $(MNThdd)/boot/uENV.txt \
+               -e "s/^root_dev=.*/root_dev=UUID=$$(blkid -o value -s UUID $(PART_ROOT))/g"
 endif
 
        # Set ramdisk mode to automatic
@@ -272,11 +248,11 @@ endif
        # not copied to a block device)
        dd if=/dev/zero bs=1M count=$(PADDING) >> $(IMG)
 
-ifeq "$(BUILD_ARCH)" "armv5tel"
-       # Install u-boot for Orangepi Zero/Nanopi DUO into image 8KB
-       dd if=/usr/share/u-boot/orangepi_zero/u-boot-sunxi-with-spl.bin of=$(IMG) bs=1K seek=8 conv=notrunc
+ifeq "$(BUILD_ARCH)" "aarch64"
+       # Install u-boot for NanoPi R2S into image 8KB
+       dd if=/usr/share/u-boot/nanopi_r2s/u-boot-rockchip.bin of=$(IMG) bs=1K seek=32 conv=notrunc
 endif
 
        # Compress Image
        xz $(XZ_OPT) < $(IMG) > $(IMAGE_FILE)
-       rm -rf $(IMG) $(MNThdd)
+       rm -rf $(IMG) $(MNThdd) $(DIR_TMP)/cdrom