linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
       [not found] <200410200849.i9K8n5921516@mail.osdl.org>
@ 2004-10-23 12:06 ` Martin Schlemmer [c]
  2004-10-24 10:08   ` Andrew Morton
  2004-10-26 22:12   ` Sam Ravnborg
  0 siblings, 2 replies; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-23 12:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: torvalds, Sam Ravnborg, Linux Kernel Mailing Lists


[-- Attachment #1.1: Type: text/plain, Size: 7262 bytes --]

Hi,

Here is some updates after talking to Sam Ravnborg.  He did not yet come
back to me, I am not sure if I understood 100% what he meant, but hopefully
somebody else will be so kind as to comment.

Here is a shortish changelog:

- Fix an issue reported by Esben Nielsen <simlo@phys.au.dk> (with
suggestion from Sam Ravnborg).  Build failed if $O (output dir) was
set.  This is done by pre-pending $srctree if the shipped list is
referenced.

- Also fix calling of gen_initramfs_list.sh if $O (output dir) is set
by pre-pending $srctree.

- I also moved initramfs_list to initramfs_list.shipped, to make sure we
always have an 'fall back' list (say you unset CONFIG_INITRAMFS_SOURCE
and deleted your custom intramfs source directory, then building will not
fail).

- Kbuild style cleanups.

- Improved error checking.  For example gen_initramfs_list.sh will
output a simple list if the target directory is empty, and we verify
that the shipped initramfs_list is present before touching it.

- Only update the temp initramfs_list if the source list/directory have
changed.

- Cleanup temporary initramfs_list when 'make clean' or 'make mrproper'
is called.


This patch should apply to both 2.6.9-bk7 and 2.6.9-mm1.

(Note that evo does some tab/newline damage)

Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

diff -uprN -X dontdiff linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh linux-2.6.9-bk7/scripts/gen_initramfs_list.sh
--- linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh	2004-10-23 11:23:49.000000000 +0200
+++ linux-2.6.9-bk7/scripts/gen_initramfs_list.sh	2004-10-23 11:26:52.000000000 +0200
@@ -76,9 +76,23 @@ parse() {
 	return 0
 }
 
-find "${srcdir}" -printf "%p %m %U %G\n" | \
-while read x; do
-	parse ${x}
-done
+dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+# If $dirlist is only one line, then the directory is empty
+if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+	echo "${dirlist}" | \
+	while read x; do
+		parse ${x}
+	done
+else
+	# Failsafe in case directory is empty
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
+fi
 
 exit 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/Makefile linux-2.6.9-bk7/usr/Makefile
--- linux-2.6.9-bk7.orig/usr/Makefile	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/Makefile	2004-10-23 13:56:28.691508824 +0200
@@ -6,9 +6,11 @@ hostprogs-y  := gen_init_cpio
 clean-files := initramfs_data.cpio.gz
 
 # If you want a different list of files in the initramfs_data.cpio
-# then you can either overwrite the cpio_list in this directory
-# or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST := $(obj)/initramfs_list
+# then you can either overwrite initramfs_list.shipped in this directory
+# or set CONFIG_INITRAMFS_SOURCE to another filename or directory.
+initramfs_list := initramfs_list
+
+clean-files += $(initramfs_list)
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,28 +25,75 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
-quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
+# Returns:
+#   valid command if everything should be fine
+#   'uptodate' if nothing needs to be done
+#   'missing' if $(srctree)/$(src)/$(initramfs_list).shipped is missing
+quiet_cmd_gen_list = GEN     $@
       cmd_gen_list = $(shell \
-        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
-	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
-	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	if [ -d $(CONFIG_INITRAMFS_SOURCE) ]; \
+	then \
+	  if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	       "x`find $(CONFIG_INITRAMFS_SOURCE) -newer "$(obj)/$(initramfs_list)" 2>/dev/null`" != "x" ]; \
+	  then \
+	    echo '$(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh \
+	      $(CONFIG_INITRAMFS_SOURCE) > "$(obj)/$(initramfs_list)"'; \
 	  else \
-	    echo 'echo Using shipped $@'; \
-	  fi; \
-	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
-	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	    echo 'uptodate'; \
+	  fi \
 	else \
-	  echo 'echo Using shipped $@'; \
+	  if [ -f $(CONFIG_INITRAMFS_SOURCE) -a \
+	       $(CONFIG_INITRAMFS_SOURCE) != "$(obj)/$(initramfs_list)" ]; \
+	  then \
+	    if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	         $(CONFIG_INITRAMFS_SOURCE) -nt "$(obj)/$(initramfs_list)" ]; \
+	    then \
+	      echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) "$(obj)/$(initramfs_list)"'; \
+	    else \
+	      echo 'uptodate'; \
+	    fi \
+	  else \
+	    if [ -f "$(srctree)/$(src)/$(initramfs_list).shipped" ]; \
+	    then \
+	      if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	           "$(srctree)/$(src)/$(initramfs_list).shipped" -nt "$(obj)/$(initramfs_list)" ]; \
+	      then \
+	        echo 'cp -f "$(srctree)/$(src)/$(initramfs_list).shipped" \
+	          "$(obj)/$(initramfs_list)"'; \
+	      else \
+	        echo 'uptodate'; \
+	      fi \
+	    else \
+	      echo 'missing'; \
+	    fi \
+	  fi \
 	fi)
 
-
-$(INITRAMFS_LIST): FORCE
-	$(call cmd,gen_list)
+initramfs_list_state_uptodate :=
+initramfs_list_state_outofdate :=
+initramfs_list_state_missing :=
+
+ifeq ($(cmd_gen_list),uptodate)
+  initramfs_list_state_uptodate := 1
+else
+  ifeq ($(cmd_gen_list),missing)
+    initramfs_list_state_missing := 1
+  else
+    initramfs_list_state_outofdate := 1
+  endif
+endif
+
+$(obj)/$(initramfs_list): FORCE
+	$(if $(nitramfs_list_state_uptodate),, \
+	  $(if $(initramfs_list_state_outofdate), $(call cmd,gen_list), \
+	    $(if $(initramfs_list_state_missing), \
+	      @echo 'File "$(src)/$(initramfs_list).shipped" does not exist'; \
+	      /bin/false)))
 
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
+      cmd_cpio = ./$< $(obj)/$(initramfs_list) > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(INITRAMFS_LIST) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(obj)/$(initramfs_list) FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list linux-2.6.9-bk7/usr/initramfs_list
--- linux-2.6.9-bk7.orig/usr/initramfs_list	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list.shipped linux-2.6.9-bk7/usr/initramfs_list.shipped
--- linux-2.6.9-bk7.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list.shipped	2004-10-23 11:26:52.000000000 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0



-- 
Martin Schlemmer


[-- Attachment #1.2: select-cpio_list-or-source-directory-for-initramfs-image-v5.patch --]
[-- Type: text/x-patch, Size: 7526 bytes --]

diff -uprN -X dontdiff linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig linux-2.6.9-rc4-mm1/drivers/block/Kconfig
--- linux-2.6.9-rc4-mm1.orig/drivers/block/Kconfig	2004-10-18 21:20:06.885571688 +0200
+++ linux-2.6.9-rc4-mm1/drivers/block/Kconfig	2004-10-17 16:58:35.000000000 +0200
@@ -348,6 +348,32 @@ config BLK_DEV_INITRD
 	  "real" root file system, etc. See <file:Documentation/initrd.txt>
 	  for details.
 
+config INITRAMFS_SOURCE
+	string "Source directory of cpio_list"
+	default ""
+	help
+	  This can be set to either a directory containing files, etc to be
+	  included in the initramfs archive, or a file containing newline
+	  separated entries.
+
+	  If it is a file, it should be in the following format:
+	    # a comment
+	    file <name> <location> <mode> <uid> <gid>
+	    dir <name> <mode> <uid> <gid>
+	    nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
+
+	  Where:
+	    <name>      name of the file/dir/nod in the archive
+	    <location>  location of the file in the current filesystem
+	    <mode>      mode/permissions of the file
+	    <uid>       user id (0=root)
+	    <gid>       group id (0=root)
+	    <dev_type>  device type (b=block, c=character)
+	    <maj>       major number of nod
+	    <min>       minor number of nod
+
+	  If you are not sure, leave it blank.
+
 config LBD
 	bool "Support for Large Block Devices"
 	depends on X86 || MIPS32 || PPC32 || ARCH_S390_31 || SUPERH
diff -uprN -X dontdiff linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh
--- linux-2.6.9-rc4-mm1.orig/scripts/gen_initramfs_list.sh	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/scripts/gen_initramfs_list.sh	2004-10-18 20:02:09.000000000 +0200
@@ -0,0 +1,98 @@
+#!/bin/bash
+# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
+# Released under the terms of the GNU GPL
+#
+# A script to generate newline separated entries (to stdout) from a directory's
+# contents suitable for use as a cpio_list for gen_init_cpio.
+#
+# Arguements: $1 -- the source directory
+#
+# TODO:  Add support for symlinks, sockets and pipes when gen_init_cpio
+#        supports them.
+
+usage() {
+	echo "Usage: $0 initramfs-source-dir"
+	exit 1
+}
+
+srcdir=$(echo "$1" | sed -e 's://*:/:g')
+
+if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then
+	usage
+fi
+
+filetype() {
+	local argv1="$1"
+
+	if [ -f "${argv1}" ]; then
+		echo "file"
+	elif [ -d "${argv1}" ]; then
+		echo "dir"
+	elif [ -b "${argv1}" -o -c "${argv1}" ]; then
+		echo "nod"
+	else
+		echo "invalid"
+	fi
+	return 0
+}
+
+parse() {
+	local location="$1"
+	local name="${location/${srcdir}//}"
+	local mode="$2"
+	local uid="$3"
+	local gid="$4"
+	local ftype=$(filetype "${location}")
+	local str="${mode} ${uid} ${gid}"
+
+	[ "${ftype}" == "invalid" ] && return 0
+	[ "${location}" == "${srcdir}" ] && return 0
+
+	case "${ftype}" in
+		"file")
+			str="${ftype} ${name} ${location} ${str}"
+			;;
+		"nod")
+			local dev_type=
+			local maj=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{sub(/,/, "", $5); print $5}')
+			local min=$(LC_ALL=C ls -l "${location}" | \
+					gawk '{print $6}')
+
+			if [ -b "${location}" ]; then
+				dev_type="b"
+			else
+				dev_type="c"
+			fi
+			str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
+			;;
+		*)
+			str="${ftype} ${name} ${str}"
+			;;
+	esac
+
+	echo "${str}"
+
+	return 0
+}
+
+dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+# If $dirlist is only one line, then the directory is empty
+if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+	echo "${dirlist}" | \
+	while read x; do
+		parse ${x}
+	done
+else
+	# Failsafe in case directory is empty
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
+fi
+
+exit 0
diff -uprN -X dontdiff linux-2.6.9-rc4-mm1.orig/usr/Makefile linux-2.6.9-rc4-mm1/usr/Makefile
--- linux-2.6.9-rc4-mm1.orig/usr/Makefile	2004-10-18 21:20:06.886571536 +0200
+++ linux-2.6.9-rc4-mm1/usr/Makefile	2004-10-18 21:02:35.722372784 +0200
@@ -6,9 +6,11 @@ hostprogs-y  := gen_init_cpio
 clean-files := initramfs_data.cpio.gz
 
 # If you want a different list of files in the initramfs_data.cpio
-# then you can either overwrite the cpio_list in this directory
-# or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST ?= $(obj)/initramfs_list
+# then you can either overwrite initramfs_list.shipped in this directory
+# or set CONFIG_INITRAMFS_SOURCE to another filename or directory.
+initramfs_list := initramfs_list
+
+clean-files += $(initramfs_list)
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,10 +25,43 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
+# This should only return a command if there was no error
+quiet_cmd_gen_list = GEN     $@
+      cmd_gen_list = $(shell \
+	if [ -d $(CONFIG_INITRAMFS_SOURCE) ]; then \
+	  tmplist="`find $(CONFIG_INITRAMFS_SOURCE) -newer $@ 2>/dev/null`"; \
+	  if [ ! -f $@ -o "x${tmplist}" != x ]; then \
+	    echo '$(CONFIG_SHELL) scripts/gen_initramfs_list.sh \
+	    			$(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	  else \
+	    echo '/bin/true'; \
+	  fi \
+	else \
+	  if [ -f $(CONFIG_INITRAMFS_SOURCE) -a $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
+	    if [ ! -f $@ -o $(CONFIG_INITRAMFS_SOURCE) -nt $@ ]; then \
+	      echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	    else \
+	      echo '/bin/true'; \
+	    fi \
+	  else \
+	    if [ -f $(srctree)/$(src)/$(initramfs_list).shipped ]; then \
+	      if [ ! -f $@ -o $(srctree)/$(src)/$(initramfs_list).shipped -nt $@ ]; then \
+	        echo 'cp -f $(srctree)/$(src)/$(initramfs_list).shipped $@'; \
+	      else \
+	        echo '/bin/true'; \
+	      fi \
+	    fi \
+	  fi \
+	fi)
+
+$(obj)/$(initramfs_list): FORCE
+	$(if $(cmd_gen_list), $(call cmd,gen_list), \
+	  error file "$(src)/$(initramfs_list).shipped" does not exist)
+
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
+      cmd_cpio = ./$< $(obj)/$(initramfs_list) > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(INITRAMFS_LIST) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(obj)/$(initramfs_list) FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -uprN -X dontdiff linux-2.6.9-rc4-mm1.orig/usr/initramfs_list linux-2.6.9-rc4-mm1/usr/initramfs_list
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list	2004-10-18 21:20:06.974558160 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -uprN -X dontdiff linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped
--- linux-2.6.9-rc4-mm1.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-rc4-mm1/usr/initramfs_list.shipped	2004-10-18 21:20:50.866885512 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0

[-- Attachment #1.3: select-cpio_list-or-source-directory-for-initramfs-image-v7.patch --]
[-- Type: text/x-patch, Size: 5869 bytes --]

diff -uprN -X dontdiff linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh linux-2.6.9-bk7/scripts/gen_initramfs_list.sh
--- linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh	2004-10-23 11:23:49.000000000 +0200
+++ linux-2.6.9-bk7/scripts/gen_initramfs_list.sh	2004-10-23 11:26:52.000000000 +0200
@@ -76,9 +76,23 @@ parse() {
 	return 0
 }
 
-find "${srcdir}" -printf "%p %m %U %G\n" | \
-while read x; do
-	parse ${x}
-done
+dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+# If $dirlist is only one line, then the directory is empty
+if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+	echo "${dirlist}" | \
+	while read x; do
+		parse ${x}
+	done
+else
+	# Failsafe in case directory is empty
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
+fi
 
 exit 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/Makefile linux-2.6.9-bk7/usr/Makefile
--- linux-2.6.9-bk7.orig/usr/Makefile	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/Makefile	2004-10-23 13:56:28.691508824 +0200
@@ -6,9 +6,11 @@ hostprogs-y  := gen_init_cpio
 clean-files := initramfs_data.cpio.gz
 
 # If you want a different list of files in the initramfs_data.cpio
-# then you can either overwrite the cpio_list in this directory
-# or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST := $(obj)/initramfs_list
+# then you can either overwrite initramfs_list.shipped in this directory
+# or set CONFIG_INITRAMFS_SOURCE to another filename or directory.
+initramfs_list := initramfs_list
+
+clean-files += $(initramfs_list)
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,28 +25,75 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
-quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
+# Returns:
+#   valid command if everything should be fine
+#   'uptodate' if nothing needs to be done
+#   'missing' if $(srctree)/$(src)/$(initramfs_list).shipped is missing
+quiet_cmd_gen_list = GEN     $@
       cmd_gen_list = $(shell \
-        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
-	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
-	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	if [ -d $(CONFIG_INITRAMFS_SOURCE) ]; \
+	then \
+	  if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	       "x`find $(CONFIG_INITRAMFS_SOURCE) -newer "$(obj)/$(initramfs_list)" 2>/dev/null`" != "x" ]; \
+	  then \
+	    echo '$(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh \
+	      $(CONFIG_INITRAMFS_SOURCE) > "$(obj)/$(initramfs_list)"'; \
 	  else \
-	    echo 'echo Using shipped $@'; \
-	  fi; \
-	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
-	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	    echo 'uptodate'; \
+	  fi \
 	else \
-	  echo 'echo Using shipped $@'; \
+	  if [ -f $(CONFIG_INITRAMFS_SOURCE) -a \
+	       $(CONFIG_INITRAMFS_SOURCE) != "$(obj)/$(initramfs_list)" ]; \
+	  then \
+	    if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	         $(CONFIG_INITRAMFS_SOURCE) -nt "$(obj)/$(initramfs_list)" ]; \
+	    then \
+	      echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) "$(obj)/$(initramfs_list)"'; \
+	    else \
+	      echo 'uptodate'; \
+	    fi \
+	  else \
+	    if [ -f "$(srctree)/$(src)/$(initramfs_list).shipped" ]; \
+	    then \
+	      if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	           "$(srctree)/$(src)/$(initramfs_list).shipped" -nt "$(obj)/$(initramfs_list)" ]; \
+	      then \
+	        echo 'cp -f "$(srctree)/$(src)/$(initramfs_list).shipped" \
+	          "$(obj)/$(initramfs_list)"'; \
+	      else \
+	        echo 'uptodate'; \
+	      fi \
+	    else \
+	      echo 'missing'; \
+	    fi \
+	  fi \
 	fi)
 
-
-$(INITRAMFS_LIST): FORCE
-	$(call cmd,gen_list)
+initramfs_list_state_uptodate :=
+initramfs_list_state_outofdate :=
+initramfs_list_state_missing :=
+
+ifeq ($(cmd_gen_list),uptodate)
+  initramfs_list_state_uptodate := 1
+else
+  ifeq ($(cmd_gen_list),missing)
+    initramfs_list_state_missing := 1
+  else
+    initramfs_list_state_outofdate := 1
+  endif
+endif
+
+$(obj)/$(initramfs_list): FORCE
+	$(if $(nitramfs_list_state_uptodate),, \
+	  $(if $(initramfs_list_state_outofdate), $(call cmd,gen_list), \
+	    $(if $(initramfs_list_state_missing), \
+	      @echo 'File "$(src)/$(initramfs_list).shipped" does not exist'; \
+	      /bin/false)))
 
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
+      cmd_cpio = ./$< $(obj)/$(initramfs_list) > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(INITRAMFS_LIST) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(obj)/$(initramfs_list) FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list linux-2.6.9-bk7/usr/initramfs_list
--- linux-2.6.9-bk7.orig/usr/initramfs_list	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list.shipped linux-2.6.9-bk7/usr/initramfs_list.shipped
--- linux-2.6.9-bk7.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list.shipped	2004-10-23 11:26:52.000000000 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-23 12:06 ` [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u] Martin Schlemmer [c]
@ 2004-10-24 10:08   ` Andrew Morton
  2004-10-24 13:59     ` Martin Schlemmer [c]
  2004-10-24 22:26     ` Sam Ravnborg
  2004-10-26 22:12   ` Sam Ravnborg
  1 sibling, 2 replies; 14+ messages in thread
From: Andrew Morton @ 2004-10-24 10:08 UTC (permalink / raw)
  To: Martin Schlemmer; +Cc: torvalds, sam, linux-kernel

"Martin Schlemmer [c]" <azarah@nosferatu.za.org> wrote:
>
> Here is some updates after talking to Sam Ravnborg.  He did not yet come
>  back to me, I am not sure if I understood 100% what he meant, but hopefully
>  somebody else will be so kind as to comment.
> 
>  Here is a shortish changelog:
> 
>  - Fix an issue reported by Esben Nielsen <simlo@phys.au.dk> (with
>  suggestion from Sam Ravnborg).  Build failed if $O (output dir) was
>  set.  This is done by pre-pending $srctree if the shipped list is
>  referenced.
> 
>  - Also fix calling of gen_initramfs_list.sh if $O (output dir) is set
>  by pre-pending $srctree.
> 
>  - I also moved initramfs_list to initramfs_list.shipped, to make sure we
>  always have an 'fall back' list (say you unset CONFIG_INITRAMFS_SOURCE
>  and deleted your custom intramfs source directory, then building will not
>  fail).
> 
>  - Kbuild style cleanups.
> 
>  - Improved error checking.  For example gen_initramfs_list.sh will
>  output a simple list if the target directory is empty, and we verify
>  that the shipped initramfs_list is present before touching it.
> 
>  - Only update the temp initramfs_list if the source list/directory have
>  changed.
> 
>  - Cleanup temporary initramfs_list when 'make clean' or 'make mrproper'
>  is called.
> 
> 
>  This patch should apply to both 2.6.9-bk7 and 2.6.9-mm1.

hmm.  You have a patch in the email body and two slightly different patches
as attachments.  All bases covered ;)

I'll stick
"select-cpio_list-or-source-directory-for-initramfs-image-v7.patch" into
-mm but would prefer that this patch come in via Sam's tree please.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-24 10:08   ` Andrew Morton
@ 2004-10-24 13:59     ` Martin Schlemmer [c]
  2004-10-24 22:26     ` Sam Ravnborg
  1 sibling, 0 replies; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-24 13:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: torvalds, Sam Ravnborg, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2048 bytes --]

On Sun, 2004-10-24 at 03:08 -0700, Andrew Morton wrote:
> "Martin Schlemmer [c]" <azarah@nosferatu.za.org> wrote:
> >
> > Here is some updates after talking to Sam Ravnborg.  He did not yet come
> >  back to me, I am not sure if I understood 100% what he meant, but hopefully
> >  somebody else will be so kind as to comment.
> > 
> >  Here is a shortish changelog:
> > 
> >  - Fix an issue reported by Esben Nielsen <simlo@phys.au.dk> (with
> >  suggestion from Sam Ravnborg).  Build failed if $O (output dir) was
> >  set.  This is done by pre-pending $srctree if the shipped list is
> >  referenced.
> > 
> >  - Also fix calling of gen_initramfs_list.sh if $O (output dir) is set
> >  by pre-pending $srctree.
> > 
> >  - I also moved initramfs_list to initramfs_list.shipped, to make sure we
> >  always have an 'fall back' list (say you unset CONFIG_INITRAMFS_SOURCE
> >  and deleted your custom intramfs source directory, then building will not
> >  fail).
> > 
> >  - Kbuild style cleanups.
> > 
> >  - Improved error checking.  For example gen_initramfs_list.sh will
> >  output a simple list if the target directory is empty, and we verify
> >  that the shipped initramfs_list is present before touching it.
> > 
> >  - Only update the temp initramfs_list if the source list/directory have
> >  changed.
> > 
> >  - Cleanup temporary initramfs_list when 'make clean' or 'make mrproper'
> >  is called.
> > 
> > 
> >  This patch should apply to both 2.6.9-bk7 and 2.6.9-mm1.
> 
> hmm.  You have a patch in the email body and two slightly different patches
> as attachments.  All bases covered ;)
> 
> I'll stick
> "select-cpio_list-or-source-directory-for-initramfs-image-v7.patch" into
> -mm but would prefer that this patch come in via Sam's tree please.
> 

No comment =)  v7 should be fine, but it have one typo that wont affect
anything, so here is v8.  I have tested with O= set, and all fail
conditions I could think of, and it seems all right.


Thanks,

-- 
Martin Schlemmer


[-- Attachment #1.2: select-cpio_list-or-source-directory-for-initramfs-image-v8.patch --]
[-- Type: text/x-patch, Size: 5870 bytes --]

diff -uprN -X dontdiff linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh linux-2.6.9-bk7/scripts/gen_initramfs_list.sh
--- linux-2.6.9-bk7.orig/scripts/gen_initramfs_list.sh	2004-10-23 11:23:49.000000000 +0200
+++ linux-2.6.9-bk7/scripts/gen_initramfs_list.sh	2004-10-23 11:26:52.000000000 +0200
@@ -76,9 +76,23 @@ parse() {
 	return 0
 }
 
-find "${srcdir}" -printf "%p %m %U %G\n" | \
-while read x; do
-	parse ${x}
-done
+dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+# If $dirlist is only one line, then the directory is empty
+if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+	echo "${dirlist}" | \
+	while read x; do
+		parse ${x}
+	done
+else
+	# Failsafe in case directory is empty
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
+fi
 
 exit 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/Makefile linux-2.6.9-bk7/usr/Makefile
--- linux-2.6.9-bk7.orig/usr/Makefile	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/Makefile	2004-10-23 13:56:28.691508824 +0200
@@ -6,9 +6,11 @@ hostprogs-y  := gen_init_cpio
 clean-files := initramfs_data.cpio.gz
 
 # If you want a different list of files in the initramfs_data.cpio
-# then you can either overwrite the cpio_list in this directory
-# or set INITRAMFS_LIST to another filename.
-INITRAMFS_LIST := $(obj)/initramfs_list
+# then you can either overwrite initramfs_list.shipped in this directory
+# or set CONFIG_INITRAMFS_SOURCE to another filename or directory.
+initramfs_list := initramfs_list
+
+clean-files += $(initramfs_list)
 
 # initramfs_data.o contains the initramfs_data.cpio.gz image.
 # The image is included using .incbin, a dependency which is not
@@ -23,28 +25,75 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
-quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
+# Returns:
+#   valid command if everything should be fine
+#   'uptodate' if nothing needs to be done
+#   'missing' if $(srctree)/$(src)/$(initramfs_list).shipped is missing
+quiet_cmd_gen_list = GEN     $@
       cmd_gen_list = $(shell \
-        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
-	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
-	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
+	if [ -d $(CONFIG_INITRAMFS_SOURCE) ]; \
+	then \
+	  if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	       "x`find $(CONFIG_INITRAMFS_SOURCE) -newer "$(obj)/$(initramfs_list)" 2>/dev/null`" != "x" ]; \
+	  then \
+	    echo '$(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh \
+	      $(CONFIG_INITRAMFS_SOURCE) > "$(obj)/$(initramfs_list)"'; \
 	  else \
-	    echo 'echo Using shipped $@'; \
-	  fi; \
-	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
-	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
+	    echo 'uptodate'; \
+	  fi \
 	else \
-	  echo 'echo Using shipped $@'; \
+	  if [ -f $(CONFIG_INITRAMFS_SOURCE) -a \
+	       $(CONFIG_INITRAMFS_SOURCE) != "$(obj)/$(initramfs_list)" ]; \
+	  then \
+	    if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	         $(CONFIG_INITRAMFS_SOURCE) -nt "$(obj)/$(initramfs_list)" ]; \
+	    then \
+	      echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) "$(obj)/$(initramfs_list)"'; \
+	    else \
+	      echo 'uptodate'; \
+	    fi \
+	  else \
+	    if [ -f "$(srctree)/$(src)/$(initramfs_list).shipped" ]; \
+	    then \
+	      if [ ! -f "$(obj)/$(initramfs_list)" -o \
+	           "$(srctree)/$(src)/$(initramfs_list).shipped" -nt "$(obj)/$(initramfs_list)" ]; \
+	      then \
+	        echo 'cp -f "$(srctree)/$(src)/$(initramfs_list).shipped" \
+	          "$(obj)/$(initramfs_list)"'; \
+	      else \
+	        echo 'uptodate'; \
+	      fi \
+	    else \
+	      echo 'missing'; \
+	    fi \
+	  fi \
 	fi)
 
-
-$(INITRAMFS_LIST): FORCE
-	$(call cmd,gen_list)
+initramfs_list_state_uptodate :=
+initramfs_list_state_outofdate :=
+initramfs_list_state_missing :=
+
+ifeq ($(cmd_gen_list),uptodate)
+  initramfs_list_state_uptodate := 1
+else
+  ifeq ($(cmd_gen_list),missing)
+    initramfs_list_state_missing := 1
+  else
+    initramfs_list_state_outofdate := 1
+  endif
+endif
+
+$(obj)/$(initramfs_list): FORCE
+	$(if $(initramfs_list_state_uptodate),, \
+	  $(if $(initramfs_list_state_outofdate), $(call cmd,gen_list), \
+	    $(if $(initramfs_list_state_missing), \
+	      @echo 'File "$(src)/$(initramfs_list).shipped" does not exist'; \
+	      /bin/false)))
 
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
+      cmd_cpio = ./$< $(obj)/$(initramfs_list) > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(INITRAMFS_LIST) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(obj)/$(initramfs_list) FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list linux-2.6.9-bk7/usr/initramfs_list
--- linux-2.6.9-bk7.orig/usr/initramfs_list	2004-10-23 11:23:54.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list	1970-01-01 02:00:00.000000000 +0200
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0
diff -uprN -X dontdiff linux-2.6.9-bk7.orig/usr/initramfs_list.shipped linux-2.6.9-bk7/usr/initramfs_list.shipped
--- linux-2.6.9-bk7.orig/usr/initramfs_list.shipped	1970-01-01 02:00:00.000000000 +0200
+++ linux-2.6.9-bk7/usr/initramfs_list.shipped	2004-10-23 11:26:52.000000000 +0200
@@ -0,0 +1,5 @@
+# This is a very simple initramfs - mostly preliminary for future expansion
+
+dir /dev 0755 0 0
+nod /dev/console 0600 0 0 c 5 1
+dir /root 0700 0 0

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-24 10:08   ` Andrew Morton
  2004-10-24 13:59     ` Martin Schlemmer [c]
@ 2004-10-24 22:26     ` Sam Ravnborg
  1 sibling, 0 replies; 14+ messages in thread
From: Sam Ravnborg @ 2004-10-24 22:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Martin Schlemmer, torvalds, sam, linux-kernel

On Sun, Oct 24, 2004 at 03:08:44AM -0700, Andrew Morton wrote:
> "Martin Schlemmer [c]" <azarah@nosferatu.za.org> wrote:
 
> hmm.  You have a patch in the email body and two slightly different patches
> as attachments.  All bases covered ;)
> 
> I'll stick
> "select-cpio_list-or-source-directory-for-initramfs-image-v7.patch" into
> -mm but would prefer that this patch come in via Sam's tree please.

Fighting with my backlog..
While being away from Linux for a while my kernel suddenly would not compile.
A make mrproper was needed.
This was no good and I realised that generating asm_offsets.h for i386 did 
not check all dependencies.

My fix involve all architectures and I want that pushed -mm before anything else.
And it get rid of the annoying print "asm_offsets.h is up to date"
I do not want to think what horor it could trigger if we change a constant and asm_offsets.h
was not re-generated when it should.

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-26 22:12   ` Sam Ravnborg
@ 2004-10-26 21:07     ` Martin Schlemmer [c]
  2004-10-26 23:15       ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-26 21:07 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andrew Morton, torvalds, Linux Kernel Mailing Lists

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

On Wed, 2004-10-27 at 00:12 +0200, Sam Ravnborg wrote:
> On Sat, Oct 23, 2004 at 02:06:28PM +0200, Martin Schlemmer [c] wrote:
> > Hi,
> > 
> > Here is some updates after talking to Sam Ravnborg.  He did not yet come
> > back to me, I am not sure if I understood 100% what he meant, but hopefully
> > somebody else will be so kind as to comment.
> 
> Hi Martin.
> Took a look at your patch and did not like it.
> Attached my version which I will push towards Linus soon.
> 

Thats ok - I never said I was an expert with kbuild =)

> Main difference is that I move logic to gen_initramfs_list-sh.
> Then I also use filechk - so I actually generate the file - but
> do not update the final file unless needed.
> 

Much more elegant, thanks.

> Current patch will not rebuild image if one of the
> programs listed are changed. But it should give a good
> foundation to do so.
> 

I will see if I get the time to get that implemented elegantly if
you do not beat me to it.


Thanks,

-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-26 23:15       ` Sam Ravnborg
@ 2004-10-26 21:36         ` Martin Schlemmer [c]
  2004-10-27  4:09         ` Dave Airlie
  2004-10-27 18:44         ` Martin Schlemmer [c]
  2 siblings, 0 replies; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-26 21:36 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andrew Morton, torvalds, Linux Kernel Mailing Lists

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

On Wed, 2004-10-27 at 01:15 +0200, Sam Ravnborg wrote:
> On Tue, Oct 26, 2004 at 11:07:29PM +0200, Martin Schlemmer [c] wrote:
>  
> > > Current patch will not rebuild image if one of the
> > > programs listed are changed. But it should give a good
> > > foundation to do so.
> > > 
> > 
> > I will see if I get the time to get that implemented elegantly if
> > you do not beat me to it.
> 
> Something as simple as putting relevant timestamps in the generated
> file as coment should do it.
> If timestamp differ then initramfs_list will be updated and initramfs
> image will be remade.
> 
> All changes isolated to gen_initramfs_list.sh.
> Care to give that a spin?
> 

Yep.  Bit late now, so will only get to it tomorrow though.


-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-23 12:06 ` [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u] Martin Schlemmer [c]
  2004-10-24 10:08   ` Andrew Morton
@ 2004-10-26 22:12   ` Sam Ravnborg
  2004-10-26 21:07     ` Martin Schlemmer [c]
  1 sibling, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2004-10-26 22:12 UTC (permalink / raw)
  To: Martin Schlemmer [c]
  Cc: Andrew Morton, torvalds, Sam Ravnborg, Linux Kernel Mailing Lists

On Sat, Oct 23, 2004 at 02:06:28PM +0200, Martin Schlemmer [c] wrote:
> Hi,
> 
> Here is some updates after talking to Sam Ravnborg.  He did not yet come
> back to me, I am not sure if I understood 100% what he meant, but hopefully
> somebody else will be so kind as to comment.

Hi Martin.
Took a look at your patch and did not like it.
Attached my version which I will push towards Linus soon.

Main difference is that I move logic to gen_initramfs_list-sh.
Then I also use filechk - so I actually generate the file - but
do not update the final file unless needed.

Current patch will not rebuild image if one of the
programs listed are changed. But it should give a good
foundation to do so.

	Sam

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/10/27 00:07:03+02:00 sam@mars.ravnborg.org 
#   kbuild/usr: initramfs list fixed and simplified
#   
#   Moving logic to scripts/gen_initramfs_list.sh make a nice cleanup in
#   usr/Makefile.
#   A new initramfs image will be generated if the initramfs_list file changes.
#   This patch also fixes the bug with make O=..
#   
#   Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
# 
# usr/Makefile
#   2004/10/27 00:06:46+02:00 sam@mars.ravnborg.org +9 -20
#   Simplify - logic moved to gen_initramfs_list.sh script
# 
# scripts/gen_initramfs_list.sh
#   2004/10/27 00:06:46+02:00 sam@mars.ravnborg.org +35 -16
#   Moved logic to this file.
#   It now handles both dirs, files and no input given.
#   For invalid input print error and boild out.
# 
# scripts/Makefile.lib
#   2004/10/27 00:06:46+02:00 sam@mars.ravnborg.org +27 -0
#   Added filechk - copy from top level Makefile
# 
# BitKeeper/etc/ignore
#   2004/10/27 00:06:24+02:00 sam@mars.ravnborg.org +1 -0
#   added usr/initramfs_list
# 
# BitKeeper/deleted/.del-initramfs_list~e02c62efaa478389
#   2004/10/27 00:02:17+02:00 sam@mars.ravnborg.org +0 -0
#   Delete: usr/initramfs_list
# 
diff -Nru a/scripts/Makefile.lib b/scripts/Makefile.lib
--- a/scripts/Makefile.lib	2004-10-27 00:07:50 +02:00
+++ b/scripts/Makefile.lib	2004-10-27 00:07:50 +02:00
@@ -232,3 +232,30 @@
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+# filechk is used to check if the content of a generated file is updated.
+# Sample usage:
+# define filechk_sample
+#	echo $KERNELRELEASE
+# endef
+# version.h : Makefile
+#	$(call filechk,sample)
+# The rule defined shall write to stdout the content of the new file.
+# The existing file will be compared with the new one.
+# - If no file exist it is created
+# - If the content differ the new file is used
+# - If they are equal no change, and no timestamp update
+
+define filechk
+	$(Q)set -e;				\
+	echo '  CHK     $@';			\
+	mkdir -p $(dir $@);			\
+	$(filechk_$(1)) $(2) > $@.tmp;		\
+	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
+		rm -f $@.tmp;			\
+	else					\
+		echo '  UPD     $@';		\
+		mv -f $@.tmp $@;		\
+	fi
+endef
+
diff -Nru a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
--- a/scripts/gen_initramfs_list.sh	2004-10-27 00:07:50 +02:00
+++ b/scripts/gen_initramfs_list.sh	2004-10-27 00:07:50 +02:00
@@ -2,25 +2,26 @@
 # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
 # Released under the terms of the GNU GPL
 #
-# A script to generate newline separated entries (to stdout) from a directory's
-# contents suitable for use as a cpio_list for gen_init_cpio.
+# Generate a newline separated list of entries from the file/directory pointed
+# out by the environment variable: CONFIG_INITRAMFS_SOURCE
 #
-# Arguements: $1 -- the source directory
+# If CONFIG_INITRAMFS_SOURCE is non-existing then generate a small dummy file.
+#
+# The output is suitable for gen_init_cpio as found in usr/Makefile.
 #
 # TODO:  Add support for symlinks, sockets and pipes when gen_init_cpio
 #        supports them.
 
-usage() {
-	echo "Usage: $0 initramfs-source-dir"
-	exit 1
+simple_initramfs() {
+	cat <<-EOF
+		# This is a very simple initramfs
+
+		dir /dev 0755 0 0
+		nod /dev/console 0600 0 0 c 5 1
+		dir /root 0700 0 0
+	EOF
 }
 
-srcdir=$(echo "$1" | sed -e 's://*:/:g')
-
-if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then
-	usage
-fi
-
 filetype() {
 	local argv1="$1"
 
@@ -76,9 +77,27 @@
 	return 0
 }
 
-find "${srcdir}" -printf "%p %m %U %G\n" | \
-while read x; do
-	parse ${x}
-done
+if [ -z $1 ]; then
+	simple_initramfs
+elif [ -f $1 ]; then
+	cat $1
+elif [ -d $1 ]; then
+	srcdir=$(echo "$1" | sed -e 's://*:/:g')
+	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
+
+	# If $dirlist is only one line, then the directory is empty
+	if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+		echo "${dirlist}" | \
+		while read x; do
+			parse ${x}
+		done
+	else
+		# Failsafe in case directory is empty
+		simple_initramfs
+	fi
+else
+	echo "  $0: Cannot open '$1' (CONFIG_INITRAMFS_SOURCE)" >&2
+	exit 1
+fi
 
 exit 0
diff -Nru a/usr/Makefile b/usr/Makefile
--- a/usr/Makefile	2004-10-27 00:07:50 +02:00
+++ b/usr/Makefile	2004-10-27 00:07:50 +02:00
@@ -3,7 +3,7 @@
 
 hostprogs-y  := gen_init_cpio
 
-clean-files := initramfs_data.cpio.gz
+clean-files := initramfs_data.cpio.gz initramfs_list
 
 # If you want a different list of files in the initramfs_data.cpio
 # then you can either overwrite the cpio_list in this directory
@@ -23,28 +23,17 @@
 # Commented out for now
 # initramfs-y := $(obj)/root/hello
 
-quiet_cmd_gen_list = GEN_INITRAMFS_LIST $@
-      cmd_gen_list = $(shell \
-        if test -f $(CONFIG_INITRAMFS_SOURCE); then \
-	  if [ $(CONFIG_INITRAMFS_SOURCE) != $@ ]; then \
-	    echo 'cp -f $(CONFIG_INITRAMFS_SOURCE) $@'; \
-	  else \
-	    echo 'echo Using shipped $@'; \
-	  fi; \
-	elif test -d $(CONFIG_INITRAMFS_SOURCE); then \
-	  echo 'scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) > $@'; \
-	else \
-	  echo 'echo Using shipped $@'; \
-	fi)
-
-
-$(INITRAMFS_LIST): FORCE
-	$(call cmd,gen_list)
+filechk_initramfs_list = $(CONFIG_SHELL) \
+ $(srctree)/scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE)
+			   
+$(obj)/initramfs_list: FORCE
+	$(call filechk,initramfs_list)
 
 quiet_cmd_cpio = CPIO    $@
-      cmd_cpio = ./$< $(INITRAMFS_LIST) > $@
+      cmd_cpio = ./$< $(obj)/initramfs_list > $@
 
-$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio $(initramfs-y) $(INITRAMFS_LIST) FORCE
+$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio \
+                            $(initramfs-y) $(obj)/initramfs_list FORCE
 	$(call if_changed,cpio)
 
 targets += initramfs_data.cpio
diff -Nru a/usr/initramfs_list b/usr/initramfs_list
--- a/usr/initramfs_list	2004-10-27 00:07:50 +02:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,5 +0,0 @@
-# This is a very simple initramfs - mostly preliminary for future expansion
-
-dir /dev 0755 0 0
-nod /dev/console 0600 0 0 c 5 1
-dir /root 0700 0 0



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-26 21:07     ` Martin Schlemmer [c]
@ 2004-10-26 23:15       ` Sam Ravnborg
  2004-10-26 21:36         ` Martin Schlemmer [c]
                           ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Sam Ravnborg @ 2004-10-26 23:15 UTC (permalink / raw)
  To: Martin Schlemmer [c]
  Cc: Sam Ravnborg, Andrew Morton, torvalds, Linux Kernel Mailing Lists

On Tue, Oct 26, 2004 at 11:07:29PM +0200, Martin Schlemmer [c] wrote:
 
> > Current patch will not rebuild image if one of the
> > programs listed are changed. But it should give a good
> > foundation to do so.
> > 
> 
> I will see if I get the time to get that implemented elegantly if
> you do not beat me to it.

Something as simple as putting relevant timestamps in the generated
file as coment should do it.
If timestamp differ then initramfs_list will be updated and initramfs
image will be remade.

All changes isolated to gen_initramfs_list.sh.
Care to give that a spin?

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-26 23:15       ` Sam Ravnborg
  2004-10-26 21:36         ` Martin Schlemmer [c]
@ 2004-10-27  4:09         ` Dave Airlie
  2004-10-27  6:21           ` Sam Ravnborg
  2004-10-27 18:44         ` Martin Schlemmer [c]
  2 siblings, 1 reply; 14+ messages in thread
From: Dave Airlie @ 2004-10-27  4:09 UTC (permalink / raw)
  To: Martin Schlemmer [c],
	Sam Ravnborg, Andrew Morton, torvalds,
	Linux Kernel Mailing Lists

On Wed, 27 Oct 2004 01:15:14 +0200, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Tue, Oct 26, 2004 at 11:07:29PM +0200, Martin Schlemmer [c] wrote:
> 
> 
> 
> > > Current patch will not rebuild image if one of the
> > > programs listed are changed. But it should give a good
> > > foundation to do so.
> > >
> >
> > I will see if I get the time to get that implemented elegantly if
> > you do not beat me to it.
> 
> Something as simple as putting relevant timestamps in the generated
> file as coment should do it.
> If timestamp differ then initramfs_list will be updated and initramfs
> image will be remade.

please put the timestamps somewhere that don't end up in the final kernel....

My life involves reproducing complete FLASH systems at any point in
time exactly the same as the ones I produced at the previous point in
time, I've had to hack about 5 or 6 things in the kernel to do this,
I'd like to try avoiding people adding any more unless they really are
needed.. or at least give me some way to override it ...

Dave.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* timestamps in kernel was Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-27  6:21           ` Sam Ravnborg
@ 2004-10-27  4:55             ` Dave Airlie
  0 siblings, 0 replies; 14+ messages in thread
From: Dave Airlie @ 2004-10-27  4:55 UTC (permalink / raw)
  To: Dave Airlie, Martin Schlemmer [c],
	Sam Ravnborg, Andrew Morton, torvalds,
	Linux Kernel Mailing Lists

> 
> Could you try to list the places - maybe they do not all make sense.

Here is my current list in things that directly affect me:
sound/core/info.c contains __DATE__ to tell what date it was compiled
on, I'm not sure this is really needed.
usr/gen_init_cpio.c uses time(NULL) to set mtimes,
scripts/Makefile.lib uses gzip with no -n flag

I can supply patches to get rid of these if people think they are a
good/bad idea...

I also hack scripts/mkcompile_h so it never changes for me (this one
is acceptable as it is very obvious that you have to do it...)

Dave.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-27  4:09         ` Dave Airlie
@ 2004-10-27  6:21           ` Sam Ravnborg
  2004-10-27  4:55             ` timestamps in kernel was " Dave Airlie
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2004-10-27  6:21 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Martin Schlemmer [c],
	Sam Ravnborg, Andrew Morton, torvalds,
	Linux Kernel Mailing Lists

On Wed, Oct 27, 2004 at 02:09:34PM +1000, Dave Airlie wrote:
 > If timestamp differ then initramfs_list will be updated and initramfs
> > image will be remade.
> 
> please put the timestamps somewhere that don't end up in the final kernel....

initramfs_list is only an inputfile to gen_cpio. So comments in this
file will/should not end up in final image.

> My life involves reproducing complete FLASH systems at any point in
> time exactly the same as the ones I produced at the previous point in
> time, I've had to hack about 5 or 6 things in the kernel to do this,

Could you try to list the places - maybe they do not all make sense.

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-26 23:15       ` Sam Ravnborg
  2004-10-26 21:36         ` Martin Schlemmer [c]
  2004-10-27  4:09         ` Dave Airlie
@ 2004-10-27 18:44         ` Martin Schlemmer [c]
  2004-10-30 23:43           ` Sam Ravnborg
  2 siblings, 1 reply; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-27 18:44 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andrew Morton, torvalds, Linux Kernel Mailing Lists


[-- Attachment #1.1: Type: text/plain, Size: 2183 bytes --]

On Wed, 2004-10-27 at 01:15 +0200, Sam Ravnborg wrote:
> On Tue, Oct 26, 2004 at 11:07:29PM +0200, Martin Schlemmer [c] wrote:
>  
> > > Current patch will not rebuild image if one of the
> > > programs listed are changed. But it should give a good
> > > foundation to do so.
> > > 
> > 
> > I will see if I get the time to get that implemented elegantly if
> > you do not beat me to it.
> 
> Something as simple as putting relevant timestamps in the generated
> file as coment should do it.
> If timestamp differ then initramfs_list will be updated and initramfs
> image will be remade.
> 
> All changes isolated to gen_initramfs_list.sh.
> Care to give that a spin?
> 

How about below?  Works as expected.  I am open to suggestions short of
coding a util to print numeric mtimes besides find, but for the life of
me could not think of another way ...


Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

diff -uprN -X dontdiff linux-2.6.9.orig/scripts/gen_initramfs_list.sh linux-2.6.9/scripts/gen_initramfs_list.sh
--- linux-2.6.9.orig/scripts/gen_initramfs_list.sh	2004-10-27 20:06:47.043999448 +0200
+++ linux-2.6.9/scripts/gen_initramfs_list.sh	2004-10-27 20:34:39.121804984 +0200
@@ -37,6 +37,18 @@ filetype() {
 	return 0
 }
 
+print_mtime() {
+	local argv1="$1"
+	local my_mtime="0"
+
+	if [ -e "${argv1}" ]; then
+		my_mtime=$(find "${argv1}" -printf "%T@\n" | sort -r | head -n 1)
+	fi
+	
+	echo "# Last modified: ${my_mtime}"
+	echo
+}
+
 parse() {
 	local location="$1"
 	local name="${location/${srcdir}//}"
@@ -77,16 +89,19 @@ parse() {
 	return 0
 }
 
-if [ -z $1 ]; then
+if [ -z "$1" ]; then
 	simple_initramfs
-elif [ -f $1 ]; then
-	cat $1
-elif [ -d $1 ]; then
+elif [ -f "$1" ]; then
+	print_mtime "$1"
+	cat "$1"
+elif [ -d "$1" ]; then
 	srcdir=$(echo "$1" | sed -e 's://*:/:g')
 	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
 
 	# If $dirlist is only one line, then the directory is empty
 	if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+		print_mtime "$1"
+		
 		echo "${dirlist}" | \
 		while read x; do
 			parse ${x}



-- 
Martin Schlemmer


[-- Attachment #1.2: initramfs_list-regen-on-mtime-v1.patch --]
[-- Type: text/x-patch, Size: 1210 bytes --]

diff -uprN -X dontdiff linux-2.6.9.orig/scripts/gen_initramfs_list.sh linux-2.6.9/scripts/gen_initramfs_list.sh
--- linux-2.6.9.orig/scripts/gen_initramfs_list.sh	2004-10-27 20:06:47.043999448 +0200
+++ linux-2.6.9/scripts/gen_initramfs_list.sh	2004-10-27 20:34:39.121804984 +0200
@@ -37,6 +37,18 @@ filetype() {
 	return 0
 }
 
+print_mtime() {
+	local argv1="$1"
+	local my_mtime="0"
+
+	if [ -e "${argv1}" ]; then
+		my_mtime=$(find "${argv1}" -printf "%T@\n" | sort -r | head -n 1)
+	fi
+	
+	echo "# Last modified: ${my_mtime}"
+	echo
+}
+
 parse() {
 	local location="$1"
 	local name="${location/${srcdir}//}"
@@ -77,16 +89,19 @@ parse() {
 	return 0
 }
 
-if [ -z $1 ]; then
+if [ -z "$1" ]; then
 	simple_initramfs
-elif [ -f $1 ]; then
-	cat $1
-elif [ -d $1 ]; then
+elif [ -f "$1" ]; then
+	print_mtime "$1"
+	cat "$1"
+elif [ -d "$1" ]; then
 	srcdir=$(echo "$1" | sed -e 's://*:/:g')
 	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
 
 	# If $dirlist is only one line, then the directory is empty
 	if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+		print_mtime "$1"
+		
 		echo "${dirlist}" | \
 		while read x; do
 			parse ${x}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-27 18:44         ` Martin Schlemmer [c]
@ 2004-10-30 23:43           ` Sam Ravnborg
  2004-10-31 10:36             ` Martin Schlemmer [c]
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2004-10-30 23:43 UTC (permalink / raw)
  To: Martin Schlemmer [c]
  Cc: Sam Ravnborg, Andrew Morton, torvalds, Linux Kernel Mailing Lists

On Wed, Oct 27, 2004 at 08:44:05PM +0200, Martin Schlemmer [c] wrote:
> > 
> 
> How about below?  Works as expected.  I am open to suggestions short of
> coding a util to print numeric mtimes besides find, but for the life of
> me could not think of another way ...

Looks good.
Please send me a version that is not whitespace damaged and with a
proper changelog.
The changelog shall be descriptive in itself without relying on context
from privious patch or comments in a mail.

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u]
  2004-10-30 23:43           ` Sam Ravnborg
@ 2004-10-31 10:36             ` Martin Schlemmer [c]
  0 siblings, 0 replies; 14+ messages in thread
From: Martin Schlemmer [c] @ 2004-10-31 10:36 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andrew Morton, torvalds, Linux Kernel Mailing Lists


[-- Attachment #1.1: Type: text/plain, Size: 1196 bytes --]

On Sun, 2004-10-31 at 01:43 +0200, Sam Ravnborg wrote:
> On Wed, Oct 27, 2004 at 08:44:05PM +0200, Martin Schlemmer [c] wrote:
> > > 
> > 
> > How about below?  Works as expected.  I am open to suggestions short of
> > coding a util to print numeric mtimes besides find, but for the life of
> > me could not think of another way ...
> 
> Looks good.
> Please send me a version that is not whitespace damaged and with a
> proper changelog.
> The changelog shall be descriptive in itself without relying on context
> from privious patch or comments in a mail.
> 

Unfortunately evolution 2.0 seems to have some issues, and the
whitespace damage is one of them.  Anyhow, here is the patch attached,
with a changelog.  Hope that is OK.

----

  Add a comment to gen_initramfs_list.sh output that contains the
  numeric mtime of the last modified file in the source directory,
  or the mtime of the source list.  This should cause the initramfs
  image to be rebuild if a file in the source directory changed, or
  the source list (if that was used rather than a directory as source).


Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

-- 
Martin Schlemmer


[-- Attachment #1.2: initramfs_list-regen-on-mtime-v1.patch --]
[-- Type: text/x-patch, Size: 1210 bytes --]

diff -uprN -X dontdiff linux-2.6.9.orig/scripts/gen_initramfs_list.sh linux-2.6.9/scripts/gen_initramfs_list.sh
--- linux-2.6.9.orig/scripts/gen_initramfs_list.sh	2004-10-27 20:06:47.043999448 +0200
+++ linux-2.6.9/scripts/gen_initramfs_list.sh	2004-10-27 20:34:39.121804984 +0200
@@ -37,6 +37,18 @@ filetype() {
 	return 0
 }
 
+print_mtime() {
+	local argv1="$1"
+	local my_mtime="0"
+
+	if [ -e "${argv1}" ]; then
+		my_mtime=$(find "${argv1}" -printf "%T@\n" | sort -r | head -n 1)
+	fi
+	
+	echo "# Last modified: ${my_mtime}"
+	echo
+}
+
 parse() {
 	local location="$1"
 	local name="${location/${srcdir}//}"
@@ -77,16 +89,19 @@ parse() {
 	return 0
 }
 
-if [ -z $1 ]; then
+if [ -z "$1" ]; then
 	simple_initramfs
-elif [ -f $1 ]; then
-	cat $1
-elif [ -d $1 ]; then
+elif [ -f "$1" ]; then
+	print_mtime "$1"
+	cat "$1"
+elif [ -d "$1" ]; then
 	srcdir=$(echo "$1" | sed -e 's://*:/:g')
 	dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
 
 	# If $dirlist is only one line, then the directory is empty
 	if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
+		print_mtime "$1"
+		
 		echo "${dirlist}" | \
 		while read x; do
 			parse ${x}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-10-31 11:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200410200849.i9K8n5921516@mail.osdl.org>
2004-10-23 12:06 ` [PATCH 2.6.9-bk7] Select cpio_list or source directory for initramfs image updates [u] Martin Schlemmer [c]
2004-10-24 10:08   ` Andrew Morton
2004-10-24 13:59     ` Martin Schlemmer [c]
2004-10-24 22:26     ` Sam Ravnborg
2004-10-26 22:12   ` Sam Ravnborg
2004-10-26 21:07     ` Martin Schlemmer [c]
2004-10-26 23:15       ` Sam Ravnborg
2004-10-26 21:36         ` Martin Schlemmer [c]
2004-10-27  4:09         ` Dave Airlie
2004-10-27  6:21           ` Sam Ravnborg
2004-10-27  4:55             ` timestamps in kernel was " Dave Airlie
2004-10-27 18:44         ` Martin Schlemmer [c]
2004-10-30 23:43           ` Sam Ravnborg
2004-10-31 10:36             ` Martin Schlemmer [c]

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).