initramfs: a lot of cleanups
cover initramfs: a lot of cleanups
Masahiro Yamada (12):
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 | 92 ++++++----
usr/default_cpio_list | 6 +
...gen_initramfs_list.sh => gen_initramfs.sh} | 167 +++++-------------
usr/initramfs_data.S | 5 +-
6 files changed, 111 insertions(+), 193 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 1/12 gen_initramfs_list.sh: remove unused variable 'default_list'
This is assigned, but not referenced.
---
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
PATCH 2/12 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".
---
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
PATCH 3/12 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.
---
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
PATCH 4/12 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".
---
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
PATCH 5/12 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.
---
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 6/12 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.
---
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 7/12 initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile
In reply to Masahiro YamadaSpecify the dependency directly in the Makefile.
---
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
PATCH 8/12 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.
---
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 9/12 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 simplify the default behavior; remove the -d option, and add the default cpio list.
---
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 10/12 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.
---
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 11/12 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
---
usr/.gitignore | 8 +--- usr/Kconfig | 10 ----- usr/Makefile | 88 +++++++++++++++++++++++++++++--------------- usr/gen_initramfs.sh | 77 ++++++++------------------------------ usr/initramfs_data.S | 5 +-- 5 files changed, 77 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 +59 -29
114 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
Re: [PATCH 11/12] initramfs: refactor the initramfs build rules
Hi Mashahiro.
I just browsed this fine patchset and noticed...
Quoted 8 lines
usr/Makefile +5
-2-##### -# Generate the initramfs cpio archive +ramfs-input := $(shell echo $(CONFIG_INITRAMFS_SOURCE)) +cpio-data := + +ifeq ($(words $(ramfs-input)),0) +
usr/Makefile line 37
Quoted 10 lines
usr/Makefile +10
-0+# If CONFIG_INITRAMFS_SOURCE is empty, generate a small initramfs with the +# default contents. +ramfs-input := $(srctree)/$(src)/default_cpio_list + +else ifeq ($(words $(ramfs-input)),1) +# If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with +# .cpio or .cpio.*, use it directly as an initramfs. +ifneq ($(filter %.cpio,$(ramfs-input)),) +cpio-data := $(ramfs-input) +endif
This part will now work if the file is named foo.cpio.bar. $(findstring .cpio, should be used and not $(filter %.cpio At least if the comment describes the intended behaviour.
usr/Makefile line 46
Quoted 9 lines
usr/Makefile +9
-0+ +ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) +cpio-data := $(ramfs-input) +# If the specified archive is suffixed with .cpio.* (i.e. already compressed), +# we do not double-compress it. +compress-y := shipped +endif + +endif
Sam
Re: [PATCH 11/12] initramfs: refactor the initramfs build rules
Hi Sam,
Quoted 18 lines · Sam Ravnborg
Hi Mashahiro.
I just browsed this fine patchset and noticed...
Quoted 14 lines
usr/Makefile +11
-2-##### -# Generate the initramfs cpio archive +ramfs-input := $(shell echo $(CONFIG_INITRAMFS_SOURCE)) +cpio-data := + +ifeq ($(words $(ramfs-input)),0) + +# If CONFIG_INITRAMFS_SOURCE is empty, generate a small initramfs with the +# default contents. +ramfs-input := $(srctree)/$(src)/default_cpio_list + +else ifeq ($(words $(ramfs-input)),1) +# If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with
Quoted 8 lines
usr/Makefile line 37
Quoted 4 lines
usr/Makefile +4
-0+# .cpio or .cpio.*, use it directly as an initramfs. +ifneq ($(filter %.cpio,$(ramfs-input)),) +cpio-data := $(ramfs-input) +endifThis part will now work if the file is named foo.cpio.bar. $(findstring .cpio, should be used and not $(filter %.cpio At least if the comment describes the intended behaviour.
The 'foo.cpio.bar' is taken care of
by ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2)
I admit the comment was confusing.
I will clarify the comments as follows:
# If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with # .cpio, use it directly as an initramfs.
ifneq ($(filter %.cpio,$(ramfs-input)),)
cpio-data := $(ramfs-input)
endif
# If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with # .cpio.*, use it directly as an initramfs, and avoid double compression. ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) cpio-data := $(ramfs-input)
compress-y := shipped
endif
Quoted 4 lines
Quoted 4 lines
usr/Makefile +4
-0+ +ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) +cpio-data := $(ramfs-input) +# If the specified archive is suffixed with .cpio.* (i.e. already compressed),
Quoted 8 lines
usr/Makefile line 46
Quoted 5 lines
usr/Makefile +5
-0+# we do not double-compress it. +compress-y := shipped +endif + +endifSam
--
Best Regards
Masahiro Yamada
Re: [PATCH 11/12] initramfs: refactor the initramfs build rules
Hi Masahiro.
Quoted 12 lines
Quoted 10 lines
usr/Makefile line 37
Quoted 6 lines
usr/Makefile +6
-0+else ifeq ($(words $(ramfs-input)),1) +# If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with +# .cpio or .cpio.*, use it directly as an initramfs. +ifneq ($(filter %.cpio,$(ramfs-input)),) +cpio-data := $(ramfs-input) +endifThis part will now work if the file is named foo.cpio.bar. $(findstring .cpio, should be used and not $(filter %.cpio At least if the comment describes the intended behaviour.
Quoted 2 lines
The 'foo.cpio.bar' is taken care of
by ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2)
Clever, I only now realized how this worked.
Quoted 14 lines
I admit the comment was confusing.
I will clarify the comments as follows:
# If
CONFIG_INITRAMFS_SOURCEspecifies a single file, and it is suffixed with # .cpio, use it directly as an initramfs.
ifneq ($(filter %.cpio,$(ramfs-input)),)
cpio-data := $(ramfs-input)
endif
Quoted 6 lines
# If
CONFIG_INITRAMFS_SOURCEspecifies a single file, and it is suffixed with # .cpio.*, use it directly as an initramfs, and avoid double compression. ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) cpio-data := $(ramfs-input)
compress-y := shipped
endif
Looks good.
Sam
PATCH 12/12 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.
---
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