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

From: Martin Schlemmer [c]
Date: Wed Oct 27 2004 - 14:46:34 EST


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

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

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