public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: Fix dependency checking for initramfs build
@ 2016-12-23  3:15 Nicholas Piggin
  2017-01-04 13:50 ` klondike
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Piggin @ 2016-12-23  3:15 UTC (permalink / raw)
  To: Michal Marek
  Cc: Nicholas Piggin, linux-kbuild, Francisco Blas Izquierdo Riera,
	Andrew Morton

When using initramfs compression, the data file gets quotes pulled
in from Kconfig, e.g., initramfs_data.cpio".gz" which make does not
match a target and causes rebuild.

Fix this by filtering out quotes from the Kconfig string.

While we're here, set the target explicitly so the Makefile does not
have to know about all the suffixes.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 usr/Makefile | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/usr/Makefile b/usr/Makefile
index 17a513268325..3116b23d44f8 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -5,8 +5,10 @@
 klibcdirs:;
 PHONY += klibcdirs
 
-suffix_y = $(CONFIG_INITRAMFS_COMPRESSION)
-AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
+suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
+datafile_y = initramfs_data.cpio$(suffix_y)
+AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE=usr/$(datafile_y)
+
 
 # Generate builtin.o based on initramfs_data.o
 obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
@@ -14,7 +16,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
 # initramfs_data.o contains the compressed initramfs_data.cpio image.
 # The image is included using .incbin, a dependency which is not
 # tracked automatically.
-$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
+$(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
 
 #####
 # Generate the initramfs cpio archive
@@ -38,10 +40,8 @@ endif
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
 
-targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
-	initramfs_data.cpio.lzma initramfs_data.cpio.xz \
-	initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
-	initramfs_data.cpio
+targets := $(datafile_y)
+
 # do not try to update files included in initramfs
 $(deps_initramfs): ;
 
@@ -51,6 +51,6 @@ $(deps_initramfs): klibcdirs
 # 2) There are changes in which files are included (added or deleted)
 # 3) If gen_init_cpio are newer than initramfs_data.cpio
 # 4) arguments to gen_initramfs.sh changes
-$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
+$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
 	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
 	$(call if_changed,initfs)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kbuild: Fix dependency checking for initramfs build
  2016-12-23  3:15 [PATCH] kbuild: Fix dependency checking for initramfs build Nicholas Piggin
@ 2017-01-04 13:50 ` klondike
  0 siblings, 0 replies; 2+ messages in thread
From: klondike @ 2017-01-04 13:50 UTC (permalink / raw)
  To: Nicholas Piggin, Michal Marek
  Cc: linux-kbuild, Andrew Morton, Florian Fainelli


[-- Attachment #1.1: Type: text/plain, Size: 3112 bytes --]

El 23/12/16 a las 04:15, Nicholas Piggin escribió:
> When using initramfs compression, the data file gets quotes pulled
> in from Kconfig, e.g., initramfs_data.cpio".gz" which make does not
> match a target and causes rebuild.
>
> Fix this by filtering out quotes from the Kconfig string.
>
> While we're here, set the target explicitly so the Makefile does not
> have to know about all the suffixes.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  usr/Makefile | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/usr/Makefile b/usr/Makefile
> index 17a513268325..3116b23d44f8 100644
> --- a/usr/Makefile
> +++ b/usr/Makefile
> @@ -5,8 +5,10 @@
>  klibcdirs:;
>  PHONY += klibcdirs
>  
> -suffix_y = $(CONFIG_INITRAMFS_COMPRESSION)
> -AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
> +suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
> +datafile_y = initramfs_data.cpio$(suffix_y)
> +AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE=usr/$(datafile_y)
> +
>  
>  # Generate builtin.o based on initramfs_data.o
>  obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
> @@ -14,7 +16,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
>  # initramfs_data.o contains the compressed initramfs_data.cpio image.
>  # The image is included using .incbin, a dependency which is not
>  # tracked automatically.
> -$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
> +$(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
>  
>  #####
>  # Generate the initramfs cpio archive
> @@ -38,10 +40,8 @@ endif
>  quiet_cmd_initfs = GEN     $@
>        cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
>  
> -targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
> -	initramfs_data.cpio.lzma initramfs_data.cpio.xz \
> -	initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
> -	initramfs_data.cpio
> +targets := $(datafile_y)
> +
>  # do not try to update files included in initramfs
>  $(deps_initramfs): ;
>  
> @@ -51,6 +51,6 @@ $(deps_initramfs): klibcdirs
>  # 2) There are changes in which files are included (added or deleted)
>  # 3) If gen_init_cpio are newer than initramfs_data.cpio
>  # 4) arguments to gen_initramfs.sh changes
> -$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
> +$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
>  	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
>  	$(call if_changed,initfs)
> -- 2.11.0

Hello!

First of all, sorry for taking too long to answer, Christmas kept me
awfully busy :(

Thanks a lot for catching the issue first, I didn't notice the spurious
rebuilds when testing my patches.

I have also reviewed and tested this one. I would split the two changes
(the quoted string fix and the one to make the Makefile not depend on
the extension) into two patches. Other than that feel free to add a
Reviewed-by and Tested-by if you need :)

Sincerely,
Francisco Blas Izquierdo Riera (klondike)



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-04 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-23  3:15 [PATCH] kbuild: Fix dependency checking for initramfs build Nicholas Piggin
2017-01-04 13:50 ` klondike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox