Patches, Patches, Patches ...

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

 



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@xxxxxxxxxx
        Communication Media & Services S.r.l.
 /"\
 \ /     ASCII RIBBON CAMPAIGN
  X        AGAINST HTML MAIL
 / \
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
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
 
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.
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
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"
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)
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: mkinitrd-dracut.sh
Description: Bourne shell script


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux