Re: [PATCH 2.6.9-bk7] Select cpio_list or source directory forinitramfs image updates [u]

From: Martin Schlemmer [c]
Date: Sun Oct 31 2004 - 06:41:35 EST


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@xxxxxxxxxxxxxxxx>

--
Martin Schlemmer

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: signature.asc
Description: This is a digitally signed message part