initramfs: a lot of cleanups
v2 cover initramfs: a lot of cleanups
Masahiro Yamada (13):
initramfs: replace klibcdirs in Makefile with FORCE gen_initramfs_list.sh: remove unused variable 'default_list' gen_initramfs_list.sh: fix the tool name in the comment
initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
initramfs: remove redundant dependency on BLK_DEV_INITRD
initramfs: make compression options not depend on INITRAMFS_SOURCE
initramfs: make initramfs compression choice non-optional
initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in
Makefile
initramfs: generate dependency list and cpio at the same time
initramfs: add default_cpio_list, and delete -d option support gen_initramfs.sh: always output cpio even without -o option
initramfs: refactor the initramfs build rules gen_initramfs.sh: remove intermediate cpio_list on errors
usr/.gitignore | 8 +-
usr/Kconfig | 26 ---
usr/Makefile | 97 ++++++----
usr/default_cpio_list | 6 +
...gen_initramfs_list.sh => gen_initramfs.sh} | 167 +++++-------------
usr/initramfs_data.S | 5 +-
6 files changed, 112 insertions(+), 197 deletions(-)
create mode 100644 usr/default_cpio_list
rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (53%)Signature · 1 line
2.17.1
PATCH v2 1/13 initramfs: replace klibcdirs in Makefile with FORCE
'klibcdirs' was added by commit d39a206bc35d ("kbuild: rebuild initramfs if content of initramfs changes"). If this is just a matter of forcing execution of the recipe line, we can replace it with FORCE.
I do not understand the purpose of
$(deps_initramfs): klibcdirs
Remove it.
---
Changes in v2:
- New patch (I forgot to submit this in v1 series)
usr/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
usr/Makefile +1 -5
@@ -3,9 +3,6 @@ # 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
@@ -50,13 +47,12 @@ 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 than 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 +$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) FORCE $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs)
Signature · 1 line
2.17.1
Re: [PATCH v2 01/13] initramfs: replace klibcdirs in Makefile with FORCE
Quoted 11 lines · Masahiro Yamada
'klibcdirs' was added by commit
d39a206bc35d("kbuild: rebuild initramfs if content of initramfs changes"). If this is just a matter of forcing execution of the recipe line, we can replace it with FORCE.I do not understand the purpose of
$(deps_initramfs): klibcdirsRemove it.
Signed-off-by Masahiro Yamada <[email protected]>
Re: [PATCH v2 01/13] initramfs: replace klibcdirs in Makefile with FORCE
In reply to Masahiro Yamada(+CC: Ben Hutchings, H. Peter Anvin)
Quoted 8 lines · Masahiro Yamada
'klibcdirs' was added by commit
d39a206bc35d("kbuild: rebuild initramfs if content of initramfs changes"). If this is just a matter of forcing execution of the recipe line, we can replace it with FORCE.I do not understand the purpose of
$(deps_initramfs): klibcdirs
Perhaps, the 'klibcdirs' target might be intended
to control the directory descending
in case klibc is dropped in the kernel tree.
Anyway, klibc is built independently
of Linux kernel, and this 'klibcdirs' target
is just a no-op stub as far as the kernel tree is concerned.
Clean it up.
Quoted 43 lines
Remove it.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- New patch (I forgot to submit this in v1 series)usr/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)usr/Makefile +1
-6@@ -3,9 +3,6 @@ # 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@@ -50,13 +47,12 @@ 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 than 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 +$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) FORCE $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs) --2.17.1
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v2 01/13] initramfs: replace klibcdirs in Makefile with FORCE
Quoted 61 lines · Masahiro Yamada
(+CC: Ben Hutchings, H. Peter Anvin)
Quoted 2 lines · Masahiro Yamada
'klibcdirs' was added by commit
d39a206bc35d("kbuild: rebuildinitramfs
Quoted 1 line
if content of initramfs changes"). If this is just a matter of
forcing
Quoted 5 lines
execution of the recipe line, we can replace it with FORCE.
I do not understand the purpose of
$(deps_initramfs): klibcdirsPerhaps, the 'klibcdirs' target might be intended
to control the directory descending
in case klibc is dropped in the kernel tree.Anyway, klibc is built independently
of Linux kernel, and this 'klibcdirs' target
is just a no-op stub as far as the kernel tree is concerned.Clean it up.
Quoted 26 lines
Remove it.
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- New patch (I forgot to submit this in v1 series)usr/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)usr/Makefile +0
-3@@ -3,9 +3,6 @@ # 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).dusr/Makefile targets := $(datafile_y) · line 52
Quoted 7 lines
usr/Makefile +0
-1@@ -50,13 +47,12 @@ 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 than initramfs_data.cpio # 2) There are changes in which files are included (added ordeleted)
Quoted 11 lines
usr/Makefile targets := $(datafile_y)
Quoted 3 lines
usr/Makefile +0
-1# 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
Quoted 7 lines
usr/Makefile +1
-1+$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) FORCE $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs) --2.17.1
Yes, it is/was a hook for the klibc integration tree.
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
PATCH v2 2/13 gen_initramfs_list.sh: remove unused variable 'default_list'
In reply to Masahiro YamadaThis is assigned, but not referenced.
---
Changes in v2: None
usr/gen_initramfs_list.sh | 1 - 1 file changed, 1 deletion(-)
usr/gen_initramfs_list.sh +0 -1
@@ -280,7 +280,6 @@ while [ $# -gt 0 ]; do shift ;; "-d") # display default initramfs list - default_list="$arg" ${dep_list}default_initramfs ;; "-h")
Signature · 1 line
2.17.1
Re: [PATCH v2 02/13] gen_initramfs_list.sh: remove unused variable 'default_list'
Quoted 3 lines · Masahiro Yamada
This is assigned, but not referenced.
Signed-off-by Masahiro Yamada <[email protected]>
PATCH v2 3/13 gen_initramfs_list.sh: fix the tool name in the comment
In reply to Masahiro YamadaThere is no tool named "gen_initramfs". The correct name is "gen_init_cpio".
---
Changes in v2: None
usr/gen_initramfs_list.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
usr/gen_initramfs_list.sh +1 -1
@@ -189,7 +189,7 @@ dir_filelist() { # if only one file is specified and it is .cpio file then use it direct as fs # if a directory is specified then add all files in given direcotry to fs -# if a regular file is specified assume it is in gen_initramfs format +# if a regular file is specified assume it is in gen_init_cpio format input_file() { source="$1" if [ -f "$1" ]; then
Signature · 1 line
2.17.1
Re: [PATCH v2 03/13] gen_initramfs_list.sh: fix the tool name in the comment
Quoted 4 lines · Masahiro Yamada
There is no tool named "
gen_initramfs". The correct name is "gen_init_cpio".Signed-off-by Masahiro Yamada <[email protected]>
PATCH v2 4/13 initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
In reply to Masahiro YamadaThe comments in usr/Makefile wrongly refer to the script name (twice).
Line 37:
# The dependency list is generated by gen_initramfs.sh -l
Line 54:
# 4) Arguments to gen_initramfs.sh changes
There does not exist such a script.
I was going to fix the comments, but after some consideration, I thought "gen_initramfs.sh" would be more suitable than "gen_initramfs_list.sh" because it generates an initramfs image in the common usage.
The script generates a list that can be fed to gen_init_cpio only when it is directly run without -o or -l option.
---
Changes in v2: None
usr/Makefile | 2 +-
usr/{gen_initramfs_list.sh => gen_initramfs.sh} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (100%)usr/Makefile +1 -1
@@ -24,7 +24,7 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE # Generate the initramfs cpio archive hostprogs-y := gen_init_cpio -initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs_list.sh +initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs.sh ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \
usr/gen_initramfs.sh renamed from usr/gen_initramfs_list.sh +0 -0
Signature · 1 line
2.17.1
Re: [PATCH v2 04/13] initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
Quoted 18 lines · Masahiro Yamada
The comments in usr/Makefile wrongly refer to the script name (twice).
Line 37:
# The dependency list is generated bygen_initramfs.sh-lLine 54:
# 4) Arguments togen_initramfs.shchangesThere does not exist such a script.
I was going to fix the comments, but after some consideration, I thought "
gen_initramfs.sh" would be more suitable than "gen_initramfs_list.sh" because it generates an initramfs image in the common usage.The script generates a list that can be fed to
gen_init_cpioonly when it is directly run without -o or -l option.Signed-off-by Masahiro Yamada <[email protected]>
Quoted 8 lines
---
Changes in v2: None
usr/Makefile | 2 +- usr/{gen_initramfs_list.sh => gen_initramfs.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (100%)
Will this break klibc? It might have a ref to the old name.
https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/Kbuild#n55
Quoted 17 lines
usr/Makefile +1
-1@@ -24,7 +24,7 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE # Generate the initramfs cpio archive hostprogs-y := gen_init_cpio -initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs_list.sh +initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs.sh ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \usr/gen_initramfs.sh renamed from usr/gen_initramfs_list.sh +0
-0
Re: [PATCH v2 04/13] initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
(+CC Ben Hutchings, H. Peter Anvin)
In my understanding, the klibc build system is standalone. So, the change in Linux kernel does not affect klibc at all. Only the depending part is UAPI headers (make headers_install).
So, this patch
(https://lore.kernel.org/patchwork/patch/1175336/)
should be OK.
Please correct me if I am wrong.
Quoted 25 lines · Greg Thelen
Quoted 22 lines · Masahiro Yamada
The comments in usr/Makefile wrongly refer to the script name (twice).
Line 37:
# The dependency list is generated bygen_initramfs.sh-lLine 54:
# 4) Arguments togen_initramfs.shchangesThere does not exist such a script.
I was going to fix the comments, but after some consideration, I thought "
gen_initramfs.sh" would be more suitable than "gen_initramfs_list.sh" because it generates an initramfs image in the common usage.The script generates a list that can be fed to
gen_init_cpioonly when it is directly run without -o or -l option.Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2: None
Quoted 7 lines
Quoted 4 lines
usr/Makefile | 2 +- usr/{gen_initramfs_list.sh => gen_initramfs.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (100%)Will this break klibc? It might have a ref to the old name.
https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/Kbuild#n55
I do not think so.
As I stated above, the klibc build system is independent of any script in the Linux kernel.
The klibc Makefile refers to scripts/gen_initramfs_list.sh, which does not exist.
My path is renamingusr/gen_initramfs_list.sh to usr/gen_initramfs.sh
If the renaming had been problematic for klibc, commit f6f57a46435d7253a52a1a07a58183678ad266a0 ("initramfs: move gen_initramfs_list.sh from scripts/ to usr/") would have already caused a problem.
Ben, Hans,
Is usr/Kbuild in klibc used?
If it is not used, is it better to delete it to avoid confusion?
Masahiro Yamada
Quoted 17 lines
Quoted 17 lines
usr/Makefile +1
-1@@ -24,7 +24,7 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE # Generate the initramfs cpio archive hostprogs-y := gen_init_cpio -initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs_list.sh +initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs.sh ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \usr/gen_initramfs.sh renamed from usr/gen_initramfs_list.sh +0
-0
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v2 04/13] initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
Quoted 11 lines · Masahiro Yamada
(+CC Ben Hutchings, H. Peter Anvin)
In my understanding, the klibc build system is standalone. So, the change in Linux kernel does not affect klibc at all. Only the depending part is UAPI headers (make
headers_install).So, this patch
(https://lore.kernel.org/patchwork/patch/1175336/)
should be OK.Please correct me if I am wrong.
I think you're right.
[...]
Quoted 7 lines
I do not think so.
As I stated above, the klibc build system is independent of any script in the Linux kernel.
The klibc
Makefilerefers toscripts/gen_initramfs_list.sh, which does not exist.
[...]
Right. I believe the original intent was to include klibc in the kernel tree, so this would have existed because of that.
There's no sign of that in the current klibc.git, but I think it might have gone through "git filter-branch" at some point after it was decided not to include it upstream. In any case, this was already broken for as long as klibc has been separate.
Ben.
Signature · 2 lines
Ben Hutchings Larkinson's Law: All laws are basically false.
Re: [PATCH v2 04/13] initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh
In reply to Masahiro YamadaQuoted 92 lines · Masahiro Yamada
(+CC Ben Hutchings, H. Peter Anvin)
In my understanding, the klibc build system is standalone. So, the change in Linux kernel does not affect klibc at all. Only the depending part is UAPI headers (make
headers_install).So, this patch
(https://lore.kernel.org/patchwork/patch/1175336/)
should be OK.Please correct me if I am wrong.
Quoted 4 lines · Greg Thelen
Quoted 1 line · Masahiro Yamada
The comments in usr/Makefile wrongly refer to the script name
(twice).
Quoted 10 lines
Quoted 10 lines
Line 37:
# The dependency list is generated bygen_initramfs.sh-lLine 54:
# 4) Arguments togen_initramfs.shchangesThere does not exist such a script.
I was going to fix the comments, but after some consideration, I
thought
Quoted 1 line
Quoted 1 line
"
gen_initramfs.sh" would be more suitable than"
gen_initramfs_list.sh"Quoted 3 lines
Quoted 3 lines
because it generates an initramfs image in the common usage.
The script generates a list that can be fed to
gen_init_cpioonlywhen
Quoted 5 lines
Quoted 5 lines
it is directly run without -o or -l option.
Signed-off-by Masahiro Yamada <[email protected]>---
Quoted 9 lines
Quoted 6 lines
Changes in v2: None
usr/Makefile | 2 +- usr/{gen_initramfs_list.sh => gen_initramfs.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (100%)Will this break klibc? It might have a ref to the old name.
https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/Kbuild#n55
I do not think so.
As I stated above, the klibc build system is independent of any script in the Linux kernel.
The klibc
Makefilerefers toscripts/gen_initramfs_list.sh, which does not exist.My path is renaming
usr/gen_initramfs_list.shtousr/gen_initramfs.shIf the renaming had been problematic for klibc, commit
f6f57a46435d7253a52a1a07a58183678ad266a0("initramfs: movegen_initramfs_list.shfromscripts/tousr/") would have already caused a problem.Ben, Hans,
Is usr/Kbuild in klibc used?
If it is not used, is it better to delete it to avoid confusion?Masahiro Yamada
Quoted 5 lines
usr/Makefile $(obj)/initramfs_data.o: $(obj)/$(datafile_y)
Quoted 5 lines
usr/Makefile +0
-0@@ -24,7 +24,7 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y)FORCE
Quoted 4 lines
usr/Makefile $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
Quoted 4 lines
usr/Makefile +0
-1# Generate the initramfs cpio archive hostprogs-y := gen_init_cpio -initramfs := $(CONFIG_SHELL)$(srctree)/$(src)/gen_initramfs_list.sh
Quoted 8 lines
Quoted 8 lines
usr/gen_initramfs.sh
Quoted 8 lines
usr/Makefile +1
-0+initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs.sh ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \usr/gen_initramfs.sh renamed from usr/gen_initramfs_list.sh +0
-0
That is correct.
The klibc integration work was mainly fine in an actual kernel tree, which pulled the klibc tree.
It has obviously bitrotted somewhat, but it wouldn't be all that hard to resurrect it if there is ever interest.
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
PATCH v2 5/13 initramfs: remove redundant dependency on BLK_DEV_INITRD
In reply to Masahiro Yamadainit/Kconfig includes usr/Kconfig inside the "if BLK_DEV_INITRD" ... "endif" block:
if BLK_DEV_INITRD
source "usr/Kconfig"
endif
Hence, all the defines in usr/Kconfig depend on BLK_DEV_INITRD.
Remove the redundant "depends on BLK_DEV_INITRD".
---
Changes in v2: None
usr/Kconfig | 6 ------ 1 file changed, 6 deletions(-)
usr/Kconfig +0 -6
@@ -54,7 +54,6 @@ config INITRAMFS_ROOT_GID config RD_GZIP bool "Support initial ramdisk/ramfs compressed using gzip" - depends on BLK_DEV_INITRD default y select DECOMPRESS_GZIP help
@@ -64,7 +63,6 @@ config RD_GZIP config RD_BZIP2 bool "Support initial ramdisk/ramfs compressed using bzip2" default y - depends on BLK_DEV_INITRD select DECOMPRESS_BZIP2 help Support loading of a bzip2 encoded initial ramdisk or cpio buffer
@@ -73,7 +71,6 @@ config RD_BZIP2 config RD_LZMA bool "Support initial ramdisk/ramfs compressed using LZMA" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZMA help Support loading of a LZMA encoded initial ramdisk or cpio buffer
@@ -81,7 +78,6 @@ config RD_LZMA config RD_XZ bool "Support initial ramdisk/ramfs compressed using XZ" - depends on BLK_DEV_INITRD default y select DECOMPRESS_XZ help
@@ -91,7 +87,6 @@ config RD_XZ config RD_LZO bool "Support initial ramdisk/ramfs compressed using LZO" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZO help Support loading of a LZO encoded initial ramdisk or cpio buffer
@@ -100,7 +95,6 @@ config RD_LZO config RD_LZ4 bool "Support initial ramdisk/ramfs compressed using LZ4" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZ4 help Support loading of a LZ4 encoded initial ramdisk or cpio buffer
Signature · 1 line
2.17.1
Re: [PATCH v2 05/13] initramfs: remove redundant dependency on BLK_DEV_INITRD
Quoted 7 lines · Masahiro Yamada
init/Kconfig includes usr/Kconfig inside the "if
BLK_DEV_INITRD" ... "endif" block:if
BLK_DEV_INITRDsource "usr/Kconfig"
Quoted 7 lines
endif
Hence, all the defines in usr/Kconfig depend on
BLK_DEV_INITRD.Remove the redundant "depends on
BLK_DEV_INITRD".Signed-off-by Masahiro Yamada <[email protected]>
Quoted 59 lines
---
Changes in v2: None
usr/Kconfig | 6 ------ 1 file changed, 6 deletions(-)usr/Kconfig +0
-6@@ -54,7 +54,6 @@ config INITRAMFS_ROOT_GID config RD_GZIP bool "Support initial ramdisk/ramfs compressed using gzip" - depends on BLK_DEV_INITRD default y select DECOMPRESS_GZIP help@@ -64,7 +63,6 @@ config RD_GZIP config RD_BZIP2 bool "Support initial ramdisk/ramfs compressed using bzip2" default y - depends on BLK_DEV_INITRD select DECOMPRESS_BZIP2 help Support loading of a bzip2 encoded initial ramdisk or cpio buffer@@ -73,7 +71,6 @@ config RD_BZIP2 config RD_LZMA bool "Support initial ramdisk/ramfs compressed using LZMA" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZMA help Support loading of a LZMA encoded initial ramdisk or cpio buffer@@ -81,7 +78,6 @@ config RD_LZMA config RD_XZ bool "Support initial ramdisk/ramfs compressed using XZ" - depends on BLK_DEV_INITRD default y select DECOMPRESS_XZ help@@ -91,7 +87,6 @@ config RD_XZ config RD_LZO bool "Support initial ramdisk/ramfs compressed using LZO" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZO help Support loading of a LZO encoded initial ramdisk or cpio buffer@@ -100,7 +95,6 @@ config RD_LZO config RD_LZ4 bool "Support initial ramdisk/ramfs compressed using LZ4" default y - depends on BLK_DEV_INITRD select DECOMPRESS_LZ4 help Support loading of a LZ4 encoded initial ramdisk or cpio buffer
PATCH v2 6/13 initramfs: make compression options not depend on INITRAMFS_SOURCE
In reply to Masahiro YamadaEven if INITRAMFS_SOURCE is empty, usr/gen_initramfs.sh generates a tiny default initramfs, which is embedded in vmlinux.
So, defining INITRAMFS_COMPRESSION* options should be valid irrespective of INITRAMFS_SOURCE.
---
Changes in v2: None
usr/Kconfig | 2 -- 1 file changed, 2 deletions(-)
usr/Kconfig +0 -2
@@ -102,7 +102,6 @@ config RD_LZ4 choice prompt "Built-in initramfs compression mode" - depends on INITRAMFS_SOURCE!="" optional help This option allows you to decide by which algorithm the builtin
@@ -211,7 +210,6 @@ config INITRAMFS_COMPRESSION_LZ4 endchoice config INITRAMFS_COMPRESSION - depends on INITRAMFS_SOURCE!="" string default "" if INITRAMFS_COMPRESSION_NONE default ".gz" if INITRAMFS_COMPRESSION_GZIP
Signature · 1 line
2.17.1
PATCH v2 7/13 initramfs: make initramfs compression choice non-optional
In reply to Masahiro YamadaCurrently, the choice of the initramfs compression mode is too complex because users are allowed to not specify the compression mode at all.
I think it makes more sense to require users to choose the compression explicitly, and delete the fallback defaults of INITRAMFS_COMPRESSION.
---
Changes in v2: None
usr/Kconfig | 8 -------- 1 file changed, 8 deletions(-)
usr/Kconfig +0 -8
@@ -102,7 +102,6 @@ config RD_LZ4 choice prompt "Built-in initramfs compression mode" - optional help This option allows you to decide by which algorithm the builtin initramfs will be compressed. Several compression algorithms are
@@ -218,10 +217,3 @@ config INITRAMFS_COMPRESSION default ".xz" if INITRAMFS_COMPRESSION_XZ default ".lzo" if INITRAMFS_COMPRESSION_LZO default ".lz4" if INITRAMFS_COMPRESSION_LZ4 - default ".gz" if RD_GZIP - default ".lz4" if RD_LZ4 - default ".lzo" if RD_LZO - default ".xz" if RD_XZ - default ".lzma" if RD_LZMA - default ".bz2" if RD_BZIP2 - default ""
Signature · 1 line
2.17.1
PATCH v2 8/13 initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile
In reply to Masahiro YamadaSpecify the dependency directly in the Makefile.
---
Changes in v2: None
usr/Makefile | 7 +++---- usr/gen_initramfs.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-)
usr/Makefile +3 -4
@@ -24,7 +24,6 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE # Generate the initramfs cpio archive hostprogs-y := gen_init_cpio -initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs.sh ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \
@@ -40,7 +39,7 @@ ifneq ($(wildcard $(obj)/$(datafile_d_y)),) endif quiet_cmd_initfs = GEN $@ - cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) + cmd_initfs = $< -o $@ $(ramfs-args) $(ramfs-input) targets := $(datafile_y)
@@ -52,8 +51,8 @@ $(deps_initramfs): ; # 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) FORCE - $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) +$(obj)/$(datafile_y): $(src)/gen_initramfs.sh $(obj)/gen_init_cpio $(deps_initramfs) FORCE + $(Q)$< -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs) subdir-$(CONFIG_UAPI_HEADER_TEST) += include
usr/gen_initramfs.sh +1 -1
@@ -235,7 +235,7 @@ arg="$1" case "$arg" in "-l") # files included in initramfs - used by kbuild dep_list="list_" - echo "deps_initramfs := $0 \\" + echo "deps_initramfs := \\" shift ;; "-o") # generate compressed cpio image named $1
Signature · 1 line
2.17.1
Re: [PATCH v2 08/13] initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile
Quoted 3 lines · Masahiro Yamada
Specify the dependency directly in the
Makefile.Signed-off-by Masahiro Yamada <[email protected]>
PATCH v2 9/13 initramfs: generate dependency list and cpio at the same time
In reply to Masahiro YamadaCurrently, this script is run twice, for the dependency list, and then for the cpio archive.
The first one is re-run every time although its build log is suppressed so nobody notices it.
Make it work more efficiently by generating the cpio and the dependency list at the same time.
---
Changes in v2: None
usr/Makefile | 3 +- usr/gen_initramfs.sh | 108 ++++++++++++++++++------------------------- 2 files changed, 47 insertions(+), 64 deletions(-)
usr/Makefile +1 -2
@@ -39,7 +39,7 @@ ifneq ($(wildcard $(obj)/$(datafile_d_y)),) endif quiet_cmd_initfs = GEN $@ - cmd_initfs = $< -o $@ $(ramfs-args) $(ramfs-input) + cmd_initfs = $< -o $@ -l $(obj)/$(datafile_d_y) $(ramfs-args) $(ramfs-input) targets := $(datafile_y)
@@ -52,7 +52,6 @@ $(deps_initramfs): ; # 3) If gen_init_cpio are newer than initramfs_data.cpio # 4) Arguments to gen_initramfs.sh changes $(obj)/$(datafile_y): $(src)/gen_initramfs.sh $(obj)/gen_init_cpio $(deps_initramfs) FORCE - $(Q)$< -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(call if_changed,initfs) subdir-$(CONFIG_UAPI_HEADER_TEST) += include
usr/gen_initramfs.sh +46 -62
187 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 10/13 initramfs: add default_cpio_list, and delete -d option support
In reply to Masahiro YamadaWhen CONFIG_INITRAMFS_SOURCE is empty, the Makefile passes the -d option to gen_initramfs.sh to create the default initramfs, which contains /dev, /dev/console, and /root.
This commit simplifies the default behavior; remove the -d option, and add the default cpio list.
---
Changes in v2: None
usr/Makefile | 2 +- usr/default_cpio_list | 6 ++++++ usr/gen_initramfs.sh | 16 ---------------- 3 files changed, 7 insertions(+), 17 deletions(-) create mode 100644 usr/default_cpio_list
usr/Makefile +1 -1
@@ -25,7 +25,7 @@ $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE hostprogs-y := gen_init_cpio ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ - $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) + $(shell echo $(CONFIG_INITRAMFS_SOURCE)),$(srctree)/$(src)/default_cpio_list) ramfs-args := \ $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
usr/default_cpio_list new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# This is a very simple, default initramfs + +dir /dev 0755 0 0 +nod /dev/console 0600 0 0 c 5 1 +dir /root 0700 0 0
usr/gen_initramfs.sh +0 -16
@@ -28,7 +28,6 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... <cpio_source> File list or directory for cpio archive. If <cpio_source> is a .cpio file it will be used as direct input to initramfs. - -d Output the default cpio list. All options except -o and -l may be repeated and are interpreted sequentially and immediately. -u and -g states are preserved across
@@ -43,18 +42,6 @@ field() { shift $1 ; echo $1 } -default_initramfs() { - cat <<-EOF >> ${output} - # This is a very simple, default initramfs - - dir /dev 0755 0 0 - nod /dev/console 0600 0 0 c 5 1 - dir /root 0700 0 0 - # file /kinit usr/kinit/kinit 0755 0 0 - # slink /init kinit 0755 0 0 - EOF -} - filetype() { local argv1="$1"
@@ -263,9 +250,6 @@ while [ $# -gt 0 ]; do [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0) shift ;; - "-d") # display default initramfs list - default_initramfs - ;; "-h") usage exit 0
Signature · 1 line
2.17.1
PATCH v2 11/13 gen_initramfs.sh: always output cpio even without -o option
In reply to Masahiro YamadaCurrently, this script outputs a cpio file when -o option is given, but otherwise a text file in the format recognized by gen_init_cpio.
This behavior is unclear. Make it always output a cpio file.
---
Changes in v2: None
usr/gen_initramfs.sh | 58 +++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 31 deletions(-)
usr/gen_initramfs.sh +27 -31
@@ -6,7 +6,6 @@ # # Generate a cpio packed initramfs. It uses gen_init_cpio to generate # the cpio archive, and then compresses it. -# The script may also be used to generate the inputfile used for gen_init_cpio # This script assumes that gen_init_cpio is located in usr/ directory # error out on errors
@@ -71,8 +70,8 @@ print_mtime() { my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1) fi - echo "# Last modified: ${my_mtime}" >> ${output} - echo "" >> ${output} + echo "# Last modified: ${my_mtime}" >> $cpio_list + echo "" >> $cpio_list } list_parse() {
@@ -125,7 +124,7 @@ parse() { ;; esac - echo "${str}" >> ${output} + echo "${str}" >> $cpio_list return 0 }
@@ -141,7 +140,7 @@ unknown_option() { } header() { - printf "\n#####################\n# $1\n" >> ${output} + printf "\n#####################\n# $1\n" >> $cpio_list } # process one directory (incl sub-directories)
@@ -177,8 +176,8 @@ input_file() { [ -n "$dep_list" ] && echo "$1" >> $dep_list return 0 fi - print_mtime "$1" >> ${output} - cat "$1" >> ${output} + print_mtime "$1" >> $cpio_list + cat "$1" >> $cpio_list if [ -n "$dep_list" ]; then echo "$1 \\" >> $dep_list cat "$1" | while read type dir file perm ; do
@@ -200,9 +199,9 @@ root_uid=0 root_gid=0 dep_list= cpio_file= -cpio_list= +cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) output="/dev/stdout" -output_file="" +output_file="/dev/stdout" is_cpio_compressed= compr="gzip -n -9 -f"
@@ -217,8 +216,7 @@ while [ $# -gt 0 ]; do ;; "-o") # generate compressed cpio image named $1 output_file="$1" - cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" - output=${cpio_list} + output=$cpio_list echo "$output_file" | grep -q "\.gz$" \ && [ -x "`which gzip 2> /dev/null`" ] \ && compr="gzip -n -9 -f"
@@ -269,27 +267,25 @@ done # If output_file is set we will generate cpio archive and compress it # we are careful to delete tmp files -if [ ! -z ${output_file} ]; then - if [ -z ${cpio_file} ]; then - timestamp= - if test -n "$KBUILD_BUILD_TIMESTAMP"; then - timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" - if test -n "$timestamp"; then - timestamp="-t $timestamp" - fi +if [ -z ${cpio_file} ]; then + timestamp= + if test -n "$KBUILD_BUILD_TIMESTAMP"; then + timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" + if test -n "$timestamp"; then + timestamp="-t $timestamp" fi - cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" - usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile} - else - cpio_tfile=${cpio_file} - fi - rm ${cpio_list} - if [ "${is_cpio_compressed}" = "compressed" ]; then - cat ${cpio_tfile} > ${output_file} - else - (cat ${cpio_tfile} | ${compr} - > ${output_file}) \ - || (rm -f ${output_file} ; false) fi - [ -z ${cpio_file} ] && rm ${cpio_tfile} + cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" + usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile} +else + cpio_tfile=${cpio_file} +fi +rm ${cpio_list} +if [ "${is_cpio_compressed}" = "compressed" ]; then + cat ${cpio_tfile} > ${output_file} +else + (cat ${cpio_tfile} | ${compr} - > ${output_file}) \ + || (rm -f ${output_file} ; false) fi +[ -z ${cpio_file} ] && rm ${cpio_tfile} exit 0
Signature · 1 line
2.17.1
PATCH v2 12/13 initramfs: refactor the initramfs build rules
In reply to Masahiro YamadaCurrently, usr/gen_initramfs.sh takes care of all the use-cases:
[1] generates a cpio file unless CONFIG_INITRAMFS_SOURCE points to a single cpio archive
[2] If CONFIG_INITRAMFS_SOURCE is the path to a cpio archive, use it as-is.
[3] Compress the cpio file according to CONFIG_INITRAMFS_COMPRESSION_* unless it is passed a compressed archive.
To simplify the script, move [2] and [3] to usr/Makefile.
If CONFIG_INITRAMFS_SOURCE is the path to a cpio archive, there is no need to run this shell script.
For the cpio archive compression, you can re-use the rules from scripts/Makefile.lib .
---
Changes in v2:
- improve the comments so that they match to the code
- use $(strip ...) instead of $(words ...) for the case CONFIG_INITRAMFS_SOURCE is empty
usr/.gitignore | 8 +--- usr/Kconfig | 10 ----- usr/Makefile | 89 +++++++++++++++++++++++++++++--------------- usr/gen_initramfs.sh | 77 ++++++++------------------------------ usr/initramfs_data.S | 5 +-- 5 files changed, 78 insertions(+), 111 deletions(-)
usr/.gitignore +1 -7
@@ -1,9 +1,3 @@ -# -# Generated files -# gen_init_cpio initramfs_data.cpio -initramfs_data.cpio.gz -initramfs_data.cpio.bz2 -initramfs_data.cpio.lzma -initramfs_list +/initramfs_inc_data
usr/Kconfig +0 -10
@@ -207,13 +207,3 @@ config INITRAMFS_COMPRESSION_LZ4 by default which could cause a build failure. endchoice - -config INITRAMFS_COMPRESSION - string - default "" if INITRAMFS_COMPRESSION_NONE - default ".gz" if INITRAMFS_COMPRESSION_GZIP - default ".bz2" if INITRAMFS_COMPRESSION_BZIP2 - default ".lzma" if INITRAMFS_COMPRESSION_LZMA - default ".xz" if INITRAMFS_COMPRESSION_XZ - default ".lzo" if INITRAMFS_COMPRESSION_LZO - default ".lz4" if INITRAMFS_COMPRESSION_LZ4
usr/Makefile +60 -29
115 lines not on this page · raw message
usr/gen_initramfs.sh +16 -61
131 lines not on this page · raw message
usr/initramfs_data.S +1 -4
@@ -22,12 +22,9 @@ in the ELF header, as required by certain architectures. */ -#include <linux/stringify.h> -#include <asm-generic/vmlinux.lds.h> - .section .init.ramfs,"a" __irf_start: -.incbin __stringify(INITRAMFS_IMAGE) +.incbin "usr/initramfs_inc_data" __irf_end: .section .init.ramfs.info,"a" .globl __initramfs_size
Signature · 1 line
2.17.1
PATCH v2 13/13 gen_initramfs.sh: remove intermediate cpio_list on errors
In reply to Masahiro YamadaThis script sets the -e option, so it exits on any error, in which case it exits without cleaning up the intermediate cpio_list.
Make sure to delete it on exit.
---
Changes in v2: None
usr/gen_initramfs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
usr/gen_initramfs.sh +2 -1
@@ -193,6 +193,8 @@ dep_list= cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) output="/dev/stdout" +trap "rm -f $cpio_list" EXIT + while [ $# -gt 0 ]; do arg="$1" shift
@@ -243,4 +245,3 @@ if test -n "$KBUILD_BUILD_TIMESTAMP"; then fi fi usr/gen_init_cpio $timestamp $cpio_list > $output -rm $cpio_list
Signature · 1 line
2.17.1
Quoted 18 lines · Masahiro Yamada
Masahiro Yamada (13):
initramfs: replace klibcdirs inMakefilewith FORCEgen_initramfs_list.sh: remove unused variable 'default_list'gen_initramfs_list.sh: fix the tool name in the comment
initramfs: renamegen_initramfs_list.shtogen_initramfs.sh
initramfs: remove redundant dependency onBLK_DEV_INITRD
initramfs: make compression options not depend onINITRAMFS_SOURCE
initramfs: make initramfs compression choice non-optional
initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in
Makefile
initramfs: generate dependency list and cpio at the same time
initramfs: adddefault_cpio_list, and delete -d option supportgen_initramfs.sh: always output cpio even without -o option
initramfs: refactor the initramfs build rulesgen_initramfs.sh: remove intermediatecpio_liston errors
All, applied to linux-kbuild.
Quoted 10 lines
usr/.gitignore | 8 +-
usr/Kconfig | 26 ---
usr/Makefile | 97 ++++++----
usr/default_cpio_list | 6 +
...gen_initramfs_list.sh => gen_initramfs.sh} | 167 +++++-------------
usr/initramfs_data.S | 5 +-
6 files changed, 112 insertions(+), 197 deletions(-)
create mode 100644 usr/default_cpio_list
rename usr/{gen_initramfs_list.sh => gen_initramfs.sh} (53%)Quoted 3 lines
--
2.17.1
--
Best Regards
Masahiro Yamada