X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=dracut-init.sh;h=50d23e2d110dd1f220eb134e7a5cb5adf3211277;hb=58e0d2d5b5b3a5e7d6dbf74baa2f08f041de5a81;hp=a195c32b5cb30c7f40bf946471e3aeb1eb102d74;hpb=3f60444ec1bff8a57a2cf4ada238e782928890eb;p=thirdparty%2Fdracut.git diff --git a/dracut-init.sh b/dracut-init.sh index a195c32b5..50d23e2d1 100644 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -19,6 +19,12 @@ # export LC_MESSAGES=C +if [[ "$EUID" = "0" ]]; then + export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr" +else + export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr" +fi + # is_func # Check whether $1 is a function. is_func() { @@ -46,13 +52,6 @@ if ! [[ -d $initdir ]]; then mkdir -p "$initdir" fi -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 - if ! [[ $kernel ]]; then kernel=$(uname -r) export kernel @@ -69,6 +68,8 @@ srcmods="/lib/modules/$kernel/" } export srcmods +[[ $DRACUT_FIRMWARE_PATH ]] || export DRACUT_FIRMWARE_PATH="/lib/firmware/updates:/lib/firmware:/lib/firmware/$kernel" + # export standard hookdirs [[ $hookdirs ]] || { hookdirs="cmdline pre-udev pre-trigger netroot " @@ -164,6 +165,13 @@ if ! [[ -x $DRACUT_INSTALL ]]; then exit 10 fi +if [[ $hostonly == "-h" ]]; then + if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f "$DRACUT_KERNEL_MODALIASES" ]]; then + export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases" + $DRACUT_INSTALL ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES" + fi +fi + [[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1 inst_dir() { [[ -e ${initdir}/"$1" ]] && return 0 # already there @@ -223,12 +231,12 @@ dracut_instmods() { local i; [[ $no_kernel = yes ]] && return for i in "$@"; do - [[ $i == "--silent" ]] && silent=1 + [[ $i == "--silent" ]] && _silent=1 done $DRACUT_INSTALL \ ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" - (($? != 0)) && (($silent == 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || : + (($? != 0)) && (($_silent == 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || : } inst_library() { @@ -253,6 +261,24 @@ inst_script() { (($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || : } +inst_fsck_help() { + local _helper="/run/dracut/fsck/fsck_help_$1.txt" + $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper + (($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper || : +} + +# Use with form hostonly="$(optional_hostonly)" inst_xxxx +# If hosotnly mode is set to "strict", hostonly restrictions will still +# be applied, else will ignore hostonly mode and try to install all +# given modules. +optional_hostonly() { + if [[ $hostonly_mode = "strict" ]]; then + printf -- "$hostonly" + else + printf "" + fi +} + mark_hostonly() { for i in "$@"; do echo "$i" >> "$initdir/lib/dracut/hostonly-files" @@ -927,11 +953,8 @@ for_each_kmod_dep() { } dracut_kernel_post() { - local _moddirname=${srcmods%%/lib/modules/*} - local _pid - for _f in modules.builtin.bin modules.builtin modules.order; do - [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" + [[ -e $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" done # generate module dependencies for the initrd @@ -970,6 +993,10 @@ instmods() { set -- "${args[@]}" fi + if (($# == 0)); then + return 0 + fi + $DRACUT_INSTALL \ ${initdir:+-D "$initdir"} \ ${loginstall:+-L "$loginstall"} \ @@ -997,3 +1024,16 @@ instmods() { [[ "$optional" ]] && return 0 return $_ret } + +if [[ "$(ln --help)" == *--relative* ]]; then + ln_r() { + ln -sfnr "${initdir}/$1" "${initdir}/$2" + } +else + ln_r() { + local _source=$1 + local _dest=$2 + [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} + ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}" + } +fi