Accepting request 202177 from Base:System

This time dracut should have the full functionality. Integrated with the mkinitrd calls during installation of the kernels and also updating the grub2 bootloader.

OBS-URL: https://build.opensuse.org/request/show/202177
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/dracut?expand=0&rev=21
This commit is contained in:
Stephan Kulow 2013-10-06 12:32:40 +00:00 committed by Git OBS Bridge
commit 97e2f40ef0
14 changed files with 723 additions and 6 deletions

38
acpi_override.patch Normal file
View File

@ -0,0 +1,38 @@
dracut: Implement ACPI table overriding
An example config file for this feature could be:
/etc/dracut.conf.d/03-acpi-override.conf
with this content:
acpi_override="yes"
acpi_table_dir="/etc/dracut.conf.d/acpi_tables"
Then all files ending with *.aml will be put into the early cpio
(kernel/firmware/acpi) and will be used to replace the BIOS provided tables
if the kernel supports this feature.
Signed-off-by: Thomas Renninger <trenn@suse.de>
Index: dracut-033/dracut.sh
===================================================================
--- dracut-033.orig/dracut.sh
+++ dracut-033/dracut.sh
@@ -1322,6 +1322,17 @@ if [[ $early_microcode = yes ]]; then
done
fi
+if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then
+ dinfo "*** Packaging ACPI tables to override BIOS provided ones ***"
+ _dest_dir="$early_cpio_dir/d/kernel/firmware/acpi"
+ mkdir -p $_dest_dir
+ for table in $acpi_table_dir/*.aml; do
+ dinfo " Adding ACPI table: $table"
+ cp $table $_dest_dir
+ create_early_cpio="yes"
+ done
+fi
+
rm -f -- "$outfile"
dinfo "*** Creating image file ***"
if [[ $create_early_cpio = yes ]]; then

View File

@ -1,3 +1,76 @@
-------------------------------------------------------------------
Fri Oct 4 17:23:19 UTC 2013 - tittiatcoke@gmail.com
- Add patch mkinitrd_update_bootloader.diff so that after
generating the initrd, the update-bootloader is called to update
grub2.
-------------------------------------------------------------------
Fri Oct 4 16:26:20 UTC 2013 - tittiatcoke@gmail.com
- Validate that the parameters passed with -i (initrd file) does
not already contain the boot_dir.
-------------------------------------------------------------------
Fri Oct 4 09:58:17 UTC 2013 - tittiatcoke@gmail.com
- Bring back the versioned Provides/Obsoletes for mkinitrd.
Otherwise we run into issues as that udev is conflicting with
mkinitrd < 2.7.0
-------------------------------------------------------------------
Wed Oct 2 14:54:51 UTC 2013 - trenn@suse.de
- Remove Provides/Obsoletes: mkinitrd versioning.
Simply obsolete and provide all mkinitrd versions.
-------------------------------------------------------------------
Wed Oct 2 13:19:23 UTC 2013 - mvyskocil@suse.com
- Mark /etc/dracut.conf.d/02-early-microcode.conf as config file
-------------------------------------------------------------------
Wed Sep 25 15:17:57 UTC 2013 - trenn@suse.de
- Add ACPI table override ability:
generalize_early_cpio.patch #PATCH-FIX-UPSTREAM
microcode_cleanup #PATCH-FIX-UPSTREAM
acpi_override.patch #PATCH-FIX-UPSTREAM
- This will replace mkinitrd with dracut as the default initrd generator.
Therefore Prefer: dracut tag in the project config of the repo is needed.
Otherwise OSC does not know how to build installation-images
(needing mkinitrd to build) and which package to take.
- To switch back and try mkinitrd instead of dracut will be:
Uninstall dracut:
- rpm -e dracut --nodeps
And install mkinitrd again:
- zypper install mkinitrd
- Adjust mkinitrd-dracut.sh to SUSE mkinitrd:
<none> : Before gives a "usage" error -> now scans /boot for kernels
and builds corresponding inirtrds for them
-i -k : Pass a list of kernels and initrd targets
(not sure it was worth the hassle to be able to pass)
-b : Boot directory to search for kernel images
-d : Change root file system. Not tested whether dracut's behavior
matches exactly what our mkinitrd does.
-s : Dummy (should even be obsolete in latest mkinitrd)
These patches have been submitted, but now feedback from mainline yet:
mkinitrd_allow_no_option.patch
mkinitrd_allow_multiple_args
quiet_options
implement_default
root_fs
suse_host_only
- Write caller and used parameters to syslog if mkinitrd is called.
So that those can easily be fixed and checked for correctness.
This should get reverted again before a bigger release.
This patch will never show up mainline and should also get reverted
from SUSE factory repo before the next release shows up:
suse_only_logger
- Build host only images for default paths in SUSE for faster build and
smaller images. Imply --force in this case as well.
* suse_host_only.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Sat Sep 21 17:36:13 UTC 2013 - crrodriguez@opensuse.org Sat Sep 21 17:36:13 UTC 2013 - crrodriguez@opensuse.org

View File

@ -18,7 +18,7 @@
%define dracutlibdir %{_prefix}/lib/dracut %define dracutlibdir %{_prefix}/lib/dracut
%define replace_mkinitrd 0 %define replace_mkinitrd 1
Name: dracut Name: dracut
Version: 033 Version: 033
@ -35,6 +35,7 @@ Source0: dracut-%{version}.tar.xz
# (not to be upstreamed) # (not to be upstreamed)
Source1: module-setup-initrd.sh Source1: module-setup-initrd.sh
Source2: parse-suse-initrd.sh Source2: parse-suse-initrd.sh
Source3: mkinitrd_setup_dummy
# PATCH-FIX-OPENSUSE correct the paths for openSUSE - tittiatcoke@gmail.com # PATCH-FIX-OPENSUSE correct the paths for openSUSE - tittiatcoke@gmail.com
Patch0: correct-paths-for-opensuse.patch Patch0: correct-paths-for-opensuse.patch
# PATCH-FIX-OPENSUSE change the default naming from initramfs to initrd - tittiatcoke@gmail.com # PATCH-FIX-OPENSUSE change the default naming from initramfs to initrd - tittiatcoke@gmail.com
@ -43,6 +44,29 @@ Patch1: use_initrd_insteadof_initramfs.patch
Patch2: use_sysconfig_values_correctly.patch Patch2: use_sysconfig_values_correctly.patch
# PATCH-FIX-OPENSUSE At the moment we have 2 paths that contain udev files (/lib/udev and /usr/lib/udev) - tittiatcoke@gmail.com # PATCH-FIX-OPENSUSE At the moment we have 2 paths that contain udev files (/lib/udev and /usr/lib/udev) - tittiatcoke@gmail.com
Patch3: use_all_paths_udev.patch Patch3: use_all_paths_udev.patch
# PATCH-FIX-UPSTREAM ACPI early table override support in early cpio - trenn@suse.de
Patch4: generalize_early_cpio.patch
# PATCH-FIX-UPSTREAM Do not create early_cpio if no suitable microcode exists - trenn@suse.de
Patch5: microcode_cleanup.patch
# PATCH-FIX-UPSTREAM Implement ACPI table overriding - trenn@suse.de
Patch6: acpi_override.patch
# PATCH-FIX-OPENSUSE SUSE mkinitrd compatibility: Introduce -i -k parameters - trenn@suse.de
Patch7: mkinitrd_allow_no_option.patch
# PATCH-FIX-OPENSUSE SUSE mkinitrd compatibility: allow multiple arguments per param - trenn@suse.de
Patch8: mkinitrd_allow_multiple_args.patch
# PATCH-FIX-UPSTREAM Limit an output to essential one implementing --quiet option - trenn@suse.de
Patch9: quiet_options.patch
# PATCH-FIX-OPENSUSE SUSE mkinitrd compatibility: Allow a call w/o passing any parameters - trenn@suse.de
Patch10: implement_default.patch
# PATCH-FIX-OPENSUSE SUSE mkinitrd compatibility: add -d to pass rootfs and dummy -s - trenn@suse.de
Patch11: root_fs.patch
# PATCH-FIX-OPENSUSE Build host only images for default_kernel_images and -i/-k ones - trenn@suse.de
Patch12: suse_host_only.patch
# PATCH-FIX-OPENSUSE Write caller and used parameters to syslog if mkinitrd is called - trenn@suse.de
Patch13: suse_only_logger.patch
# PATCH-FIX-OPENSUSE Call the update-bootloader after dracut finished creating the initrd - tittiatcoke@gmail.com
Patch14: mkinitrd_update_bootloader.diff
BuildRequires: bash BuildRequires: bash
BuildRequires: dash BuildRequires: dash
@ -53,8 +77,8 @@ BuildRequires: docbook-xsl-stylesheets
BuildRequires: libxslt BuildRequires: libxslt
BuildRequires: pkgconfig(systemd) >= 199 BuildRequires: pkgconfig(systemd) >= 199
%if %{replace_mkinitrd} %if %{replace_mkinitrd}
Obsoletes: mkinitrd <= 2.7.2 Obsoletes: mkinitrd < 2.8.2
Provides: mkinitrd = 2.7.2 Provides: mkinitrd = 2.8.2
%endif %endif
Requires: bash Requires: bash
@ -68,7 +92,7 @@ Requires: hardlink
Requires: logrotate Requires: logrotate
Requires: modutils Requires: modutils
Requires: sed Requires: sed
Requires: systemd > 198 Requires: systemd >= 200
Requires: udev > 166 Requires: udev > 166
Requires: util-linux >= 2.21 Requires: util-linux >= 2.21
Requires: xz Requires: xz
@ -119,6 +143,17 @@ This package contains tools to assemble the local initrd and host configuration.
%patch1 -p1 %patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%build %build
%configure\ %configure\
@ -172,6 +207,11 @@ rm %{buildroot}%{_bindir}/mkinitrd
rm %{buildroot}%{_bindir}/lsinitrd rm %{buildroot}%{_bindir}/lsinitrd
rm %{buildroot}%{_mandir}/man8/mkinitrd* rm %{buildroot}%{_mandir}/man8/mkinitrd*
rm %{buildroot}%{_mandir}/man1/lsinitrd* rm %{buildroot}%{_mandir}/man1/lsinitrd*
%else
# moved to /sbin
mkdir -p %{buildroot}/sbin
mv %{buildroot}%{_bindir}/mkinitrd %{buildroot}/sbin/mkinitrd
install -m 0755 %{S:3} %{buildroot}/sbin/mkinitrd_setup
%endif %endif
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
@ -185,7 +225,8 @@ rm -rf %{buildroot}
%doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg %doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg
%{_bindir}/dracut %{_bindir}/dracut
%if %{replace_mkinitrd} %if %{replace_mkinitrd}
%{_bindir}/mkinitrd /sbin/mkinitrd
/sbin/mkinitrd_setup
%{_bindir}/lsinitrd %{_bindir}/lsinitrd
/etc/bash_completion.d/lsinitrd /etc/bash_completion.d/lsinitrd
%endif %endif
@ -202,7 +243,7 @@ rm -rf %{buildroot}
%config %{_sysconfdir}/dracut.conf.d/01-dist.conf %config %{_sysconfdir}/dracut.conf.d/01-dist.conf
%endif %endif
%ifarch %ix86 x86_64 %ifarch %ix86 x86_64
%{_sysconfdir}/dracut.conf.d/02-early-microcode.conf %config %{_sysconfdir}/dracut.conf.d/02-early-microcode.conf
%endif %endif
%dir %{_sysconfdir}/dracut.conf.d %dir %{_sysconfdir}/dracut.conf.d
%{_mandir}/man8/dracut.8* %{_mandir}/man8/dracut.8*

View File

@ -0,0 +1,62 @@
dracut: Generlize microcode early cpio usage
ACPI early table override also may need to place files into an early cpio.
Reflect this in variable and file names.
This change is renaming only and does not introduce any real change.
Signed-off-by: Thomas Renninger <trenn@suse.de>
Index: dracut-033/dracut.sh
===================================================================
--- dracut-033.orig/dracut.sh
+++ dracut-033/dracut.sh
@@ -696,9 +696,9 @@ readonly initdir="$(mktemp --tmpdir="$TM
}
if [[ $early_microcode = yes ]]; then
- readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)"
- [ -d "$microcode_dir" ] || {
- printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2
+ readonly early_cpio_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_cpio.XXXXXX)"
+ [ -d "$early_cpio_dir" ] || {
+ printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_cpio.XXXXXX failed." >&2
exit 1
}
fi
@@ -707,7 +707,7 @@ trap '
ret=$?;
[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
- [[ $keep ]] && echo "Not removing $microcode_dir." >&2 || { [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; };
+ [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
[[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
exit $ret;
' EXIT
@@ -1296,7 +1296,7 @@ if [[ $early_microcode = yes ]]; then
dinfo "*** Generating early-microcode cpio image ***"
ucode_dir=(amd-ucode intel-ucode)
ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
- _dest_dir="$microcode_dir/d/kernel/x86/microcode"
+ _dest_dir="$early_cpio_dir/d/kernel/x86/microcode"
_dest_idx="0 1"
mkdir -p $_dest_dir
if [[ $hostonly ]]; then
@@ -1316,14 +1316,15 @@ if [[ $early_microcode = yes ]]; then
fi
done
done
- (cd "$microcode_dir/d"; find . -print0 | cpio --null -o -H newc --quiet >../ucode.cpio)
+ create_early_cpio="yes"
fi
rm -f -- "$outfile"
dinfo "*** Creating image file ***"
-if [[ $early_microcode = yes ]]; then
+if [[ $create_early_cpio = yes ]]; then
# The microcode blob is _before_ the initramfs blob, not after
- mv $microcode_dir/ucode.cpio $outfile.$$
+ (cd "$early_cpio_dir/d"; find . -print0 | cpio --null -o -H newc --quiet >../early.cpio)
+ mv $early_cpio_dir/early.cpio $outfile.$$
fi
if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null -R 0:0 -H newc -o --quiet| \
$compress >> "$outfile.$$"; ); then

91
implement_default.patch Normal file
View File

@ -0,0 +1,91 @@
mkinitrd-dracut.sh: Allow mkinitrd call without passing any parameters
Before this gave a "usage" error.
Now boot_dir (by default /boot) is scanned for available kernels and sane
initrd default targets get defined and the corresponding initramfs files
are generated.
Signed-off-by: Thomas Renninger <trenn@suse.de>
Index: dracut-033/mkinitrd-dracut.sh
===================================================================
--- dracut-033.orig/mkinitrd-dracut.sh
+++ dracut-033/mkinitrd-dracut.sh
@@ -46,6 +46,67 @@ read_arg() {
fi
}
+# Taken over from SUSE mkinitrd
+default_kernel_images() {
+ local regex kernel_image kernel_version version_version initrd_image
+ local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
+
+ case "$(uname -m)" in
+ s390|s390x)
+ regex='image'
+ ;;
+ ppc|ppc64)
+ regex='vmlinux'
+ ;;
+ i386|x86_64)
+ regex='vmlinuz'
+ ;;
+ arm*)
+ regex='[uz]Image'
+ ;;
+ aarch64)
+ regex='Image'
+ ;;
+ *) regex='vmlinu.'
+ ;;
+ esac
+
+ # user mode linux
+ if grep -q UML /proc/cpuinfo; then
+ regex='linux'
+ fi
+
+ kernel_images=""
+ initrd_images=""
+ for kernel_image in $(ls $boot_dir \
+ | sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
+ | grep -v kdump$ ) ; do
+
+ # Note that we cannot check the RPM database here -- this
+ # script is itself called from within the binary kernel
+ # packages, and rpm does not allow recursive calls.
+
+ [ -L "$boot_dir/$kernel_image" ] && continue
+ [ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
+ kernel_version=$(/usr/bin/get_kernel_version \
+ $boot_dir/$kernel_image 2> /dev/null)
+ initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
+ if [ "$kernel_image" != "$initrd_image" -a \
+ -n "$kernel_version" -a \
+ -d "/lib/modules/$kernel_version" ]; then
+ kernel_images="$kernel_images $boot_dir/$kernel_image"
+ initrd_images="$initrd_images $boot_dir/$initrd_image"
+ fi
+ done
+ for kernel_image in $kernel_images;do
+ kernels="$kernels ${kernel_image#*-}"
+ done
+ for initrd_image in $initrd_images;do
+ targets="$targets $initrd_image"
+ done
+
+}
+
while (($# > 0)); do
case ${1%%=*} in
--with-usb) read_arg usbmodule "$@" || shift $?
@@ -124,7 +185,8 @@ while (($# > 0)); do
shift
done
-[[ $targets && $kernels ]] || usage
+[[ $targets && $kernels ]] || default_kernel_images
+[[ $targets && $kernels ]] || (error "No kernel found in $boot_dir" && usage)
# We can have several targets/kernels, transform the list to an array
targets=( $targets )

30
microcode_cleanup.patch Normal file
View File

@ -0,0 +1,30 @@
dracut: Do not create early_cpio if no suitable microcode exist in hostonly
case
Intel microcodes only exist for very specific family/model/stepping CPUs.
If no microcode gets added, there is no need to create an empty
(only directories) cpio later that gets glued to the initrd.
This also fixes:
Index: dracut-033/dracut.sh
===================================================================
--- dracut-033.orig/dracut.sh
+++ dracut-033/dracut.sh
@@ -1311,12 +1311,15 @@ if [[ $early_microcode = yes ]]; then
dinfo "*** Constructing ${ucode_dest[$idx]} ****"
if [[ $hostonly ]]; then
_src=$(get_ucode_file)
+ if ! [[ -r $_fwdir/$_fw/$_src ]];then
+ break;
+ fi
fi
cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
+ create_early_cpio="yes"
fi
done
done
- create_early_cpio="yes"
fi
rm -f -- "$outfile"

View File

@ -0,0 +1,103 @@
mkinitrd-dracut.sh: Enhance param parsing: Allow multiple arguments per param
Currently --with parameter had to be passed as: --with="mod1 mod2".
Now one can pass: --with "mod1 mod2" or even --with mod1 mod2.
Signed-off-by: Thomas Renninger <trenn@suse.de>
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index ace7725..d8e92f3 100755
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -26,36 +26,43 @@ read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
- local rematch='^[^=]*=(.*)$'
+ param="$1"
+ local rematch='^[^=]*=(.*)$' result
if [[ $2 =~ $rematch ]]; then
- read "$1" <<< "${BASH_REMATCH[1]}"
- elif [[ $3 != -* ]]; then
- # Only read next arg if it not an arg itself.
- read "$1" <<< "$3"
- # There is no way to shift our callers args, so
- # return 1 to indicate they should do it instead.
- return 1
+ read "$param" <<< "${BASH_REMATCH[1]}"
+ else
+ for ((i=3; $i <= $#; i++)); do
+ # Only read next arg if it not an arg itself.
+ if [[ ${@:$i:1} = -* ]];then
+ break
+ fi
+ result="$result ${@:$i:1}"
+ # There is no way to shift our callers args, so
+ # return "no of args" to indicate they should do it instead.
+ done
+ read "$1" <<< "$result"
+ return $(($i - 3))
fi
}
while (($# > 0)); do
case ${1%%=*} in
- --with-usb) read_arg usbmodule "$@" || shift
+ --with-usb) read_arg usbmodule "$@" || shift $?
basicmodules="$basicmodules ${usbmodule:-usb-storage}"
unset usbmodule;;
- --with-avail) read_arg modname "$@" || shift
+ --with-avail) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
- --with) read_arg modname "$@" || shift
+ --with) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
--version)
echo "mkinitrd: dracut compatibility wrapper"
exit 0;;
-v|--verbose) dracut_args="${dracut_args} -v";;
-f|--force) dracut_args="${dracut_args} -f";;
- --preload) read_arg modname "$@" || shift
+ --preload) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
--image-version) img_vers=yes;;
- --rootfs) read_arg rootfs "$@" || shift
+ --rootfs) read_arg rootfs "$@" || shift $?
dracut_args="${dracut_args} --filesystems $rootfs";;
--nocompress) dracut_args="$dracut_args --no-compress";;
--help) usage -n;;
@@ -82,24 +89,29 @@ while (($# > 0)); do
--looppath*) ;;
--dsdt*) ;;
--bootchart) ;;
- -b) read_arg boot_dir "$@" || shift
+ -b) read_arg boot_dir "$@" || shift $?
if [ ! -d $boot_dir ];then
error "Boot directory $boot_dir does not exist"
exit 1
fi
;;
-k) # Would be nice to get a list of images here
- read_arg kernel_images "$@" || shift
+ read_arg kernel_images "$@" || shift $?
for kernel_image in $kernel_images;do
kernels="$kernels ${kernel_image#*-}"
done
;;
- -i) read_arg initrd_images "$@" || shift
+ -i) read_arg initrd_images "$@" || shift $?
for initrd_image in $initrd_images;do
- targets="$targets $boot_dir/$initrd_images"
+ case $initrd_image in
+ "$boot_dir"*)
+ targets="$targets $initrd_image";;
+ *)
+ targets="$targets $boot_dir/$initrd_image";;
+ esac
done
;;
- *) if [[ ! $targets ]]; then
+ *) if [[ ! $targets ]]; then
targets=$1
elif [[ ! $kernels ]]; then
kernels=$1

View File

@ -0,0 +1,88 @@
mkinitrd-dracut.sh: Introduce -i -k parameters
In SUSE, one can pass a list of kernel files via -k parameter.
For each an initrd is generated as passed via -i parameters.
Make the dracut mkinitrd wrapper compatible to those.
For now only one kernel file and initrd target can be specified.
This will get enhanced with a follow-up patch.
Signed-off-by: Thomas Renninger <trenn@suse.de>
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
old mode 100644
new mode 100755
index ffea2d1..ace7725
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -1,6 +1,8 @@
#!/bin/bash --norc
kver=$(uname -r)
+boot_dir="/boot"
+
error() { echo "$@" >&2; }
usage () {
@@ -80,10 +82,27 @@ while (($# > 0)); do
--looppath*) ;;
--dsdt*) ;;
--bootchart) ;;
- *) if [[ ! $target ]]; then
- target=$1
- elif [[ ! $kernel ]]; then
- kernel=$1
+ -b) read_arg boot_dir "$@" || shift
+ if [ ! -d $boot_dir ];then
+ error "Boot directory $boot_dir does not exist"
+ exit 1
+ fi
+ ;;
+ -k) # Would be nice to get a list of images here
+ read_arg kernel_images "$@" || shift
+ for kernel_image in $kernel_images;do
+ kernels="$kernels ${kernel_image#*-}"
+ done
+ ;;
+ -i) read_arg initrd_images "$@" || shift
+ for initrd_image in $initrd_images;do
+ targets="$targets $boot_dir/$initrd_images"
+ done
+ ;;
+ *) if [[ ! $targets ]]; then
+ targets=$1
+ elif [[ ! $kernels ]]; then
+ kernels=$1
else
usage
fi;;
@@ -91,11 +110,24 @@ while (($# > 0)); do
shift
done
-[[ $target && $kernel ]] || usage
-[[ $img_vers ]] && target="$target-$kernel"
+[[ $targets && $kernels ]] || usage
+
+# We can have several targets/kernels, transform the list to an array
+targets=( $targets )
+[[ $kernels ]] && kernels=( $kernels )
-if [[ $basicmodules ]]; then
+for ((i=0 ; $i<${#targets[@]} ; i++)); do
+
+ if [[ $img_vers ]];then
+ target="${targets[$i]}-${kernels[$i]}"
+ else
+ target="${targets[$i]}"
+ fi
+ kernel="${kernels[$i]}"
+
+ if [[ $basicmodules ]]; then
dracut $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
-else
+ else
dracut $dracut_args "$target" "$kernel"
-fi
+ fi
+done

3
mkinitrd_setup_dummy Normal file
View File

@ -0,0 +1,3 @@
#/bin/bash
true

View File

@ -0,0 +1,14 @@
diff -urNB dracut-033/mkinitrd-dracut.sh new/mkinitrd-dracut.sh
--- dracut-033/mkinitrd-dracut.sh 2013-10-04 19:12:51.654775024 +0200
+++ new/mkinitrd-dracut.sh 2013-10-04 19:14:25.088173450 +0200
@@ -236,3 +236,10 @@
fi
fi
done
+
+if [ -z "$(type -p update-bootloader)" ] ; then
+ echo 2>&1 "Did not refresh the bootloader. You might need to refresh it manually."
+else
+ update-bootloader --refresh
+fi
+

61
quiet_options.patch Normal file
View File

@ -0,0 +1,61 @@
mkinitrd-dracut.sh: Implement --quiet|-q option
Dracut is rather verbose. This optional parameter is to limit the output
to the essential: For each generated initrd show the kernel, target and
possibly additional options passed to dracut.
Signed-off-by: Thomas Renninger <trenn@suse.de>
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index d8e92f3..803abc0 100755
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -2,6 +2,7 @@
kver=$(uname -r)
boot_dir="/boot"
+quiet=0
error() { echo "$@" >&2; }
@@ -89,6 +90,7 @@ while (($# > 0)); do
--looppath*) ;;
--dsdt*) ;;
--bootchart) ;;
+ --quiet|-q) quiet=1;;
-b) read_arg boot_dir "$@" || shift $?
if [ ! -d $boot_dir ];then
error "Boot directory $boot_dir does not exist"
@@ -128,6 +130,7 @@ done
targets=( $targets )
[[ $kernels ]] && kernels=( $kernels )
+echo "Creating: target|kernel|dracut args|basicmodules "
for ((i=0 ; $i<${#targets[@]} ; i++)); do
if [[ $img_vers ]];then
@@ -137,9 +140,21 @@ for ((i=0 ; $i<${#targets[@]} ; i++)); do
fi
kernel="${kernels[$i]}"
- if [[ $basicmodules ]]; then
- dracut $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
+ # Duplicate code: No way found how to redirect output based on $quiet
+ if [[ $quiet == 1 ]];then
+ echo "$target|$kernel|$dracut_args|$basicmodules"
+ if [[ $basicmodules ]]; then
+ dracut $dracut_args --add-drivers "$basicmodules" "$target" \
+ "$kernel" &>/dev/null
+ else
+ dracut $dracut_args "$target" "$kernel" &>/dev/null
+ fi
else
- dracut $dracut_args "$target" "$kernel"
+ if [[ $basicmodules ]]; then
+ dracut $dracut_args --add-drivers "$basicmodules" "$target" \
+ "$kernel"
+ else
+ dracut $dracut_args "$target" "$kernel"
+ fi
fi
done

31
root_fs.patch Normal file
View File

@ -0,0 +1,31 @@
mkinitrd-dracut.sh: Also allow -d to specify the root_fs and -s dummy
-d is the SUSE mkinitrd version option to pass the rootfs.
-s is to enable splash which may not be needed, but some callers rely on it,
not to return an error.
Make this wrapper compatible to it.
Signed-off-by: Thomas Renninger <trenn@suse.de>
Index: dracut-033/mkinitrd-dracut.sh
===================================================================
--- dracut-033.orig/mkinitrd-dracut.sh
+++ dracut-033/mkinitrd-dracut.sh
@@ -124,7 +124,7 @@ while (($# > 0)); do
--preload) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
--image-version) img_vers=yes;;
- --rootfs) read_arg rootfs "$@" || shift $?
+ --rootfs|-d) read_arg rootfs "$@" || shift $?
dracut_args="${dracut_args} --filesystems $rootfs";;
--nocompress) dracut_args="$dracut_args --no-compress";;
--help) usage -n;;
@@ -151,6 +151,7 @@ while (($# > 0)); do
--looppath*) ;;
--dsdt*) ;;
--bootchart) ;;
+ -s) ;;
--quiet|-q) quiet=1;;
-b) read_arg boot_dir "$@" || shift $?
if [ ! -d $boot_dir ];then

64
suse_host_only.patch Normal file
View File

@ -0,0 +1,64 @@
mkinitrd-dracut.sh: Build host images for default_kernel_images and -i/-k paths
default_kernel_images and -i/-k paths are new (SuSE) code paths and
would have resulted in usage errors before.
There we want to build host only images for faster building and
smaller images.
Also force creation (overriding) of initrd images in these code paths.
Signed-off-by: Thomas Renninger <trenn@suse.de>
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index f7b53f1..a1519ea 100755
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -3,6 +3,8 @@ kver=$(uname -r)
boot_dir="/boot"
quiet=0
+host_only=0
+force=0
error() { echo "$@" >&2; }
@@ -104,7 +106,8 @@ default_kernel_images() {
for initrd_image in $initrd_images;do
targets="$targets $initrd_image"
done
-
+ host_only=1
+ force=1
}
while (($# > 0)); do
@@ -119,8 +122,8 @@ while (($# > 0)); do
--version)
echo "mkinitrd: dracut compatibility wrapper"
exit 0;;
- -v|--verbose) dracut_args="${dracut_args} -v";;
- -f|--force) dracut_args="${dracut_args} -f";;
+ -v|--verbose) dracut_args="${dracut_args} -v --keep";;
+ -f|--force) force=1;;
--preload) read_arg modname "$@" || shift $?
basicmodules="$basicmodules $modname";;
--image-version) img_vers=yes;;
@@ -164,6 +167,8 @@ while (($# > 0)); do
for kernel_image in $kernel_images;do
kernels="$kernels ${kernel_image#*-}"
done
+ host_only=1
+ force=1
;;
-i) read_arg initrd_images "$@" || shift $?
for initrd_image in $initrd_images;do
@@ -193,6 +198,9 @@ done
targets=( $targets )
[[ $kernels ]] && kernels=( $kernels )
+[[ $host_only == 1 ]] && dracut_args="${dracut_args} -H"
+[[ $force == 1 ]] && dracut_args="${dracut_args} -f"
+
echo "Creating: target|kernel|dracut args|basicmodules "
for ((i=0 ; $i<${#targets[@]} ; i++)); do

18
suse_only_logger.patch Normal file
View File

@ -0,0 +1,18 @@
diff --git a/mkinitrd-dracut.sh b/mkinitrd-dracut.sh
index a1519ea..dacba60 100755
--- a/mkinitrd-dracut.sh
+++ b/mkinitrd-dracut.sh
@@ -110,6 +110,13 @@ default_kernel_images() {
force=1
}
+if which logger &>/dev/null && which tr &>/dev/null;then
+ self=$(tr "\000" " " </proc/$$/cmdline)
+ self=${self#/bin/bash --norc }
+ parent=$(tr "\000" " " </proc/$PPID/cmdline)
+ logger -- "$self called by $parent"
+fi
+
while (($# > 0)); do
case ${1%%=*} in
--with-usb) read_arg usbmodule "$@" || shift $?