On Tue, Apr 11, 2006 at 12:32:09AM +0200, Sam Ravnborg wrote:> On Sun, Apr 09, 2006 at 10:59:20PM +0200, Sam Ravnborg wrote:> > This fix has been implemented in preparation for the upcoming klibc> > merge in -mm. But as it fixes a real (but rare I hope) bug in vanilla> > kernel it will be added to my pending 2.6.17 kbuild queue.> > > > I've done quite some changes to the gen_initramfs script and> > being shell programming newbie review by more experienced shell> > hackers would be appreciated.> > > > I did a git mv scripts/gen_initramfs_list.sh usr/gen_initramfs.sh> > But the changes was so many that git does not see the rename.> > Due to the rename the diffstat shows a bit mroe changes than reality.> > This patch turned out to be bogus.> I have something new in the works - will be finished tomorrow.And here it goes.

initramfs.cpio.gz being build in usr/ and included in the kernel was not rebuild when the included files changed.

To fix this the following was done: - let gen_initramfs.sh generate a list of files and directories included in the initramfs - gen_initramfs generate the gzipped cpio archive so we could simplify the kbuild file (Makefile) - utilising the kbuild infrastructure so when uid/gid root mapping changes the initramfs will be rebuild

With this change we have a much more robust initramfs generation.

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

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.shindex 6d41116..56b3bed 100644--- a/scripts/gen_initramfs_list.sh+++ b/scripts/gen_initramfs_list.sh@@ -1,22 +1,55 @@ #!/bin/bash # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>-# Released under the terms of the GNU GPL-#-# Generate a newline separated list of entries from the file/directory-# supplied as an argument.-#-# If a file/directory is not supplied then generate a small dummy file.+# Copyright (c) 2006 Sam Ravnborg <sam@ravnborg.org> #-# The output is suitable for gen_init_cpio built from usr/gen_init_cpio.c.+# Released under the terms of the GNU GPL #+# Generate a cpio packed initramfs. It uses gen_init_cpio to generate+# the cpio archive, and gzip to pack 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+set -e++usage() {+cat << EOF+Usage:+$0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...+ -o <file> Create gzipped initramfs file named <file> using+ gen_init_cpio and gzip+ -u <uid> User ID to map to user ID 0 (root).+ <uid> is only meaningful if <cpio_source>+ is a directory.+ -g <gid> Group ID to map to group ID 0 (root).+ <gid> is only meaningful if <cpio_source>+ is a directory.+ <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+<cpio_source> options so an explicit "-u 0 -g 0" is required+to reset the root/group mapping.+EOF+}