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 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 Wed Jul 31 10:22:56 CEST 2008 - rw@suse.de

137
elilo.pl
View File

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

View File

@ -21,7 +21,7 @@
Name: elilo Name: elilo
Summary: EFI Linux Loader Summary: EFI Linux Loader
Version: 3.8 Version: 3.8
Release: 22 Release: 23
ExclusiveArch: ia64 %ix86 x86_64 ExclusiveArch: ia64 %ix86 x86_64
Group: System/Boot Group: System/Boot
AutoReqProv: on AutoReqProv: on
@ -61,7 +61,9 @@ Authors:
%patch4 -p1 %patch4 -p1
%patch5 -p1 %patch5 -p1
perl -pe 's{\@EDITION\@}{%{version}-%{release}}; 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 perl -pi -e 's{/usr/lib}{%{_libexecdir}}' Make.defaults
chmod 555 elilo.pl && touch -r %{SOURCE1} elilo.pl chmod 555 elilo.pl && touch -r %{SOURCE1} elilo.pl
! fgrep '%%{version}-%%{release}' 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 tools/eliloalt $RPM_BUILD_ROOT/sbin
install -p -m 555 elilo.pl $RPM_BUILD_ROOT/sbin/elilo install -p -m 555 elilo.pl $RPM_BUILD_ROOT/sbin/elilo
%if 0 %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 install -D -p elilo.8 $RPM_BUILD_ROOT/usr/share/man/man8/elilo.8
%endif %endif
@ -95,12 +98,18 @@ echo "Please run /sbin/elilo!"
/sbin/elilo /sbin/elilo
/sbin/eliloalt /sbin/eliloalt
%if 0 %if 0
/usr/share/man/man5/*
/usr/share/man/man8/* /usr/share/man/man8/*
%endif %endif
%changelog %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 * 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 * Thu Jul 31 2008 rw@suse.de
- elilo.efi - elilo.efi
* Update to final elilo-3.8 for uEFI support. (fate#301882) * Update to final elilo-3.8 for uEFI support. (fate#301882)