* [PATCH 1/5] Even more dracut functionality
@ 2009-02-11 23:41 Victor Lowther
[not found] ` <255e595fd4f868ab0f6e085deb0bfd4a2afc8ae7.1234395178.git.victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Victor Lowther @ 2009-02-11 23:41 UTC (permalink / raw)
To: initramfs-u79uwXL29TY76Z2rM5mHXA
Some more functionality -- no more hardcoded executable locations in the
dracut script, usind ldd to find library dependencies instead of eu-readelf,
and so on.
These patches are on the even-more-functionality branch at
http://git.fnordovax.org/dracut, and apply on top of the other two patch series.
--
dracut will now search for files in the usual binary locations if a
full path is not passed to the inst function.
---
dracut | 8 ++++----
dracut-functions | 17 ++++++++++++++---
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/dracut b/dracut
index 30f0f9d..1042a0a 100755
--- a/dracut
+++ b/dracut
@@ -48,11 +48,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="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed"
-lvmexe="/sbin/lvm"
-cryptexe="/sbin/cryptsetup"
+exe="bash mount mknod mkdir modprobe udevd udevadm nash pidof sleep chroot echo cat sed"
+lvmexe="lvm"
+cryptexe="cryptsetup"
# and some things that are nice for debugging
-debugexe="/bin/ls /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
+debugexe="ls ln ps grep more dmesg"
# udev things we care about
udevexe="/lib/udev/vol_id /lib/udev/console_init"
diff --git a/dracut-functions b/dracut-functions
index 97ac626..52ef722 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -31,7 +31,6 @@ IF_dynamic=""
inst_simple() {
local src=$1 target="${initdir}${2:-$1}"
[[ -f $target ]] && return 0
- echo "Installing $src to $target"
mkdir -p "${target%/*}"
cp -fL "$src" "$target"
}
@@ -51,7 +50,14 @@ inst_library() {
fi
}
-
+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
+}
# Same as above.
# If the file is a binary executable, install all its
@@ -114,6 +120,7 @@ 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.
@@ -122,7 +129,11 @@ inst() {
echo "usage: inst <file> <root> [<destination file>]"
return 1
fi
- local src=$1 dest=${2:-$1}
+ local src=$(find_binary "$1") || {
+ echo "Cannot find requested file $1. Exiting."
+ exit 1
+ }
+ local dest=${2:-$src}
for x in inst_symlink inst_script inst_binary inst_simple; do
$x "$src" "$dest" && return 0
done
--
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 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
* Re: [PATCH 1/5] Even more dracut functionality
[not found] ` <20090212002109.GE21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
@ 2009-02-12 2:35 ` Victor Lowther
[not found] ` <921e043f0902111835h1975c2f5y87e67d6314df97a2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Victor Lowther @ 2009-02-12 2:35 UTC (permalink / raw)
To: Karel Zak; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
On Wed, Feb 11, 2009 at 6:21 PM, Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>
> 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")
What will that do when passed an absolute path to a file that is not
an executable?
> 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
* Re: [PATCH 1/5] Even more dracut functionality
[not found] ` <921e043f0902111835h1975c2f5y87e67d6314df97a2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-02-12 11:18 ` Karel Zak
[not found] ` <20090212111859.GA3201-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Karel Zak @ 2009-02-12 11:18 UTC (permalink / raw)
To: Victor Lowther; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
On Wed, Feb 11, 2009 at 08:35:21PM -0600, Victor Lowther wrote:
> On Wed, Feb 11, 2009 at 6:21 PM, Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >
> > 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
btw, what when you want to generate initramfs from a different set of
utils than you have in your standard system? What about to support
something like
dracut --prefix=/usr/local
or follow $PATH rather than hardcode paths to the dracut script.
> >> + [[ ${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")
>
> What will that do when passed an absolute path to a file that is not
> an executable?
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
src=$(type -Pa "$1") || src="$1"
[[ ! -f "$src" ]] && {
echo "Cannot find requested file $1. Exiting."
exit 1
}
... but that's real nit-picking (and I love shell or awk exercises ;-)
Your find_binary() is good of course. I look forward to see your patches
in dracut git repository.
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
* Re: [PATCH 1/5] Even more dracut functionality
[not found] ` <20090212111859.GA3201-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
@ 2009-02-12 12:06 ` Victor Lowther
0 siblings, 0 replies; 10+ messages in thread
From: Victor Lowther @ 2009-02-12 12:06 UTC (permalink / raw)
To: Karel Zak; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
On Thu, 2009-02-12 at 12:18 +0100, Karel Zak wrote:
> On Wed, Feb 11, 2009 at 08:35:21PM -0600, Victor Lowther wrote:
> > On Wed, Feb 11, 2009 at 6:21 PM, Karel Zak <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > >
> > > 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
>
> btw, what when you want to generate initramfs from a different set of
> utils than you have in your standard system? What about to support
> something like
>
> dracut --prefix=/usr/local
>
> or follow $PATH rather than hardcode paths to the dracut script.
The reason I hardcoded it was to reduce errors because of administrators
doing stupid things with $PATH.
The other piece of functionality I am thinking about is how to tell
dracut that you should use $wherever as the place to start your searches
at for files to put on to the initrd.
It may be easier to modularize the binary installation code -- package
up the current stuff in a separate file we can source, call it the
default method, and let folks who are keen on busybox or klibc or
whatever write their own method that overrides the default one.
> Karel
>
--
Victor Lowther
RHCE# 805008539634727
LPIC-2# LPI000140019
--
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
end of thread, other threads:[~2009-02-12 12:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 23:41 [PATCH 1/5] Even more dracut functionality Victor Lowther
[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 ` [PATCH 4/5] " Victor Lowther
2009-02-11 23:42 ` [PATCH 5/5] " 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
[not found] ` <20090212002109.GE21052-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
2009-02-12 2:35 ` Victor Lowther
[not found] ` <921e043f0902111835h1975c2f5y87e67d6314df97a2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-02-12 11:18 ` Karel Zak
[not found] ` <20090212111859.GA3201-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
2009-02-12 12:06 ` Victor Lowther
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.