Accepting request 1096565 from Kernel:kdump
OBS-URL: https://build.opensuse.org/request/show/1096565 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/kexec-tools?expand=0&rev=149
This commit is contained in:
commit
3c9b362b38
226
kexec-bootloader
226
kexec-bootloader
@ -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:
|
|
@ -1,68 +0,0 @@
|
|||||||
'\" t
|
|
||||||
.\" Title: kexec-bootloader
|
|
||||||
.\" Author: Bernhard Walle <bwalle@suse.de>
|
|
||||||
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
|
|
||||||
.\" 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 <bwalle@suse\&.de>\&. 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
|
|
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jun 28 15:10:51 UTC 2023 - Michal Suchanek <msuchanek@suse.com>
|
||||||
|
|
||||||
|
- 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
|
Tue Apr 4 04:04:04 UTC 2023 - olaf@aepfle.de
|
||||||
|
|
||||||
|
@ -16,18 +16,18 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# Temporarily bump version to aid package split
|
||||||
|
%global realversion 2.0.26
|
||||||
Name: kexec-tools
|
Name: kexec-tools
|
||||||
Version: 2.0.26
|
Version: %{realversion}.0
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: Tools for loading replacement kernels into memory
|
Summary: Tools for loading replacement kernels into memory
|
||||||
License: GPL-2.0-or-later
|
License: GPL-2.0-or-later
|
||||||
Group: System/Kernel
|
Group: System/Kernel
|
||||||
URL: https://projects.horms.net/projects/kexec/
|
URL: https://projects.horms.net/projects/kexec/
|
||||||
Source: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz
|
Source: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.xz
|
||||||
Source100: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.sign
|
Source1: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.sign
|
||||||
Source101: kexec-tools.keyring
|
Source2: kexec-tools.keyring
|
||||||
Source1: kexec-bootloader
|
|
||||||
Source2: kexec-bootloader.8
|
|
||||||
Source3: kexec-load.service
|
Source3: kexec-load.service
|
||||||
Source4: %{name}-rpmlintrc
|
Source4: %{name}-rpmlintrc
|
||||||
Patch3: %{name}-disable-test.patch
|
Patch3: %{name}-disable-test.patch
|
||||||
@ -41,7 +41,7 @@ BuildRequires: systemd-rpm-macros
|
|||||||
BuildRequires: zlib-devel
|
BuildRequires: zlib-devel
|
||||||
#!BuildIgnore: fop
|
#!BuildIgnore: fop
|
||||||
#!BuildIgnore: gcc-PIE
|
#!BuildIgnore: gcc-PIE
|
||||||
Requires: perl-Bootloader
|
Requires: perl-Bootloader >= 1.6
|
||||||
Requires(post): suse-module-tools
|
Requires(post): suse-module-tools
|
||||||
Requires(postun):suse-module-tools
|
Requires(postun):suse-module-tools
|
||||||
%{?systemd_requires}
|
%{?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.
|
the loaded kernel after it panics.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q -n %{name}-%{realversion}
|
||||||
%autopatch -p1
|
%autopatch -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -70,11 +70,9 @@ export LDFLAGS="-pie"
|
|||||||
|
|
||||||
%install
|
%install
|
||||||
%make_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}
|
mkdir -p %{buildroot}/%{_unitdir}
|
||||||
install -m644 %{SOURCE3} %{buildroot}/%{_unitdir}
|
install -m644 %{SOURCE3} %{buildroot}/%{_unitdir}
|
||||||
|
mkdir -p %{buildroot}/%{_sbindir}
|
||||||
ln -s service %{buildroot}%{_sbindir}/rckexec-load
|
ln -s service %{buildroot}%{_sbindir}/rckexec-load
|
||||||
%if 0%{?suse_version} < 1550
|
%if 0%{?suse_version} < 1550
|
||||||
mkdir -p %{buildroot}/sbin
|
mkdir -p %{buildroot}/sbin
|
||||||
@ -119,7 +117,6 @@ ln -s %{_sbindir}/kexec %{buildroot}/sbin
|
|||||||
%endif
|
%endif
|
||||||
%{_sbindir}/rckexec-load
|
%{_sbindir}/rckexec-load
|
||||||
%{_sbindir}/kexec
|
%{_sbindir}/kexec
|
||||||
%{_sbindir}/kexec-bootloader
|
|
||||||
%{_sbindir}/vmcore-dmesg
|
%{_sbindir}/vmcore-dmesg
|
||||||
%{_unitdir}/kexec-load.service
|
%{_unitdir}/kexec-load.service
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user