Browse Source

Set some global variables in dracut-functions.sh

master
Harald Hoyer 13 years ago
parent
commit
8d95b8b338
  1. 34
      dracut-functions.sh
  2. 22
      dracut.sh

34
dracut-functions.sh

@ -20,6 +20,9 @@ @@ -20,6 +20,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Generic substring function. If $2 is in $1, return 0.
strstr() { [ "${1#*$2*}" != "$1" ]; }

if ! [[ $dracutbasedir ]]; then
dracutbasedir=${BASH_SOURCE[0]%/*}
[[ $dracutbasedir = "dracut-functions" ]] && dracutbasedir="."
@ -27,6 +30,34 @@ if ! [[ $dracutbasedir ]]; then @@ -27,6 +30,34 @@ if ! [[ $dracutbasedir ]]; then
dracutbasedir="$(readlink -f $dracutbasedir)"
fi

# Detect lib paths
if ! [[ $libdirs ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
&& [[ -d /lib64 ]]; then
libdirs+=" /lib64"
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
else
libdirs+=" /lib"
[[ -d /usr/lib ]] && libdirs+=" /usr/lib"
fi
export libdirs
fi

if ! [[ $kernel ]]; then
kernel=$(uname -r)
export kernel
fi

srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && {
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
srcmods="$drivers_dir"
}
export srcmods

if ! type dinfo >/dev/null 2>&1; then
. "$dracutbasedir/dracut-logger.sh"
dlog_init
@ -41,9 +72,6 @@ fi @@ -41,9 +72,6 @@ fi
export hookdirs
}

# Generic substring function. If $2 is in $1, return 0.
strstr() { [ "${1#*$2*}" != "$1" ]; }

# Create all subdirectories for given path without creating the last element.
# $1 = path
mksubdirs() { mkdir -m 0755 -p ${1%/*}; }

22
dracut.sh

@ -531,18 +531,6 @@ ddebug "Executing $0 $dracut_args" @@ -531,18 +531,6 @@ ddebug "Executing $0 $dracut_args"
exit 0
}

# Detect lib paths
if ! [[ $libdirs ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
&& [[ -d /lib64 ]]; then
libdirs+=" /lib64"
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
else
libdirs+=" /lib"
[[ -d /usr/lib ]] && libdirs+=" /usr/lib"
fi
fi

# This is kinda legacy -- eventually it should go away.
case $dracutmodules in
""|auto) dracutmodules="all" ;;
@ -550,16 +538,6 @@ esac @@ -550,16 +538,6 @@ esac

abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"

srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && {
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
srcmods="$drivers_dir"
}
export srcmods

[[ -f $srcmods/modules.dep ]] || {
dfatal "$srcmods/modules.dep is missing. Did you run depmod?"
exit 1

Loading…
Cancel
Save