-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
+#!/bin/bash --norc
#
# Generator script for a dracut initramfs
# Tries to retain some degree of compatibility with the command line
exclusively include in the initramfs.
--add-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs.
+ --force-drivers [LIST] Specify a space-separated list of kernel
+ modules to add to the initramfs and make sure they
+ are tried to be loaded via modprobe same as passing
+ rd.driver.pre=DRIVER kernel parameter.
--omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem
--xz Compress the generated initramfs using xz.
Make sure that your kernel has xz support compiled
in, otherwise you will not be able to boot.
- --lzo Compress the generated initramfs using lzop.
+ --lzo Compress the generated initramfs using lzop.
Make sure that your kernel has lzo support compiled
in, otherwise you will not be able to boot.
- --lz4 Compress the generated initramfs using lz4.
+ --lz4 Compress the generated initramfs using lz4.
Make sure that your kernel has lz4 support compiled
in, otherwise you will not be able to boot.
--compress [COMPRESSION] Compress the generated initramfs with the
--printsize Print out the module install size
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
--logfile [FILE] Logfile to use (overrides configuration setting)
+ --reproducible Create reproducible images
+ --loginstall [DIR] Log all files installed from the host to [DIR]
+ --uefi Create an UEFI executable with the kernel cmdline and
+ kernel combined
+ --uefi-stub [FILE] Use the UEFI stub [FILE] to create an UEFI executable
+ --kernel-image [FILE] location of the kernel image
If [LIST] has multiple arguments, then you have to put these in quotes.
done
}
+# Fills up host_devs stack variable and makes sure there are no duplicates
+push_host_devs() {
+ local _dev
+ for _dev in ${host_devs[@]}; do
+ [ "$_dev" = "$1" ] && return
+ done
+ push host_devs "$1"
+}
+
+
# function pop()
# pops the last value from a stack
# assigns value to second argument variable
--long add: \
--long force-add: \
--long add-drivers: \
+ --long force-drivers: \
--long omit-drivers: \
--long modules: \
--long omit: \
--long noimageifnotneeded \
--long early-microcode \
--long no-early-microcode \
+ --long reproducible \
+ --long loginstall: \
+ --long uefi \
+ --long uefi-stub: \
+ --long kernel-image: \
-- "$@")
if (( $? != 0 )); then
-a|--add) push add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--force-add) push force_add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--add-drivers) push add_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ --force-drivers) push force_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--omit-drivers) push omit_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-m|--modules) push dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-o|--omit) push omit_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-L|--stdlog) stdloglvl_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--compress) compress_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--prefix) prefix_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ --loginstall) loginstall_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--rebuild) if [ $rebuild_file == $outfile ]; then
force=yes
fi
--printsize) printsize="yes";;
--regenerate-all) regenerate_all="yes";;
--noimageifnotneeded) noimageifnotneeded="yes";;
-
+ --reproducible) reproducible_l="yes";;
+ --uefi) uefi="yes";;
+ --uefi-stub)
+ uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+ --kernel-image)
+ kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--) shift; break;;
*) # should not even reach this point
fi
fi
-for i in /usr/sbin /sbin /usr/bin /bin; do
- rl=$i
- if [ -L "$i" ]; then
- rl=$(readlink -f $i)
- fi
- if [[ "$NPATH" != *:$rl* ]] ; then
- NPATH+=":$rl"
- fi
-done
-export PATH="${NPATH#:}"
unset LC_MESSAGES
unset LC_CTYPE
export LC_ALL=C
export LANG=C
-unset NPATH
unset LD_LIBRARY_PATH
unset LD_PRELOAD
unset GREP_OPTIONS
[[ -e $f ]] && . "$f"
done
+DRACUT_PATH=${DRACUT_PATH:-/sbin /bin /usr/sbin /usr/bin}
+
+for i in $DRACUT_PATH; do
+ rl=$i
+ if [ -L "$i" ]; then
+ rl=$(readlink -f $i)
+ fi
+ if [[ "$NPATH" != *:$rl* ]] ; then
+ NPATH+=":$rl"
+ fi
+done
+export PATH="${NPATH#:}"
+unset NPATH
+
# these optins add to the stuff in the config file
if (( ${#add_dracutmodules_l[@]} )); then
while pop add_dracutmodules_l val; do
[[ $early_microcode_l ]] && early_microcode=$early_microcode_l
[[ $early_microcode ]] || early_microcode=no
[[ $logfile_l ]] && logfile="$logfile_l"
+[[ $reproducible_l ]] && reproducible="$reproducible_l"
+[[ $loginstall_l ]] && loginstall="$loginstall_l"
+[[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
+[[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
+
# eliminate IFS hackery when messing with fw_dir
fw_dir=${fw_dir//:/ }
+# check for logfile and try to create one if it doesn't exist
+if [[ -n "$logfile" ]];then
+ if [[ ! -f "$logfile" ]];then
+ touch "$logfile"
+ if [ ! $? -eq 0 ] ;then
+ printf "%s\n" "dracut: touch $logfile failed." >&2
+ fi
+ fi
+fi
+
# handle compression options.
[[ $compress ]] || compress="gzip"
case $compress in
bzip2) compress="bzip2 -9";;
lzma) compress="lzma -9 -T0";;
xz) compress="xz --check=crc32 --lzma2=dict=1MiB -T0";;
- gzip) compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
+ gzip) compress="gzip -n -9";
+ if command -v pigz > /dev/null 2>&1; then
+ compress="pigz -9 -n -T -R"
+ elif command -v gzip --help 2>&1 | grep -q rsyncable; then
+ compress="gzip -n -9 --rsyncable"
+ fi
+ ;;
lzo) compress="lzop -9";;
lz4) compress="lz4 -l -9";;
esac
[[ $hostonly = yes ]] && hostonly="-h"
[[ $hostonly != "-h" ]] && unset hostonly
+[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
+
readonly TMPDIR="$tmpdir"
readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
[ -d "$initdir" ] || {
ret=$?;
[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
[[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
+ [[ $keep ]] && echo "Not removing $uefi_outdir." >&2 || { [[ $uefi_outdir ]] && rm -Rf -- "$uefi_outdir"; };
[[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
exit $ret;
' EXIT
kmsgloglvl=0
fi
+if [[ -f $dracutbasedir/dracut-version.sh ]]; then
+ . $dracutbasedir/dracut-version.sh
+fi
+
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
. $dracutbasedir/dracut-functions.sh
else
rm -fr -- ${initdir}/*
fi
-if [[ -f $dracutbasedir/dracut-version.sh ]]; then
- . $dracutbasedir/dracut-version.sh
-fi
-
# Verify bash version, current minimum is 3.1
if (( BASH_VERSINFO[0] < 4 )); then
dfatal 'You need at least Bash 4 to use dracut, sorry.'
fi
add_drivers=${add_drivers/-/_}
+if (( ${#force_drivers_l[@]} )); then
+ while pop force_drivers_l val; do
+ force_drivers+=" $val "
+ done
+fi
+force_drivers=${force_drivers/-/_}
+
if (( ${#omit_drivers_l[@]} )); then
while pop omit_drivers_l val; do
omit_drivers+=" $val "
omit_drivers_corrected=""
for d in $omit_drivers; do
[[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
+ [[ " $drivers $force_drivers " == *\ $d\ * ]] && continue
omit_drivers_corrected+="$d|"
done
omit_drivers="${omit_drivers_corrected%|}"
dfatal "No permission to write $outfile."
exit 1
fi
+
+ if [[ $loginstall ]]; then
+ if ! mkdir -p "$loginstall"; then
+ dfatal "Could not create directory to log installed files to '$loginstall'."
+ exit 1
+ fi
+ loginstall=$(readlink -f "$loginstall")
+ fi
+
+ if [[ $uefi = yes ]]; then
+ if ! command -v objcopy &>/dev/null; then
+ dfatal "Need 'objcopy' to create a UEFI executable"
+ exit 1
+ fi
+ unset EFI_MACHINE_TYPE_NAME
+ case $(arch) in
+ x86_64)
+ EFI_MACHINE_TYPE_NAME=x64;;
+ ia32)
+ EFI_MACHINE_TYPE_NAME=ia32;;
+ *)
+ dfatal "Architecture '$(arch)' not supported to create a UEFI executable"
+ exit 1
+ ;;
+ esac
+
+ if ! [[ -s $uefi_stub ]]; then
+ for uefi_stub in \
+ "/lib/systemd/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" \
+ "/usr/lib/gummiboot/linux${EFI_MACHINE_TYPE_NAME}.efi.stub"; do
+ [[ -s $uefi_stub ]] || continue
+ break
+ done
+ fi
+ if ! [[ -s $uefi_stub ]]; then
+ dfatal "Can't find a uefi stub '$uefi_stub' to create a UEFI executable"
+ exit 1
+ fi
+
+ if ! [[ $kernel_image ]]; then
+ for kernel_image in "/lib/modules/$kernel/vmlinuz" "/boot/vmlinuz-$kernel"; do
+ [[ -s "$kernel_image" ]] || continue
+ break
+ done
+ fi
+ if ! [[ -s $kernel_image ]]; then
+ dfatal "Can't find a kernel image '$kernel_image' to create a UEFI executable"
+ exit 1
+ fi
+ fi
+fi
+
+if [[ $acpi_override = yes ]] && ! check_kernel_config CONFIG_ACPI_INITRD_TABLE_OVERRIDE; then
+ dwarn "Disabling ACPI override, because kernel does not support it. CONFIG_ACPI_INITRD_TABLE_OVERRIDE!=y"
+ unset acpi_override
+fi
+
+if [[ $early_microcode = yes ]]; then
+ if [[ $hostonly ]]; then
+ [[ $(get_cpu_vendor) == "AMD" ]] \
+ && ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
+ && unset early_microcode
+ [[ $(get_cpu_vendor) == "Intel" ]] \
+ && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
+ && unset early_microcode
+ else
+ ! check_kernel_config CONFIG_MICROCODE_AMD_EARLY \
+ && ! check_kernel_config CONFIG_MICROCODE_INTEL_EARLY \
+ && unset early_microcode
+ fi
+ [[ $early_microcode != yes ]] \
+ && dwarn "Disabling early microcode, because kernel does not support it. CONFIG_MICROCODE_[AMD|INTEL]_EARLY!=y"
fi
# Need to be able to have non-root users read stuff (rpcbind etc)
for line in "${fstab_lines[@]}"; do
set -- $line
+ dev="$1"
#dev mp fs fsopts
- push host_devs "$1"
- host_fs_types["$1"]="$3"
+ case "$dev" in
+ UUID=*)
+ dev=$(blkid -l -t UUID=${dev#UUID=} -o device)
+ ;;
+ LABEL=*)
+ dev=$(blkid -l -t LABEL=${dev#LABEL=} -o device)
+ ;;
+ PARTUUID=*)
+ dev=$(blkid -l -t PARTUUID=${dev#PARTUUID=} -o device)
+ ;;
+ PARTLABEL=*)
+ dev=$(blkid -l -t PARTLABEL=${dev#PARTLABEL=} -o device)
+ ;;
+ esac
+ [ -z "$dev" ] && dwarn "Bad fstab entry $@" && continue
+ push_host_devs "$dev"
+ host_fs_types["$dev"]="$3"
done
for f in $add_fstab; do
[[ -e $f ]] || continue
while read dev rest; do
- push host_devs "$dev"
+ push_host_devs "$dev"
done < "$f"
done
for dev in $add_device; do
- push host_devs "$dev"
+ push_host_devs "$dev"
done
if (( ${#add_device_l[@]} )); then
while pop add_device_l val; do
add_device+=" $val "
- push host_devs "$val"
+ push_host_devs "$val"
done
fi
_dev=$(find_block_device "$mp")
_bdev=$(readlink -f "/dev/block/$_dev")
[[ -b $_bdev ]] && _dev=$_bdev
- push host_devs $_dev
+ push_host_devs $_dev
[[ "$mp" == "/" ]] && root_dev="$_dev"
- push host_devs "$_dev"
+ push_host_devs "$_dev"
done
if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
done < /etc/crypttab
fi
- push host_devs "$(readlink -f "$dev")"
+ push_host_devs "$(readlink -f "$dev")"
break
done < /etc/fstab
done < /proc/swaps
fi
if [[ $journaldev ]]; then
dev="$(readlink -f "$dev")"
- push host_devs "$dev"
+ push_host_devs "$dev"
_get_fs_type "$dev"
check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
fi
[[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
-export initdir dracutbasedir dracutmodules \
+[[ -d $tmpfilesdir ]] \
+ || tmpfilesdir=$(pkg-config systemd --variable=tmpfilesdir 2>/dev/null)
+
+if ! [[ -d "$tmpfilesdir" ]]; then
+ [[ -f /lib/tmpfiles.d ]] && tmpfilesdir=/lib/tmpfiles.d
+ [[ -f /usr/lib/tmpfiles.d ]] && tmpfilesdir=/usr/lib/tmpfiles.d
+fi
+
+export initdir dracutbasedir \
+ dracutmodules force_add_dracutmodules add_dracutmodules omit_dracutmodules \
+ mods_to_load \
fw_dir drivers_dir debug no_kernel kernel_only \
omit_drivers mdadmconf lvmconf root_dev \
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
debug host_fs_types host_devs sshkey add_fstab \
DRACUT_VERSION udevdir prefix filesystems drivers \
systemdutildir systemdsystemunitdir systemdsystemconfdir \
- host_modalias host_modules hostonly_cmdline
+ host_modalias host_modules hostonly_cmdline loginstall \
+ tmpfilesdir
mods_to_load=""
# check all our modules to see if they should be sourced.
dracut_module_included "fips" && export DRACUT_FIPS_MODE=1
-if [[ $print_cmdline ]]; then
- modules_loaded=" "
+do_print_cmdline()
+{
+ local -A _mods_to_print
+ for i in $modules_loaded $mods_to_load; do
+ _mods_to_print[$i]=1
+ done
+
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
+ [[ ${_mods_to_print[$_d_mod]} ]] || continue
module_cmdline "$_d_mod"
done
unset moddir
+}
+
+if [[ $print_cmdline ]]; then
+ do_print_cmdline
printf "\n"
exit 0
fi
fi
if [[ $kernel_only != yes ]]; then
- for d in usr/bin usr/sbin bin etc lib sbin tmp usr var $libdirs; do
+ for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/tmp $libdirs; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -L "/$d" ]; then
inst_symlink "/$d" "${prefix}/$d"
ln -sfn ../run "$initdir/var/run"
ln -sfn ../run/lock "$initdir/var/lock"
- ln -sfn ../run/log "$initdir/var/log"
else
for d in lib "$libdir"; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
- if [[ "$mods_to_load" == *\ $_d_mod\ * ]]; then
- if [[ $show_modules = yes ]]; then
- printf "%s\n" "$_d_mod"
- else
- dinfo "*** Including module: $_d_mod ***"
- fi
- if [[ $kernel_only == yes ]]; then
+ [[ "$mods_to_load" == *\ $_d_mod\ * ]] || continue
+ if [[ $show_modules = yes ]]; then
+ printf "%s\n" "$_d_mod"
+ else
+ dinfo "*** Including module: $_d_mod ***"
+ fi
+ if [[ $kernel_only == yes ]]; then
+ module_installkernel "$_d_mod" || {
+ dfatal "installkernel failed in module $_d_mod"
+ exit 1
+ }
+ else
+ module_install "$_d_mod"
+ if [[ $no_kernel != yes ]]; then
module_installkernel "$_d_mod" || {
dfatal "installkernel failed in module $_d_mod"
exit 1
}
- else
- module_install "$_d_mod"
- if [[ $no_kernel != yes ]]; then
- module_installkernel "$_d_mod" || {
- dfatal "installkernel failed in module $_d_mod"
- exit 1
- }
- fi
- fi
- mods_to_load=${mods_to_load// $_d_mod /}
- modules_loaded+="$_d_mod "
-
- #print the module install size
- if [ -n "$printsize" ]; then
- _isize_new=$(du -sk ${initdir}|cut -f1)
- _isize_delta=$((_isize_new - _isize))
- printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
- _isize=$_isize_new
fi
fi
+ mods_to_load=${mods_to_load// $_d_mod /}
+ modules_loaded+="$_d_mod "
+
+ #print the module install size
+ if [ -n "$printsize" ]; then
+ _isize_new=$(du -sk ${initdir}|cut -f1)
+ _isize_delta=$((_isize_new - _isize))
+ printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
+ _isize=$_isize_new
+ fi
done
unset moddir
if [[ $add_drivers ]]; then
hostonly='' instmods -c $add_drivers
fi
+ if [[ $force_drivers ]]; then
+ hostonly='' instmods -c $force_drivers
+ rm -f $initdir/etc/cmdline.d/20-force_driver.conf
+ for mod in $force_drivers; do
+ echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf
+ done
+ fi
if [[ $filesystems ]]; then
hostonly='' instmods -c $filesystems
fi
if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
dinfo "*** Resolving executable dependencies ***"
- find "$initdir" -type f \
- '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
- -not -path '*.ko' -print0 \
+ find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \
| xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R ${DRACUT_FIPS_MODE:+-H} --
dinfo "*** Resolving executable dependencies done***"
fi
done
fi
-while pop include_src src && pop include_target tgt; do
- if [[ $src && $tgt ]]; then
+while pop include_src src && pop include_target target; do
+ if [[ $src && $target ]]; then
if [[ -f $src ]]; then
- inst $src $tgt
+ inst $src $target
else
ddebug "Including directory: $src"
- mkdir -p "${initdir}/${tgt}"
+ destdir="${initdir}/${target}"
+ mkdir -p "$destdir"
# check for preexisting symlinks, so we can cope with the
# symlinks to $prefix
- for i in "$src"/*; do
- [[ -e "$i" || -h "$i" ]] || continue
- s=${initdir}/${tgt}/${i#$src/}
- if [[ -d "$i" ]]; then
- if ! [[ -e "$s" ]]; then
- mkdir -m 0755 -p "$s"
- chmod --reference="$i" "$s"
+ # Objectname is a file or a directory
+ for objectname in "$src"/*; do
+ [[ -e "$objectname" || -h "$objectname" ]] || continue
+ if [[ -d "$objectname" ]]; then
+ # objectname is a directory, let's compute the final directory name
+ object_destdir=${destdir}/${objectname#$src/}
+ if ! [[ -e "$object_destdir" ]]; then
+ mkdir -m 0755 -p "$object_destdir"
+ chmod --reference="$objectname" "$object_destdir"
fi
- cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
+ cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
else
- cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
+ cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
fi
done
fi
mkdir -p $_dest_dir
for table in $acpi_table_dir/*.aml; do
dinfo " Adding ACPI table: $table"
- cp $table $_dest_dir
+ cp -a $table $_dest_dir
create_early_cpio="yes"
done
fi
exit 1
fi
+if [[ $hostonly_cmdline ]] ; then
+ unset _stored_cmdline
+ if [ -d $initdir/etc/cmdline.d ];then
+ dinfo "Stored kernel commandline:"
+ for conf in $initdir/etc/cmdline.d/*.conf ; do
+ [ -e "$conf" ] || continue
+ dinfo "$(< $conf)"
+ _stored_cmdline=1
+ done
+ fi
+ if ! [[ $_stored_cmdline ]]; then
+ dinfo "No dracut internal kernel commandline stored in initrd"
+ fi
+fi
rm -f -- "$outfile"
-dinfo "*** Creating image file ***"
+dinfo "*** Creating image file '$outfile' ***"
+
+if [[ $uefi = yes ]]; then
+ uefi_outfile="$outfile"
+ readonly uefi_outdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initrd.XXXXXX)"
+ # redirect initrd output
+ outfile="$uefi_outdir/initrd"
+fi
+
+if [[ $DRACUT_REPRODUCIBLE ]]; then
+ find "$initdir" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
+ | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
+
+ [[ "$(cpio --help)" == *--reproducible* ]] && CPIO_REPRODUCIBLE=1
+fi
[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
if [[ $create_early_cpio = yes ]]; then
echo 1 > "$early_cpio_dir/d/early_cpio"
+
+ if [[ $DRACUT_REPRODUCIBLE ]]; then
+ find "$early_cpio_dir/d" -newer "$dracutbasedir/dracut-functions.sh" -print0 \
+ | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh"
+ fi
+
# The microcode blob is _before_ the initramfs blob, not after
- (cd "$early_cpio_dir/d"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > $outfile)
+ (
+ cd "$early_cpio_dir/d"
+ find . -print0 | sort -z \
+ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet > $outfile
+ )
fi
-if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
- $compress >> "$outfile"; ); then
+
+if ! (
+ umask 077; cd "$initdir"
+ find . -print0 | sort -z \
+ | cpio ${CPIO_REPRODUCIBLE:+--reproducible} --null $cpio_owner_root -H newc -o --quiet \
+ | $compress >> "$outfile"
+ ); then
dfatal "dracut: creation of $outfile failed"
exit 1
fi
-dinfo "*** Creating image file done ***"
+dinfo "*** Creating initrd image file '$outfile' done ***"
if (( maxloglvl >= 5 )); then
if [[ $allowlocal ]]; then
fi
fi
+if [[ $uefi = yes ]]; then
+ if [[ $kernel_cmdline ]]; then
+ echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt"
+ elif [[ $hostonly_cmdline = yes ]] && [ -d $initdir/etc/cmdline.d ];then
+ for conf in $initdir/etc/cmdline.d/*.conf ; do
+ [ -e "$conf" ] || continue
+ printf "%s " "$(< $conf)" >> "$uefi_outdir/cmdline.txt"
+ done
+ else
+ do_print_cmdline > "$uefi_outdir/cmdline.txt"
+ fi
+ echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
+
+ dinfo "Using UEFI kernel cmdline:"
+ dinfo $(< "$uefi_outdir/cmdline.txt")
+
+ [[ -s /etc/os-release ]] && uefi_osrelease="/etc/os-release"
+
+ objcopy \
+ ${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \
+ --add-section .cmdline="$uefi_outdir/cmdline.txt" --change-section-vma .cmdline=0x30000 \
+ --add-section .linux="$kernel_image" --change-section-vma .linux=0x40000 \
+ --add-section .initrd="$outfile" --change-section-vma .initrd=0x3000000 \
+ "$uefi_stub" "$uefi_outfile"
+ dinfo "*** Creating UEFI image file '$uefi_outfile' done ***"
+fi
+
exit 0