]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
[PATCH 41/50] dracut will now search for files in the usual binary locations if a
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 13 Feb 2009 12:43:09 +0000 (04:43 -0800)
committerDave Jones <davej@redhat.com>
Mon, 16 Feb 2009 18:56:42 +0000 (13:56 -0500)
dracut
dracut-functions

diff --git a/dracut b/dracut
index 30f0f9da4eb6a97a0121783027e4bad56501fb59..1042a0aad133a20290933dfb833f2621a681c4af 100755 (executable)
--- 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"
 
index 97ac626010813a6e6d626158fd869252b7bfe228..52ef722b88f7effa3760fa73bb239c97e4da6c12 100755 (executable)
@@ -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