Hello community, here is the log from the commit of package perl-Bootloader for openSUSE:Factory checked in at 2015-12-03 13:27:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Bootloader (Old) and /work/SRC/openSUSE:Factory/.perl-Bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Bootloader" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Bootloader/perl-Bootloader.changes 2015-10-17 16:37:27.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Bootloader.new/perl-Bootloader.changes 2015-12-03 13:27:51.000000000 +0100 @@ -1,0 +2,15 @@ +Wed Nov 25 14:16:19 UTC 2015 - [email protected] + +- make grub_installdevice parsing more robust +- continue after wrong entries in grub_install_device +- move bootloader scripts into separate subdirectories +- updated doc +- introduce separate per-bootloader scripts +- add documentation +- some minor corrections +- support --reinit option to force grub2 install +- adjust Makefile +- add new wrapper script to get rid of old perl-Bootloader code for grub2 +- 0.900 + +------------------------------------------------------------------- Old: ---- perl-Bootloader-0.844.tar.xz New: ---- perl-Bootloader-0.900.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Bootloader.spec ++++++ --- /var/tmp/diff_new_pack.PvYcqB/_old 2015-12-03 13:27:52.000000000 +0100 +++ /var/tmp/diff_new_pack.PvYcqB/_new 2015-12-03 13:27:52.000000000 +0100 @@ -17,7 +17,7 @@ Name: perl-Bootloader -Version: 0.844 +Version: 0.900 Release: 0 Requires: coreutils Requires: perl-base = %{perl_version} ++++++ perl-Bootloader-0.844.tar.xz -> perl-Bootloader-0.900.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/Makefile new/perl-Bootloader-0.900/Makefile --- old/perl-Bootloader-0.844/Makefile 2015-10-06 13:11:56.000000000 +0200 +++ new/perl-Bootloader-0.900/Makefile 2015-11-25 16:06:16.000000000 +0100 @@ -32,10 +32,20 @@ perl -Ilib -MExtUtils::MakeMaker -e 'WriteMakefile (NAME => "Bootloader", VERSION_FROM => "lib/Bootloader/Library.pm" )' ; \ make install_vendor @mkdir -p $(DESTDIR)/sbin $(DESTDIR)/usr/sbin - @install -m 755 update-bootloader $(DESTDIR)/sbin @install -m 755 pbl-yaml $(DESTDIR)/usr/sbin @install -d -m 755 $(DESTDIR)/usr/lib/bootloader - @install -m 755 bootloader_entry $(DESTDIR)/usr/lib/bootloader + @install -m 755 bootloader_entry $(DESTDIR)/usr/lib/bootloader/bootloader_entry.old + @install -m 755 update-bootloader $(DESTDIR)/usr/lib/bootloader/update-bootloader.old + @install -d -m 755 $(DESTDIR)/usr/lib/bootloader/grub2 + @install -m 755 grub2/install $(DESTDIR)/usr/lib/bootloader/grub2 + @install -m 755 grub2/config $(DESTDIR)/usr/lib/bootloader/grub2 + @install -d -m 755 $(DESTDIR)/usr/lib/bootloader/grub2-efi + @install -m 755 grub2-efi/install $(DESTDIR)/usr/lib/bootloader/grub2-efi + @install -m 755 grub2/config $(DESTDIR)/usr/lib/bootloader/grub2-efi + @install -m 755 pbl $(DESTDIR)/usr/lib/bootloader/pbl + @perl -pi -e 's/0\.0/$(VERSION)/ if /VERSION = /' $(DESTDIR)/usr/lib/bootloader/pbl + @ln -snf ../usr/lib/bootloader/pbl $(DESTDIR)/sbin/update-bootloader + @ln -snf pbl $(DESTDIR)/usr/lib/bootloader/bootloader_entry @install -d -m 755 $(DESTDIR)/boot @install -m 644 boot.readme $(DESTDIR)/boot/ @install -d -m 755 $(DESTDIR)/usr/share/man/man8/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/VERSION new/perl-Bootloader-0.900/VERSION --- old/perl-Bootloader-0.844/VERSION 2015-10-06 13:11:56.000000000 +0200 +++ new/perl-Bootloader-0.900/VERSION 2015-11-25 16:06:16.000000000 +0100 @@ -1 +1 @@ -0.844 +0.900 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/changelog new/perl-Bootloader-0.900/changelog --- old/perl-Bootloader-0.844/changelog 2015-10-06 13:11:56.000000000 +0200 +++ new/perl-Bootloader-0.900/changelog 2015-11-25 16:06:16.000000000 +0100 @@ -1,3 +1,15 @@ +2015-09-02: 0.900 + - make grub_installdevice parsing more robust + - continue after wrong entries in grub_install_device + - move bootloader scripts into separate subdirectories + - updated doc + - introduce separate per-bootloader scripts + - add documentation + - some minor corrections + - support --reinit option to force grub2 install + - adjust Makefile + - add new wrapper script to get rid of old perl-Bootloader code for grub2 + 2015-10-06: 0.844 - rework boot.readme (bsc #948778) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/grub2/config new/perl-Bootloader-0.900/grub2/config --- old/perl-Bootloader-0.844/grub2/config 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.900/grub2/config 2015-11-25 16:06:16.000000000 +0100 @@ -0,0 +1,14 @@ +#! /bin/bash + +if [ -x /usr/sbin/grub2-mkconfig ] ; then + if [ -d /boot/grub2 ] ; then + ( set -x ; /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg ) + else + echo "/boot/grub2: no such directory" + exit 1 + fi +else + echo "grub2-mkconfig: command not found" + exit 1 +fi + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/grub2/install new/perl-Bootloader-0.900/grub2/install --- old/perl-Bootloader-0.844/grub2/install 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.900/grub2/install 2015-11-25 16:06:16.000000000 +0100 @@ -0,0 +1,42 @@ +#! /bin/bash + +target=$(uname --hardware-platform) + +if [ -z "$target" ] ; then + echo "no target platform" + exit 1 +fi + +case "$target" in + i?86 | x86_64 ) target=i386-pc ;; + ppc | ppc64 ) target=powerpc-ieee1275 ;; + s390x ) target=s390x-emu ;; +esac + +echo "target = $target" + +err=0 + +if [ -x /usr/sbin/grub2-install ] ; then + if [ -f /etc/default/grub_installdevice ] ; then + while read foo ; do + # ignore everything that doesn't look like a path + [ "${foo::1}" != "/" ] && continue + if [ -b "$foo" -o -f "$foo" ] ; then + ( set -x ; /usr/sbin/grub2-install --target="$target" --force --skip-fs-probe "$foo" ) || err=1 + else + echo "$foo: not a block device" + err=1 + fi + done </etc/default/grub_installdevice + else + echo "/etc/default/grub_installdevice: no such file" + err=1 + fi +else + echo "grub2-install: command not found" + err=1 +fi + +exit $err + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/grub2-efi/install new/perl-Bootloader-0.900/grub2-efi/install --- old/perl-Bootloader-0.844/grub2-efi/install 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.900/grub2-efi/install 2015-11-25 16:06:16.000000000 +0100 @@ -0,0 +1,29 @@ +#! /bin/bash + +target=$(uname --hardware-platform) + +if [ -z "$target" ] ; then + echo "no target platform" + exit 1 +fi + +case "$target" in + i?86 ) target=i386 ;; + x86_64 | amd64 ) target=x86_64 ;; + aarch64 ) target=arm64 ;; + armv7l ) target=arm ;; +esac + +target="$target-efi" + +echo "target = $target" + +if [ -x /usr/sbin/shim-install ] ; then + ( set -x ; /usr/sbin/shim-install --config-file=/boot/grub2/grub.cfg ) +elif [ -x /usr/sbin/grub2-install ] ; then + ( set -x ; /usr/sbin/grub2-install --target="$target" ) +else + echo "grub2-install: command not found" + exit 1 +fi + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/new_pbl.txt new/perl-Bootloader-0.900/new_pbl.txt --- old/perl-Bootloader-0.844/new_pbl.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.900/new_pbl.txt 2015-11-25 16:06:16.000000000 +0100 @@ -0,0 +1,58 @@ +=== perl-Bootloader - redone === + +The script we are talking about is here: + +https://github.com/openSUSE/perl-bootloader/blob/test_10/pbl + +It replaces both 'bootloader_entry' and 'update-bootloader'. + +It currently checks /etc/sysconfig/bootloader::LOADER_TYPE and + - if "" -> does nothing + - if /usr/lib/bootloader/$LOADER_TYPE exists, runs scripts from this directry + - else -> calls old 'bootloader_entry' resp. 'update-bootloader' scripts (for compat) + +There are two functions (scripts in $LOADER_TYPE dir) defined: + - install: install the bootloader (to the disk) + - config: update the boot loader config file (e.g. /boot/grub2/grub.cfg) + +If a script is missing, it is assumed that it is not necessary to do +anything (that is, it's not considered an error). + + +There are 2 cases: + +(1) if the script is called with '--reinit', then run $LOADER_TYPE/install, + followed by $LOADER_TYPE/config + +(2) else run $LOADER_TYPE/config + +Apart from this, the script arguments are ignored. + +This basically mirrors what we currently (sle12/factory) do for grub2. + +The scripts in /usr/lib/bootloader/ should exit with 0 if ok, else a failure is assumed. +Any output (stdout or stderr) is logged to /var/log/pbl.log. + +ibs home:snwint:sle12test/perl-Bootloader has a test package that can be +used as a drop-in replacement for testing. + + +== What next? == + +Going forward I've had some discussion with Raymund and Michael about how to improve +the current situation. + +Issues atm: + +- grub2-install: you have to find out and specify --target; that should ideally not + be necessary +- grub2-install: you have to add an install device or even repeat the call for several + devices for i386-pc (and only there) +- grub2-install: i386-pc needs some extra options (like --force --skip-fs-probe) +- sometimes you have to call shim + +Ideas so far: + +- put the exact setup command into /etc/install_grub or so (like grub1) +- put the grub2 platform into /etc/sysconfig/bootloader (say, TARGET=[grub2-]x86_64-efi) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.844/pbl new/perl-Bootloader-0.900/pbl --- old/perl-Bootloader-0.844/pbl 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.900/pbl 2015-11-25 16:06:16.000000000 +0100 @@ -0,0 +1,224 @@ +#! /usr/bin/perl + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# This is a (wrapper) script to update the bootloader config. +# +# It checks /etc/sysconfig/bootloader for the bootloader type. +# +# If there's no bootloader configured, it does nothing. +# +# If the directory /usr/lib/bootloader/$LOADER exists, runs the scripts from +# that directory. +# +# For any other bootloader it runs the old bootloader_entry and +# update-bootloader scripts (renamed to *.old). +# + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +use strict; +use POSIX qw ( strftime uname ); + +use Data::Dumper; +$Data::Dumper::Sortkeys = 1; +$Data::Dumper::Terse = 1; +$Data::Dumper::Indent = 1; + +my $VERSION = "0.0"; + +my $pbl_dir = "/usr/lib/bootloader"; + +sub new; +sub info; +sub get_bootloader; +sub run_command; + +my $program; +my $log; +my $loader; +my $exit_code = 0; +my @todo; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +sub new +{ + $log->{session_id} = $program . sprintf("-%04d", int rand 10000); + + # log to logfile if we can, else to STDERR + + if(open my $f, ">>/var/log/pbl.log") { + my $tmp = select $f; + $| = 1; + select $tmp; + binmode $f, ':utf8'; + $log->{log_fh} = $f; + } + elsif(open my $f, ">&STDERR") { + binmode $f, ':utf8'; + $log->{log_fh} = $f; + $log->{log_is_stderr} = 1; + } + + # find root device & detect if we are chroot-ed + my $r = "?"; + my @r0 = stat "/"; + my @r1 = stat "/proc/1/root"; + if(@r0 && @r1) { + my $r0 = ($r0[0] >> 8) . ":" . ($r0[0] & 0xff); + $r = readlink "/dev/block/$r0"; + $r =~ s#^..#/dev# if defined $r; + $r = $r0 unless defined $r; + if($r0[0] != $r1[0] || $r0[1] != $r1[1]) { + $r .= " (chroot)"; + } + } + + info(1, "$log->{session_id} = $0, version = $VERSION, root = $r"); +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# info(level, message, var, depth) +# +# level: 0 .. 3 (debug, info, warning, error) +# message: log message (single line string) +# var (optional): either a SCALAR or a REF +# - SCALAR (may be multiline) will be logged in a block delimited +# by '<<<<<<<<<<<<<<<<' and '>>>>>>>>>>>>>>>>' +# - REF will be logged using Data::Dumper +# depth (optional): maximum depth when logging a REF +# +sub info +{ + my $level = shift; + my $message = shift; + + new if !$log; + + my $line = (caller(1))[2]; + my $func = (caller(1))[3]; + $func =~ s/^main:://; + + $func = 'main', $line = (caller(0))[2] if $func eq ''; + + my $id = $log->{session_id} || "???-0000.0"; + + # we split the log line a bit into prefix & message + + my $prefix = strftime("%Y-%m-%d %H:%M:%S", localtime) . " <$level>"; + + $message = "$id $func.$line: $message"; + + if($_[0]) { + my $x = $_[0]; + my $m = $_[1]; + if(ref $x) { + $Data::Dumper::Maxdepth = $m if $m; + chomp($x = Dumper $x); + $Data::Dumper::Maxdepth = 0 if $m; + } + else { + chomp $x; + $x = "<<<<<<<<<<<<<<<<\n$x\n>>>>>>>>>>>>>>>>"; + } + + $message .= "\n$x"; + } + + if($log->{log_fh}) { + print { $log->{log_fh} } "$prefix $message\n"; + } + + # log error messages to STDERR unless we already did + + if(!$log->{log_is_stderr} && $level > 2) { + print STDERR "$program: $prefix $message\n"; + } +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +sub get_bootloader +{ + my $bl; + + if(open my $f, "/etc/sysconfig/bootloader") { + while(<$f>) { + $bl = $1, last if /^LOADER_TYPE=(\S*)/; + } + close $f; + } + + $bl =~ s/^["']|["']$//g; + + return $bl; +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +sub run_command +{ + my $command = shift; + my $try = shift; + + my $ret; + my $output; + + if(open my $f, "($command) 2>&1 |") { + local $/; + $output = <$f>; + close $f; + $ret = $? >> 8; + chomp $output; + $output .= "\n"; + } + else { + $ret = 127; + $output = "$command: " . ($! == 13 ? $! : "command not found") . " \n"; + } + + if(!$ret || $try) { + info(1, "'$command' = $ret, output:", $output); + $ret = 0; + } + else { + info(3, "'$command' failed with exit code $ret, output:", $output); + } + + return $ret; +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +($program = $0) =~ s#^.*/##; + +info(1, join(' ', ($0, @ARGV))); + +$loader = get_bootloader; + +info(1, "bootloader = $loader"); + +exit 0 if !$loader; + +push @todo, 'config'; + +unshift @todo, 'install' if grep { /^--reinit$/ } @ARGV; + +if(-d "$pbl_dir/$loader") { + for (@todo) { + if(-x "$pbl_dir/$loader/$_") { + $exit_code = run_command("$pbl_dir/$loader/$_") || $exit_code; + } + else { + info(1, "$loader::$_ skipped"); + } + } +} +else { + exec "/usr/lib/bootloader/$program.old", @ARGV; + info(3, "/usr/lib/bootloader/$program.old: command not found"); + $exit_code = 1; +} + +exit $exit_code; +
