SHA256
1
0
forked from pool/elilo
OBS User unknown 2008-10-27 22:57:25 +00:00 committed by Git OBS Bridge
parent 90742f4604
commit c5cde82155
3 changed files with 126 additions and 36 deletions

View File

@ -1,7 +1,15 @@
-------------------------------------------------------------------
Mon Oct 27 18:16:02 CET 2008 - rw@suse.de
- elilo.pl
* Mask 'relocatable' (unless supported). (bnc#438276)
* Remove old files from target directory. (bnc#398416)
-------------------------------------------------------------------
Fri Oct 17 08:52:44 CEST 2008 - olh@suse.de
- add ExclusiveArch ia64 x86 x86_64
- elilo.spec
* Add ExclusiveArch ia64 x86 x86_64
-------------------------------------------------------------------
Wed Jul 31 10:22:56 CEST 2008 - rw@suse.de

137
elilo.pl
View File

@ -1,21 +1,24 @@
#!/usr/bin/perl -w
# $Id: elilo.pl,v 0.14 2008/07/30 09:36:48 rw Exp $
# $Id: elilo.pl,v 0.16 2008/10/27 17:15:29 rw Exp $
use strict;
my $C = $0; $C =~ s%^.*/%%;
my $C = $0; $C =~ s{^.*/}{};
my $dbg = (exists( $ENV{"ELILO_DEBUG"})) ? $ENV{"ELILO_DEBUG"} : "";
my $Edition = q(@EDITION@);
my $Arch = q(@ARCH@);
my $LibD = q(@LIBEXECDIR@);
my $MPold = "$dbg/boot";
my $MPnew = "$dbg/boot/efi";
my $Dlibold = "$dbg@LIBEXECDIR@/elilo";
my $Dlib = "$dbg@LIBEXECDIR@/efi";
my $Dlibold = "$dbg$LibD/elilo";
my $Dlib = "$dbg$LibD/efi";
my $Fconf = "elilo.conf";
my $Sconf = "$dbg/etc/" . $Fconf;
my $Reserved = qr(^(efi-mountpoint|vendor-directory|elilo-origin))o;
my %Sconf = ();
my $keep = 0;
my $test = 0;
my $verbose = 0;
my $warn = 0;
@ -36,7 +39,7 @@ $| = 1;
$[ = 0;
sub Version() {
my $v = q($Revision: 0.14 $ );
my $v = q($Revision: 0.16 $ );
$v =~ s/^\$ Rev.*:\ ([0-9.]+)\ \$\ /$1/x;
$v .= " (part of elilo-$Edition)" if ( $Edition ne "\@EDITION\@" );
print "$C version $v\n";
@ -74,6 +77,7 @@ sub Transfer ($$) {
my( $out, $tmp, $c, @f, %f, $opt);
my $default_label = "";
my $default_loc;
my $image = "";
my @Out = ();
$out = "$dir/$Fconf";
$tmp = "$out.tmp";
@ -95,28 +99,55 @@ sub Transfer ($$) {
}
while ( <IN> ) {
next if ( m/$Reserved/xo );
if ( m%^\s*(?:image|initrd)\s*=\s*% ) {
if ( m{^\s*(?:image|initrd)\s*=\s*} ) {
chomp;
s%^(\s*(?:image|initrd)\s*=\s*)(/\S+/)?([^/\s]+)\s*$%$1$3%;
my( $t, $p, $f) = ($1, $2, $3);
s{^(\s*(image|initrd)\s*=\s*)(/\S+/)?([^/\s]+)\s*$}{$1$4};
my( $t, $p, $f) = ($2, $3, $4);
#Info( 0, "$C: $in: $.: t=$t p=$p f=$f\n");
$_ .= "\n";
if ( ! defined( $p) ) {
$p = "/boot/";
}
$image = "" if ( $t eq "image" );
if ( ! defined( $f) ) {
Warn( "$in: $.: invalid file-specification\n" .
">> $_");
$c++;
} elsif ( exists( $f{$f}) ) {
Info( 3, "$in: $.: file duplication skipped (previous: $f{$f})\n" .
">> $_");
} elsif ( $opt && ! -r "$dbg$p$f" ) {
Info( 0, "$C: $in: $.: missing optional '$p$f' skipped\n");
} elsif ( exists( $f{$f}) ) {
$image = $dbg . "$p$f" if ( $t eq "image" );
Info( 3, "$in: $.: file duplication skipped (previous: $f{$f})\n" .
">> $_");
} else {
$image = $dbg . "$p$f" if ( $t eq "image" );
push @f, $dbg . "$p$f";
$f{$f} = $.;
}
} elsif (m%^(\s*label\s*=\s*)(\S+)%) {
} elsif ( $image && m{^(\s*description\s*=\s*")([^"]+)(".*)$} ) {
my( $p, $d, $s) = ($1, $2, $3);
my $t = "";
if ( $d =~ m{\%L} ) {
if ( -l $image ) {
($t = readlink( $image)) =~ s{^vmlinuz-}{};
} else {
#($t = $image) =~ s{^.*vmlinux-}{};
$t = "no symlink";
}
Info( 2, " \%L => '$t'\n");
$d =~ s{\%L}{$t};
} elsif ( $d =~ m{\%G} ) {
my $cmd = "/sbin/get_kernel_version";
if ( -x $cmd ) {
chomp( $t = `$cmd $image`);
} else {
$t = "";
}
$d =~ s{\%G}{$t};
Info( 2, " \%G => '$t'\n");
}
$_ = $p . $d . $s . "\n";
} elsif (m{^(\s*label\s*=\s*)(\S+)}) {
my ($pre, $label) = ($1, $2);
if (exists $Labels{$label}) {
my $t = 1;
@ -129,11 +160,18 @@ sub Transfer ($$) {
$_ = $pre . $l . "\n";
}
$Labels{$label} = 1;
} elsif (m%^\s*default\s*=\s*(\S+)%) {
} elsif (m{^\s*default\s*=\s*(\S+)}) {
$default_label = $1;
$default_loc = $#Out + 1;
} elsif (m%^\s*read-only\s*$%) {
$_ = "#read-only # Deprecated! (May be forced by appending 'ro')\n";
} elsif (m{^\s*read-only\s*$}) {
$_ = "#read-only # Deprecated!" .
" (Add comment in '$Sconf' to overrule.)" .
"\n";
Info( 2, " $in: $.: deprecated 'read-only' ignored.\n");
} elsif (m{^\s*relocatable\s*$} && $Arch =~ m{86}) {
$_ = "#relocatable # Unsupported on this architecture!\n" .
"# (May be forced by adding a comment in '$Sconf'.)\n";
Info( 2, " $in: $.: unsupported 'relocatable' ignored.\n");
}
push @Out, $_;
}
@ -170,7 +208,6 @@ sub Transfer ($$) {
sub System($@) {
my( $fatal, @C) = @_;
my $cmd = $C[0];
my $rc = ($fatal) ? 1 : 0;
foreach my $c ( @C[1..$#C] ) {
if ( $c =~ /\s/ ) {
@ -184,12 +221,28 @@ sub System($@) {
system @C;
if ($? == -1) {
Panic( $rc, "$C[0]: failed to execute: $!\n");
Panic( $fatal, "$C[0]: failed to execute: $!\n");
} elsif ($? & 127) {
Panic( $rc, sprintf( "$C[0]: died with signal %d, %s coredump\n",
Panic( $fatal, sprintf( "$C[0]: died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without'));
} elsif ( $? >> 8 != 0 ) {
Panic( $rc, "$C[0]: failed\n");
Panic( $fatal, "$C[0]: failed\n");
}
}
sub Purge($) {
my( $d) = @_;
if ( $keep ) {
Info( 1, "## skip removal of old files from '$d'\n");
return 0;
}
Info( 1, "## remove old files from '$d'\n");
my @F = glob( "$d/*");
foreach my $f ( @F ) {
next if ( $f =~ m{.*/elilo.(conf|efi)$} );
Info( 1, "> rm $f\n");
next if ($test);
unlink( $f);
}
}
@ -250,24 +303,24 @@ sub InstallFPSWA($) {
sub isMP($) {
my ( $d) = @_;
Info( 3, "### isMP($d):\n");
foreach my $f ( ("/proc/mounts", "/etc/mtab") ) {
Info( 4, "#### looking in $f\n");
my @I = ("/proc/mounts", "/etc/mtab");
Info( 3, "### isMP($d):");
foreach my $f ( @I ) {
open( IN, "< $f") || next;
while ( <IN> ) {
chomp;
my @F = split;
if ( $F[1] eq $d ) {
Info( 3, "### found in '$f' line $. => true\n");
Info( 3, " found in '$f' line $. => true\n");
close( IN);
return( 1);
}
}
close( IN);
Info( 3, "### not found in $f => false\n");
Info( 3, " not found in '$f' => false\n");
return( 0);
}
Info( 3, "### no info available => false\n");
Info( 3, " not found in [" . join( ", ", @I) . "] => false\n");
return( 0);
}
@ -282,22 +335,36 @@ sub isMP($) {
pod2usage(2) unless ( GetOptions( \%Opt,
'help|h', 'man|m', 'version|V', 'verbose|v+',
'test|t', 'purge') && ! $Opt{'help'} );
'test|t', 'keep|k') && ! $Opt{'help'} );
Version() if ( $Opt{'version'} );
pod2usage(-exitstatus => 0, -verbose => 2) if ( $Opt{'man'} );
pod2usage(1) if ( $Opt{'help'} );
$test = 1 if ( $Opt{'test'} );
$keep = 1 if ( $Opt{'keep'} );
$verbose += $Opt{'verbose'} if ( $Opt{'verbose'} );
}
# try to read variables $Sconf
# run-time init
if ( $Arch =~ m{ARCH} ) {
chomp( $Arch = qx{uname -m});
Info( 3, "### Arch: '$Arch'\n");
}
if ( $Dlib =~ m{LIBEXECDIR} ) {
$Dlib = "$dbg/usr/lib" . (($Arch eq "x86_64") ? "64/" : "/");
$Dlibold = $Dlib . "elilo";
$Dlib = $Dlib . "efi";
$Dlib = $Dlibold if (! -r "$Dlib/elilo.efi" && -r "$Dlibold/elilo.efi");
Info( 3, "### Dlib: '$Dlib'\n");
}
# try to read variables from $Sconf
%Sconf = Parse( $Sconf);
# check environment
if ( exists( $Sconf{"efi-mountpoint"}) ) {
$MP = $dbg . $Sconf{"efi-mountpoint"};
Panic( 1, "EFI partions specification in $Sconf invalid.\n")
Panic( 2, "EFI partition specification in $Sconf invalid.\n")
unless ( -d $MP ); # or is it "$MP/efi"?
} elsif ( -d $MPnew . "/efi/" . $VD || isMP($MPnew) ) {
$MP = $MPnew;
@ -305,7 +372,7 @@ if ( exists( $Sconf{"efi-mountpoint"}) ) {
$MP = $MPold;
} else {
Info( 1, "## Neither new ($MPnew/efi/$VD) nor old ($MPold/efi/$VD)?\n");
Panic( 2, "EFI partiton not found.\n");
Panic( 2, "EFI partition not found.\n");
}
Info( 2, "## Mount-point '$MP'...\n");
if ( exists( $Sconf{"vendor-directory"}) ) {
@ -315,12 +382,15 @@ if ( exists( $Sconf{"vendor-directory"}) ) {
}
$D = $MP . "/efi/" . $VD;
Info( 1, "## Using '$D'...\n");
System( 1, "mkdir", "-p", $D) unless ( -d $D );
System( 2, "mkdir", "-p", $D) unless ( -d $D );
if ( -r $Sconf ) {
# extract kernels and initrds and write fixed .conf
my @F = Transfer( $Sconf, $D);
# remove old files
Purge( $D);
# copy stuff
Info( 1, "## copy new files to '$D'\n");
unshift @F, "$Dlib/elilo.efi";
foreach ( @F ) {
Install( 0, "-p", $_, $D);
@ -329,12 +399,14 @@ if ( -r $Sconf ) {
InstallFPSWA( $MP);
} elsif ( $MP eq $MPold && -r "$D/$Fconf" ) {
# assume old setup with only '/vmlinuz' and '/initrd'
Install( 1, "-p", "$Dlib/elilo.efi", $D);
Install( 2, "-p", "$Dlib/elilo.efi", $D);
InstallFPSWA( $MP);
} elsif ( $MP eq $MPold ) {
Panic( 2, "$D/$Fconf: not found\n");
} else {
} elsif ( ! -e $Sconf ) {
Panic( 2, "$Sconf: not found\n");
} else {
Panic( 2, "$Sconf: not readable\n");
}
if ( $warn > 0 ) {
@ -353,6 +425,7 @@ elilo - Installer for the EFI Linux Loader
/sbin/elilo [options]
Options:
-k --keep don't purge old files
-t --test test only
-v --verbose increase verbosity
-h --help brief help message

View File

@ -21,7 +21,7 @@
Name: elilo
Summary: EFI Linux Loader
Version: 3.8
Release: 22
Release: 23
ExclusiveArch: ia64 %ix86 x86_64
Group: System/Boot
AutoReqProv: on
@ -61,7 +61,9 @@ Authors:
%patch4 -p1
%patch5 -p1
perl -pe 's{\@EDITION\@}{%{version}-%{release}};
s{\@LIBEXECDIR\@}{%{_libexecdir}}' < %{SOURCE1} > elilo.pl &&
s{\@LIBEXECDIR\@}{%{_libexecdir}};
s{\@ARCH\@}{%{_target_cpu}};
' < %{SOURCE1} > elilo.pl &&
perl -pi -e 's{/usr/lib}{%{_libexecdir}}' Make.defaults
chmod 555 elilo.pl && touch -r %{SOURCE1} elilo.pl
! fgrep '%%{version}-%%{release}' elilo.pl
@ -78,6 +80,7 @@ install -m 444 elilo.efi $RPM_BUILD_ROOT%{_libexecdir}/efi
install tools/eliloalt $RPM_BUILD_ROOT/sbin
install -p -m 555 elilo.pl $RPM_BUILD_ROOT/sbin/elilo
%if 0
install -D -p elilo.5 $RPM_BUILD_ROOT/usr/share/man/man5/elilo.conf.5
install -D -p elilo.8 $RPM_BUILD_ROOT/usr/share/man/man8/elilo.8
%endif
@ -95,12 +98,18 @@ echo "Please run /sbin/elilo!"
/sbin/elilo
/sbin/eliloalt
%if 0
/usr/share/man/man5/*
/usr/share/man/man8/*
%endif
%changelog
* Mon Oct 27 2008 rw@suse.de
- elilo.pl
* Mask 'relocatable' (unless supported). (bnc#438276)
* Remove old files from target directory. (bnc#398416)
* Fri Oct 17 2008 olh@suse.de
- add ExclusiveArch ia64 x86 x86_64
- elilo.spec
* Add ExclusiveArch ia64 x86 x86_64
* Thu Jul 31 2008 rw@suse.de
- elilo.efi
* Update to final elilo-3.8 for uEFI support. (fate#301882)