[klibc] [PATCH] klibc: fix gen_initramfs_init.sh when using -d

Sam Ravnborg sam at ravnborg.org
Sat Apr 15 07:19:24 PDT 2006


gen_initramfs_list.sh failed to generate a dependency list when
it was supplied the -d option.
Restructured gen_initramfs_list.sh to support dependency info with -d.
This also fixes a bug where we did not properly process
when more than one dir was specified.
Finally update dependency info for the -d case (list_default_initramfs)

In usr/Kbuild remove "" around CONFIG_RAMFS_SOURCE so the shell
recognize two directories as two arguments.

Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
---

Patch made on top of linux/kernel/git/hpa/linux-2.6-klibc.
Now I hope that this trivial thing is finally fixed...

	Sam

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 2773126..45c81b0 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -37,8 +37,7 @@ EOF
 }
 
 list_default_initramfs() {
-	# echo usr/kinit/kinit
-	:
+	echo usr/kinit/kinit \\
 }
 
 default_initramfs() {
@@ -167,8 +166,6 @@ header() {
 
 # process one directory (incl sub-directories)
 dir_filelist() {
-	${dep_list}header "$1"
-
 	srcdir=$(echo "$1" | sed -e 's://*:/:g')
 	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
 
@@ -187,9 +184,9 @@ # if only one file is specified and it i
 # 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
 input_file() {
-	source="$1"
-	if [ -f "$1" ]; then
-		${dep_list}header "$1"
+	if [ "$1" == "-d" ]; then
+		${dep_list}default_initramfs
+	elif [ -f "$1" ]; then
 		is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')"
 		if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
 			cpio_file=$1
@@ -210,6 +207,15 @@ input_file() {
 	fi
 }
 
+# input file/dir - process it
+process_file() {
+	if [ -z ${print_header} ]; then
+		${dep_list}header "$1"
+	fi
+	print_header=y
+	input_file "$1" "$2"
+}
+
 prog=$0
 root_uid=0
 root_gid=0
@@ -245,21 +251,17 @@ while [ $# -gt 0 ]; do
 			root_gid="$1"
 			shift
 			;;
-		"-d")	# display default initramfs list
-			default_list="$arg"
-			${dep_list}default_initramfs
-			;;
 		"-h")
 			usage
 			exit 0
 			;;
 		*)
 			case "$arg" in
-				"-"*)
-					unknown_option
+				"-d")	process_file "$arg" "$#"
+					;;
+				"-"*)	unknown_option
 					;;
-				*)	# input file/dir - process it
-					input_file "$arg" "$#"
+				*)	process_file "$arg" "$#"
 					;;
 			esac
 			;;
diff --git a/usr/Kbuild b/usr/Kbuild
index e243e11..c4f5be2 100644
--- a/usr/Kbuild
+++ b/usr/Kbuild
@@ -37,8 +37,9 @@ # 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)), \
-                    $(CONFIG_INITRAMFS_SOURCE),-d)
+ramfs-input := $(shell echo $(CONFIG_INITRAMFS_SOURCE))
+ramfs-input := $(if $(ramfs-input), $(ramfs-input), -d)
+
 ramfs-args  := \
         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
         $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \



More information about the klibc mailing list