]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - lfs/flash-images
ovpnmain.cgi: Remove using dropped &General::getlastip() function
[ipfire-2.x.git] / lfs / flash-images
index 24cf327a525855c0ff21d92a70f27058ef4334a0..6b762b1549336462c5c904380b3b32845e062eae 100644 (file)
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
 ###############################################################################
 #                                                                             #
 # 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        #
 #                                                                             #
 # 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        #
@@ -36,7 +36,7 @@ ifeq "$(EFI)" "1"
 endif
 PART_ROOT  = /dev/mapper/$(patsubst /dev/%,%,$(DEVICE))p3
 
 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 = $(IMAGES_DIR)/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).img.xz
 
 FSTAB_FMT = UUID=%s %-8s %-4s %-10s %d %d\n
 
 
 FSTAB_FMT = UUID=%s %-8s %-4s %-10s %d %d\n
 
@@ -50,21 +50,25 @@ check :
 
 download :
 
 
 download :
 
-md5 :
+b2 :
 
 ###############################################################################
 # Installation Details
 ###############################################################################
 
 ###############################################################################
 # Installation Details
 ###############################################################################
-MNThdd   := /install/harddisk
-IMG      := /install/images/image.img
+MNThdd   := $(DIR_TMP)/harddisk
+IMG      := $(DIR_TMP)/image.img
 
 # All sizes in blocks
 
 # All sizes in blocks
-ifeq "$(BUILD_ARCH)" "armv5tel"
+ifeq "$(BUILD_PLATFORM)" "arm"
  BOOTLOADER =
  S_OFFSET = 8192
 
  # FAT32
  PART_TYPE = c
  BOOTLOADER =
  S_OFFSET = 8192
 
  # FAT32
  PART_TYPE = c
+ifeq "$(BUILD_ARCH)" "aarch64"
+ BOOTLOADER = grub
+ S_OFFSET = 32768
+endif
 else
  BOOTLOADER = grub
  S_OFFSET = 8192
 else
  BOOTLOADER = grub
  S_OFFSET = 8192
@@ -73,10 +77,10 @@ else
  PART_TYPE = L
 endif
 
  PART_TYPE = L
 endif
 
-# /boot:  128MB - OFFSET
-# /    : 1200 MB
-S_BOOT := $(shell echo $$(( 262144 - $(S_OFFSET) )))
-S_ROOT := 2477600
+# /boot:  512 MB - OFFSET
+# /    : 2048 MB
+S_BOOT := $(shell echo $$(( 1048576 - $(S_OFFSET) )))
+S_ROOT := 4194304
 
 ifeq "$(EFI)" "1"
  S_EFI = 65536 # 32 MB
 
 ifeq "$(EFI)" "1"
  S_EFI = 65536 # 32 MB
@@ -89,7 +93,7 @@ PADDING = 100 # MB
 ifeq "$(EFI)" "1"
  SFDISK      = $(SFDISK_BOOT)$(SFDISK_EFI)$(SFDISK_ROOT)
 else
 ifeq "$(EFI)" "1"
  SFDISK      = $(SFDISK_BOOT)$(SFDISK_EFI)$(SFDISK_ROOT)
 else
- SFDISK      = $(SFDISK_BOOT)$(SFDISK_ROOT)
+ SFDISK      = $(SFDISK_BOOT),0,0\n$(SFDISK_ROOT)
 endif
 
 SFDISK_BOOT = $(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n
 endif
 
 SFDISK_BOOT = $(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n
@@ -97,13 +101,10 @@ 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))
 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
-       mountpoint $(MNThdd) && exit 1 || exit 0
-
        rm -rf $(IMG) $(MNThdd) && mkdir -p $(MNThdd)
 
        # Allocate image on disk
        rm -rf $(IMG) $(MNThdd) && mkdir -p $(MNThdd)
 
        # Allocate image on disk
-       dd if=/dev/zero of=$(IMG) bs=512 count=$$(( $(S_OFFSET) + $(S_BOOT) + $(S_EFI) + $(S_ROOT) ))
+       dd if=/dev/zero of=$(IMG) bs=512 count=0 seek=$$(( $(S_OFFSET) + $(S_BOOT) + $(S_EFI) + $(S_ROOT) ))
        losetup $(DEVICE) $(IMG)
 
        # Write Partition table
        losetup $(DEVICE) $(IMG)
 
        # Write Partition table
@@ -138,23 +139,12 @@ ifeq "$(EFI)" "1"
        mount $(PART_EFI) $(MNThdd)/boot/efi
 endif
 
        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
+       # Copy all files
+       $(call COPY_FILES,$(DIR_SRC)/config/rootfiles/common,$(MNThdd))
+
+       # Create mount points
+       $(call CREATE_MOUNTPOINTS,$(MNThdd))
 
 
-       # Install IPFire
-ifneq "$(BUILD_PLATFORM)" "arm"
-       tar -x --xz -C $(MNThdd)/ -f /install/cdrom/distro.img
-else
-       tar -x -C $(MNThdd)/ -f /install/cdrom/distro.img
-endif
-       -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
-       mkdir $(MNThdd)/proc
        mount --bind /proc $(MNThdd)/proc
        mount --bind /dev  $(MNThdd)/dev
        mount --bind /sys  $(MNThdd)/sys
        mount --bind /proc $(MNThdd)/proc
        mount --bind /dev  $(MNThdd)/dev
        mount --bind /sys  $(MNThdd)/sys
@@ -163,7 +153,7 @@ endif
 
        # Create /etc/fstab
        printf "$(FSTAB_FMT)" "$$(blkid -o value -s UUID $(PART_BOOT))" "/boot" \
 
        # 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
 ifeq "$(EFI)" "1"
        printf "$(FSTAB_FMT)" "$$(blkid -o value -s UUID $(PART_EFI))" "/boot/efi" \
                "auto" "defaults" 1 2 >> $(MNThdd)/etc/fstab
@@ -185,7 +175,8 @@ ifeq "$(BOOTLOADER)" "grub"
 
        # Create configuration
        mkdir -pv $(MNThdd)/boot/grub
 
        # Create configuration
        mkdir -pv $(MNThdd)/boot/grub
-       chroot $(MNThdd) grub-mkconfig -o /boot/grub/grub.cfg
+       GRUB_FIRST_BOOT=true KERNEL_RELEASE="$(KVER)" chroot $(MNThdd) \
+               grub-mkconfig -o /boot/grub/grub.cfg
 
        # Boot the first kernel by default
        chroot $(MNThdd) grub-set-default 0
 
        # Boot the first kernel by default
        chroot $(MNThdd) grub-set-default 0
@@ -195,13 +186,15 @@ ifeq "$(BOOTLOADER)" "grub"
        sed -i $(MNThdd)/boot/grub/grub.cfg \
                -e "s/root=[A-Za-z0-9\/=-]*/root=UUID=$$(blkid -o value -s UUID $(PART_ROOT))/g"
 
        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)
        # Install GRUB
        grub-install --force --recheck --no-floppy --target=i386-pc \
                --root-directory=$(MNThdd) $(DEVICE)
+endif
 
 ifeq "$(EFI)" "1"
        # Install GRUB for EFI
 
 ifeq "$(EFI)" "1"
        # Install GRUB for EFI
-       grub-install --target=$(BUILD_ARCH)-efi --removable --no-nvram \
+       grub-install --target=$(GRUB_ARCH)-efi --removable --no-nvram \
                --boot-directory=$(MNThdd)/boot --efi-directory=$(MNThdd)/boot/efi
 endif
 
                --boot-directory=$(MNThdd)/boot --efi-directory=$(MNThdd)/boot/efi
 endif
 
@@ -210,6 +203,12 @@ endif
        rm -f $(MNThdd)/etc/grub.d/11_linux_scon
 endif
 
        rm -f $(MNThdd)/etc/grub.d/11_linux_scon
 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
        echo RAMDISK_MODE=2 > $(MNThdd)/etc/sysconfig/ramdisk
 
        # Set ramdisk mode to automatic
        echo RAMDISK_MODE=2 > $(MNThdd)/etc/sysconfig/ramdisk
 
@@ -236,7 +235,6 @@ endif
        -fsck.ext4 -f -y $(PART_ROOT)
        fsck.ext4 -f -y $(PART_ROOT)
 
        -fsck.ext4 -f -y $(PART_ROOT)
        fsck.ext4 -f -y $(PART_ROOT)
 
-       sleep 10     #Ubuntu compiling: allow time to automount/dismount
        kpartx -d -v $(DEVICE)
        losetup -d $(DEVICE)
 
        kpartx -d -v $(DEVICE)
        losetup -d $(DEVICE)
 
@@ -244,11 +242,14 @@ endif
        # not copied to a block device)
        dd if=/dev/zero bs=1M count=$(PADDING) >> $(IMG)
 
        # 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)
 endif
 
        # Compress Image
        xz $(XZ_OPT) < $(IMG) > $(IMAGE_FILE)
-       rm -rf $(IMG) $(MNThdd)
+       rm -rf $(IMG) $(MNThdd) $(DIR_TMP)/cdrom
+
+       # Create checksum file
+       cd $(IMAGES_DIR) && b2sum "$(notdir $(IMAGE_FILE))" > "$(notdir $(IMAGE_FILE)).b2"