* [PATCH 2/5] Even more dracut cleanups
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-02-11 23:42 ` Victor Lowther
2009-02-11 23:42 ` [PATCH 3/5] " Victor Lowther
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:42 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Add very basic module functionality to dracut.
Move the i18n stuff to it.
---
dracut | 45 +++----------------------------------
dracut-functions | 2 -
modules/10redhat-i18n | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 43 deletions(-)
diff --git a/dracut b/dracut
index 1042a0a..3e3d6f7 100755
--- a/dracut
+++ b/dracut
@@ -98,47 +98,10 @@ done
# terminfo bits make things work better if you fall into interactive mode
for f in $(find /lib/terminfo -type f) ; do cp --parents $f "$initdir" ; done
-## this stuff should be moved out of the main dracut script
-
-# FIXME: i18n stuff isn't really distro-independent :/
-if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
- if [ -f /etc/sysconfig/console/default.kmap ]; then
- KEYMAP=/etc/sysconfig/console/default.kmap
- else
- . /etc/sysconfig/keyboard
- [[ $KEYTABLE && -d /lib/kbd/keymaps ]] && KEYMAP="$KEYTABLE.map"
- fi
- if [[ $KEYMAP ]]; then
- [ -f /etc/sysconfig/keyboard ] && inst /etc/sysconfig/keyboard
- inst /bin/loadkeys
- findkeymap $KEYMAP
-
- for FN in $KEYMAPS; do
- inst $FN
- case $FN in
- *.gz) gzip -d "$initdir$FN" ;;
- *.bz2) bzip2 -d "$initdir$FN" ;;
- esac
- done
- fi
-fi
-
-if [ -f /etc/sysconfig/i18n ]; then
- . /etc/sysconfig/i18n
- inst /etc/sysconfig/i18n
- [[ $SYSFONT ]] || SYSFONT=latarcyrheb-sun16
- inst /bin/setfont
-
- for FN in /lib/kbd/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
-fi
+# source any third-party package provided modules
+for f in "$dsrc/modules"/*; do
+ [[ -x $f ]] && . "$f"
+done
## final stuff that has to happen
diff --git a/dracut-functions b/dracut-functions
index 52ef722..8beba8b 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -120,10 +120,8 @@ inst_symlink() {
inst "$realsrc" && ln -s "$realsrc" "$target"
}
-
# general purpose installation function
# Same args as above.
-# Just tries to install as a binary, a shell script, then a simple data file.
inst() {
if (($# != 1 && $# != 2)); then
echo "usage: inst <file> <root> [<destination file>]"
diff --git a/modules/10redhat-i18n b/modules/10redhat-i18n
new file mode 100644
index 0000000..ae50bbc
--- /dev/null
+++ b/modules/10redhat-i18n
@@ -0,0 +1,59 @@
+#!/bin/bash
+findkeymap () {
+ local MAP=$1
+ [[ ! -f $MAP ]] && \
+ MAP=$(find /lib/kbd/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1)
+ [[ " $KEYMAPS " = *" $MAP "* ]] && return
+ KEYMAPS="$KEYMAPS $MAP"
+ case $MAP in
+ *.gz) cmd=zgrep;;
+ *.bz2) cmd=bzgrep;;
+ *) cmd=grep ;;
+ 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
+ findkeymap $FN
+ done
+ done
+}
+
+# FIXME: i18n stuff isn't really distro-independent :/
+if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
+ if [ -f /etc/sysconfig/console/default.kmap ]; then
+ KEYMAP=/etc/sysconfig/console/default.kmap
+ else
+ . /etc/sysconfig/keyboard
+ [[ $KEYTABLE && -d /lib/kbd/keymaps ]] && KEYMAP="$KEYTABLE.map"
+ fi
+ if [[ $KEYMAP ]]; then
+ [ -f /etc/sysconfig/keyboard ] && inst /etc/sysconfig/keyboard
+ inst loadkeys
+ findkeymap $KEYMAP
+
+ for FN in $KEYMAPS; do
+ inst $FN
+ case $FN in
+ *.gz) gzip -d "$initdir$FN" ;;
+ *.bz2) bzip2 -d "$initdir$FN" ;;
+ esac
+ done
+ fi
+fi
+
+if [ -f /etc/sysconfig/i18n ]; then
+ . /etc/sysconfig/i18n
+ inst /etc/sysconfig/i18n
+ [[ $SYSFONT ]] || SYSFONT=latarcyrheb-sun16
+ inst setfont
+
+ for FN in /lib/kbd/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
+fi
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 3/5] Even more dracut cleanups
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-11 23:42 ` [PATCH 2/5] Even more dracut cleanups Victor Lowther
@ 2009-02-11 23:42 ` Victor Lowther
2009-02-11 23:42 ` [PATCH 4/5] " Victor Lowther
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:42 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Use ldd to find shared library deps.
This replaces the eu-readelf and ld-linux.so.2 hackery.
As a bonus it will keep working if someone (for some bizzare reason)
needs to load a non-elf executable or shared library on the initrd.
---
dracut-functions | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index 8beba8b..62038f6 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -66,16 +66,10 @@ inst_binary() {
local bin="$1" target="${2:-$1}"
local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
[[ -f $initdir$target ]] && return 0
-
- LDSO=$(LANG=C eu-readelf -l $bin 2>/dev/null | \
- awk '/interpreter/ {print $4}' |sed -e 's/]$//')
- [[ $LDSO && $LDSO != $bin ]] || LDSO="$IF_RTLD"
- [[ $LDSO && $LDSO != $bin ]] || return 1
- [[ $IF_RTLD ]] || IF_RTLD="$LDSO"
-
# I love bash!
- while read NAME I0 FILE ADDR I1 ; do
- [[ $FILE = $bin ]] && continue
+ while read line; do
+ [[ $line =~ '([^ ]*/lib/[^ ]*\.so[^ ]*)' ]] || continue
+ FILE=${BASH_REMATCH[1]}
[[ $FILE = not || $NAME = not ]] && {
echo "Missing a shared library required by $bin." >&2
echo "dracut cannot create an initrd." >&2
@@ -96,8 +90,7 @@ inst_binary() {
continue
}
inst_library "$FILE"
- done < <(LD_TRACE_PRELINKING=1 LD_WARN= LD_TRACE_LOADED_OBJECTS=1 \
- $LDSO $bin 2>/dev/null)
+ done < <(ldd $bin 2>/dev/null)
inst_simple "$bin" "$target"
}
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 4/5] Even more dracut cleanups
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-11 23:42 ` [PATCH 2/5] Even more dracut cleanups Victor Lowther
2009-02-11 23:42 ` [PATCH 3/5] " Victor Lowther
@ 2009-02-11 23:42 ` Victor Lowther
2009-02-11 23:42 ` [PATCH 5/5] " Victor Lowther
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:42 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Get rid of echoer script
We can use sh -c to accomplish the same goal
Also move cat back on to the list of debugging tools -- all the files we were
using it on in the initrd can use read to accomplish the same goal.
---
Makefile | 3 +--
dracut | 6 ++----
echoer | 4 ----
init | 7 ++++---
pre-mount/50cryptroot | 2 +-
rules.d/63-luks.rules | 2 +-
6 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 6d7cb68..365cdf1 100644
--- a/Makefile
+++ b/Makefile
@@ -11,9 +11,8 @@ install:
install -m 0755 init $(DESTDIR)/usr/libexec/dracut/init
install -m 0755 switch_root $(DESTDIR)/usr/libexec/dracut/switch_root
install -m 0755 dracut-functions $(DESTDIR)/usr/libexec/dracut/functions
- install -m 0755 echoer $(DESTDIR)/usr/libexec/dracut/echoer
mkdir $(DESTDIR)/usr/libexec/dracut/rules.d
- for rule in rules.d/*.rules ; do install -m 0644 $$rule $(DESTDIR)/usr/libexec/dracut/rules.d ; done
+ for rule in rules.d/*.rules ; do install -m 0644 $$rule $(DESTDIR)/usr/libexec/dracut ; done
for hooks in pre-*/* ; do install -m 0755 $$hook $(DESTDIR/usr/libexec/dracut ; done
clean:
rm -f *~
diff --git a/dracut b/dracut
index 3e3d6f7..c8550c7 100755
--- a/dracut
+++ b/dracut
@@ -36,7 +36,6 @@ fi
initfile=$dsrc/init
switchroot=$dsrc/switch_root
rulesdir=$dsrc/rules.d
-echoer=$dsrc/echoer
hookdirs="pre-udev pre-mount pre-pivot"
initdir=$(mktemp -d -t initramfs.XXXXXX)
@@ -48,11 +47,11 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do
done
# executables that we have to have
-exe="bash mount mknod mkdir modprobe udevd udevadm nash pidof sleep chroot echo cat sed"
+exe="bash mount mknod mkdir modprobe udevd udevadm nash pidof sleep chroot echo sed"
lvmexe="lvm"
cryptexe="cryptsetup"
# and some things that are nice for debugging
-debugexe="ls ln ps grep more dmesg"
+debugexe="ls ln ps grep more dmesg cat"
# udev things we care about
udevexe="/lib/udev/vol_id /lib/udev/console_init"
@@ -70,7 +69,6 @@ fi
# install our scripts and hooks
inst "$initfile" "/init"
inst "$switchroot" "/sbin/switch_root"
-inst "$echoer" "/echoer"
for hookdir in $hookdirs; do
for hook in "$dsrc/$hookdir"/*; do
[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
diff --git a/echoer b/echoer
deleted file mode 100755
index 9fc7abf..0000000
--- a/echoer
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-target=$1
-shift
-echo "$@" >"$target"
\ No newline at end of file
diff --git a/init b/init
index 4b36e69..c8ac4e5 100755
--- a/init
+++ b/init
@@ -10,12 +10,13 @@ emergency_shell()
echo ; echo
echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
echo
- exec sh -i
+ sh -i 2>/dev/console
}
getarg() {
- local o;
- for o in $(cat /proc/cmdline); do
+ local o line
+ read -r line </proc/cmdline
+ for o in $line; do
[ "${o%%=*}" = "$1" ] && { echo $o; break; }
done
return 1
diff --git a/pre-mount/50cryptroot b/pre-mount/50cryptroot
index de7eca4..0664f24 100755
--- a/pre-mount/50cryptroot
+++ b/pre-mount/50cryptroot
@@ -1,7 +1,7 @@
#!/bin/sh
[ -f /cryptroot ] && {
echo "Encrypted root detected."
- cryptopts=$(cat /cryptroot)
+ read cryptopts </cryptroot
/sbin/cryptsetup luksOpen $cryptopts || emergency_shell
udevadm settle --timeout=30
}
diff --git a/rules.d/63-luks.rules b/rules.d/63-luks.rules
index ab907e9..4d6a379 100644
--- a/rules.d/63-luks.rules
+++ b/rules.d/63-luks.rules
@@ -8,6 +8,6 @@ SUBSYSTEM!="block", GOTO="luks_end"
ACTION!="add|change", GOTO="luks_end"
KERNEL!="sr*", IMPORT{program}="vol_id --export $tempnode"
-ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/echoer /cryptroot $env{DEVNAME} luks-$env{ID_FS_UUID}"
+ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/bin/sh -c 'echo $env{DEVNAME} luks-$env{ID_FS_UUID} >/cryptroot'"
LABEL="luks_end"
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/5] Even more dracut cleanups
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 preceding siblings ...)
2009-02-11 23:42 ` [PATCH 4/5] " Victor Lowther
@ 2009-02-11 23:42 ` Victor Lowther
2009-02-11 23:53 ` [PATCH 6/5] Even more dracut functionality Victor Lowther
2009-02-12 0:21 ` [PATCH 1/5] " Karel Zak
5 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:42 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Really die if a library is not found.
Also explain how to find out what the missing library is.
---
dracut-functions | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index 62038f6..e80d786 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -68,10 +68,11 @@ inst_binary() {
[[ -f $initdir$target ]] && return 0
# I love bash!
while read line; do
- [[ $line =~ '([^ ]*/lib/[^ ]*\.so[^ ]*)' ]] || continue
+ [[ $line =~ '([^ ]*/lib/[^ ]*\.so[^ ]*|not found)' ]] || continue
FILE=${BASH_REMATCH[1]}
- [[ $FILE = not || $NAME = not ]] && {
+ [[ $FILE = 'not found' ]] && {
echo "Missing a shared library required by $bin." >&2
+ echo "Run \"ldd $bin\" to find out what it is." >&2
echo "dracut cannot create an initrd." >&2
exit 1
}
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 6/5] Even more dracut functionality
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (3 preceding siblings ...)
2009-02-11 23:42 ` [PATCH 5/5] " Victor Lowther
@ 2009-02-11 23:53 ` Victor Lowther
2009-02-12 0:21 ` [PATCH 1/5] " Karel Zak
5 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:53 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
fixed library-matching regex
Forgot about /lib64, oops.
---
dracut-functions | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index e80d786..a0a1906 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -68,7 +68,7 @@ inst_binary() {
[[ -f $initdir$target ]] && return 0
# I love bash!
while read line; do
- [[ $line =~ '([^ ]*/lib/[^ ]*\.so[^ ]*|not found)' ]] || continue
+ [[ $line =~ '([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*|not found)' ]] || continue
FILE=${BASH_REMATCH[1]}
[[ $FILE = 'not found' ]] && {
echo "Missing a shared library required by $bin." >&2
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/5] Even more dracut functionality
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (4 preceding siblings ...)
2009-02-11 23:53 ` [PATCH 6/5] Even more dracut functionality Victor Lowther
@ 2009-02-12 0:21 ` Karel Zak
[not found] ` <20090212002109.GE21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
5 siblings, 1 reply; 10+ messages in thread
From: Karel Zak @ 2009-02-12 0:21 UTC (permalink / raw)
To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
I know, that's nit-picking, but I cannot resist ;-)
On Wed, Feb 11, 2009 at 03:41:56PM -0800, Victor Lowther wrote:
> +find_binary() {
> + local binpath="/bin /sbin /usr/bin /usr/sbin" p
> + [[ ${1##*/} = $1 ]] || { echo $1; return 0; }
> + for p in $binpath; do
> + [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
> + done
> + return 1
> +}
[...]
> + local src=$(find_binary "$1") || {
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
local src=$(type -Pa "$1")
Karel
--
Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread