From c22641c87287e2c3a955874f91da837131251afc2a13c9da6e04d4bd5a0c239b Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mon, 3 Jul 2023 13:03:34 +0000 Subject: [PATCH] Accepting request 1096559 from home:snwint:branches:Kernel:kdump - Pull kexec-bootloader from perl-Bootloader, bump version so that perl-Bootloader can obsolete kexec-tools containing kexec-bootloader (bsc#1211082). OBS-URL: https://build.opensuse.org/request/show/1096559 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=157 --- kexec-bootloader | 226 -------------------------------------------- kexec-bootloader.8 | 68 ------------- kexec-tools.changes | 7 ++ kexec-tools.spec | 21 ++-- 4 files changed, 16 insertions(+), 306 deletions(-) delete mode 100644 kexec-bootloader delete mode 100644 kexec-bootloader.8 diff --git a/kexec-bootloader b/kexec-bootloader deleted file mode 100644 index f06e6a5..0000000 --- a/kexec-bootloader +++ /dev/null @@ -1,226 +0,0 @@ -#!/usr/bin/perl -w -# -# This program is free software; you can redistribute it and/or {{{ -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. }}} -# -use Bootloader::Tools; -use strict; -use Getopt::Long; - -use constant FALSE => 0; -use constant TRUE => 1; - -my $GRUBDIR = "/boot/grub"; -my $GRUBDEFAULT = "$GRUBDIR/default"; -my $debug = FALSE; -my $showHelp = FALSE; - -# -# Prints the given stuff (variable number of arguments) if debugging has -# been enabled. Does nothing otherwise. -sub print_debug(@) # {{{ -{ - if ($debug) { - print STDERR @_; - print STDERR "\n"; - } -} # }}} - -# -# Displays help. Does not exit. -sub show_help() -{ - print STDERR "kexec-bootloader\n"; - print STDERR "Loads kexec kernel from bootloader configuration.\n\n"; - print STDERR "Options:\n"; - print STDERR " -h | --help Shows that help message.\n"; - print STDERR " -D | --debug Prints debugging information.\n"; -} - - -# -# Returns the value stored with "grubonce". If no value has been stored -# or the /boot/grub/default file is not readable, then -1 is returned. -# -# Also emulate the behaviour when using GRUB which resets the 'magic once' flag -# when booting. Because we use kexec, we have to reset that 'magic once' flag -# ourselves. -sub get_grubonce_and_reset_magic() # {{{ -{ - # no /boot/grub/default file - if (! -f $GRUBDEFAULT) { - print_debug("get_grubonce_and_reset_magic(): No $GRUBDEFAULT."); - return -1; - } - - # read /boot/grub/default - open(FH, $GRUBDEFAULT) or return -1; - my $value; - my $ret = sysread(FH, $value, 10); - close(FH); - - # only if we have read 4 bytes it's valid - if ($ret != 10) { - print_debug("get_grubonce_and_reset_magic(): ". - "Read returned $ret instead of 4."); - return -1; - } - - - $value =~ s/\n//g; - my $once = int($value); - - # 0x4000 is the "magic once flag" - unless ($once & 0x4000) { - print_debug("get_grubonce_and_reset_magic(): No magic 0x40000."); - return -1; - } - - my $defaultno = $once & ~0x4000; - my $buf = $defaultno . "\0" . "\n" x 9; - - # now reset the grubonce flag - open(FH, ">$GRUBDEFAULT") or return $defaultno; - $ret = syswrite(FH, $buf, 10); - close(FH); - - return $defaultno; -} # }}} - -# -# Parses command line options and sets global variables. -sub parse_options() # {{{ -{ - GetOptions( - "D|debug" => \$debug, - "h|help" => \$showHelp - ); -} # }}} - - -parse_options(); -if ($showHelp) { - show_help(); - exit(0); -} -Bootloader::Tools::InitLibrary(); -my $loader = Bootloader::Tools::GetBootloader(); -my $default = -1; - -if ($loader =~ m/GRUB/i) { - $default = get_grubonce_and_reset_magic(); - print_debug("GRUB Default: $default"); -} - -my $section = undef; -# do we have a default? -if ($default >= 0) { - my @sections = Bootloader::Tools::GetSectionList(); - print_debug("Number of sections: " . $#sections); - - if ($#sections < 0 || $#sections < $default) { - print STDERR "WARNING: grubonce default number ($default) is invalid.\n"; - print STDERR " Falling back to the default GRUB section.\n"; - } else { - my $sect_name = $sections[$default]; - $section = Bootloader::Tools::GetSection($sect_name); - } -} - -# use the default section if we didn't get any default otherwise -if (!$section) { - $section = Bootloader::Tools::GetDefaultSection(); -} - -if (!$section) { - print STDERR "Unable to get default section of bootloader configuration.\n"; - exit(1); -} - -my $image=$section->{"image"}; -my $initrd=$section->{"initrd"}; - -for my $file ($image, $initrd) { - # handle btfs /@ -> / - $file =~ s!^/@/!/!; - # handle /boot on separate partition - if($file !~ m!^/boot/! && ! -e $file && -e "/boot$file") { - $file="/boot$file" - } -} - -if ($debug) { - print "Type : " . $section->{"type"}."\n"; - print "Name : " . $section->{"name"}."\n"; - print "Image : " . $image."\n"; - print "Initrd : " . $initrd."\n"; - print "VGA : " . $section->{"vgamode"}."\n"; - print "Append : " . $section->{"append"}."\n"; - print "Root : " . $section->{"root"}."\n"; -} - -if ($section->{"type"} ne "image") { - print STDERR "Default boot section is no image.\n"; - exit(1); -} - - -# check if the image exists -if (! -f $image) { - print STDERR "Image '" . $image . "' does not exist.\n"; - exit(1); -} - -# check if the initrd exists -if ($initrd && ! -f $initrd) { - print STDERR "Initrd '" . $initrd . "' does not exist.\n"; - exit(1); -} - -# build the command list -my $cmd = "kexec"; - -# append image -$cmd .= " -a -l '" . $image . "'"; - -# append initrd if available -if ($initrd) { - $cmd .= " --initrd='" . $initrd . "'"; -} - -# build append line -my $append = ""; -if ($section->{"root"}) { - $append .= "root=" . $section->{"root"}; -} -if ($section->{"vga"}) { - $append .= " vga=" . $section->{"vga"}; -} -if ($section->{"append"}) { - $append .= " " . $section->{"append"}; -} - -# and tell that kexec -$cmd .= " --append='" . $append . "'"; - -print_debug("Kexec call: " . $cmd); -if (system($cmd) != 0) { - print STDERR "kexec($cmd) failed."; - exit(1); -} - -exit(0); - -# :vim set ts=4 sw=4 et fdm=markers: :collapseFolds=1: diff --git a/kexec-bootloader.8 b/kexec-bootloader.8 deleted file mode 100644 index e6ca79e..0000000 --- a/kexec-bootloader.8 +++ /dev/null @@ -1,68 +0,0 @@ -'\" t -.\" Title: kexec-bootloader -.\" Author: Bernhard Walle -.\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 01/19/2018 -.\" Manual: User Manuals -.\" Source: SUSE -.\" Language: English -.\" -.TH "KEXEC\-BOOTLOADER" "8" "01/19/2018" "SUSE" "User Manuals" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- -.\" disable hyphenation -.nh -.\" disable justification (adjust text to left margin only) -.ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- -.SH "NAME" -kexec-bootloader \- Load kexec kernel from bootloader configuration -.SH "SYNOPSIS" -.sp -kexec\-bootloader [\-D] -.SH "DESCRIPTION" -.sp -kexec\-bootloader takes the default section of bootloader configuration and loads that kernel, initrd with \fIkexec \-l\fR and the respective command line\&. -.sp -Under systemd kexec\-bootloader may be invoked by kexec\-load\&.service (/usr/bin/systemctl kexec) to perform a kexec\&. To emulate previous SLE configurable behaviour where kexec occurs automatically at system reboot the systemd reboot target should be altered via \*(Aqln \-s /usr/lib/systemd/system/kexec\&.target /etc/systemd/system/reboot\&.target -.SH "OPTIONS" -.PP -\fB\-h\fR | \fB\-\-help\fR -.RS 4 -Shows a short usage message\&. -.RE -.PP -\fB\-D\fR | \fB\-\-debug\fR -.RS 4 -Prints debugging output\&. -.RE -.SH "RETURN VALUE" -.sp -The program returns \fB0\fR on success and \fB1\fR on failure\&. -.SH "BUGS" -.sp -Please report bugs and enhancement requests at https://bugzilla\&.novell\&.com\&. -.SH "COPYING" -.sp -Copyright (c) 2008 Bernhard Walle \&. Free use of this software is granted under the terms of the GNU General Public License (GPL), version 2 or later\&. -.SH "SEE ALSO" -.sp -\fBkexec\fR(8) -.SH "AUTHOR" -.PP -\fBBernhard Walle\fR <\&bwalle@suse\&.de\&> -.RS 4 -Author. -.RE diff --git a/kexec-tools.changes b/kexec-tools.changes index fd46b0f..820b307 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jun 28 15:10:51 UTC 2023 - Michal Suchanek + +- Pull kexec-bootloader from perl-Bootloader, bump version so that + perl-Bootloader can obsolete kexec-tools containing kexec-bootloader + (bsc#1211082). + ------------------------------------------------------------------- Tue Apr 4 04:04:04 UTC 2023 - olaf@aepfle.de diff --git a/kexec-tools.spec b/kexec-tools.spec index 28fb07d..b889e78 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -16,18 +16,18 @@ # +# Temporarily bump version to aid package split +%global realversion 2.0.26 Name: kexec-tools -Version: 2.0.26 +Version: %{realversion}.0 Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0-or-later Group: System/Kernel URL: https://projects.horms.net/projects/kexec/ -Source: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz -Source100: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.sign -Source101: kexec-tools.keyring -Source1: kexec-bootloader -Source2: kexec-bootloader.8 +Source: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.xz +Source1: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.sign +Source2: kexec-tools.keyring Source3: kexec-load.service Source4: %{name}-rpmlintrc Patch3: %{name}-disable-test.patch @@ -41,7 +41,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel #!BuildIgnore: fop #!BuildIgnore: gcc-PIE -Requires: perl-Bootloader +Requires: perl-Bootloader >= 1.6 Requires(post): suse-module-tools Requires(postun):suse-module-tools %{?systemd_requires} @@ -57,7 +57,7 @@ kernel may be asked to start the loaded kernel on reboot, or to start the loaded kernel after it panics. %prep -%setup -q +%setup -q -n %{name}-%{realversion} %autopatch -p1 %build @@ -70,11 +70,9 @@ export LDFLAGS="-pie" %install %make_install -install -c -m 0644 %{SOURCE2} %{buildroot}/%{_mandir}/man8 -mkdir -p %{buildroot}/%{_sbindir} -install -m 0755 %{SOURCE1} %{buildroot}/%{_sbindir} mkdir -p %{buildroot}/%{_unitdir} install -m644 %{SOURCE3} %{buildroot}/%{_unitdir} +mkdir -p %{buildroot}/%{_sbindir} ln -s service %{buildroot}%{_sbindir}/rckexec-load %if 0%{?suse_version} < 1550 mkdir -p %{buildroot}/sbin @@ -119,7 +117,6 @@ ln -s %{_sbindir}/kexec %{buildroot}/sbin %endif %{_sbindir}/rckexec-load %{_sbindir}/kexec -%{_sbindir}/kexec-bootloader %{_sbindir}/vmcore-dmesg %{_unitdir}/kexec-load.service