Accepting request 135536 from Base:System
Automatic submission by obs-autosubmit OBS-URL: https://build.opensuse.org/request/show/135536 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/perl-Bootloader?expand=0&rev=120
This commit is contained in:
commit
1aa319b1e9
30
boot.readme
30
boot.readme
@ -1,30 +0,0 @@
|
|||||||
This file is for first help if you occur some problems during booting.
|
|
||||||
|
|
||||||
FAQ
|
|
||||||
|
|
||||||
Q: Kernel upgrade break my tuned bootloader settings, I want edit it manually.
|
|
||||||
A: set LOADER_TYPE="none" in /etc/sysconfig/bootloader. Hint is used /boot/vmlinuz and /boot/initrd symlinks as files which is already point to actual kernel. WARNING after kernel upgrade you must update also configuration manually, otherwise you cannot boot.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Configuration files for bootloader (if you want manually edit it)
|
|
||||||
|
|
||||||
/etc/sysconfig/bootloader - contain various settings for bootloader and is used by perl-Bootloader
|
|
||||||
|
|
||||||
for grub (x86*) or trustedgrub -
|
|
||||||
/boot/grub/menu.lst - main configuration for sections
|
|
||||||
/boot/grub/device.map - mapping of real device to grub device
|
|
||||||
/etc/grub.conf - batch file for grub if you need update your bootloader location
|
|
||||||
|
|
||||||
for lilo ( x86* or ppc) -
|
|
||||||
/etc/lilo.conf - main configuration file
|
|
||||||
|
|
||||||
for elilo ( x86_64 or ia) -
|
|
||||||
/etc/elilo.conf - main configuration file
|
|
||||||
efibootmgr - utility for efi labels
|
|
||||||
/boot/efi/efi/SuSE/elilo.conf - configuration after elilo preprocess, use only if elilo break original configuration, in other case edit directly elilo.conf in /etc
|
|
||||||
|
|
||||||
for zipl (s390)-
|
|
||||||
/etc/zipl.conf - main configuration file
|
|
||||||
|
|
||||||
|
|
353
bootloader_entry
353
bootloader_entry
@ -1,353 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# This script represents an interface between the postinstall and postuninstall
|
|
||||||
# scripts of kernel rpms and the update-bootloader script.
|
|
||||||
#
|
|
||||||
# Interface:
|
|
||||||
# ----------
|
|
||||||
# /usr/lib/bootloader/bootloader_entry [add|remove] <kernel-flavor> <kernel-release> <image-name> <initrd-name>
|
|
||||||
#
|
|
||||||
# Call Semantics:
|
|
||||||
# ---------------
|
|
||||||
# [ -x $cmd ] && $cmd <parameters>
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Author: aosthof@suse.de
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
# Print how to use this script correctly
|
|
||||||
function usage()
|
|
||||||
{
|
|
||||||
echo "Unknown or missing parameter."
|
|
||||||
echo "Usage: $0 [add|remove] <kernel-flavor> <kernel-release> <image-name> <initrd-name> [force-default]"
|
|
||||||
echo
|
|
||||||
echo "The old interface with 4 parameters is still supported, but deprecated."
|
|
||||||
echo "This interface will be dropped in the near future."
|
|
||||||
echo "Usage: $0 [add|remove] <kernel-package-name> <image-name> <initrd-name>"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Get all command line arguments
|
|
||||||
function getargs()
|
|
||||||
{
|
|
||||||
# old interface with 4 parameters
|
|
||||||
if [ $# -eq 4 ] ; then
|
|
||||||
action=${1} # contains the action to be executed, e.g. "add" or "remove"
|
|
||||||
flavor=${2#*-} # contains the kernel-flavor, e.g. "default" or "xen"
|
|
||||||
flavor=${flavor%%-*}
|
|
||||||
release=${2#*-*-} # contains the kernel-release, e.g. "2.6.18-4-default"
|
|
||||||
release=${release%.*.*}
|
|
||||||
release="${release}-${flavor}"
|
|
||||||
image=${3} # contains the full image name, e.g. "vmlinuz-2.6.18-4-default"
|
|
||||||
initrd=${4} # contains the full initrd name, e.g. "initrd-2.6.18-4-default"
|
|
||||||
|
|
||||||
# new interface with 5 or 6 parameters, depends whether option
|
|
||||||
# "force-default" is used or not
|
|
||||||
else
|
|
||||||
action=${1} # contains the action to be executed, e.g. "add" or "remove"
|
|
||||||
flavor=${2} # contains the kernel-flavor, e.g. "default" or "xen"
|
|
||||||
release=${3} # contains the kernel-release, e.g. "2.6.18-4-default"
|
|
||||||
image=${4} # contains the full image name, e.g. "vmlinuz-2.6.18-4-default"
|
|
||||||
initrd=${5} # contains the full initrd name, e.g. "initrd-2.6.18-4-default"
|
|
||||||
forcedefault=${6} # contains action which forces corresponding boot entry beeing the
|
|
||||||
# default boot entry, enabled by given parameter "force-default"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Wrapper for the update-bootloader function
|
|
||||||
function update_bootloader()
|
|
||||||
{
|
|
||||||
echo "bootloader_entry: This is (wrapper) function update_bootloader" >> $logname
|
|
||||||
|
|
||||||
[ -x /sbin/update-bootloader ] || return 0
|
|
||||||
|
|
||||||
# call update-bootloader and also append stderr to the log file
|
|
||||||
/sbin/update-bootloader "$@" 1>>$logname 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Add a new bootloader entry #
|
|
||||||
##############################
|
|
||||||
function add_entry()
|
|
||||||
{
|
|
||||||
echo "bootloader_entry: This is function add_entry()" >> $logname
|
|
||||||
|
|
||||||
# If running in instsys, write command(s) to be executed in a file
|
|
||||||
# which will be executed by yast2-bootloader after installation of
|
|
||||||
# packages is finished.
|
|
||||||
#
|
|
||||||
# This is to prevent inconsistencies triggered by libata migration.
|
|
||||||
|
|
||||||
if [ "$YAST_IS_RUNNING" == instsys -a "$DELAYED_RUN_UPDATE_BOOTLOADER" != yes ]; then
|
|
||||||
cat - >> $delayed_exec_file <<-EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export DELAYED_RUN_UPDATE_BOOTLOADER=yes
|
|
||||||
|
|
||||||
/usr/lib/bootloader/bootloader_entry $@
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod 755 $delayed_exec_file
|
|
||||||
else
|
|
||||||
# Set up the new kernel
|
|
||||||
if [ -f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/sysconfig/bootloader ] &&
|
|
||||||
[ -f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub/menu.lst -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/lilo.conf -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/elilo.conf -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/zipl.conf ]; then
|
|
||||||
default=""
|
|
||||||
if test ! "$PBL_AUTOTEST"; then
|
|
||||||
default="--default"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $flavor in
|
|
||||||
(kdump|um)
|
|
||||||
;;
|
|
||||||
(xen*)
|
|
||||||
opt_xen_kernel=
|
|
||||||
if [ -e /proc/xen/xsd_port -o ! -e /proc/xen ]; then
|
|
||||||
set -- $flavor
|
|
||||||
set -- ${1#xen}
|
|
||||||
opt_xen_kernel=--xen-kernel=/boot/xen${1:+-$1}.gz
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$forcedefault" == "force-default" ]; then
|
|
||||||
# Add the new bootloader entry (xen kernel)
|
|
||||||
# and force it beeing the default entry
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
$default \
|
|
||||||
--force-default \
|
|
||||||
--add \
|
|
||||||
--force $opt_xen_kernel \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
else
|
|
||||||
# Add the new bootloader entry (xen kernel)
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
$default \
|
|
||||||
--add \
|
|
||||||
--force $opt_xen_kernel \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the bootloader (e.g., lilo).
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
(debug)
|
|
||||||
if [ "$forcedefault" == "force-default" ]; then
|
|
||||||
# Add the new bootloader entry (debug kernel)
|
|
||||||
# and force it beeing the default entry
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
--force-default \
|
|
||||||
--add \
|
|
||||||
--force \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
else
|
|
||||||
# Add the new bootloader entry (debug kernel)
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
--add \
|
|
||||||
--force \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the bootloader (e.g., lilo).
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
(*)
|
|
||||||
if [ "$forcedefault" == "force-default" ]; then
|
|
||||||
# Add the new bootloader entry
|
|
||||||
# and force it beeing the default entry
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
--default \
|
|
||||||
--force-default \
|
|
||||||
--add \
|
|
||||||
--force \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
else
|
|
||||||
# Add the new bootloader entry
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
$default \
|
|
||||||
--add \
|
|
||||||
--force \
|
|
||||||
--name "$release" \
|
|
||||||
|| exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the bootloader (e.g., lilo).
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif [ -f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/sysconfig/bootloader ] &&
|
|
||||||
[ -f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub2/grub.cfg -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub2-efi/grub.cfg ]; then
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Remove an existing bootloader entry #
|
|
||||||
#######################################
|
|
||||||
function remove_entry()
|
|
||||||
{
|
|
||||||
echo "bootloader_entry: This is function remove_entry()" >> $logname
|
|
||||||
|
|
||||||
# If running in instsys, write command(s) to be executed in a file
|
|
||||||
# which will be executed by yast2-bootloader after installation of
|
|
||||||
# packages is finished.
|
|
||||||
#
|
|
||||||
# This is to prevent inconsistencies triggered by libata migration.
|
|
||||||
|
|
||||||
if [ "$YAST_IS_RUNNING" == instsys -a "$DELAYED_RUN_UPDATE_BOOTLOADER" != yes ]; then
|
|
||||||
cat - >> $delayed_exec_file <<-EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export DELAYED_RUN_UPDATE_BOOTLOADER=yes
|
|
||||||
|
|
||||||
/usr/lib/bootloader/bootloader_entry $@
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod 755 $delayed_exec_file
|
|
||||||
else
|
|
||||||
if [ -f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/sysconfig/bootloader ] &&
|
|
||||||
[ -f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub/menu.lst -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/lilo.conf -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/elilo.conf -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/zipl.conf ]; then
|
|
||||||
# Do not specify the name of a bootloader entry when removing it, thus
|
|
||||||
# removing all sections matching the kernel image and initrd names
|
|
||||||
# (either both a "linux" and a "failsafe" section, or a section
|
|
||||||
# installed with the kernel postinstall script).
|
|
||||||
#
|
|
||||||
# Rationale: we do not know whether the old entry has
|
|
||||||
# - the product name as its name (when installed with
|
|
||||||
# yast-bootloader) or
|
|
||||||
# - "Kernel-<version>" (when installed with the kernel package's
|
|
||||||
# postinstall script and perl-Bootloader).
|
|
||||||
#
|
|
||||||
# So we cannot use the name to find the correct section.
|
|
||||||
# This is safe, because on grub, this does still not match other
|
|
||||||
# sections on other partitions with the same name for the kernel
|
|
||||||
# image and initrd (because they will still have the (hdx,y) prefix
|
|
||||||
# in perl-Bootloader). Other bootloaders do not specify other
|
|
||||||
# sections at all, or do only chainload them (BootLILO.ycp), and
|
|
||||||
# thus do not match either. (#223030)
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "$flavor" =~ xen ]] && [ -e /proc/xen/xsd_port -o ! -e /proc/xen ]; then
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
--xen \
|
|
||||||
--remove \
|
|
||||||
--force \
|
|
||||||
|| exit 1
|
|
||||||
else
|
|
||||||
update_bootloader --image /boot/$image \
|
|
||||||
--initrd /boot/$initrd \
|
|
||||||
--remove \
|
|
||||||
--force \
|
|
||||||
|| exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the bootloader (e.g., lilo).
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
elif [ -f $PERL_BOOTLOADER_TESTSUITE_PATH/etc/sysconfig/bootloader ] &&
|
|
||||||
[ -f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub2/grub.cfg -o \
|
|
||||||
-f $PERL_BOOTLOADER_TESTSUITE_PATH/boot/grub2-efi/grub.cfg ]; then
|
|
||||||
update_bootloader --refresh || exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##################### M A I N ###############################################
|
|
||||||
|
|
||||||
# Log how program was called
|
|
||||||
logname=$PERL_BOOTLOADER_TESTSUITE_PATH"/var/log/YaST2/perl-BL-standalone-log"
|
|
||||||
echo "bootloader_entry was called as: $*" >> $logname
|
|
||||||
|
|
||||||
# Log parts of the current system configuration
|
|
||||||
(
|
|
||||||
echo "/proc/mounts:"
|
|
||||||
cat /proc/mounts
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "/sys:"
|
|
||||||
ls -l /sys
|
|
||||||
echo
|
|
||||||
|
|
||||||
fstab="/etc/fstab"
|
|
||||||
if [ -e $fstab ] ; then
|
|
||||||
echo "fstab:"
|
|
||||||
cat $fstab
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "excerpts of /dev:"
|
|
||||||
#if doesn't find anything you can be on strange architecture (like ps3) and dump all block devices
|
|
||||||
ls -l /dev/{[hs]d[ab]?,md[0-3],.udev,disk/by-*} 2>/dev/null || ls -l /dev | grep ^b
|
|
||||||
echo
|
|
||||||
|
|
||||||
device_map="/boot/grub/device.map"
|
|
||||||
if [ -e $device_map ] ; then
|
|
||||||
echo "device.map:"
|
|
||||||
cat $device_map
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
) >> $logname
|
|
||||||
|
|
||||||
if test ! "$PBL_SKIP_BOOT_TEST"; then
|
|
||||||
if test `grep -c "^[^#[:space:]]\+[[:space:]]\+/boot[[:space:]]" /etc/fstab` -ne \
|
|
||||||
`grep -c "^[^[:space:]]\+[[:space:]]\+/boot[[:space:]]" /proc/mounts`; then
|
|
||||||
echo "/boot directory is not mounted. If this is bad detection you can avoid it by 'export PBL_SKIP_BOOT_TEST=1'";
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# File containing commands for later execution
|
|
||||||
delayed_exec_file="/boot/perl-BL_delayed_exec"
|
|
||||||
|
|
||||||
# Checks if correct amount of arguments is given
|
|
||||||
if [ "$#" -lt "4" -o "$#" -gt "6" ] ; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get all given arguments
|
|
||||||
getargs $@
|
|
||||||
|
|
||||||
# Find out which action should be executed
|
|
||||||
case $action in
|
|
||||||
add)
|
|
||||||
# Add a new bootloader entry
|
|
||||||
add_entry "$@"
|
|
||||||
;;
|
|
||||||
remove)
|
|
||||||
# Remove an existing bootloader entry
|
|
||||||
remove_entry "$@"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# Unknown argument
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6126184a9fac51dfd34b3d75de2d8f1463345aef41ff71c648ed6bd19e6c0e8f
|
|
||||||
size 153820
|
|
3
perl-Bootloader-0.702.tar.bz2
Normal file
3
perl-Bootloader-0.702.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:355ec0152a6b734ec1fb2f51d8e0b158bade580b159b752bb4b781f9821874bc
|
||||||
|
size 178595
|
@ -1,3 +1,35 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Sep 6 16:25:49 CEST 2012 - snwint@suse.de
|
||||||
|
|
||||||
|
- if called from yast: log directly to y2log, not via limal
|
||||||
|
- don't use udev for device mapping; instead read symlinks in dev tree
|
||||||
|
- add package-local make target
|
||||||
|
- clean up spec file
|
||||||
|
- log root device & chroot
|
||||||
|
- use additional log file /var/log/pbl.log for now to work around broken yast logging
|
||||||
|
- 0.702
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Aug 30 12:07:22 CEST 2012 - snwint@suse.de
|
||||||
|
|
||||||
|
- pbl rewrite continued
|
||||||
|
- 0.701
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Aug 30 12:07:21 CEST 2012 - mchang@suse.com
|
||||||
|
|
||||||
|
- add management to GRUB_BACKGROUND
|
||||||
|
- export section and write as global option
|
||||||
|
- manage GRUB_DISABLE_OS_PROBER settings
|
||||||
|
- use grub device name in /etc/default/grub_installdevice
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Aug 23 16:52:34 CEST 2012 - snwint@suse.de
|
||||||
|
|
||||||
|
- rewite pbl's logging functions
|
||||||
|
- start new version number scheme
|
||||||
|
- 0.700
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Aug 20 14:06:18 CEST 2012 - mchang@suse.com
|
Mon Aug 20 14:06:18 CEST 2012 - mchang@suse.com
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: perl-Bootloader
|
Name: perl-Bootloader
|
||||||
Version: 0.6.8
|
Version: 0.702
|
||||||
Release: 0
|
Release: 0
|
||||||
Requires: perl-base = %{perl_version}
|
Requires: perl-base = %{perl_version}
|
||||||
Requires: e2fsprogs
|
Requires: e2fsprogs
|
||||||
@ -26,9 +26,6 @@ Summary: Library for Configuring Boot Loaders
|
|||||||
License: GPL-2.0+
|
License: GPL-2.0+
|
||||||
Group: System/Boot
|
Group: System/Boot
|
||||||
Source: perl-Bootloader-%{version}.tar.bz2
|
Source: perl-Bootloader-%{version}.tar.bz2
|
||||||
Source1: update-bootloader
|
|
||||||
Source2: bootloader_entry
|
|
||||||
Source3: boot.readme
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildRequires: perl
|
BuildRequires: perl
|
||||||
Conflicts: multipath-tools < 0.4.8-40.25.1
|
Conflicts: multipath-tools < 0.4.8-40.25.1
|
||||||
@ -48,55 +45,44 @@ Authors:
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
rm -rf perl-Bootloader-testsuite
|
|
||||||
mkdir -p lib
|
|
||||||
mv src lib/Bootloader
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
touch Makefile.PL
|
|
||||||
perl -MExtUtils::MakeMaker -e 'WriteMakefile (NAME => "Bootloader")'
|
|
||||||
make %{?_smp_mflags}
|
|
||||||
pod2man %{SOURCE1} | gzip > update-bootloader.8.gz
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
|
make DESTDIR=$RPM_BUILD_ROOT install
|
||||||
install -d -m 700 $RPM_BUILD_ROOT/var/log/YaST2
|
install -d -m 700 $RPM_BUILD_ROOT/var/log/YaST2
|
||||||
make DESTDIR=$RPM_BUILD_ROOT install_vendor
|
|
||||||
%perl_process_packlist
|
%perl_process_packlist
|
||||||
mkdir -p $RPM_BUILD_ROOT/sbin
|
|
||||||
install -m 755 %_sourcedir/update-bootloader $RPM_BUILD_ROOT/sbin
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/usr/lib/bootloader
|
|
||||||
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/usr/lib/bootloader
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/boot
|
|
||||||
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/boot/
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/usr/share/man/man8/
|
|
||||||
install -m 644 update-bootloader.8.gz $RPM_BUILD_ROOT/usr/share/man/man8/
|
|
||||||
#install only needed files for bootloader for specific architecture
|
#install only needed files for bootloader for specific architecture
|
||||||
%ifarch %ix86 x86_64
|
%ifarch %ix86 x86_64
|
||||||
rm $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{ZIPL*,PowerLILO*}
|
rm -f $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{ZIPL*,PowerLILO*}
|
||||||
rm $RPM_BUILD_ROOT/%{_mandir}/man?/{*ZIPL*,*PowerLILO*}
|
rm -f $RPM_BUILD_ROOT/%{_mandir}/man?/{*ZIPL*,*PowerLILO*}
|
||||||
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
||||||
sed -i '/ZIPL/D;/PowerLILO/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
sed -i '/ZIPL/D;/PowerLILO/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
%ifarch ppc ppc64
|
%ifarch ppc ppc64
|
||||||
rm $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{ZIPL*,LILO*,ELILO*,GRUB*}
|
rm -f $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{ZIPL*,LILO*,ELILO*,GRUB*}
|
||||||
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
||||||
sed -i '/ZIPL/D;/ELILO/D;/\/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
sed -i '/ZIPL/D;/ELILO/D;/\/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
%ifarch s390 s390x
|
%ifarch s390 s390x
|
||||||
rm $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{*LILO*,GRUB*}
|
rm -f $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{*LILO*,GRUB*}
|
||||||
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
||||||
sed -i '/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
sed -i '/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
%ifarch ia32 ia64
|
%ifarch ia32 ia64
|
||||||
rm $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{LILO*,GRUB*,ZIPL*,PowerLILO*}
|
rm -f $RPM_BUILD_ROOT/%{perl_vendorlib}/Bootloader/Core/{LILO*,GRUB*,ZIPL*,PowerLILO*}
|
||||||
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
%if 0%{?suse_version} == 0 || 0%{?suse_version} <= 1130
|
||||||
sed -i '/ZIPL/D;/PowerLILO/D;/\/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
sed -i '/ZIPL/D;/PowerLILO/D;/\/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorarch}/auto/Bootloader/.packlist
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
%post
|
||||||
|
echo -n >>/var/log/pbl.log
|
||||||
|
chmod 600 /var/log/pbl.log
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-, root, root)
|
%defattr(-, root, root)
|
||||||
%doc COPYING
|
%doc COPYING
|
||||||
@ -110,5 +96,6 @@ sed -i '/ZIPL/D;/PowerLILO/D;/\/LILO/D;/GRUB/D;' $RPM_BUILD_ROOT/%{perl_vendorar
|
|||||||
/usr/lib/bootloader
|
/usr/lib/bootloader
|
||||||
/boot/boot.readme
|
/boot/boot.readme
|
||||||
%dir %attr(0700,root,root) /var/log/YaST2
|
%dir %attr(0700,root,root) /var/log/YaST2
|
||||||
|
%ghost %attr(0600,root,root) /var/log/pbl.log
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
@ -1,539 +0,0 @@
|
|||||||
#! /usr/bin/perl
|
|
||||||
|
|
||||||
use POSIX;
|
|
||||||
use Getopt::Long;
|
|
||||||
use Bootloader::Tools;
|
|
||||||
use Bootloader::Path;
|
|
||||||
use Bootloader::MBRTools;
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
# keep Pod::Usage optional (bnc #760464)
|
|
||||||
eval "use Pod::Usage";
|
|
||||||
|
|
||||||
if(!exists $::{pod2usage}) {
|
|
||||||
sub pod2usage {
|
|
||||||
die "usage: update-bootloader [operation] [options]\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my %oper;
|
|
||||||
my ($opt_default, $opt_force, $opt_force_default, $opt_help, $opt_man, $opt_previous, $opt_xen)
|
|
||||||
= (0,0,0,0,0,0,0);
|
|
||||||
my ($opt_image, $opt_initrd, $opt_name, $opt_xen_name, $opt_failsafe, $opt_xen_kernel)
|
|
||||||
= ('','','','','',undef);
|
|
||||||
my $add_product = 0;
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
update-bootloader - update/change bootloader configuration using
|
|
||||||
Bootloader::Tools perl module
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
update-bootloader [operation] [options]
|
|
||||||
|
|
||||||
operation is one of --add, --remove or --refresh.
|
|
||||||
|
|
||||||
valid options are --help, --man, --image <file>, --initrd <file>,
|
|
||||||
--xen-kernel <file>, --xen, --default, --previous, --name <string>, --force,
|
|
||||||
--force-default.
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
B<update-bootloader> will let you modify your bootloader configuration using
|
|
||||||
Bootloader::Tools perl module.
|
|
||||||
|
|
||||||
=head1 OPERATIONS
|
|
||||||
|
|
||||||
=over 8
|
|
||||||
|
|
||||||
=item B<--add>
|
|
||||||
|
|
||||||
add an new image section.
|
|
||||||
Needs a call to --refresh to take effect.
|
|
||||||
|
|
||||||
=item B<--remove>
|
|
||||||
|
|
||||||
remove the specified image section.
|
|
||||||
Needs a call to --refresh to take effect.
|
|
||||||
|
|
||||||
=item B<--refresh>
|
|
||||||
|
|
||||||
activate the new config e.g. write boot loader to disk
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 PARAMETER
|
|
||||||
|
|
||||||
=over 8
|
|
||||||
|
|
||||||
=item B<--help>
|
|
||||||
|
|
||||||
Print a brief help message and exits.
|
|
||||||
|
|
||||||
=item B<--man>
|
|
||||||
|
|
||||||
Prints the manual page and exits.
|
|
||||||
|
|
||||||
=item B<--image> F<file>
|
|
||||||
|
|
||||||
specify path to kernel image
|
|
||||||
|
|
||||||
=item B<--initrd> F<file>
|
|
||||||
|
|
||||||
specify path to initrd file
|
|
||||||
|
|
||||||
=item B<--xen>
|
|
||||||
|
|
||||||
specify that you what to add a xen and not a regular image section
|
|
||||||
|
|
||||||
=item B<--xen-kernel> F<file>
|
|
||||||
|
|
||||||
specify that you what to add a xen section with a specific image.
|
|
||||||
Implies --xen option.
|
|
||||||
|
|
||||||
=item B<--default>
|
|
||||||
|
|
||||||
let the new section to be added be the default section if appropriate. Only
|
|
||||||
allowed together with --add operation
|
|
||||||
|
|
||||||
=item B<--previous>
|
|
||||||
|
|
||||||
set some usuable defaults for image, initrd and name when
|
|
||||||
|
|
||||||
=item B<--name> F<string>
|
|
||||||
|
|
||||||
specify the name of the section to be added/removed
|
|
||||||
|
|
||||||
=item B<--force>
|
|
||||||
|
|
||||||
dont complain, just do the right thing
|
|
||||||
|
|
||||||
=item B<--force-default>
|
|
||||||
|
|
||||||
force the new section to be added to be the default section. Only
|
|
||||||
allowed together with --add operation
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
# Get product name and version
|
|
||||||
# If zypper is not available or versions is empty, use /etc/SuSE-release instead
|
|
||||||
# linux is last possible fallback
|
|
||||||
|
|
||||||
sub GetProduct {
|
|
||||||
my $namever;
|
|
||||||
my $loader = Bootloader::Tools::GetBootloader();
|
|
||||||
|
|
||||||
# first try: use zypper
|
|
||||||
if ( -f '/usr/bin/zypper' ){
|
|
||||||
my $zypper_out = qx{zypper --terse tos -l};
|
|
||||||
if ($zypper_out =~ m/^labelLong\s*(\S.*\S)\s*\nlabelShort\s*(\S.*\S)[\s\n]*$/){
|
|
||||||
return $1 if ($1 ne "" && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi"));
|
|
||||||
return $2 if ($2 ne "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Second try: Is there a usable /etc/SuSE-release?
|
|
||||||
# This should really not be used anymore, as the syntax changed
|
|
||||||
# no 'SP1' in the output.
|
|
||||||
if (open(RELEASE, "</etc/SuSE-release") && ($loader eq "grub" || $loader eq "grub2" || $loader eq "grub2-efi")) {
|
|
||||||
# first line is sufficient
|
|
||||||
$namever = <RELEASE>;
|
|
||||||
|
|
||||||
# delete everything starting with the first parenthesis
|
|
||||||
$namever =~ s/\s*\(.*//;
|
|
||||||
|
|
||||||
close(RELEASE);
|
|
||||||
chomp $namever;
|
|
||||||
return "$namever";
|
|
||||||
}
|
|
||||||
|
|
||||||
# the last line of defense ...
|
|
||||||
return "Linux";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub test_gettext {
|
|
||||||
my $filename = "Locale/gettext.pm";
|
|
||||||
my $realfilename;
|
|
||||||
foreach my $prefix (@INC) {
|
|
||||||
$realfilename = "$prefix/$filename";
|
|
||||||
if (-f $realfilename) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undef
|
|
||||||
}
|
|
||||||
|
|
||||||
my $logname = Bootloader::Path::Logname();
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader called:\n" . $0 . " " . join (" ", @ARGV) . "\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
GetOptions (\%oper,
|
|
||||||
'add|a' ,
|
|
||||||
'refresh' ,
|
|
||||||
'remove|r' ,
|
|
||||||
'examinembr|e=s',
|
|
||||||
'default|d' => \$opt_default,
|
|
||||||
'force-default' => \$opt_force_default,
|
|
||||||
'help|h' => \$opt_help,
|
|
||||||
'force' => \$opt_force,
|
|
||||||
'image=s' => \$opt_image,
|
|
||||||
'initrd=s' => \$opt_initrd,
|
|
||||||
'man|m' => \$opt_man,
|
|
||||||
'xen' => \$opt_xen,
|
|
||||||
'xen-kernel=s' => \$opt_xen_kernel,
|
|
||||||
'name=s' => \$opt_name,
|
|
||||||
'previous|p' => \$opt_previous)
|
|
||||||
or pod2usage(2);
|
|
||||||
pod2usage(1) if $opt_help;
|
|
||||||
pod2usage(-exitstatus => 0, -verbose => 2) if $opt_man;
|
|
||||||
|
|
||||||
die("Specify exactly one operation, either 'add', 'remove' or 'refresh'\n")
|
|
||||||
unless scalar keys(%oper) == 1;
|
|
||||||
|
|
||||||
die("Option 'default' is only allowed for operation 'add'\n")
|
|
||||||
if ($opt_default and not defined $oper{add});
|
|
||||||
|
|
||||||
die("Option 'force-default' is only allowed for operation 'add'\n")
|
|
||||||
if ($opt_force_default and not defined $oper{add});
|
|
||||||
|
|
||||||
if (defined $oper{"examinembr"}) {
|
|
||||||
my $ret = Bootloader::MBRTools::examineMBR($oper{"examinembr"});
|
|
||||||
if (defined $ret){
|
|
||||||
print "$ret\n";
|
|
||||||
exit 0;
|
|
||||||
} else {
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bootloader::Tools::GetBootloader() eq "none")
|
|
||||||
{
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("none bootloader, skipped updating \n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bootloader::Tools::GetBootloader() =~ /^(grub2|grub2-efi)$/)
|
|
||||||
{
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("grub2 bootloader, no add/remove section support\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
delete $oper{add};
|
|
||||||
delete $oper{remove};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($opt_image and $opt_image !~ m;^/;) {
|
|
||||||
$opt_image = getcwd . '/' . $opt_image
|
|
||||||
}
|
|
||||||
if ($opt_initrd and $opt_initrd !~ m;^/;) {
|
|
||||||
$opt_initrd = getcwd . '/' . $opt_initrd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $opt_xen_kernel) {
|
|
||||||
$opt_xen = 1;
|
|
||||||
} elsif ($opt_xen) {
|
|
||||||
my $xen_flavor = $opt_image;
|
|
||||||
$xen_flavor =~ s/.*-(\w+)/$1/;
|
|
||||||
|
|
||||||
if ($xen_flavor eq "xenpae") {
|
|
||||||
$opt_xen_kernel = "/boot/xen-pae.gz";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_xen_kernel = "/boot/xen.gz";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
my $type = $opt_xen ? "xen" : "image";
|
|
||||||
|
|
||||||
InitLibrary();
|
|
||||||
|
|
||||||
|
|
||||||
if ($opt_previous) {
|
|
||||||
unless ($opt_image) {
|
|
||||||
$opt_image = GetDefaultImage() . ".previous";
|
|
||||||
}
|
|
||||||
unless($opt_initrd) {
|
|
||||||
$opt_initrd = GetDefaultInitrd() . ".previous";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# FIXME: these section names should be unified somehow together with multi
|
|
||||||
# language and grafical menu handling
|
|
||||||
if (defined $oper{add}) {
|
|
||||||
my $loader = Bootloader::Tools::GetBootloader();
|
|
||||||
|
|
||||||
unless ($opt_name) {
|
|
||||||
if ($opt_xen and $opt_previous) {
|
|
||||||
if ($loader eq "grub" || $loader eq "lilo" || $loader eq "grub2") {
|
|
||||||
$opt_name = "Previous Xen";
|
|
||||||
$add_product = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_name = "previous xen";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ($opt_xen) {
|
|
||||||
if ($loader eq "grub" || $loader eq "lilo" || $loader eq "grub2") {
|
|
||||||
$opt_name = "Xen";
|
|
||||||
$add_product = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_name = "xen";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ($opt_previous) {
|
|
||||||
if ($loader eq "grub" || $loader eq "lilo" || $loader eq "grub2") {
|
|
||||||
$opt_name = "Previous Kernel";
|
|
||||||
$add_product = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_name = "previous";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_name = $opt_image;
|
|
||||||
$opt_name =~ s/.*\///;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# only localize on grub and lilo
|
|
||||||
#FIXME jreidinger: I think this now doesn't work. because pbl get only version + type of kernel....maybe help translate strings like failsafe etc
|
|
||||||
if (($loader eq "grub" || $loader eq "lilo") && defined(test_gettext())) {
|
|
||||||
require Locale::gettext;
|
|
||||||
setlocale(LC_MESSAGES, Bootloader::Tools::GetSystemLanguage());
|
|
||||||
|
|
||||||
my $d = Locale::gettext->domain("bootloader");
|
|
||||||
$d->dir("/usr/share/YaST2/locale");
|
|
||||||
my $opt_trans = $d->get($opt_name);
|
|
||||||
chomp ($opt_trans);
|
|
||||||
|
|
||||||
#log what is translated
|
|
||||||
my $logname = Bootloader::Path::Logname();
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("translate :\n" . $0 . " " . join (" ", @ARGV) . "\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
# check whether translation only contains [a-zA-Z0-9 _]
|
|
||||||
# otherwise fall back to untranslated string
|
|
||||||
if ($opt_trans =~ /^[a-zA-Z\d _]+$/g ) {
|
|
||||||
$opt_name = $opt_trans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Naming scheme for default, smp, bigsmp and pae kernels
|
|
||||||
if (($opt_name =~ /-default/) ||
|
|
||||||
($opt_name =~ /-smp/) ||
|
|
||||||
($opt_name =~ /-bigsmp/) ||
|
|
||||||
($opt_name =~ /-pae/)) {
|
|
||||||
|
|
||||||
if ($loader eq "grub" || $loader eq "grub2") {
|
|
||||||
$opt_name =~ s/-[^-]*$//;
|
|
||||||
$opt_failsafe = "Failsafe -- " . GetProduct() . " - " . $opt_name;
|
|
||||||
$opt_name = GetProduct() . " - " . $opt_name;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_failsafe = "Failsafe";
|
|
||||||
$opt_name = GetProduct();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Naming scheme for all xen kernels, thus xen and xenpae
|
|
||||||
elsif ($opt_xen) {
|
|
||||||
if ($loader eq "grub" || $loader eq "grub2") {
|
|
||||||
my $version = $opt_name;
|
|
||||||
$version =~ s/-xen.*$//;
|
|
||||||
|
|
||||||
$opt_name =~ s/^.*(xen.*)$/$1/;
|
|
||||||
$opt_name = ucfirst ($opt_name);
|
|
||||||
|
|
||||||
$opt_xen_name = "$opt_name -- " . GetProduct() . " - " . $version;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$opt_xen_name =~ s/^.*(xen.*)$/$1/;
|
|
||||||
$opt_xen_name = ucfirst ($opt_xen_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Naming scheme for all other kernels
|
|
||||||
else {
|
|
||||||
my $flavor = $opt_name;
|
|
||||||
$flavor =~ s/.*-(\w+)/$1/;
|
|
||||||
$flavor = ucfirst ($flavor);
|
|
||||||
|
|
||||||
# Create long labels for grub
|
|
||||||
if ($loader eq "grub" || $loader eq "grub2") {
|
|
||||||
my $version = $opt_name;
|
|
||||||
$version =~ s/-[^-]*$//;
|
|
||||||
|
|
||||||
$opt_name = $flavor . " -- " . GetProduct() . " - " . $version;
|
|
||||||
$opt_failsafe = "Failsafe -- " . GetProduct() . " - " . $version;
|
|
||||||
}
|
|
||||||
# Create short labels for all other loaders
|
|
||||||
else {
|
|
||||||
$opt_name = GetProduct();
|
|
||||||
$opt_failsafe = "Failsafe";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# execute selected operation
|
|
||||||
#
|
|
||||||
if (defined $oper{add}) {
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: now executing operation add\n");
|
|
||||||
print LOG ("update-bootloader: changed opt name is $opt_name\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
die("Please specify name and kernel image for new section\n")
|
|
||||||
unless $opt_name and $opt_image;
|
|
||||||
|
|
||||||
my @params = (
|
|
||||||
type => $type,
|
|
||||||
image => $opt_image,
|
|
||||||
);
|
|
||||||
if (CountSections(@params) != 0) {
|
|
||||||
if (not $opt_force) {
|
|
||||||
die("There are already sections with image '$opt_image'\n");
|
|
||||||
}
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: section already exist. Skip add.\n");
|
|
||||||
close LOG;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
# If, if option $opt_force_default is set, let this new kernel be
|
|
||||||
# the default one.
|
|
||||||
if ($opt_force_default) {
|
|
||||||
push @params, default => $opt_default;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Else, find out the flavor of the default kernel. If it is the same
|
|
||||||
# flavor as the one of the new kernel, let the new kernel be the
|
|
||||||
# default one.
|
|
||||||
else {
|
|
||||||
my $default_image = GetDefaultImage();
|
|
||||||
|
|
||||||
if (-l $default_image) {
|
|
||||||
$default_image = readlink ($default_image);
|
|
||||||
}
|
|
||||||
|
|
||||||
$default_image =~ s/^.*-//;
|
|
||||||
|
|
||||||
if ($opt_image =~ m/.*-${default_image}$/) {
|
|
||||||
push @params, default => $opt_default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
push @params, xen => $opt_xen_kernel if $type eq "xen";
|
|
||||||
push @params, initrd => $opt_initrd if $opt_initrd;
|
|
||||||
|
|
||||||
# Add "xen" section
|
|
||||||
if ($opt_xen) {
|
|
||||||
# Add original_name to params to be able to create comment line
|
|
||||||
push @params, original_name => "xen";
|
|
||||||
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: calling Tools::AddSection (XEN)\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
AddSection($opt_xen_name, @params);
|
|
||||||
}
|
|
||||||
# Add "normal" section
|
|
||||||
else {
|
|
||||||
# Add original_name to params to be able to create comment line
|
|
||||||
push @params, original_name => "linux";
|
|
||||||
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: calling Tools::AddSection (normal)\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
AddSection($opt_name, @params);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $arch = `uname --hardware-platform`;
|
|
||||||
chomp ($arch);
|
|
||||||
|
|
||||||
# Add a "Failsafe" section, but only if the underlying architecture is
|
|
||||||
# one of i386, x86_84 or ia64 and the kernel flavor is either default,
|
|
||||||
# smp, bigsmp or pae and not a xen kernel.
|
|
||||||
if ((($arch eq "i386") ||
|
|
||||||
($arch eq "x86_64") ||
|
|
||||||
($arch eq "s390x") ||
|
|
||||||
($arch eq "ia64")) &&
|
|
||||||
(($opt_image =~ /-default/) ||
|
|
||||||
($opt_image =~ /-smp/) ||
|
|
||||||
($opt_image =~ /-desktop/) ||
|
|
||||||
($opt_image =~ /-bigsmp/) ||
|
|
||||||
($opt_image =~ /-pae/)) &&
|
|
||||||
($opt_xen != 1)) {
|
|
||||||
# Add original_name to params to be able to create comment line
|
|
||||||
push @params, original_name => "failsafe";
|
|
||||||
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: calling Tools::AddSection (failsafe)\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
AddSection($opt_failsafe, @params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $oper{remove}) {
|
|
||||||
my @params = (
|
|
||||||
type => $type,
|
|
||||||
image => $opt_image,
|
|
||||||
);
|
|
||||||
push @params, xen => $opt_xen_kernel if $type eq "xen";
|
|
||||||
push @params, initrd => $opt_initrd if $opt_initrd;
|
|
||||||
push @params, name => $opt_name if $opt_name;
|
|
||||||
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: now executing operation remove\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
my $num = CountSections(@params);
|
|
||||||
|
|
||||||
if ($num > 0) {
|
|
||||||
if ($num > 1 and not $opt_force) {
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: found $num sections, no opt_force: not removing\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
die("There is more than one section with image '$opt_image'\n");
|
|
||||||
} else {
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: calling Tools::RemoveSections\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
RemoveSections(@params);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: no $opt_image found\n");
|
|
||||||
close LOG;
|
|
||||||
}
|
|
||||||
open (LOG, ">>$logname");
|
|
||||||
print LOG ("update-bootloader: finished operation remove\n");
|
|
||||||
close LOG;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $oper{refresh}) {
|
|
||||||
# Always set $avoid_init=0 to guarentee bootloader installed (bnc#759224)
|
|
||||||
my $ret = UpdateBootloader(0);
|
|
||||||
exit 1 if ( !$ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Local variables:
|
|
||||||
# mode: perl
|
|
||||||
# mode: font-lock
|
|
||||||
# mode: auto-fill
|
|
||||||
# fill-column: 78
|
|
||||||
# End:
|
|
||||||
#
|
|
Loading…
Reference in New Issue
Block a user