# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-[[ -d "$initdir/.kernelmodseen" ]] || mkdir -p "$initdir/.kernelmodseen"
+
+if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then
+ if ! [[ -d "$initdir/.kernelmodseen" ]]; then
+ mkdir -p "$initdir/.kernelmodseen"
+ fi
+ DRACUT_KERNEL_LAZY_HASHDIR="$initdir/.kernelmodseen"
+fi
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 = *$2* ]]; }
+# find a binary. If we were not passed the full path directly,
+# search in the usual places to find the binary.
+find_binary() {
+ if [[ -z ${1##/*} ]]; then
+ if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then
+ echo $1
+ return 0
+ fi
+ fi
+
+ type -P $1
+}
+
if ! [[ $dracutbasedir ]]; then
dracutbasedir=${BASH_SOURCE[0]%/*}
[[ $dracutbasedir = "dracut-functions" ]] && dracutbasedir="."
dracutbasedir="$(readlink -f $dracutbasedir)"
fi
+if ! [[ $DRACUT_INSTALL ]]; then
+ DRACUT_INSTALL=$(find_binary dracut-install)
+fi
+
+if ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/dracut-install ]]; then
+ DRACUT_INSTALL=$dracutbasedir/dracut-install
+fi
+
# Detect lib paths
if ! [[ $libdirs ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
return 1
}
-if [[ -x /usr/bin/dracut-install ]]; then
+if [[ $DRACUT_INSTALL ]]; then
[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
inst_dir() {
[[ -e ${initdir}/"$1" ]] && return 0 # already there
- dracut-install ${initdir+-D "$initdir"} -d "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} -d "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -d "$@" || :
}
inst() {
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
- #dinfo "dracut-install -l $@"
- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ #dinfo "$DRACUT_INSTALL -l $@"
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
inst_simple() {
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -e $1 ]] || return 1 # no source
- dracut-install ${initdir+-D "$initdir"} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} "$@" || :
}
inst_symlink() {
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -L $1 ]] || return 1
- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
dracut_install() {
- #dinfo "initdir=$initdir dracut-install -l $@"
- dracut-install ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ #dinfo "initdir=$initdir $DRACUT_INSTALL -l $@"
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} -a ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
inst_library() {
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -e $1 ]] || return 1 # no source
- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
inst_binary() {
- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
inst_script() {
- dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
- (($? != 0)) && derror dracut-install ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
+ $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@"
+ (($? != 0)) && derror $DRACUT_INSTALL ${initdir+-D "$initdir"} ${DRACUT_RESOLVE_DEPS+-l} ${DRACUT_FIPS_MODE+-H} "$@" || :
}
else
echo "${links}"
}
-# find a binary. If we were not passed the full path directly,
-# search in the usual places to find the binary.
-find_binary() {
- if [[ -z ${1##/*} ]]; then
- if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then
- echo $1
- return 0
- fi
- fi
-
- type -P $1
-}
-
# attempt to install any programs specified in a udev rule
inst_rule_programs() {
local _prog _bin
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \
&& return 0
- if [[ -e "$initdir/.kernelmodseen/${1##*/}" ]]; then
- read ret < "$initdir/.kernelmodseen/${1##*/}"
+ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -e "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}" ]]; then
+ read ret < "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}"
return $ret
fi
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
ret=$?
- [ -d "$initdir/.kernelmodseen" ] && \
- echo $ret > "$initdir/.kernelmodseen/${1##*/}"
+ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \
+ [[ -d "$DRACUT_KERNEL_LAZY_HASHDIR" ]] && \
+ echo $ret > "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}"
(($ret != 0)) && return $ret
local _modname=${1##*/} _fwdir _found _fw
dracut_kernel_post() {
local _moddirname=${srcmods%%/lib/modules/*}
- if [[ -f "$initdir/.kernelmodseen/lazylist" ]]; then
+ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" ]]; then
xargs modprobe -a ${_moddirname+-d ${_moddirname}/} --ignore-install --show-depends \
- < "$initdir/.kernelmodseen/lazylist" 2>/dev/null \
+ < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist" 2>/dev/null \
| sort -u \
| while read _cmd _modpath _options; do
[[ $_cmd = insmod ]] || continue
echo "$_modpath"
- done > "$initdir/.kernelmodseen/lazylist.dep"
+ done > "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
(
- if [[ -x /usr/bin/dracut-install ]] && [[ -z $_moddirname ]]; then
- xargs dracut-install ${initdir+-D "$initdir"} -a < "$initdir/.kernelmodseen/lazylist.dep"
+ if [[ -x $DRACUT_INSTALL ]] && [[ -z $_moddirname ]]; then
+ xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
else
while read _modpath; do
local _destpath=$_modpath
[[ $_moddirname ]] && _destpath=${_destpath##$_moddirname/}
_destpath=${_destpath##*/lib/modules/$kernel/}
inst_simple "$_modpath" "/lib/modules/$kernel/${_destpath}" || exit $?
- done < "$initdir/.kernelmodseen/lazylist.dep"
+ done < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
fi
) &
- if [[ -x /usr/bin/dracut-install ]]; then
- xargs modinfo -k $kernel -F firmware < "$initdir/.kernelmodseen/lazylist.dep" \
+ if [[ -x $DRACUT_INSTALL ]]; then
+ xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep" \
| while read line; do
for _fwdir in $fw_dir; do
echo $_fwdir/$line;
done;
- done |xargs dracut-install ${initdir+-D "$initdir"} -a -o
+ done |xargs $DRACUT_INSTALL ${initdir+-D "$initdir"} -a -o
else
- for _fw in $(xargs modinfo -k $kernel -F firmware < "$initdir/.kernelmodseen/lazylist.dep"); do
+ for _fw in $(xargs modinfo -k $kernel -F firmware < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"); do
for _fwdir in $fw_dir; do
if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then
inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw"
exit 1
fi
- rm -fr "$initdir/.kernelmodseen"
+ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr "$DRACUT_KERNEL_LAZY_HASHDIR"
}
find_kernel_modules_by_path () (
_mod=${_mod##*/}
# if we are already installed, skip this module and go on
# to the next one.
- if [[ -f "$initdir/.kernelmodseen/${_mod%.ko}.ko" ]]; then
- read _ret <"$initdir/.kernelmodseen/${_mod%.ko}.ko"
+ if [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \
+ [[ -f "$DRACUT_KERNEL_LAZY_HASHDIR/${_mod%.ko}.ko" ]]; then
+ read _ret <"$DRACUT_KERNEL_LAZY_HASHDIR/${_mod%.ko}.ko"
return $_ret
fi
&& ! [[ "$add_drivers" =~ " ${_mod} " ]] \
&& return 0
- if [[ "$_check" = "yes" ]] || ! [[ $DRACUT_KERNEL_LAZY ]]; then
+ if [[ "$_check" = "yes" ]] || ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then
# We use '-d' option in modprobe only if modules prefix path
# differs from default '/'. This allows us to use Dracut with
# old version of modprobe which doesn't have '-d' option.
--set-version $kernel ${_moddirname} $_mpargs
((_ret+=$?))
else
- echo $_mod >> "$initdir/.kernelmodseen/lazylist"
+ [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \
+ echo $_mod >> "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist"
fi
;;
esac