[source] image: add a helper variable for getting kernel/rootfs from within image Build/* templates
LEDE Commits
lede-commits at lists.infradead.org
Sun Jul 31 03:25:52 PDT 2016
nbd pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=63b525dd6b209af5554a2d053efd4b3ce6f60c9c
commit 63b525dd6b209af5554a2d053efd4b3ce6f60c9c
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Sat Jul 30 14:19:11 2016 +0200
image: add a helper variable for getting kernel/rootfs from within image Build/* templates
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
include/image-commands.mk | 19 +++++++++++--------
target/linux/apm821xx/image/Makefile | 8 ++++----
target/linux/ar71xx/image/generic.mk | 12 ++++++------
target/linux/ar71xx/image/tp-link.mk | 2 +-
target/linux/ar71xx/image/ubnt.mk | 2 +-
target/linux/ath25/image/Makefile | 12 ++++++------
target/linux/bcm53xx/image/Makefile | 6 +++---
target/linux/brcm2708/image/Makefile | 4 ++--
target/linux/brcm47xx/image/Makefile | 4 ++--
target/linux/brcm63xx/image/Makefile | 22 +++++++++++-----------
target/linux/lantiq/image/Makefile | 8 ++++----
target/linux/lantiq/image/tp-link.mk | 2 +-
target/linux/ramips/image/Makefile | 4 ++--
13 files changed, 54 insertions(+), 51 deletions(-)
diff --git a/include/image-commands.mk b/include/image-commands.mk
index f95a68d..790e929 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -1,5 +1,8 @@
# Build commands that can be called from Device/* templates
+IMAGE_KERNEL = $(word 1,$^)
+IMAGE_ROOTFS = $(word 2,$^)
+
define Build/uImage
mkimage -A $(LINUX_KARCH) \
-O linux -T kernel \
@@ -30,7 +33,7 @@ define Build/tplink-safeloader
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
-B $(TPLINK_BOARD_NAME) \
-V $(REVISION) \
- -k $(word 1,$^) \
+ -k $(IMAGE_KERNEL) \
-r $@ \
-o $@.new \
-j \
@@ -92,18 +95,18 @@ define Build/patch-cmdline
endef
define Build/append-kernel
- dd if=$(word 1,$^) $(if $(1),bs=$(1) conv=sync) >> $@
+ dd if=$(IMAGE_KERNEL) $(if $(1),bs=$(1) conv=sync) >> $@
endef
define Build/append-rootfs
- dd if=$(word 2,$^) $(if $(1),bs=$(1) conv=sync) >> $@
+ dd if=$(IMAGE_ROOTFS) $(if $(1),bs=$(1) conv=sync) >> $@
endef
define Build/append-ubi
sh $(TOPDIR)/scripts/ubinize-image.sh \
$(if $(UBOOTENV_IN_UBI),--uboot-env) \
- $(if $(KERNEL_IN_UBI),--kernel $(word 1,$^)) \
- $(word 2,$^) \
+ $(if $(KERNEL_IN_UBI),--kernel $(IMAGE_KERNEL)) \
+ $(IMAGE_ROOTFS) \
$@.tmp \
-p $(BLOCKSIZE) -m $(PAGESIZE) \
$(if $(SUBPAGESIZE),-s $(SUBPAGESIZE)) \
@@ -142,7 +145,7 @@ endef
define Build/combined-image
-sh $(TOPDIR)/scripts/combined-image.sh \
- "$(word 1,$^)" \
+ "$(IMAGE_KERNEL)" \
"$@" \
"$@.new"
@mv $@.new $@
@@ -151,7 +154,7 @@ endef
define Build/sysupgrade-tar
sh $(TOPDIR)/scripts/sysupgrade-tar.sh \
--board $(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)) \
- --kernel $(call param_get_default,kernel,$(1),$(word 1,$^)) \
- --rootfs $(call param_get_default,rootfs,$(1),$(word 2,$^)) \
+ --kernel $(call param_get_default,kernel,$(1),$(IMAGE_KERNEL)) \
+ --rootfs $(call param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \
$@
endef
diff --git a/target/linux/apm821xx/image/Makefile b/target/linux/apm821xx/image/Makefile
index c49e57a..25ee67b 100644
--- a/target/linux/apm821xx/image/Makefile
+++ b/target/linux/apm821xx/image/Makefile
@@ -179,7 +179,7 @@ define Build/boot-img
$(CP) $@.scr $@.bootdir/boot/boot.scr
$(CP) $@.dtb $@.bootdir/boot/$(DEVICE_DTB)
- $(CP) $(word 1,$^) $@.bootdir/boot/uImage
+ $(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
genext2fs --block-size $(BLOCKSIZE) --size-in-blocks $$((1024 * $(BOOT_SIZE))) --root $@.bootdir $@.boot
@@ -189,7 +189,7 @@ define Build/boot-img
endef
define Build/hdd-img
- ./mbl_gen_hdd_img.sh $@ $@.boot $(word 2,$^)
+ ./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS)
$(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
endef
@@ -204,9 +204,9 @@ endef
define Build/recovery-tar
sh ./mbl_gen_recovery_tar.sh \
--profile $(DEVICE_PROFILE) \
- --dtb $(word 1,$^).dtb \
+ --dtb $(IMAGE_KERNEL).dtb \
--dtbname $(DEVICE_DTB) \
- --kernel $(word 1,$^) \
+ --kernel $(IMAGE_KERNEL) \
--rootfs $@ \
$@
endef
diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index 6e5ef2b..bd92a84 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -476,8 +476,8 @@ TARGET_DEVICES += hiwifi-hc6361
# - 28 bytes seama_header
# - 36 bytes of META data (4-bytes aligned)
define Build/seama-factory
- ( dd if=/dev/zero bs=64 count=1; cat $(word 1,$^) ) >$@.loader.tmp
- ( dd if=$@.loader.tmp bs=64k conv=sync; dd if=$(word 2,$^) ) >$@.tmp.0
+ ( dd if=/dev/zero bs=64 count=1; cat $(IMAGE_KERNEL) ) >$@.loader.tmp
+ ( dd if=$@.loader.tmp bs=64k conv=sync; dd if=$(IMAGE_ROOTFS) ) >$@.tmp.0
tail -c +65 $@.tmp.0 >$@.tmp.1
$(STAGING_DIR_HOST)/bin/seama \
-i $@.tmp.1 \
@@ -491,10 +491,10 @@ endef
define Build/seama-sysupgrade
$(STAGING_DIR_HOST)/bin/seama \
- -i $(word 1,$^) \
+ -i $(IMAGE_KERNEL) \
-m "dev=/dev/mtdblock/1" -m "type=firmware"
- ( dd if=$(word 1,$^).seama bs=64k conv=sync; dd if=$(word 2,$^) ) >$@
- rm -f $(word 1,$^).seama
+ ( dd if=$(IMAGE_KERNEL).seama bs=64k conv=sync; dd if=$(IMAGE_ROOTFS) ) >$@
+ rm -f $(IMAGE_KERNEL).seama
endef
define Build/seama-initramfs
@@ -505,7 +505,7 @@ define Build/seama-initramfs
endef
define Build/seama-pad-rootfs
- $(STAGING_DIR_HOST)/bin/padjffs2 $(word 2,$^) -c 64 >>$@
+ $(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 64 >>$@
endef
define Device/seama
diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk
index f93eec6..5fb1095 100644
--- a/target/linux/ar71xx/image/tp-link.mk
+++ b/target/linux/ar71xx/image/tp-link.mk
@@ -12,7 +12,7 @@ define Build/mktplinkfw
-$(STAGING_DIR_HOST)/bin/mktplinkfw \
-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \
-m $(TPLINK_HEADER_VERSION) \
- -k $(word 1,$^) \
+ -k $(IMAGE_KERNEL) \
-r $@ \
-o $@.new \
-j -X 0x40000 \
diff --git a/target/linux/ar71xx/image/ubnt.mk b/target/linux/ar71xx/image/ubnt.mk
index ab245df..98c9ca0 100644
--- a/target/linux/ar71xx/image/ubnt.mk
+++ b/target/linux/ar71xx/image/ubnt.mk
@@ -7,7 +7,7 @@
define Build/mkubntimage
$(STAGING_DIR_HOST)/bin/mkfwimage \
-B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
- -k $(word 1,$^) \
+ -k $(IMAGE_KERNEL) \
-r $@ \
-o $@
endef
diff --git a/target/linux/ath25/image/Makefile b/target/linux/ath25/image/Makefile
index 784cee8..4face05 100644
--- a/target/linux/ath25/image/Makefile
+++ b/target/linux/ath25/image/Makefile
@@ -10,24 +10,24 @@ include $(INCLUDE_DIR)/image.mk
define Build/mkfwimage
$(STAGING_DIR_HOST)/bin/mkfwimage \
-B $(1).OpenWrt.$(REVISION) \
- -k $(word 1,$^) \
- -r $(word 2,$^) \
+ -k $(IMAGE_KERNEL) \
+ -r $(IMAGE_ROOTFS) \
-o $@.new && \
mv $@.new $@
endef
define Build/combined-image
-sh $(TOPDIR)/scripts/combined-image.sh \
- "$(word 1,$^)" \
- "$(word 2,$^)" \
+ "$(IMAGE_KERNEL)" \
+ "$(IMAGE_ROOTFS)" \
"$@.new" && \
mv $@.new $@
endef
define Build/mkmylofw
$(STAGING_DIR_HOST)/bin/mkmylofw -B $(1) \
- -p0x020000:0x130000:ah:0x80041000:linux:$(word 1,$^) \
- -p0x150000:0x2a0000:::rootfs:$(word 2,$^) \
+ -p0x020000:0x130000:ah:0x80041000:linux:$(IMAGE_KERNEL) \
+ -p0x150000:0x2a0000:::rootfs:$(IMAGE_ROOTFS) \
$@.new && \
mv $@.new $@
endef
diff --git a/target/linux/bcm53xx/image/Makefile b/target/linux/bcm53xx/image/Makefile
index 89639f4..10474eb 100644
--- a/target/linux/bcm53xx/image/Makefile
+++ b/target/linux/bcm53xx/image/Makefile
@@ -26,7 +26,7 @@ define Build/trx-serial
$(STAGING_DIR_HOST)/bin/trx \
-o $@.new \
-m 33554432 \
- -f $(word 1,$^) -a 1024 \
+ -f $(IMAGE_KERNEL) -a 1024 \
-f $@ -a 0x10000 -A $(KDIR)/fs_mark
mv $@.new $@
endef
@@ -39,7 +39,7 @@ define Build/trx-nand
$(STAGING_DIR_HOST)/bin/trx \
-o $@.new \
-m 33554432 \
- -f $(word 1,$^) -a 0x20000 -b 0x400000 \
+ -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
-f $@ \
-A $(KDIR)/ubi_mark -a 0x20000
mv $@.new $@
@@ -57,7 +57,7 @@ define Build/seama-nand
entity $@.entity \
-m "dev=/dev/mtdblock/7" \
-m "type=firmware" \
- -f $(word 1,$^) \
+ -f $(IMAGE_KERNEL) \
-b 0x400000 \
-f $@ \
-f $(KDIR)/ubi_mark
diff --git a/target/linux/brcm2708/image/Makefile b/target/linux/brcm2708/image/Makefile
index 7656211..81a7647 100644
--- a/target/linux/brcm2708/image/Makefile
+++ b/target/linux/brcm2708/image/Makefile
@@ -30,7 +30,7 @@ define Build/boot-img
mcopy -i $@.boot $(KDIR)/fixup_cd.dat ::
mcopy -i $@.boot cmdline.txt ::
mcopy -i $@.boot config.txt ::
- mcopy -i $@.boot $(word 1,$^) ::kernel.img
+ mcopy -i $@.boot $(IMAGE_KERNEL) ::kernel.img
$(foreach dts,$(shell echo $(DEVICE_DTS)),mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::;)
mmd -i $@.boot ::/overlays
mcopy -i $@.boot $(DTS_DIR)/overlays/*.dtbo ::/overlays/
@@ -38,7 +38,7 @@ define Build/boot-img
endef
define Build/sdcard-img
- ./gen_rpi_sdcard_img.sh $@ $@.boot $(word 2,$^) \
+ ./gen_rpi_sdcard_img.sh $@ $@.boot $(IMAGE_ROOTFS) \
$(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
$(if $(CONFIG_TARGET_IMAGES_GZIP),gzip -9n -c $@ > $(BIN_DIR)/$(notdir $@).gz)
endef
diff --git a/target/linux/brcm47xx/image/Makefile b/target/linux/brcm47xx/image/Makefile
index a65e9e0..b9cdbf4 100644
--- a/target/linux/brcm47xx/image/Makefile
+++ b/target/linux/brcm47xx/image/Makefile
@@ -53,7 +53,7 @@ define Build/trx-with-loader
-m 33554432 \
-o $@ \
-f $(KDIR)/loader.gz \
- -f $(word 1,$^) \
+ -f $(IMAGE_KERNEL) \
$(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
endef
@@ -72,7 +72,7 @@ define Build/trx-without-loader
$(STAGING_DIR_HOST)/bin/trx \
-m 33554432 \
-o $@ \
- -f $(word 1,$^) \
+ -f $(IMAGE_KERNEL) \
$(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
endef
diff --git a/target/linux/brcm63xx/image/Makefile b/target/linux/brcm63xx/image/Makefile
index 5a1918c..ca1792a 100644
--- a/target/linux/brcm63xx/image/Makefile
+++ b/target/linux/brcm63xx/image/Makefile
@@ -102,12 +102,12 @@ $(subst root.,,$(notdir $(1)))
endef
define Build/cfe-bin
- $(STAGING_DIR_HOST)/bin/imagetag -i $(word 1,$^) -f $(word 2,$^) \
+ $(STAGING_DIR_HOST)/bin/imagetag -i $(IMAGE_KERNEL) -f $(IMAGE_ROOTFS) \
--output $@ --boardid $(CFE_BOARD_ID) --chipid $(CFE_CHIP_ID) \
--entry $(LOADER_ENTRY) --load-addr $(LOADER_ENTRY) \
--info1 "$(call Image/LimitName16,$(DEVICE_NAME))" \
- --info2 "$(call Image/FileSystemStrip,$(word 2,$^))" \
- $(call rootfspad/$(call Image/FileSystemStrip,$(word 2,$^))) \
+ --info2 "$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))" \
+ $(call rootfspad/$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))) \
$(CFE_EXTRAS) $(1)
endef
@@ -115,15 +115,15 @@ define Build/cfe-old-bin
$(TOPDIR)/scripts/brcmImage.pl -t -p \
-o $@ -b $(CFE_BOARD_ID) -c $(CFE_CHIP_ID) \
-e $(LOADER_ENTRY) -a $(LOADER_ENTRY) \
- -k $(word 1,$^) -r $(word 2,$^) \
+ -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) \
$(CFE_EXTRAS)
endef
define Build/cfe-spw303v-bin
- $(STAGING_DIR_HOST)/bin/imagetag -i $(word 1,$^) -f $(word 2,$^) \
+ $(STAGING_DIR_HOST)/bin/imagetag -i $(IMAGE_KERNEL) -f $(IMAGE_ROOTFS) \
--output $@ --boardid $(CFE_BOARD_ID) --chipid $(CFE_CHIP_ID) \
--entry $(LOADER_ENTRY) --load-addr $(LOADER_ENTRY) \
- $(call rootfspad/$(call Image/FileSystemStrip,$(word 2,$^))) \
+ $(call rootfspad/$(call Image/FileSystemStrip,$(IMAGE_ROOTFS))) \
$(CFE_EXTRAS) $(1)
endef
@@ -144,20 +144,20 @@ endef
define Build/redboot-bin
# Prepare kernel and rootfs
- dd if=$(word 1,$^) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz bs=65536 conv=sync
- dd if=$(word 2,$^) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^)) bs=64k conv=sync
- echo -ne \\xDE\\xAD\\xC0\\xDE >> $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^))
+ dd if=$(IMAGE_KERNEL) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz bs=65536 conv=sync
+ dd if=$(IMAGE_ROOTFS) of=$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS)) bs=64k conv=sync
+ echo -ne \\xDE\\xAD\\xC0\\xDE >> $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS))
# Generate the scripted image
$(TOPDIR)/scripts/redboot-script.pl \
-k $(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz \
- -r $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^)) \
+ -r $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS)) \
-a $(strip $(LOADADDR)) -f 0xbe430000 -l 0x7c0000 \
-s 0x1000 -t 20 -o $@.redbootscript
dd if="$@.redbootscript" of="$@.redbootscript.padded" bs=4096 conv=sync
cat \
"$@.redbootscript.padded" \
"$(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz" \
- "$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(word 2,$^))" \
+ "$(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS))" \
> "$@"
endef
diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile
index 0718e9d..f45da41 100644
--- a/target/linux/lantiq/image/Makefile
+++ b/target/linux/lantiq/image/Makefile
@@ -152,21 +152,21 @@ define Build/mkbrncmdline
endef
define Build/mkbrnimg
- mkbrnimg -s $(SIGNATURE) -m $(MAGIC) -p $(CRC32_POLY) -o $@ $(word 1,$^) $(word 2,$^)
+ mkbrnimg -s $(SIGNATURE) -m $(MAGIC) -p $(CRC32_POLY) -o $@ $(IMAGE_KERNEL) $(IMAGE_ROOTFS)
endef
define Build/fullimage
mkimage -A mips -O linux -C lzma -T filesystem -a 0x00 \
-e 0x00 -n 'LEDE RootFS' \
- -d $(word 2,$^) $(word 2,$^).new
+ -d $(IMAGE_ROOTFS) $(IMAGE_ROOTFS).new
- cat $(word 1,$^) $(word 2,$^).new > $@.tmp
+ cat $(IMAGE_KERNEL) $(IMAGE_ROOTFS).new > $@.tmp
mkimage -A mips -O linux -T multi -a 0x00 -C none \
-e 0x00 -n 'OpenWrt fullimage' \
-d $@.tmp $@
- rm $(word 2,$^).new
+ rm $(IMAGE_ROOTFS).new
rm $@.tmp
endef
diff --git a/target/linux/lantiq/image/tp-link.mk b/target/linux/lantiq/image/tp-link.mk
index 5544191..dbf0d66 100644
--- a/target/linux/lantiq/image/tp-link.mk
+++ b/target/linux/lantiq/image/tp-link.mk
@@ -6,7 +6,7 @@ endef
define Build/mktplinkfw2
mktplinkfw2 -B $(BOARD_ID) -s -a 0x4 -j \
- -k $(word 1,$^) -r $(word 2,$^) \
+ -k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) \
-o $@
endef
DEVICE_VARS += BOARD_ID
diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile
index 0a92765..c62974c 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -49,8 +49,8 @@ define Build/trx
$(STAGING_DIR_HOST)/bin/trx \
-o $@ \
-m $(IMAGE_SIZE) \
- -f $(word 1,$^) \
- -a 4 -f $(word 2,$^)
+ -f $(IMAGE_KERNEL) \
+ -a 4 -f $(IMAGE_ROOTFS)
endef
define Build/relocate-kernel
More information about the lede-commits
mailing list