From 7d00cfe9bb693e376ac9d035e13f8ce8a5ff572c Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Fri, 27 Jan 2017 16:10:40 +0100 Subject: [PATCH] build: centralize fakeroot code This patch moves the fakeroot code required by some devices to `image-commands.mk`. Create the fakeroot on the fly by using the undocumented -s (skip copy) parameter of mkimage. Signed-off-by: Joseph C. Lehner [remove unused NETGEAR_KERNEL_MAGIC, remove workarounds to have a dummy rootfs for mkimage] Signed-off-by: Mathias Kresin --- include/image-commands.mk | 16 ++++++++++---- target/linux/apm821xx/image/Makefile | 20 ++---------------- target/linux/ipq806x/image/Makefile | 11 +++------- target/linux/ramips/image/mt7620.mk | 4 ++-- .../ramips/image/netgear-fake-uImage-hdr.bin | Bin 64 -> 0 bytes 5 files changed, 19 insertions(+), 32 deletions(-) delete mode 100644 target/linux/ramips/image/netgear-fake-uImage-hdr.bin diff --git a/include/image-commands.mk b/include/image-commands.mk index 7d124ece19..49e438954a 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -62,6 +62,18 @@ define Build/netgear-dni mv $@.new $@ endef +# append a fake/empty rootfs uImage header, to fool the bootloaders +# rootfs integrity check +define Build/append-uImage-fakeroot-hdr + rm -f $@.fakeroot + $(STAGING_DIR_HOST)/bin/mkimage \ + -A $(LINUX_KARCH) -O linux -T filesystem -C none \ + -n '$(call toupper,$(LINUX_KARCH)) LEDE fakeroot' \ + -s \ + $@.fakeroot + cat $@.fakeroot >> $@ +endef + define Build/tplink-safeloader -$(STAGING_DIR_HOST)/bin/tplink-safeloader \ -B $(TPLINK_BOARD_NAME) \ @@ -143,10 +155,6 @@ define Build/append-rootfs dd if=$(IMAGE_ROOTFS) >> $@ endef -define Build/append-file - cat "$(1)" >> "$@" -endef - define Build/append-ubi sh $(TOPDIR)/scripts/ubinize-image.sh \ $(if $(UBOOTENV_IN_UBI),--uboot-env) \ diff --git a/target/linux/apm821xx/image/Makefile b/target/linux/apm821xx/image/Makefile index 0ded83dd99..a11e989705 100644 --- a/target/linux/apm821xx/image/Makefile +++ b/target/linux/apm821xx/image/Makefile @@ -129,23 +129,6 @@ define Build/create-uImage-dtb @mv $@.new $@ endef -define Build/append-fakerootfs - rm -rf $@.fakerootsquashfs $@.fakefs - - # append a fake/empty rootfs to fool netgear's uboot - # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg() - dd if=/dev/zero of=$@.fakerd bs=16 count=1 conv=sync - - -$(STAGING_DIR_HOST)/bin/mkimage \ - -A $(LINUX_KARCH) -O linux -T filesystem -C none \ - -a 0x00000000 -e 0x00000000 \ - -n '$(DEVICE_PROFILE) fakerootfs' \ - -d $@.fakerd $@.fakefs - - cat $@.fakefs >> $@ - rm -rf $@.fakerootsquashfs $@.fakefs -endef - define Build/wndr4700-specialImage rm -rf $@.fakerd $@.new @@ -192,7 +175,8 @@ define Device/WNDR4700 IMAGE_SIZE := 24960k IMAGES := factory.img sysupgrade.tar kernel.dtb KERNEL_SIZE := 1920k - KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | append-fakerootfs + KERNEL := dtb | kernel-bin | lzma | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | \ + append-uImage-fakeroot-hdr KERNEL_INITRAMFS := kernel-bin | gzip | dtb | wndr4700-specialImage gzip IMAGE/factory.img := create-uImage-dtb | append-kernel | pad-to 2M | append-ubi | \ netgear-dni | check-size $$$$(IMAGE_SIZE) diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile index 33dc31d41e..b00e197586 100644 --- a/target/linux/ipq806x/image/Makefile +++ b/target/linux/ipq806x/image/Makefile @@ -9,12 +9,6 @@ KERNEL_LOADADDR := 0x42208000 define Image/Prepare $(CP) $(LINUX_DIR)/vmlinux $(KDIR)/$(IMG_PREFIX)-vmlinux.elf - mkimage -A arm -O linux -T filesystem -C none \ - -a $(KERNEL_LOADADDR) -e $(KERNEL_LOADADDR) \ - -n 'ARM OpenWrt fakeroot' \ - -s $(KDIR_TMP)/root.dummy-uImage.tmp - echo -ne '\xff' > $(KDIR_TMP)/root.dummy - cat $(KDIR_TMP)/root.dummy $(KDIR_TMP)/root.dummy-uImage.tmp > $(KDIR)/root.dummy endef define Image/BuildKernel @@ -64,7 +58,8 @@ define Device/DniImage FILESYSTEMS := squashfs KERNEL_SUFFIX := -uImage KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none - KERNEL = kernel-bin | append-dtb | pad-to $$$$(($$(KERNEL_SIZE)-2*64-1)) | uImage none | append-file $(KDIR)/root.dummy + KERNEL = kernel-bin | append-dtb | uImage none | pad-offset $$(KERNEL_SIZE) 64 | \ + append-uImage-fakeroot-hdr KERNEL_NAME := zImage NETGEAR_BOARD_ID := NETGEAR_HW_ID := @@ -161,7 +156,7 @@ define Device/EA8500 BLOCKSIZE := 128k KERNEL_SIZE := 3072k FILESYSTEMS := squashfs - KERNEL = kernel-bin | append-dtb | uImage none | append-file $(KDIR)/root.dummy + KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakeroot-hdr PROFILES += $$(DEVICE_NAME) BOARD_NAME := ea8500 UBINIZE_OPTS := -E 5 diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 50eae2f63e..446bd9981e 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -58,7 +58,7 @@ define Device/ex2700 BLOCKSIZE := 4k IMAGE_SIZE := $(ralink_default_fw_size_4M) IMAGES += factory.bin - KERNEL := $(KERNEL_DTB) | uImage lzma | pad-offset 64k 64 | append-file netgear-fake-uImage-hdr.bin + KERNEL := $(KERNEL_DTB) | uImage lzma | pad-offset 64k 64 | append-uImage-fakeroot-hdr IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \ netgear-dni DEVICE_TITLE := Netgear EX2700 @@ -71,7 +71,7 @@ define Device/wn3000rpv3 DTS := WN3000RPV3 BLOCKSIZE := 4k IMAGES += factory.bin - KERNEL := $(KERNEL_DTB) | uImage lzma | pad-offset 64k 64 | append-file netgear-fake-uImage-hdr.bin + KERNEL := $(KERNEL_DTB) | uImage lzma | pad-offset 64k 64 | append-uImage-fakeroot-hdr IMAGE/factory.bin := $$(sysupgrade_bin) | check-size $$$$(IMAGE_SIZE) | \ netgear-dni DEVICE_TITLE := Netgear WN3000RPv3 diff --git a/target/linux/ramips/image/netgear-fake-uImage-hdr.bin b/target/linux/ramips/image/netgear-fake-uImage-hdr.bin deleted file mode 100644 index 9a534b63502d5e7cdf1d7a7fe644a5025651387c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 64 lcmY#ql?