Browse files

initramfs: fix initramfs rebuilds w/ compression after disabling

This is a follow-up to commit 57ddfda ("initramfs: fix disabling of
initramfs (and its compression)").  This particular commit fixed the use
case where we build the kernel with an initramfs with no compression,
and then we build the kernel with no initramfs.

Now this still left us with the same case as described here:

not working with initramfs compression.  This can be seen by the
following steps/timestamps:

.initramfs_data.cpio.gz.cmd is correct:

  cmd_usr/initramfs_data.cpio.gz := /bin/bash
  ./scripts/ -o usr/initramfs_data.cpio.gz  -u 1000 -g 1000  /home/fainelli/work/uclinux-rootfs/romfs /home/fainelli/work/uclinux-rootfs/misc/

and was generated the first time we did generate the gzip initramfs, so
the command has not changed, nor its arguments, so we just don't call
it, no initramfs cpio is re-generated as a consequence.

The fix for this problem is just to properly keep track of the
.initramfs_cpio_data.d file by suffixing it with the compression
extension.  This takes care of properly tracking dependencies such that
the initramfs get (re)generated any time files are added/deleted etc.

Fixes: db2aa7f ("initramfs: allow again choice of the embedded initramfs compression algorithm")
Fixes: 9e3596b ("kbuild: initramfs cleanup, set target from Kconfig")
Signed-off-by: Florian Fainelli <>
Cc: "Francisco Blas Izquierdo Riera (klondike)" <>
Cc: Nicholas Piggin <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
  • Loading branch information...
ffainelli authored and torvalds committed Nov 2, 2017
1 parent ab615a5 commit e08b1877452a0055c65f6394163ce5a0fbd720a3
Showing with 5 additions and 4 deletions.
  1. +5 −4 usr/Makefile
@@ -8,6 +8,7 @@ PHONY += klibcdirs
suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
datafile_y = initramfs_data.cpio$(suffix_y)
datafile_d_y = .$(datafile_y).d
AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
@@ -30,12 +31,12 @@ ramfs-args := \
# .initramfs_data.cpio.d is used to identify all files included
# $(datafile_d_y) is used to identify all files included
# in initramfs and to detect if any files are added/removed.
# Removed files are identified by directory timestamp being updated
# The dependency list is generated by -l
ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
include $(obj)/.initramfs_data.cpio.d
ifneq ($(wildcard $(obj)/$(datafile_d_y)),)
include $(obj)/$(datafile_d_y)
quiet_cmd_initfs = GEN $@
@@ -53,5 +54,5 @@ $(deps_initramfs): klibcdirs
# 3) If gen_init_cpio are newer than initramfs_data.cpio
# 4) arguments to changes
$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y)
$(call if_changed,initfs)

0 comments on commit e08b187

Please sign in to comment.