Hello community, here is the log from the commit of package perl-Bootloader for openSUSE:Factory checked in at 2015-03-29 20:17:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-02-13 08:34:06.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Bootloader.new/perl-Bootloader.changes 2015-03-29 20:17:08.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Mar 26 13:01:23 CET 2015 - [email protected] + +- remove unrelated comment +- add device scannning speed-ups done for sle11-sp3 (bnc #910479) +- 0.831 + +------------------------------------------------------------------- Old: ---- perl-Bootloader-0.830.tar.xz New: ---- perl-Bootloader-0.831.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Bootloader.spec ++++++ --- /var/tmp/diff_new_pack.BLupBH/_old 2015-03-29 20:17:09.000000000 +0200 +++ /var/tmp/diff_new_pack.BLupBH/_new 2015-03-29 20:17:09.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-Bootloader -Version: 0.830 +Version: 0.831 Release: 0 Requires: coreutils Requires: perl-base = %{perl_version} ++++++ perl-Bootloader-0.830.tar.xz -> perl-Bootloader-0.831.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.830/VERSION new/perl-Bootloader-0.831/VERSION --- old/perl-Bootloader-0.830/VERSION 2015-02-11 09:36:06.000000000 +0100 +++ new/perl-Bootloader-0.831/VERSION 2015-03-26 12:58:27.000000000 +0100 @@ -1 +1 @@ -0.830 +0.831 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.830/changelog new/perl-Bootloader-0.831/changelog --- old/perl-Bootloader-0.830/changelog 2015-02-11 09:36:06.000000000 +0100 +++ new/perl-Bootloader-0.831/changelog 2015-03-26 12:58:27.000000000 +0100 @@ -1,3 +1,7 @@ +2015-03-26: 0.831 + - remove unrelated comment + - add device scannning speed-ups done for sle11-sp3 (bnc #910479) + 2014-12-16: 0.830 - Initialize GRUB_USE_LINUXEFI from target setting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.830/src/FileIO.pm new/perl-Bootloader-0.831/src/FileIO.pm --- old/perl-Bootloader-0.830/src/FileIO.pm 2015-02-11 09:36:06.000000000 +0100 +++ new/perl-Bootloader-0.831/src/FileIO.pm 2015-03-26 12:58:27.000000000 +0100 @@ -16,10 +16,15 @@ C<< use Bootloader::FileIO; >> -C<< $files_ref = Bootloader::Core->ReadFiles(\@file_list); >> +C<< $files_ref = Bootloader::FileIO->ReadFiles(\@file_list); >> + +C<< $lines_ref = Bootloader::FileIO->ReadFile($file_name); >> -C<< $lines_ref = Bootloader::Core->ReadFile($file_name); >> +C<< $number = Bootloader::FileIO->ReadNumber($file_name); >> +C<< $lines_ref = Bootloader::FileIO->WriteFile($file, $lines); >> + +C<< $lines_ref = Bootloader::FileIO->WriteFileRaw($file, $data); >> =head1 DESCRIPTION @@ -90,6 +95,26 @@ =item +C<< $lines_ref = Bootloader::FileIO->ReadNumber($file_name); >> + +Reads a file and expects the first line to start with a number. + +=cut + +sub ReadNumber +{ + my $self = shift; + my $file = shift; + + open(my $fd, $file); + my $num = <$fd> + 0; + close $fd; + + return $num; +} + + +=item C<< $lines_ref = Bootloader::FileIO->WriteFile($file, $lines); >> Writes file to disk. @@ -112,7 +137,45 @@ if(open(my $fh, '>', $file)) { print $fh $l; - close $fh; + if(!close($fh)) { + $self->error("Failed to close $file: $!"); + $ok = 0; + } + } + else { + $self->error("Failed to open $file: $!"); + $ok = 0; + } + + umask $saved_umask; + + return $ok; +} + + +=item +C<< $lines_ref = Bootloader::FileIO->WriteFileRaw($file, $data); >> + +Writes file to disk. +Returns 1 on success, 0 otherwise. + +=cut + +sub WriteFileRaw +{ + my $self = shift; + my $file = shift; + my $data = shift; + my $ok = 1; + + my $saved_umask = umask 0066; + + if(open(my $fh, '>', $file)) { + print $fh $data; + if(!close($fh)) { + $self->error("Failed to close $file: $!"); + $ok = 0; + } } else { $self->error("Failed to open $file: $!"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/perl-Bootloader-0.830/src/Tools.pm new/perl-Bootloader-0.831/src/Tools.pm --- old/perl-Bootloader-0.830/src/Tools.pm 2015-02-11 09:36:06.000000000 +0100 +++ new/perl-Bootloader-0.831/src/Tools.pm 2015-03-26 12:58:27.000000000 +0100 @@ -162,91 +162,102 @@ =cut # FIXME: this has to be read through yast::storage -sub ReadPartitions { - my $udevmap = shift; - my $sb = "/sys/block"; - my $mounted = undef; - unless (-e $sb) { - $mounted = `mount /sys`; - $lib_ref->milestone("Mount /sys"); - } - opendir(BLOCK_DEVICES, "$sb") || - die ("ReadPartitions(): Failed to open dir $sb"); - - # get disk devices - my @disks = grep { - !m/^\./ && (( -r "$sb/$_/ext_range" and qx{ cat $sb/$_/ext_range } > 1) || ( -r "$sb/$_/range" and qx{ cat $sb/$_/range } > 1)) - } readdir(BLOCK_DEVICES); - closedir BLOCK_DEVICES; +sub ReadPartitions +{ + my $self = $lib_ref; + my $udevmap = shift; - $lib_ref->milestone("disks =", \@disks); + my $sb = Bootloader::Path::Prefix("/sys/block"); - # get partition info for all partitions on all @disks - my @devices = (); + # get partition info for all partitions on all @disks + my @devices = (); - # Add DM RAID Partitions to @devices - if (DMRaidAvailable()){ - my $dev_ref = ReadDMRaidPartitions(); - push (@devices, @{$dev_ref}); + my @disks; - } + if (! -e $sb) { + $self->error("/sys not mounted"); - foreach my $disk (@disks) - { - my $dev_disk = "/dev/$disk"; - if (!IsDMDevice($dev_disk) && !IsDMRaidSlave($dev_disk)){ - # get partitions of $disk - opendir(BLOCK_DEVICES, "$sb/$disk") || - die ("ReadPartitions(): Failed to open dir $sb/$disk"); - - my @parts = grep { - !m/^\./ and -d "$sb/$disk/$_" and -f "$sb/$disk/$_/dev" - } readdir (BLOCK_DEVICES); - closedir BLOCK_DEVICES; - - $lib_ref->milestone("partitions =", \@parts); - - # generate proper device names and other info for all @part[ition]s - #raid have ! in names for /dev/raid/name (bnc#607852) - $dev_disk =~ s:!:/:; - foreach my $part (@parts) - { - chomp ($part); - $part = "/dev/$part"; - #raid have ! in names for /dev/raid/name - $part =~ s:!:/:; - $part = $udevmap->{$part} if (defined $udevmap->{$part}); - - my $index = substr ($part, length ($dev_disk)); - while (length ($index) > 0 && substr ($index, 0, 1) !~ /[0-9]/) - { - $index = substr ($index, 1); - } - # The @devices array will contain the following members: - # - # index type value (example) - # - # 0 device /dev/sda9 - # 1 disk /dev/sda - # 2 nr 9 - # 3 fsid 258 (not needed for update) - # 4 fstype Apple_HFS(not needed for update) - # 5 part_type `primary(not needed for update) - # 6 start_cyl 0(not needed for update) - # 7 size_cyl 18237(not needed for update) + return \@devices; + } - push @devices, [$part, $dev_disk, $index, 0, "", "","",""]; - } - } + # get disk devices + if(opendir(my $dh, $sb)) { + @disks = grep { + !/^\./ && + ($self->ReadNumber("$sb/$_/ext_range") > 1 || $self->ReadNumber("$sb/$_/range") > 1) + } readdir($dh); + + closedir $dh; + } + else { + $self->error("Failed to open $sb"); + + return \@devices; + } + + $self->milestone("disks =", \@disks); + + # add DM RAID partitions to @devices + my $dm_devs = ReadDMRaidPartitions(); + push @devices, @$dm_devs if defined $dm_devs; + + for my $disk (@disks) { + next if IsDMDevice($disk) || IsDMRaidSlave($disk); + + my $dev_disk = "/dev/$disk"; + # raids have ! in names for /dev/raid/name (bnc #607852) + $dev_disk =~ s#!#/#; + + my @parts; + + # get partitions of $disk + if(opendir(my $dh, "$sb/$disk")) { + @parts = grep { + !/^\./ && + -f "$sb/$disk/$_/dev" + } readdir($dh); + + closedir $dh; } + else { + $self->error("Failed to open $sb/$disk"); - if (defined $mounted){ - $mounted = `unmount /sys`; + next; } - return \@devices; + $lib_ref->milestone("partitions =", \@parts); + + # generate proper device names and other info for all @part[ition]s + for my $part (@parts) { + $part = "/dev/$part"; + # raids have ! in names for /dev/raid/name (bnc #607852) + $part =~ s#!#/#; + + $part = $udevmap->{$part} if defined $udevmap->{$part}; + + my $index = $part =~ /(\d+)$/ ? $1 : 0; + + # The @devices array will contain the following members: + # + # index type value (example) + # + # 0 device /dev/sda9 + # 1 disk /dev/sda + # 2 nr 9 + # 3 fsid 258 (obsolete) + # 4 fstype Apple_HFS (obsolete) + # 5 part_type `primary (obsolete) + # 6 start_cyl 0 (obsolete) + # 7 size_cyl 18237 (obsolete) + + push @devices, [ $part, $dev_disk, $index, 0, "", "", "", "" ]; + } + } + + return \@devices; } + =item C<< Bootloader::Tools::GetMultipath (); >> @@ -401,31 +412,40 @@ DMRaid Partitions look like: <strange name>_part\d - =cut -sub ReadDMRaidPartitions { +# FIXME: do such devices really exist? + +sub ReadDMRaidPartitions +{ + my $self = $lib_ref; + + return undef if !DMRaidAvailable(); - my @dmdisks = (); - my @dmparts = (); + my @dmdisks = (); + my @dmparts = (); + my $dmdev; - open(DMDEV, "$dmsetup info -c --noheadings -o name |") || - die ("ReadDMRaidPartitions(): dmsetup failed."); + if(!open(DMDEV, "$dmsetup info -c --noheadings -o name |")) { + $self->error("dmsetup failed"); + + return undef; + } while (<DMDEV>) { - my $dmdev = $_; + $dmdev = $_; chomp($dmdev); #FIXME: I should not need to do this twice if ($dmdev !~ m/part/) { - $lib_ref->milestone("Find raid partition $dmdev"); + $self->milestone("found raid disk $dmdev"); # $dmdev is the base device $dmdev = "/dev/mapper/" . $dmdev; push @dmdisks, $dmdev; } #FIXME: need to check what needs to be removed else { - $lib_ref->milestone("Find raid disk $dmdev"); + $self->milestone("found raid part $dmdev"); $dmdev = "/dev/mapper/" . $dmdev; push @dmparts, $dmdev; } @@ -433,17 +453,25 @@ close DMDEV; my @devices = (); + my $dmpart; + my $tmp_part; - foreach my $dmdev (@dmdisks) { - foreach my $dmpart (@dmparts) { + foreach $dmdev (@dmdisks) { + foreach $dmpart (@dmparts) { if ($dmpart =~ m/$dmdev/) { - $dmpart =~ m/^($dmdev)_part(\d+)$/; - push @devices, [$dmpart, $dmdev, $2]; + my $index = substr ($dmpart, length($dmpart)-2,2); + + while (length ($index) > 0 && substr ($index, 0, 1) !~ /[0-9]/) { + $index = substr ($index, 1); + } + push @devices, [$dmpart, $dmdev, $index]; } } } - return \@devices; + $self->milestone("dmraid partitions = ", \@devices); + + return \@devices; } =item @@ -453,15 +481,23 @@ =cut -sub ReadDMRaidDisks { +# FIXME: seems to be unused + +sub ReadDMRaidDisks +{ + my $self = $lib_ref; + + return undef if !DMRaidAvailable(); - my @dmdisks = (); - my @dmparts = (); - my $dmdev; + my @dmdisks = (); + my @dmparts = (); + my $dmdev; + if(!open(DMDEV, "$dmsetup info -c --noheadings -oname |")) { + $self->error("dmsetup failed"); - open(DMDEV, "$dmsetup info -c --noheadings -oname |") || - die ("ReadDMRaidDisks(): dmsetup failed."); + return undef; + } while(<DMDEV>){ $dmdev = $_; @@ -473,7 +509,10 @@ push @dmdisks, $dmdev; } } - return \@dmdisks; + + $self->milestone("dmraid disks = ", \@dmdisks); + + return \@dmdisks; } =item @@ -484,42 +523,26 @@ =cut -sub IsDMRaidSlave { - my $disk = shift; +sub IsDMRaidSlave +{ + my $self = $lib_ref; + my $dev = shift; - unless ( DMRaidAvailable() and -e $dmsetup) { - return 0; - } + my $r = $self->{cache}{IsDMRaidSlave}{$dev}; - my $majmin_disk = `stat -c "%t:%T" $disk`; - chomp($majmin_disk); - my @dmparts = (); - - - my @dm_devs = qx{$dmsetup info -c --noheadings -o name | grep -v part}; - chomp @dm_devs; - - if ($dm_devs[0] !~ /No devices found/) { - foreach my $dmdisk (@dm_devs) { - my @tables = qx{$dmsetup table '$dmdisk'}; - chomp @tables; - - foreach my $line (@tables) { - next if $line !~ /mirror/; - my @content = split(/ /, $line); - - foreach my $majmins (@content){ - if ($majmins =~ m/(\d+):(\d+)/) { - if ("$majmins" eq "$majmin_disk") { - return 1; - } - } - } - } - } - } + if(defined $r) { + $self->debug("IsDMRaidSlave($dev) (cached) = $r"); + + return $r; + } + + my @d = glob Bootloader::Path::Prefix("/sys/block/$dev/holders/*"); - return 0; + $r = @d && -d $d[0] ? 1 : 0; + + $self->milestone("IsDMRaidSlave($dev) = $r"); + + return $self->{cache}{IsDMRaidSlave}{$dev} = $r; } =item @@ -530,22 +553,24 @@ =cut -sub IsDMDevice { - my $dev = shift; +sub IsDMDevice +{ + my $self = $lib_ref; + my $dev = shift; + + my $r = $self->{cache}{IsDMDevice}{$dev}; - unless ( DMRaidAvailable() and -e $dmsetup) { - return 0; - } + if(defined $r) { + $self->debug("IsDMDevice($dev) (cached) = $r"); - my $cmd = "$dmsetup info -c --noheadings -oname '$dev'"; - if (my $test = qx{$cmd 2>/dev/null}){ - chomp $test; + return $r; + } - if ($dev =~ m/$test/){ - return 1; - } - } - return 0; + $r = -f Bootloader::Path::Prefix("/sys/block/$dev/dm/name") ? 1 : 0; + + $self->milestone("IsDMDevice($dev) = $r"); + + return $self->{cache}{IsDMDevice}{$dev} = $r; } =item -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
