diff --git a/doc/README.SUSE b/doc/README.SUSE index fb737a0..5e9d6eb 100644 --- a/doc/README.SUSE +++ b/doc/README.SUSE @@ -136,7 +136,7 @@ recommended way to produce a binary kernel is: (6) Install the kernel and the modules (``make modules_install'', followed by ``make install''). This will automatically create - an initrd for the new kernel as well (see ``mkinitrd -h''). + an initrd for the new kernel as well (see ``dracut -h''). (7) Add the kernel to the boot manager. When using lilo, run ``lilo'' to update the boot map. diff --git a/rpm/group-source-files.pl b/rpm/group-source-files.pl index 89fa8e8..3a8aa85 100755 --- a/rpm/group-source-files.pl +++ b/rpm/group-source-files.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl +use File::Spec; use Getopt::Long; use strict; @@ -20,7 +21,12 @@ sub main sub scan { - my $loc = shift @_; + # Normalize file path, mainly to strip away the ending forward slash, + # or any double forward slashes. + my $loc = File::Spec->canonpath(shift @_); + # We cannot use an absolute path (e.g. /usr/src/linux-5.14.21-150500.41) + # during find because it's under build root, but rpm wants one later. + my $abs_loc = rpm_path($loc); my(@dev, @ndev); foreach $_ (`find "$loc"`) @@ -43,16 +49,12 @@ sub scan m{^\Q$loc\E/arch/[^/]+/tools\b} || m{^\Q$loc\E/include/[^/]+\b} || m{^\Q$loc\E/scripts\b}; - if (substr($_, 0, 1) ne "/") { - # We cannot use an absolute path during find, - # but rpm wants one later. - $_ = "/$_"; - } - $is_devel ? push(@dev, $_) : push(@ndev, $_); + my $abs_path = rpm_path($_); + $is_devel ? push(@dev, $abs_path) : push(@ndev, $abs_path); } - push(@dev, &calc_dirs("/$loc", \@dev)); - push(@ndev, &calc_dirs("/$loc", \@ndev)); + push(@dev, &calc_dirs($abs_loc, \@dev)); + push(@ndev, &calc_dirs($abs_loc, \@ndev)); return (\@dev, \@ndev); } @@ -62,11 +64,14 @@ sub calc_dirs my %dirs; foreach my $file (@$files) { - my $path = $file; + my ($volume,$path,$basename) = File::Spec->splitpath($file); + my @dirs = File::Spec->splitdir($path); do { - $path =~ s{/[^/]+$}{}; + # Always create $path from catdir() to avoid ending forward slash + $path = File::Spec->catdir(@dirs); $dirs{$path} = 1; - } while ($path ne $base and $path ne ""); + pop @dirs; + } while ($path ne $base); # This loop also makes sure that $base itself is included. } @@ -86,3 +91,11 @@ sub output print FH join("\n", @$ndev), "\n"; close FH; } + +sub rpm_path +{ + my $path = shift @_; + # Always prepend forward slash and let canonpath take care of + # duplicate forward slashes. + return File::Spec->canonpath("/$path"); +} diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index c9b3600..119e148 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -173,6 +173,9 @@ Recommends: kernel-firmware # The following is copied to the -base subpackage as well # BEGIN COMMON DEPS Requires(pre): suse-kernel-rpm-scriptlets +Requires(post): suse-kernel-rpm-scriptlets +Requires: suse-kernel-rpm-scriptlets +Requires(preun): suse-kernel-rpm-scriptlets Requires(postun): suse-kernel-rpm-scriptlets Requires(pre): coreutils awk # For /usr/lib/module-init-tools/weak-modules2 @@ -184,21 +187,16 @@ Requires(post): modutils # test -x update-bootloader, having perl-Bootloader is not a hard requirement. # But, there is no way to tell rpm or yast to schedule the installation # of perl-Bootloader before kernel-binary.rpm if both are in the list of -# packages to install/update. Likewise, this is true for mkinitrd. +# packages to install/update. Likewise, this is true for dracut. # Need a perl-Bootloader with /usr/lib/bootloader/bootloader_entry Requires(post): perl-Bootloader >= 0.4.15 -%if %build_vanilla -Requires(post): mkinitrd -%else -# Require a mkinitrd that can handle usbhid/hid-generic built-in (bnc#773559) -Requires(post): mkinitrd >= 2.7.1 -%endif +Requires(post): dracut # Install the package providing /etc/SuSE-release early enough, so that # the grub entry has correct title (bnc#757565) Requires(post): distribution-release -# Do not install p-b and mkinitrd for the install check, the %post script is +# Do not install p-b and dracut for the install check, the %post script is # able to handle this -#!BuildIgnore: perl-Bootloader mkinitrd distribution-release +#!BuildIgnore: perl-Bootloader dracut distribution-release # Remove some packages that are installed automatically by the build system, # but are not needed to build the kernel #!BuildIgnore: autoconf automake gettext-runtime libtool cvs gettext-tools udev insserv @@ -1119,7 +1117,7 @@ Requires: %{name}_%_target_cpu = %version-%source_rel Requires(pre): coreutils awk Requires(post): modutils Requires(post): perl-Bootloader -Requires(post): mkinitrd +Requires(post): dracut @PROVIDES_OBSOLETES_EXTRA@ %obsolete_rebuilds %name-extra Supplements: packageand(product(SLED):%{name}_%_target_cpu) @@ -1185,7 +1183,7 @@ Requires: %name-extra_%_target_cpu = %version-%source_rel Requires(pre): coreutils awk Requires(post): modutils Requires(post): perl-Bootloader -Requires(post): mkinitrd +Requires(post): dracut @PROVIDES_OBSOLETES_OPTIONAL@ %obsolete_rebuilds %name-optional Supplements: packageand(product(Leap):%{name}_%_target_cpu) diff --git a/rpm/kernel-cert-subpackage b/rpm/kernel-cert-subpackage index 04a71b3..ed475d7 100644 --- a/rpm/kernel-cert-subpackage +++ b/rpm/kernel-cert-subpackage @@ -2,6 +2,9 @@ Summary: UEFI Secure Boot Certificate For Package %{-n*}-kmp Group: System/Kernel Requires(pre): suse-kernel-rpm-scriptlets +Requires(post): suse-kernel-rpm-scriptlets +Requires: suse-kernel-rpm-scriptlets +Requires(preun): suse-kernel-rpm-scriptlets Requires(postun): suse-kernel-rpm-scriptlets %description -n %{-n*}-ueficert This package contains the UEFI Secure Boot certificate used to sign diff --git a/rpm/kernel-module-subpackage b/rpm/kernel-module-subpackage index 3a3d18c..61bedf6 100644 --- a/rpm/kernel-module-subpackage +++ b/rpm/kernel-module-subpackage @@ -27,6 +27,9 @@ Provides: multiversion(kernel) Provides: %{-n*}-kmp-%1-%_this_kmp_kernel_version Requires: coreutils grep Requires(pre): suse-kernel-rpm-scriptlets +Requires(post): suse-kernel-rpm-scriptlets +Requires: suse-kernel-rpm-scriptlets +Requires(preun): suse-kernel-rpm-scriptlets Requires(postun): suse-kernel-rpm-scriptlets %{-c:Requires: %{-n*}-ueficert} Enhances: kernel-%1 diff --git a/rpm/kernel-obs-build.spec.in b/rpm/kernel-obs-build.spec.in index c5999c8..7c00206 100644 --- a/rpm/kernel-obs-build.spec.in +++ b/rpm/kernel-obs-build.spec.in @@ -53,14 +53,7 @@ BuildRequires: kernel %endif ExclusiveArch: @ARCHS@ -%if 0%{?suse_version} < 1315 -# For SLE 11 -BuildRequires: mkinitrd -BuildRequires: perl-Bootloader -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%else BuildRequires: dracut -%endif Summary: package kernel and initrd for OBS VM builds License: GPL-2.0-only Group: SLES @@ -145,12 +138,6 @@ ROOT="" %define kernel_name Image %endif -%if 0%{?suse_version} && 0%{?suse_version} < 1315 -# For SLE 11 -/sbin/mkinitrd $ROOT \ - -m "$KERNEL_MODULES" \ - -k /boot/%{kernel_name}-*-default -M /boot/System.map-*-default -i /tmp/initrd.kvm -B -%else # --host-only mode is needed for unlimited TasksMax workaround (boo#965564) dracut --reproducible --host-only --no-hostonly-cmdline \ --no-early-microcode --nofscks --strip --hardlink \ @@ -162,7 +149,6 @@ dracut --reproducible --host-only --no-hostonly-cmdline \ --compress "zstd -19 -T0" \ %endif $(echo /boot/%{kernel_name}-*%{kernel_flavor} | sed -n -e 's,[^-]*-\(.*'%{kernel_flavor}'\),\1,p') -%endif #cleanup rm -rf /usr/lib/dracut/modules.d/80obs