[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#573580: new option to ignore hooks etc. under /usr/share/initramfs-tools



Package: initramfs-tools
Version: 0.92o
Severity: wishlist
Tags: patch

Hi,

What do you think about adding such a feature?  It would be useful
for creating custom initramfs images for other machines in conjunction
with the -d option.  Find attached a patch against the Lenny branch.

Thanks,
Feri.
>From eee04d47a9571de8ce5823fd6d1de88d6ae4298d Mon Sep 17 00:00:00 2001
From: Ferenc Wagner <wferi@niif.hu>
Date: Fri, 12 Mar 2010 16:57:26 +0100
Subject: [PATCH] mkinitramfs: new -b option to ignore stuff under /usr/share/initramfs-tools

---
 mkinitramfs   |   23 ++++++++++++++---------
 mkinitramfs.8 |    7 +++++++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/mkinitramfs b/mkinitramfs
index 0fc45db..7cc6dd6 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -4,6 +4,7 @@ umask 0022
 export PATH='/usr/bin:/sbin:/bin'
 
 # Defaults
+system="y"
 keep="n"
 CONFDIR="/etc/initramfs-tools"
 verbose="n"
@@ -11,7 +12,7 @@ errors_to="2>/dev/null"
 # BUSYBOXDIR="/usr/lib/initramfs-tools/bin/"
 BUSYBOXDIR="/bin"
 
-OPTIONS=`getopt -o d:ko:r:v --long supported-host-version:,supported-target-version: -n "$0" -- "$@"`
+OPTIONS=`getopt -o bd:ko:r:v --long supported-host-version:,supported-target-version: -n "$0" -- "$@"`
 
 # Check for non-GNU getopt
 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
@@ -20,6 +21,10 @@ eval set -- "$OPTIONS"
 
 while true; do
 	case "$1" in
+	-b)
+		unset system # prepare a "bare" initramfs, based on user configuration only
+		shift
+		;;
 	-d)
 		CONFDIR="$2"
 		shift 2
@@ -84,7 +89,7 @@ fi
 
 . "${CONFDIR}/initramfs.conf"
 EXTRA_CONF=''
-for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
+for i in ${system:+/usr/share/initramfs-tools/conf.d/*} ${CONFDIR}/conf.d/*; do
 	EXTRA_CONF="${EXTRA_CONF} $(basename $i \
 		| grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
 done
@@ -93,13 +98,13 @@ done
 for i in ${EXTRA_CONF}; do
 	if [ -e  ${CONFDIR}/conf.d/${i} ]; then
 		. ${CONFDIR}/conf.d/${i}
-	elif [ -e  /usr/share/initramfs-tools/conf.d/${i} ]; then
+	elif [ -n "$system" ] && [ -e  /usr/share/initramfs-tools/conf.d/${i} ]; then
 		. /usr/share/initramfs-tools/conf.d/${i}
 	fi
 done
 
 # source package confs
-for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
+for i in ${system:+/usr/share/initramfs-tools/conf-hooks.d/*}; do
 	if [ -e "${i}" ]; then
 		. "${i}"
 	fi
@@ -127,7 +132,7 @@ fi
 # Check that we're using a new enough kernel version, first for ourselves,
 # then for each of the hooks, which can have a MINKVER variable defined
 check_minkver ${version}
-check_minkver ${version} /usr/share/initramfs-tools/hooks
+[ -n "$system" ] && check_minkver ${version} /usr/share/initramfs-tools/hooks
 check_minkver ${version} ${CONFDIR}/hooks
 
 case "${version}" in
@@ -185,7 +190,7 @@ for d in bin conf/conf.d etc lib/modules sbin scripts ${MODULESDIR}; do
 done
 
 # MODULES=list case.  Always honour.
-for x in "${CONFDIR}/modules" /usr/share/initramfs-tools/modules.d/*; do
+for x in "${CONFDIR}/modules" ${system:+/usr/share/initramfs-tools/modules.d/*}; do
 	if [ -f "${x}" ]; then
 		add_modules_from_file "${x}"
 	fi
@@ -224,7 +229,7 @@ rm -f ${DESTDIR}/bin/kinit* ${DESTDIR}/bin/gzip
 copy_exec /usr/share/initramfs-tools/init /init
 
 # add existant boot scripts
-for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \
+[ -n "$system" ] && for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \
 	-regextype posix-extended -regex '.*/[[:alnum:]_]+$' -type f); do
 	[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
 		|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
@@ -243,7 +248,7 @@ copy_exec "${CONFDIR}/initramfs.conf" /conf
 for i in ${EXTRA_CONF}; do
 	if [ -e "${CONFDIR}/conf.d/${i}" ]; then
 		copy_exec "${CONFDIR}/conf.d/${i}" /conf/conf.d
-	elif [ -e "/usr/share/initramfs-tools/conf.d/${i}" ]; then
+	elif [ -n "$system" ] && [ -e "/usr/share/initramfs-tools/conf.d/${i}" ]; then
 		copy_exec "/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
 	fi
 done
@@ -280,7 +285,7 @@ if [ "$DPKG_ARCH" = arm ] || [ "$DPKG_ARCH" = armeb ]; then
 	cp -a /lib/libgcc_s.so.1 "${DESTDIR}/lib/"
 fi
 
-run_scripts /usr/share/initramfs-tools/hooks
+[ -n "$system" ] && run_scripts /usr/share/initramfs-tools/hooks
 run_scripts "${CONFDIR}"/hooks
 
 # Apply DSDT to initramfs
diff --git a/mkinitramfs.8 b/mkinitramfs.8
index abb3f39..5a18b29 100644
--- a/mkinitramfs.8
+++ b/mkinitramfs.8
@@ -5,6 +5,7 @@ mkinitramfs \- low-level tool for generating an initramfs image
 
 .SH SYNOPSIS
 .B mkinitramfs
+.RB [ \-b ]
 .RB [ \-d
 .IR confdir ]
 .RB [ \-k ]
@@ -45,6 +46,12 @@ happens in this early userspace.
 
 .SH OPTIONS
 .TP
+\fB \-b
+Create a `bare' initramfs image by ignoring the system-wide hooks, scripts,
+modules and configuration under 
+.IR /usr/share/initramfs-tools .
+
+.TP
 \fB \-d \fI confdir
 Set an alternate configuration directory.
 
-- 
1.5.6.5


Reply to: