dracut-048-14.git20180726

- bring back 51-dracut-rescue-postinst.sh
This commit is contained in:
Harald Hoyer 2018-07-26 13:06:11 +02:00
parent ff2fda3aeb
commit f97365c3db
10 changed files with 459 additions and 2 deletions

View File

@ -21,3 +21,4 @@ index 001225b4..88bca1d4 100644
kmod_module_unref(mod); kmod_module_unref(mod);
continue; continue;
} }

70
0006.patch Normal file
View File

@ -0,0 +1,70 @@
From a0eadcdc644d571da58f718d73dacb4f68bef56b Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 5 Dec 2013 09:29:28 +0100
Subject: [PATCH] 00warpclock: Set correct timezone
Add module for setting correct timezone.
References: bnc#830060
For now, this module will not be included automatically due to different
expectations (see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=981617)
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Molkentin <daniel.molkentin@suse.com>
---
modules.d/00warpclock/module-setup.sh | 29 +++++++++++++++++++++++++++++
modules.d/00warpclock/warpclock.sh | 9 +++++++++
2 files changed, 38 insertions(+)
diff --git a/modules.d/00warpclock/module-setup.sh b/modules.d/00warpclock/module-setup.sh
new file mode 100644
index 00000000..ea1348ed
--- /dev/null
+++ b/modules.d/00warpclock/module-setup.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# called by dracut
+check() {
+ # hwclock does not exist on S390(x), bail out silently then
+ local _arch=$(uname -m)
+ [ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1
+
+ [ -e /etc/localtime -a -e /etc/adjtime ] || return 1
+ require_binaries /sbin/hwclock || return 1
+
+ return 255
+}
+
+# called by dracut
+depends() {
+ return 0
+}
+
+# called by dracut
+install() {
+ inst /usr/share/zoneinfo/UTC
+ inst /etc/localtime
+ inst /etc/adjtime
+ inst_hook pre-trigger 00 "$moddir/warpclock.sh"
+ inst /sbin/hwclock
+}
diff --git a/modules.d/00warpclock/warpclock.sh b/modules.d/00warpclock/warpclock.sh
new file mode 100644
index 00000000..f64818c6
--- /dev/null
+++ b/modules.d/00warpclock/warpclock.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if test -e /etc/adjtime ; then
+ while read line ; do
+ if test "$line" = LOCAL ; then
+ hwclock --systz
+ fi
+ done < /etc/adjtime
+fi

20
0007.patch Normal file
View File

@ -0,0 +1,20 @@
From aac3a0652adc2b200d5b8fedfbce99cfde88b525 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2018 09:54:13 +0200
Subject: [PATCH] NEWS: forgot to update the latest version
---
NEWS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 2de38ad7..60b430aa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-dracut-047
+dracut-048
==========
dracut.sh:

49
0008.patch Normal file
View File

@ -0,0 +1,49 @@
From f81c864eede2a11bfeb849cb2a2634be034ed7fb Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 25 Jul 2018 16:34:08 +0800
Subject: [PATCH] lsinitrd: allow to only unpack certain files
Before this patch, "--unpack" will always unpack the whole image.
Make "--unpack" be able to unpack only certain files, it will be
easier to retrieve files from initramfs image.
Signed-off-by: Kairui Song <kasong@redhat.com>
---
lsinitrd.sh | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 80fbf922..1b9a93b6 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -159,8 +159,15 @@ list_files()
unpack_files()
{
- $CAT "$image" 2>/dev/null | cpio -id --quiet $verbose
- ((ret+=$?))
+ if (( ${#filenames[@]} > 0 )); then
+ for f in "${!filenames[@]}"; do
+ $CAT "$image" 2>/dev/null | cpio -id --quiet $verbose $f
+ ((ret+=$?))
+ done
+ else
+ $CAT "$image" 2>/dev/null | cpio -id --quiet $verbose
+ ((ret+=$?))
+ fi
}
@@ -175,7 +182,10 @@ case $bin in
CAT="cat --"
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
if [[ "$is_early" ]]; then
- if [[ -n "$unpackearly" ]]; then
+ if [[ -n "$unpack" ]]; then
+ # should use --unpackearly for early CPIO
+ :
+ elif [[ -n "$unpackearly" ]]; then
unpack_files
elif (( ${#filenames[@]} > 0 )); then
extract_files

58
0009.patch Normal file
View File

@ -0,0 +1,58 @@
From 986b12d391b8de6c820da1af9bfdb4153c340370 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 25 Jul 2018 16:47:37 +0800
Subject: [PATCH] lsinitrd: optimize performance when handling multiple files
Currently, when trying to unpack or print the content of multiple
files, lsinitrd will decompress the image and pipe the decompressed
content to cpio to retrive each file if the image is compressed.
Which mean if we want to extract 10 files the image will be decompressed
10 times, which is a waste of time.
This patch will let lsinitrd decompress the image file to a temp file
first if multiple file names are given, then cpio will read from the
decompressed temp file, which will speed up a lot.
Time consumption test for command:
`lsinitrd initramfs-4.16.15-300.fc28.x86_64.img \
usr/lib/dracut/build-parameter.txt \
usr/lib/dracut/modules.txt \
etc/machine-id \
etc/hostname \
usr/lib/udev/rules.d/99-systemd.rules`
Before the patch:
2.37user 0.33system 0:02.12elapsed
After the patch:
0.50user 0.42system 0:00.72elapsed
There would be a more significant time difference if we try to
extract more files.
---
lsinitrd.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 1b9a93b6..0cb89e9c 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -251,6 +251,17 @@ if [[ $SKIP ]]; then
CAT=skipcpio
fi
+if (( ${#filenames[@]} > 1 )); then
+ TMPFILE="$(mktemp -t --suffix=.cpio lsinitrd.XXXXXX)"
+ $CAT "$image" 2>/dev/null > $TMPFILE
+ trap "rm -f '$TMPFILE'" EXIT
+ pre_decompress()
+ {
+ cat $TMPFILE
+ }
+ CAT=pre_decompress
+fi
+
ret=0
if [[ -n "$unpack" ]]; then

49
0010.patch Normal file
View File

@ -0,0 +1,49 @@
From 143420bc05079ffa040a63decbb2585c59e44011 Mon Sep 17 00:00:00 2001
From: Kairui Song <kasong@redhat.com>
Date: Wed, 25 Jul 2018 23:50:47 +0800
Subject: [PATCH] lsinitrd: update help message and man page
Signed-off-by: Kairui Song <kasong@redhat.com>
---
lsinitrd.1.asc | 6 ++++++
lsinitrd.sh | 3 +++
2 files changed, 9 insertions(+)
diff --git a/lsinitrd.1.asc b/lsinitrd.1.asc
index b6a704c2..193a4471 100644
--- a/lsinitrd.1.asc
+++ b/lsinitrd.1.asc
@@ -34,11 +34,17 @@ OPTIONS
**-k, --kver** _<kernel version>_::
inspect the initramfs of <kernel version>.
+**-m, --mod**::
+ list dracut modules included of the initramfs image.
+
**--unpack**::
unpack the initramfs to the current directory, instead of displaying the contents.
+ If optional filenames are given, will only unpack specified files, else the whole image will be unpacked.
+ Won't unpack anything from early cpio part.
**--unpackearly**::
unpack the early microcode initramfs to the current directory, instead of displaying the contents.
+ Same as --unpack, but only unpack files from early cpio part.
**-v, --verbose**::
unpack verbosely
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 0cb89e9c..a2fa4d7a 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -28,7 +28,10 @@ usage()
echo "-m, --mod list modules."
echo "-f, --file <filename> print the contents of <filename>."
echo "--unpack unpack the initramfs, instead of displaying the contents."
+ echo " If optional filenames are given, will only unpack specified files,"
+ echo " else the whole image will be unpacked. Won't unpack anything from early cpio part."
echo "--unpackearly unpack the early microcode part of the initramfs."
+ echo " Same as --unpack, but only unpack files from early cpio part."
echo "-v, --verbose unpack verbosely."
echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
echo

110
0011.patch Normal file
View File

@ -0,0 +1,110 @@
From 819ea3865161d440353b2f961f3dfeaabeed333d Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2018 12:49:45 +0200
Subject: [PATCH] Bring back 51-dracut-rescue-postinst.sh
can only be obsoleted after F30
---
51-dracut-rescue-postinst.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++
dracut.spec | 6 ++++
2 files changed, 74 insertions(+)
diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh
new file mode 100755
index 00000000..67f5b717
--- /dev/null
+++ b/51-dracut-rescue-postinst.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+export LANG=C
+
+KERNEL_VERSION="$1"
+KERNEL_IMAGE="$2"
+
+[[ -f /etc/os-release ]] && . /etc/os-release
+
+if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
+ systemd-machine-id-setup
+fi
+
+[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
+
+[[ $MACHINE_ID ]] || exit 1
+[[ -f $KERNEL_IMAGE ]] || exit 1
+
+INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
+NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
+
+[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
+
+dropindirs_sort()
+{
+ suffix=$1; shift
+ args=("$@")
+ files=$(
+ while (( $# > 0 )); do
+ for i in ${1}/*${suffix}; do
+ [[ -f $i ]] && echo ${i##*/}
+ done
+ shift
+ done | sort -Vu
+ )
+
+ for f in $files; do
+ for d in "${args[@]}"; do
+ if [[ -f "$d/$f" ]]; then
+ echo "$d/$f"
+ continue 2
+ fi
+ done
+ done
+}
+
+# source our config dir
+for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
+ [[ -e $f ]] && . "$f"
+done
+
+[[ $dracut_rescue_image != "yes" ]] && exit 0
+
+if [[ ! -f $INITRDFILE ]]; then
+ dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
+ ((ret+=$?))
+fi
+
+if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
+ cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
+ ((ret+=$?))
+fi
+
+new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
+
+((ret+=$?))
+
+exit $ret
diff --git a/dracut.spec b/dracut.spec
index c218b63d..10cd7839 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -259,6 +259,10 @@ rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%if 0%{?fedora} || 0%{?rhel}
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
+
+# FIXME: remove after F30
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
+install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%files
@@ -452,6 +456,8 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?fedora} || 0%{?rhel}
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
+# FIXME: remove after F30
+%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%changelog

22
0012.patch Normal file
View File

@ -0,0 +1,22 @@
From 25111d717eab662bd104295f034ed7d2d6cc606b Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2018 13:00:24 +0200
Subject: [PATCH] dracut.spec: add 00warpclock dracut module
---
dracut.spec | 1 +
1 file changed, 1 insertion(+)
diff --git a/dracut.spec b/dracut.spec
index 10cd7839..754ed3c9 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -317,6 +317,7 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%endif
%{dracutlibdir}/modules.d/00bash
%{dracutlibdir}/modules.d/00systemd
+%{dracutlibdir}/modules.d/00warpclock
%{dracutlibdir}/modules.d/01systemd-initrd
%{dracutlibdir}/modules.d/03modsign
%{dracutlibdir}/modules.d/03rescue

60
0013.patch Normal file
View File

@ -0,0 +1,60 @@
From 55a12055c511979be0a471d0d7c24c040b830887 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2018 13:04:20 +0200
Subject: [PATCH] dracut.spec: Remove needless use of %defattr
---
dracut.spec | 7 -------
1 file changed, 7 deletions(-)
diff --git a/dracut.spec b/dracut.spec
index 754ed3c9..9b9d497a 100644
--- a/dracut.spec
+++ b/dracut.spec
@@ -266,7 +266,6 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%endif
%files
-%defattr(-,root,root,0755)
%if %{with doc}
%doc README HACKING TODO AUTHORS NEWS dracut.html dracut.png dracut.svg
%endif
@@ -407,7 +406,6 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%endif
%files network
-%defattr(-,root,root,0755)
%{dracutlibdir}/modules.d/02systemd-networkd
%{dracutlibdir}/modules.d/40network
%{dracutlibdir}/modules.d/45ifcfg
@@ -426,18 +424,15 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%{dracutlibdir}/modules.d/99uefi-lib
%files caps
-%defattr(-,root,root,0755)
%{dracutlibdir}/modules.d/02caps
%files live
-%defattr(-,root,root,0755)
%{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/90dmsquash-live
%{dracutlibdir}/modules.d/90dmsquash-live-ntfs
%{dracutlibdir}/modules.d/90livenet
%files tools
-%defattr(-,root,root,0755)
%if %{with doc}
%doc %{_mandir}/man8/dracut-catimages.8*
@@ -449,11 +444,9 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne
%dir /var/lib/dracut/overlay
%files config-generic
-%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
%files config-rescue
-%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?fedora} || 0%{?rhel}
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install

View File

@ -5,11 +5,11 @@
# strip the automatically generated dep here and instead co-own the # strip the automatically generated dep here and instead co-own the
# directory. # directory.
%global __requires_exclude pkg-config %global __requires_exclude pkg-config
%define dist_free_release 6.git20180718 %define dist_free_release 14.git20180726
Name: dracut Name: dracut
Version: 048 Version: 048
Release: %{dist_free_release}%{?dist}.1 Release: %{dist_free_release}%{?dist}
Summary: Initramfs generator using udev Summary: Initramfs generator using udev
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
@ -33,6 +33,14 @@ Patch2: 0002.patch
Patch3: 0003.patch Patch3: 0003.patch
Patch4: 0004.patch Patch4: 0004.patch
Patch5: 0005.patch Patch5: 0005.patch
Patch6: 0006.patch
Patch7: 0007.patch
Patch8: 0008.patch
Patch9: 0009.patch
Patch10: 0010.patch
Patch11: 0011.patch
Patch12: 0012.patch
Patch13: 0013.patch
Source1: https://www.gnu.org/licenses/lgpl-2.1.txt Source1: https://www.gnu.org/licenses/lgpl-2.1.txt
@ -265,6 +273,10 @@ rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
# FIXME: remove after F30
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif %endif
%files %files
@ -318,6 +330,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%endif %endif
%{dracutlibdir}/modules.d/00bash %{dracutlibdir}/modules.d/00bash
%{dracutlibdir}/modules.d/00systemd %{dracutlibdir}/modules.d/00systemd
%{dracutlibdir}/modules.d/00warpclock
%{dracutlibdir}/modules.d/01systemd-initrd %{dracutlibdir}/modules.d/01systemd-initrd
%{dracutlibdir}/modules.d/03modsign %{dracutlibdir}/modules.d/03modsign
%{dracutlibdir}/modules.d/03rescue %{dracutlibdir}/modules.d/03rescue
@ -451,9 +464,14 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/dracut.conf.d/02-rescue.conf %{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
# FIXME: remove after F30
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif %endif
%changelog %changelog
* Thu Jul 26 2018 Harald Hoyer <harald@redhat.com> - 048-14.git20180726
- bring back 51-dracut-rescue-postinst.sh
* Wed Jul 18 2018 Harald Hoyer <harald@redhat.com> - 048-6.git20180718 * Wed Jul 18 2018 Harald Hoyer <harald@redhat.com> - 048-6.git20180718
- git snapshot - git snapshot