Hello community, here is the log from the commit of package perl-Bootloader for openSUSE:Factory checked in at 2013-10-30 15:48:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2013-10-17 17:43:24.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Bootloader.new/perl-Bootloader.changes 2013-10-30 15:48:30.000000000 +0100 @@ -1,0 +2,7 @@ +Tue Oct 29 15:13:22 CET 2013 - snw...@suse.de + +- add pbl-yaml: a command line interface to perl-Bootloader using YAML files + for input and output +- 0.800 + +------------------------------------------------------------------- Old: ---- perl-Bootloader-0.711.tar.xz New: ---- perl-Bootloader-0.800.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Bootloader.spec ++++++ --- /var/tmp/diff_new_pack.U34GMd/_old 2013-10-30 15:48:31.000000000 +0100 +++ /var/tmp/diff_new_pack.U34GMd/_new 2013-10-30 15:48:31.000000000 +0100 @@ -17,7 +17,7 @@ Name: perl-Bootloader -Version: 0.711 +Version: 0.800 Release: 0 Requires: coreutils Requires: e2fsprogs @@ -44,6 +44,16 @@ Alexander Osthof <aost...@suse.de> Josef Reidinger <jreidin...@suse.cz> +%package YAML +Requires: %{name} = %{version} +Requires: perl-YAML-LibYAML +Summary: YAML interface for perl-Bootloader +Group: System/Boot + +%description YAML +A command line interface to perl-Bootloader using YAML files for input and output. + + %prep %setup -q @@ -100,4 +110,8 @@ %dir %attr(0700,root,root) /var/log/YaST2 %ghost %attr(0600,root,root) /var/log/pbl.log +%files YAML +%defattr(-, root, root) +%{_sbindir}/pbl-yaml + %changelog ++++++ perl-Bootloader-0.711.tar.xz -> perl-Bootloader-0.800.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/Makefile new/perl-Bootloader-0.800/Makefile --- old/perl-Bootloader-0.711/Makefile 2013-10-02 14:22:43.000000000 +0200 +++ new/perl-Bootloader-0.800/Makefile 2013-10-29 14:26:23.000000000 +0100 @@ -41,8 +41,9 @@ touch Makefile.PL ; \ perl -Ilib -MExtUtils::MakeMaker -e 'WriteMakefile (NAME => "Bootloader", VERSION_FROM => "lib/Bootloader/Library.pm" )' ; \ make install_vendor - @mkdir -p $(DESTDIR)/sbin + @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 -d -m 755 $(DESTDIR)/boot diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/pbl-yaml new/perl-Bootloader-0.800/pbl-yaml --- old/perl-Bootloader-0.711/pbl-yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.800/pbl-yaml 2013-10-29 14:38:13.000000000 +0100 @@ -0,0 +1,225 @@ +#! /usr/bin/perl + +use strict; +use Getopt::Long; +use Data::Dumper; + +# There are various YAML implementations for perl. These are the main +# options: +# +# YAML: has problems parsing its own data +# YAML::Tiny: has huge problems parsing its own data +# YAML::Syck: works, doesn't make a difference between '1' and 1 +# YAML::XS: works, makes strings utf8 when reading data +use YAML::XS; + +use Bootloader::Tools; +# Explicitly load all loader specific modules as Bootloader::Library +# normally loads them depending on loader type but we don't know in advance +# what objects show up in our YAML input data. +# +eval "use Bootloader::Core::$_" for qw ( ELILO GRUB GRUB2 GRUB2EFI LILO NONE PowerLILO ZIPL ); + +sub Usage; +sub ReadYAML; +sub WriteYAML; + +# we need something to log to until we have the real state setup +my $logger = Bootloader::Library->new(); + +# the current state +my $pbl_state; + +my $opt_state_in; +my $opt_state_out; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# parse arguments + +Usage 0 if @ARGV == 0; + +GetOptions( + 'state-in=s' => \$opt_state_in, + 'state-out=s' => \$opt_state_out, + 'state=s' => sub { $opt_state_out = $opt_state_in = $_[1] }, + 'version' => sub { print "$Bootloader::Library::VERSION\n"; exit 0 }, + 'help' => sub { Usage 0 }, +) || Usage 1; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# read existing state, if any + +if($opt_state_in) { + $pbl_state = ReadYAML($opt_state_in, 1); + if($pbl_state) { + # increment session id + $pbl_state->{session_id} =~ s/\.(\d+)$/.${\($1+1)}/; + # restart log + $pbl_state->StartLog(); + } +} + +# if we didn't get a saved state, start with a fresh one +$pbl_state = $logger if !defined $pbl_state; + +# use normal logging function +$logger = $pbl_state; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# process all commands +# command format: 'foo=Func(bar)' (no spaces!) +# foo and bar are optional + +for my $cmd (@ARGV) { + if($cmd =~ /^(([^=]+)=)?([\w]+)\(([^()]*)\)$/) { + my $res_file = $2; + my $func = $3; + my $arg_file = $4; + my $multi = $arg_file =~ s/^@//; + + my @args; + if($arg_file ne "") { + my $args = ReadYAML($arg_file); + if($multi && ref($args) eq 'ARRAY') { + @args = @$args; + } + else { + @args = ($args); + } + } + + my $res; + + if(exists $Bootloader::Tools::{$func}) { + # InitLibrary() is a bit special, as it creates the state + if($func eq 'InitLibrary') { + $res = Bootloader::Tools::InitLibrary($pbl_state); + } + else { + Bootloader::Tools::SetState($pbl_state); + eval "\$res = Bootloader::Tools::$func(\@args)"; + } + } + elsif(exists $Bootloader::Library::{$func}) { + $res = $pbl_state->$func(@args); + } + else { + $logger->error("$func: no such function"); + } + + WriteYAML($res_file, $res) if $res_file ne ""; + } + else { + $logger->error("$cmd: invalid command format"); + } +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# store final state + +WriteYAML($opt_state_out, $pbl_state) if $opt_state_out; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +sub Usage +{ + my $err = $_[0]; + + if($err) { + print STDERR "Try 'pbl-yaml --help' for more information.\n"; + + exit $err; + } + + print <<" usage"; +Usage: pbl-yaml [OPTIONS] COMMANDS +perl-Bootloader library call wrapper using YAML files for arguments. + +Options: + --state-in FILE Read perl-Bootloader state from FILE. + If it can't be read, a new state is created. + --state-out FILE Store final perl-Bootloader state in FILE. + --state FILE Use FILE for reading and storing the state. + --version Print perl-Bootloader version. + --help Write this help text. + +Commands: + + COMMANDS have the form 'RESULT=FUNCTION(ARGUMENT) or RESULT=FUNCTION(\@ARGUMENTS)'. + + ARGUMENT is a YAML file containing a single argument. ARGUMENTS is a YAML + file containing an array of arguments. The return value of FUNCTION will + be stored in RESULT. RESULT and ARGUMENT are optional. + + FUNCTION is a function from either Bootloader::Tools or Bootloader::Library. + +Examples: + + pbl-yaml --state foo1 'InitLibrary()' 'bar=ReadSettings()' + pbl-yaml --state foo2 'x1=GetDeviceMapping()' 'x2=ReadMountPoints(x1)' 'x3=ReadPartitions(x1)' + +Note: + + Logging is done via perl-Bootloader. That means it ends up in + /var/log/pbl.log or on STDERR if that file is not writable. + + usage + + exit $err; +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Read data from file. +# +sub ReadYAML +{ + my $file = $_[0]; + my $warn_only = $_[1]; + + my $x; + + if(open my $f, "<", $file) { + local $/; + $_ = <$f>; + close $f; + $x = YAML::XS::Load($_); + } + + if(!defined $x) { + if($warn_only) { + $logger->milestone("$file: no YAML data"); + } + else { + $logger->error("$file: no YAML data"); + } + } + + return $x; +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Write data to file. +# +sub WriteYAML +{ + my $file = $_[0]; + my $data = $_[1]; + + my $x = YAML::XS::Dump($data); + + if(defined $x && open my $f, ">", $file) { + print $f $x; + close $f; + } + else { + $logger->error("$file: failed to write YAML data"); + } +} + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/perl-Bootloader.changes new/perl-Bootloader-0.800/perl-Bootloader.changes --- old/perl-Bootloader-0.711/perl-Bootloader.changes 2013-10-15 13:10:14.000000000 +0200 +++ new/perl-Bootloader-0.800/perl-Bootloader.changes 2013-10-29 15:14:25.000000000 +0100 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Oct 29 15:13:22 CET 2013 - snw...@suse.de + +- add pbl-yaml: a command line interface to perl-Bootloader using YAML files + for input and output +- 0.800 + +------------------------------------------------------------------- Tue Oct 15 13:09:05 CEST 2013 - snw...@suse.de - more flexible GetProduct() uses /etc/os-release (bnc #845606) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/perl-Bootloader.spec.in new/perl-Bootloader-0.800/perl-Bootloader.spec.in --- old/perl-Bootloader-0.711/perl-Bootloader.spec.in 2013-10-02 14:22:43.000000000 +0200 +++ new/perl-Bootloader-0.800/perl-Bootloader.spec.in 2013-10-29 15:12:34.000000000 +0100 @@ -39,6 +39,15 @@ Alexander Osthof <aost...@suse.de> Josef Reidinger <jreidin...@suse.cz> +%package YAML +Requires: perl-YAML-LibYAML +Requires: %{name} = %{version} +Summary: YAML interface for perl-Bootloader + +%description YAML +A command line interface to perl-Bootloader using YAML files for input and output. + + %prep %setup -q @@ -95,4 +104,8 @@ %dir %attr(0700,root,root) /var/log/YaST2 %ghost %attr(0600,root,root) /var/log/pbl.log -%changelog -n perl-Bootloader +%files YAML +%defattr(-, root, root) +%{_sbindir}/pbl-yaml + +%changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/src/Library.pm new/perl-Bootloader-0.800/src/Library.pm --- old/perl-Bootloader-0.711/src/Library.pm 2013-10-02 14:22:43.000000000 +0200 +++ new/perl-Bootloader-0.800/src/Library.pm 2013-10-29 11:35:11.000000000 +0100 @@ -121,6 +121,9 @@ elsif($c1 eq 'update-bootloader') { $name = 'pbl'; } + elsif($c1 eq 'pbl-yaml') { + $name = 'pbl-yaml'; + } elsif($c0 eq 'Bootloader::Tools') { $name = 'libpbl'; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/src/Logger.pm new/perl-Bootloader-0.800/src/Logger.pm --- old/perl-Bootloader-0.711/src/Logger.pm 2013-10-02 14:22:43.000000000 +0200 +++ new/perl-Bootloader-0.800/src/Logger.pm 2013-10-18 11:07:28.000000000 +0200 @@ -57,8 +57,12 @@ { my $self = shift; + delete $self->{logger}{log_fh}; + delete $self->{logger}{log_fh_old}; + delete $self->{logger}{log_fh_yast}; + delete $self->{logger}{log_is_stderr}; + $self->{logger}{session_id} = $self->{session_id}; - $self->{logger}{logs} = []; $self->{logger}{log_level} = $ENV{Y2DEBUG} ? 0 : 1; $self->{logger}{yast_prefix} = ((uname())[1] || "unknown") . "($$) [pbl]"; @@ -123,10 +127,7 @@ { my $self = shift; - my $ret = $self->{logger}{logs}; - $self->{logger}{logs} = []; - - return $ret; + return []; } @@ -176,15 +177,6 @@ $message .= "\n$x"; } - # don't keep logs if we can log to y2log directly - if(!$self->{logger}{log_fh_yast}) { - push @{$self->{logger}{logs}}, { - message => $message, - prefix => $prefix, - level => $level_name, - }; - } - if($self->{logger}{log_fh}) { print { $self->{logger}{log_fh} } "$prefix $message\n"; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/src/Tools.pm new/perl-Bootloader-0.800/src/Tools.pm --- old/perl-Bootloader-0.711/src/Tools.pm 2013-10-02 14:22:44.000000000 +0200 +++ new/perl-Bootloader-0.800/src/Tools.pm 2013-10-18 11:26:52.000000000 +0200 @@ -750,11 +750,13 @@ initializes the bootloader configuration library. Fills its internal structures needed for it to run properly. +Optionally takes an existing library state as argument. + =cut sub InitLibrary { - $lib_ref = Bootloader::Library->new(); + $lib_ref = shift // Bootloader::Library->new(); my $um = GetDeviceMapping(); my $mp = ReadMountPoints($um); @@ -779,6 +781,12 @@ } +sub SetState +{ + $lib_ref = shift; +} + + # internal: does section match with set of tags sub match_section { my ($sect_ref, $opt_ref,) = @_; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/version new/perl-Bootloader-0.800/version --- old/perl-Bootloader-0.711/version 2013-10-15 13:08:34.000000000 +0200 +++ new/perl-Bootloader-0.800/version 2013-10-29 15:13:14.000000000 +0100 @@ -1 +1 @@ -0.711 +0.800 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.711/yaml-demo new/perl-Bootloader-0.800/yaml-demo --- old/perl-Bootloader-0.711/yaml-demo 1970-01-01 01:00:00.000000000 +0100 +++ new/perl-Bootloader-0.800/yaml-demo 2013-10-29 11:11:19.000000000 +0100 @@ -0,0 +1,9 @@ +#! /bin/sh + +rm -f foo x? + +./pbl-yaml --state foo 'x1=GetBootloader()' +./pbl-yaml --state foo 'SetLoaderType(x1a)' +./pbl-yaml --state foo 'x2=GetDeviceMapping()' +./pbl-yaml --state foo 'x3=ReadPartitions(x2)' +./pbl-yaml --state foo 'x4=DefinePartitions(x3)' -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org