All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Berra <bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Patches, Patches, Patches ...
Date: Tue, 29 Dec 2009 13:54:47 +0100	[thread overview]
Message-ID: <20091229125447.GA5522@maude.comedia.it> (raw)

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

Hello,
I am trying to integrate dracut into Mandriva, so far it looks good but
I had to do some modifications in order to have it working.
- dracut-003-kbd.patch: we have kbd data in /usr/lib, so this patch will
search for /lib/kbd and /usr/lib/kbd and use the existing one
- dracut-003-terminfo.patch: same applies to terminfo database
- dracut-003-kogz.patch: we use compressed kernel modules, this adds
support for those. I actually don't like very much the
uncompressing/nm/delete thinghy and I think we should put uncompressed
modules in the initrd, which is alreeady compressed, but I did not come
up with a clean patch yet
- dracut-003-selinux.patch: we dont' use selinux, so it makes no sense to
force load policy if selinux is not installed at all.

While testing it I also found some issue which I worked around:
- dracut-003-umount.patch: some modules call umount, but don't install it.
- dracut-003-rdshell.patch: for some unknown reason the emergency shell
starts with stderr closed, at first I even tought it was not working at
all, then I came up with this hack, which seems to work properly. I also
change the prompt to remind which step are we breaking to.

and added a feature:
- dracut-003-addmod.patch: this makes dracut load kernel module
   specified in add-drivers even if building an host-only mkinitrd, it is
useful in cases where we might change some storage drivers and still
don't want to build an enormous initrd (e.g. ahci/ata_piix)

latest is a wrapper around dracut with the syntax from mkinitrd, could
help transition to dracut.
mkinitrd-dracut.sh

patches are attached.

btw i am unable to git clone from sourceforge:
$ git clone -v git://dracut.git.sourceforge.net/gitroot/dracut
Initialized empty Git repository in /home/bluca/GIT/dracut/.git/
fatal: The remote end hung up unexpectedly

Regards,
L.

-- 
Luca Berra -- bluca-APJUtua8uzqonA0d6jMUrA@public.gmane.org
         Communication Media & Services S.r.l.
  /"\
  \ /     ASCII RIBBON CAMPAIGN
   X        AGAINST HTML MAIL
  / \

[-- Attachment #2: dracut-003-addmod.patch --]
[-- Type: text/plain, Size: 709 bytes --]

diff -p -up dracut-003/dracut-functions.addmod dracut-003/dracut-functions
--- dracut-003/dracut-functions.addmod	2009-12-28 13:54:56.674196205 +0100
+++ dracut-003/dracut-functions	2009-12-28 21:49:33.163412583 +0100
@@ -499,7 +499,8 @@ instmods() {
 	        [[ -f $initdir/$1 ]] && { shift; continue; }
 		# If we are building a host-specific initramfs and this
 		# module is not already loaded, move on to the next one.
-		[[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && {
+		[[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && \
+	        ! echo $add_drivers | grep -qe "\<${mod}\>" &&	{
 		    shift; continue; 
 		}
 		# ok, load the module, all its dependencies, and any firmware

[-- Attachment #3: dracut-003-kbd.patch --]
[-- Type: text/plain, Size: 2482 bytes --]

diff -p -up dracut-003/modules.d/10redhat-i18n/install.kbd dracut-003/modules.d/10redhat-i18n/install
--- dracut-003/modules.d/10redhat-i18n/install.kbd	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/modules.d/10redhat-i18n/install	2009-12-29 11:00:52.655463682 +0100
@@ -3,7 +3,7 @@
 findkeymap () {
     local MAP=$1
     [[ ! -f $MAP ]] && \
-	MAP=$(find /lib/kbd/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1)
+	MAP=$(find ${kbddir}/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1)
     [[ " $KEYMAPS " = *" $MAP "* ]] && return
     KEYMAPS="$KEYMAPS $MAP"
     case $MAP in
@@ -13,7 +13,7 @@ findkeymap () {
     esac
 
     for INCL in $($cmd "^include " $MAP | cut -d' ' -f2 | tr -d '"'); do
-        for FN in $(find /lib/kbd/keymaps -type f -name $INCL\*); do
+        for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
             findkeymap $FN
         done
     done
@@ -27,7 +27,7 @@ install_local()
             KEYMAP=/etc/sysconfig/console/default.kmap
 	else
             . /etc/sysconfig/keyboard
-            [[ $KEYTABLE && -d /lib/kbd/keymaps ]] && KEYMAP="$KEYTABLE.map"
+            [[ $KEYTABLE && -d ${kbddir}/keymaps ]] && KEYMAP="$KEYTABLE.map"
 	fi
 	if [[ $KEYMAP ]]; then
             [ -f /etc/sysconfig/keyboard ] && inst /etc/sysconfig/keyboard
@@ -58,27 +58,31 @@ install_local()
 	[[ $SYSFONT ]] || SYSFONT=latarcyrheb-sun16
 	inst setfont
 
-	for FN in /lib/kbd/consolefonts/$SYSFONT.* ; do
+	for FN in ${kbddir}/consolefonts/$SYSFONT.* ; do
             inst "$FN"
             case $FN in
 		*.gz) gzip -d "$initdir$FN" ;;
 		*.bz2) bzip2 -d "$initdir$FN" ;;
             esac
 	done
-	[[ $SYSFONTACM ]] && inst /lib/kbd/consoletrans/$SYSFONTACM
-	[[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP
+	[[ $SYSFONTACM ]] && inst ${kbddir}/consoletrans/$SYSFONTACM
+	[[ $UNIMAP ]] && inst ${kbddir}/unimaps/$UNIMAP
     fi
 }
 
+for kbddir in /usr/lib/kbd /lib/kbd; do
+	[[ -d ${kbddir} ]] && break
+done
+
 if [[ $hostonly ]]; then 
     install_local
 else
-    for i in $(find /lib/kbd -type f -print); do
+    for i in $(find ${kbddir} -type f -print); do
 	dracut_install $i
     done
     # remove unnecessary files
-    rm -f "$initdir/lib/kbd/consoletrans/utflist" 2>/dev/null
-    find "$initdir/lib/kbd/" -name README\* -exec rm -f '{}' \;
+    rm -f "$initdir${kbddir}/consoletrans/utflist" 2>/dev/null
+    find "$initdir${kbddir}/" -name README\* -exec rm -f '{}' \;
     dracut_install gzip bzip2
 fi
 

[-- Attachment #4: dracut-003-kogz.patch --]
[-- Type: text/plain, Size: 1784 bytes --]

diff -p -up dracut-003/dracut-functions.kogz dracut-003/dracut-functions
--- dracut-003/dracut-functions.kogz	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/dracut-functions	2009-12-28 13:53:08.957798593 +0100
@@ -407,7 +407,7 @@ check_modules() {
 # $1 = full path to kernel module to install
 install_kmod_with_fw() {
     local modname=${1##*/} fwdir found
-    modname=${modname%.ko}
+    modname=${modname%.ko*}
     inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
 	return 0 # no need to go further if the module is already installed
     for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
@@ -450,12 +450,21 @@ for_each_kmod_dep() {
 # This function returns the full filenames of modules that match $1
 filter_kernel_modules () (
     if ! [[ $hostonly ]]; then
-	filtercmd='find "$srcmods/kernel/drivers" -name "*.ko"'
+	filtercmd='find "$srcmods/kernel/drivers" -name "*.ko" -o -name "*.ko.gz"'
     else
 	filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
     fi
     for modname in $(eval $filtercmd); do
-	"$1" "$modname" && echo "$modname"
+        case $modname in
+            *.ko)
+                "$1" "$modname" && echo "$modname"
+                ;;
+            *.ko.gz)
+                gzip -dc "$modname" > $initdir/$$.ko
+                $1 $initdir/$$.ko && echo "$modname"
+                rm -f $initdir/$$.ko
+                ;;
+        esac
     done
 )
 
@@ -464,7 +473,7 @@ instmods() {
     [[ $no_kernel = yes ]] && return
     local mod mpargs modpath modname cmd
     while (($# > 0)); do
-	mod=${1%.ko}
+	mod=${1%.ko*}
 	case $mod in
 	    =*) # This introduces 2 incompatible meanings for =* arguments
                 # to instmods.  We need to decide which one to keep.

[-- Attachment #5: dracut-003-rdshell.patch --]
[-- Type: text/plain, Size: 3368 bytes --]

diff -p -up dracut-003/modules.d/99base/init.rdshell.orig dracut-003/modules.d/99base/init
--- dracut-003/modules.d/99base/init.rdshell.orig	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/modules.d/99base/init	2009-12-29 13:08:20.844275792 +0100
@@ -35,6 +35,12 @@ wait_for_loginit()
 
 emergency_shell()
 {
+    if [ $1 = "-n" ]; then
+        _rdshell_name=$2
+        shift 2 
+    else
+        _rdshell_name=dracut
+    fi
     wait_for_loginit
     echo ; echo
     echo $@
@@ -43,7 +49,9 @@ emergency_shell()
     if getarg rdshell || getarg rdbreak; then
         echo "Dropping to debug shell."
         echo
-        sh -i
+        export PS1="$_rdshell_name:\${PWD}# "
+        [ -e /.profile ] || echo "exec 0</dev/console 1>/dev/console 2>/dev/console" > /.profile
+        sh -i -l
     else
         echo "Boot has failed, sleeping forever."
         while :; do sleep 365d;done
@@ -101,7 +109,7 @@ UDEVVERSION=$(udevadm --version)
 source_conf /etc/conf.d
 
 # run scriptlets to parse the command line
-getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
+getarg 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
 source_all cmdline
 
 [ -z "$root" ] && die "No or empty root= argument"
@@ -118,7 +126,7 @@ source_all cmdline
 } > /tmp/root.info
 
 # pre-udev scripts run before udev starts, and are run only once.
-getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev"
+getarg 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break before pre-udev"
 source_all pre-udev
 
 # start up udev and trigger cold plugs
@@ -135,13 +143,13 @@ fi
 getarg rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info
 getarg rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug
 
-getarg 'rdbreak=pre-trigger' && emergency_shell "Break before pre-trigger"
+getarg 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
 source_all pre-trigger
 
 # then the rest
 udevadm trigger $udevtriggeropts  >/dev/null 2>&1
 
-getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
+getarg 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
 
 i=0
 while :; do
@@ -187,11 +195,11 @@ unset queuetriggered
 
 # pre-mount happens before we try to mount the root filesystem,
 # and happens once.
-getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount"
+getarg 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
 source_all pre-mount
 
 
-getarg 'rdbreak=mount' && emergency_shell "Break mount"
+getarg 'rdbreak=mount' && emergency_shell -n mount "Break mount"
 # mount scripts actually try to mount the root filesystem, and may
 # be sourced any number of times. As soon as one suceeds, no more are sourced.
 i=0
@@ -213,7 +221,7 @@ done
 } | vinfo
 
 # pre pivot scripts are sourced just before we switch over to the new root.
-getarg 'rdbreak=pre-pivot' && emergency_shell "Break pre-pivot"
+getarg 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
 source_all pre-pivot
 
 # by the time we get here, the root filesystem should be mounted.
@@ -228,7 +236,7 @@ done
     emergency_shell
 }
 
-getarg rdbreak && emergency_shell "Break before switch_root"
+getarg rdbreak && emergency_shell -n switch_root "Break before switch_root"
 
 # stop udev queue before killing it
 udevadm control --stop-exec-queue

[-- Attachment #6: dracut-003-selinux.patch --]
[-- Type: text/plain, Size: 641 bytes --]

diff -p -up dracut-003/modules.d/99base/install.selinux dracut-003/modules.d/99base/install
--- dracut-003/modules.d/99base/install.selinux	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/modules.d/99base/install	2009-12-29 12:01:56.033557750 +0100
@@ -23,5 +23,7 @@ fi
 inst "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
 inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
 inst_hook cmdline 20 "$moddir/parse-blacklist.sh"
-inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"
+if [ -x "/usr/sbin/load_policy" -o -x "/sbin/load_policy" ]; then
+	inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"
+fi
 mkdir -p "${initdir}/var/run"

[-- Attachment #7: dracut-003-terminfo.patch --]
[-- Type: text/plain, Size: 723 bytes --]

diff -p -up dracut-003/modules.d/95terminfo/install.terminfo dracut-003/modules.d/95terminfo/install
--- dracut-003/modules.d/95terminfo/install.terminfo	2009-12-29 11:10:16.287854710 +0100
+++ dracut-003/modules.d/95terminfo/install	2009-12-29 11:10:14.294156785 +0100
@@ -1,8 +1,8 @@
 #!/bin/bash
 # terminfo bits make things work better if you fall into interactive mode
-TERMINFODIR="/lib/terminfo"
+for TERMINFODIR in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+	[ -d ${TERMINFODIR} ] && break
+done
 
-[ ! -d ${TERMINFODIR} -a -d "/etc/terminfo" ] && \
-	TERMINFODIR="/etc/terminfo"
-
-dracut_install $(find ${TERMINFODIR} -type f)
+[ -d ${TERMINFODIR} ] && \
+	dracut_install $(find ${TERMINFODIR} -type f)

[-- Attachment #8: dracut-003-umount.patch --]
[-- Type: text/plain, Size: 987 bytes --]

diff -p -up dracut-003/modules.d/01fips/install.umount dracut-003/modules.d/01fips/install
--- dracut-003/modules.d/01fips/install.umount	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/modules.d/01fips/install	2009-12-29 11:36:04.542497926 +0100
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 inst_hook pre-trigger 01 "$moddir/fips.sh"
-dracut_install sha512hmac rmmod insmod mount uname
+dracut_install sha512hmac rmmod insmod mount uname umount
 
 libdir="lib"
 if ldd $(find_binary sha512hmac) |grep -q /lib64/libc; then
diff -p -up dracut-003/modules.d/95rootfs-block/install.umount dracut-003/modules.d/95rootfs-block/install
--- dracut-003/modules.d/95rootfs-block/install.umount	2009-11-27 15:25:46.000000000 +0100
+++ dracut-003/modules.d/95rootfs-block/install	2009-12-29 11:34:52.025654159 +0100
@@ -1,4 +1,5 @@
 #!/bin/sh
+dracut_install umount
 inst_hook cmdline 95 "$moddir/parse-block.sh"
 inst_hook pre-udev 30 "$moddir/block-genrules.sh"
 inst_hook mount 99 "$moddir/mount-root.sh"

[-- Attachment #9: mkinitrd-dracut.sh --]
[-- Type: application/x-sh, Size: 3931 bytes --]

             reply	other threads:[~2009-12-29 12:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-29 12:54 Luca Berra [this message]
     [not found] ` <20091229125447.GA5522-hdG+WfPrfN2JmafXlB/IVQ@public.gmane.org>
2009-12-29 16:10   ` Patches, Patches, Patches David Dillow
     [not found]     ` <1262103052.8998.8.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2009-12-30  7:42       ` Luca Berra
2010-01-18  9:11   ` Harald Hoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091229125447.GA5522@maude.comedia.it \
    --to=bluca-apjutua8uzqona0d6jmura@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.