mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-25 19:14:39 +08:00
e08b187745
This is a follow-up to commit57ddfdaa9a
("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: http://lkml.kernel.org/r/20170521033337.6197-1-f.fainelli@gmail.com not working with initramfs compression. This can be seen by the following steps/timestamps: https://www.spinics.net/lists/kernel/msg2598153.html .initramfs_data.cpio.gz.cmd is correct: cmd_usr/initramfs_data.cpio.gz := /bin/bash ./scripts/gen_initramfs_list.sh -o usr/initramfs_data.cpio.gz -u 1000 -g 1000 /home/fainelli/work/uclinux-rootfs/romfs /home/fainelli/work/uclinux-rootfs/misc/initramfs.dev 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. Link: http://lkml.kernel.org/r/20170930033936.6722-1-f.fainelli@gmail.com Fixes:db2aa7fd15
("initramfs: allow again choice of the embedded initramfs compression algorithm") Fixes:9e3596b0c6
("kbuild: initramfs cleanup, set target from Kconfig") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Cc: "Francisco Blas Izquierdo Riera (klondike)" <klondike@xiscosoft.net> Cc: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
59 lines
2.0 KiB
Makefile
59 lines
2.0 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# kbuild file for usr/ - including initramfs image
|
|
#
|
|
|
|
klibcdirs:;
|
|
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)"
|
|
|
|
|
|
# Generate builtin.o based on initramfs_data.o
|
|
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)/$(datafile_y) FORCE
|
|
|
|
#####
|
|
# Generate the initramfs cpio archive
|
|
|
|
hostprogs-y := gen_init_cpio
|
|
initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
|
|
ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
|
|
$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
|
|
ramfs-args := \
|
|
$(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
|
|
$(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
|
|
|
|
# $(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 gen_initramfs.sh -l
|
|
ifneq ($(wildcard $(obj)/$(datafile_d_y)),)
|
|
include $(obj)/$(datafile_d_y)
|
|
endif
|
|
|
|
quiet_cmd_initfs = GEN $@
|
|
cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
|
|
|
|
targets := $(datafile_y)
|
|
|
|
# do not try to update files included in initramfs
|
|
$(deps_initramfs): ;
|
|
|
|
$(deps_initramfs): klibcdirs
|
|
# We rebuild initramfs_data.cpio if:
|
|
# 1) Any included file is newer then initramfs_data.cpio
|
|
# 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)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
|
|
$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y)
|
|
$(call if_changed,initfs)
|