Browse Source

This gets rid of the annoying perhaps you are not root for gdkbirdaao,

and only tests if root and using a method which has lilo .. default if
method hasn't been chosen.
master
freesource 23 years ago
parent
commit
16a076e283
  1. 110
      gbootroot

110
gbootroot

@ -3777,9 +3777,10 @@ sub initrd {
} # end sub initrd } # end sub initrd
# This was submitted by Cristian "cretzu." # This was submitted by Cristian "cretzu."
sub gdkbirdaao sub gdkbirdaao {
{
# Guess Default Kernel Boot Image Root Device And Append Options (gdbirdaao) # Guess Default Kernel Boot Image Root Device And Append Options
#(gdbirdaao)
# #
# We return a list with 3 elements: # We return a list with 3 elements:
# #
@ -3802,11 +3803,19 @@ sub gdkbirdaao
my $ret_root_dev = ''; my $ret_root_dev = '';
my $ret_append = ''; my $ret_append = '';
if (-e $lilo_conf and !-d $lilo_conf)
{ # enough of the annoying "perhaps you are not root"
# ofcourse this test is always ran assuming lilo is used.
if ( $> == 0 ) {
if ( !$container[METHOD] ||
$container[METHOD] eq "2 disk compression" ) {
if (-e $lilo_conf and !-d $lilo_conf) {
my @lilo_lines; my @lilo_lines;
open(LIL, $lilo_conf) or warn "*** $lilo_conf not found, perhaps because you are not root?"; open(LIL, $lilo_conf) or
warn "*** $lilo_conf not found\n";
@lilo_lines = <LIL>; @lilo_lines = <LIL>;
close(LIL); close(LIL);
chomp(@lilo_lines); chomp(@lilo_lines);
@ -3818,8 +3827,7 @@ sub gdkbirdaao
my $image_block_name = ''; my $image_block_name = '';
my $root_dev = ''; my $root_dev = '';
for (@lilo_lines) for (@lilo_lines) {
{
# ignore comment lines # ignore comment lines
next if m/^\s*[#]/; next if m/^\s*[#]/;
@ -3829,75 +3837,91 @@ sub gdkbirdaao
s/\s*=\s*/=/; s/\s*=\s*/=/;
# 'default=whatever' returns just a label # 'default=whatever' returns just a label
if (m/default=(.+)\s*/) if (m/default=(.+)\s*/) {
{
$default_label = $1; $default_label = $1;
} }
# start of a new 'image=<kernel path>' image block or similar # start of a new 'image=<kernel path>'
elsif (m/(image|other)=(.+)\s*/) # image block or similar
{ elsif (m/(image|other)=(.+)\s*/) {
$image_block_name = sprintf("%s%02d", $image_block_name =
sprintf("%s%02d",
$image_block_name_prefix, $image_block_name_prefix,
$image_block_no); $image_block_no);
$image_blocks{$image_block_name}{'kernel_image_path'} = $2; $image_blocks{$image_block_name}
$image_blocks{$image_block_name}{'root_device'} = $root_dev; {'kernel_image_path'} = $2;
$image_blocks{$image_block_name}
{'root_device'} = $root_dev;
$image_block_no += 1; $image_block_no += 1;
} }
# image block label # image block label
elsif (m/label=(.+)\s*/) elsif (m/label=(.+)\s*/) {
{ $image_blocks{$image_block_name}
$image_blocks{$image_block_name}{'block_label'} = $1; {'block_label'} = $1;
} }
# 'root=<root device>' # 'root=<root device>'
elsif (m#root=/dev/(.+)\s*#) elsif (m#root=/dev/(.+)\s*#) {
{
# inside an image block # inside an image block
if ($image_block_name and if ($image_block_name and
defined($image_blocks{$image_block_name}{'root_device'})) defined($image_blocks
{ {$image_block_name}
$image_blocks{$image_block_name}{'root_device'} = $1; {'root_device'})) {
$image_blocks{$image_block_name}
{'root_device'} = $1;
} }
# loose # loose
else else {
{
$root_dev = $1 if !$root_dev; $root_dev = $1 if !$root_dev;
} }
} }
elsif (m#append=\"(.+)\"#) elsif (m#append=\"(.+)\"#) {
{ $image_blocks{$image_block_name}
$image_blocks{$image_block_name}{'append'} = $1; {'append'} = $1;
} }
else else {
{
# Ignore everything else # Ignore everything else
} }
} }
# we'll now find the kernel image and root device # we'll now find the kernel image and root device
foreach $image_block_name (sort keys %image_blocks) foreach $image_block_name (sort keys %image_blocks) {
{ # Assume there's no specified default label;
# Assume there's no specified default label; take the first # take the first
$ret_root_dev = $image_blocks{$image_block_name}{'root_device'} $ret_root_dev =
$image_blocks{$image_block_name}{'root_device'}
if !$ret_root_dev; if !$ret_root_dev;
$ret_image_path = $image_blocks{$image_block_name}{'kernel_image_path'} $ret_image_path =
$image_blocks{$image_block_name}
{'kernel_image_path'}
if !$ret_image_path; if !$ret_image_path;
$ret_append = $image_blocks{$image_block_name}{'append'} $ret_append =
$image_blocks{$image_block_name}{'append'}
if !$ret_append; if !$ret_append;
# do we have a default kernel? # do we have a default kernel?
if (defined $image_blocks{$image_block_name}{'block_label'}) { if (defined $image_blocks{$image_block_name}
if ($image_blocks{$image_block_name}{'block_label'} eq $default_label) {'block_label'}) {
{ if ($image_blocks{$image_block_name}
{'block_label'} eq $default_label) {
# Found the block match for the default label # Found the block match for the default label
$ret_root_dev = $image_blocks{$image_block_name}{'root_device'}; $ret_root_dev =
$ret_image_path = $image_blocks{$image_block_name}{'kernel_image_path'}; $image_blocks{$image_block_name}
$ret_append = $image_blocks{$image_block_name}{'append'}; {'root_device'};
$ret_image_path =
$image_blocks{$image_block_name}
{'kernel_image_path'};
$ret_append = $image_blocks
{$image_block_name}{'append'};
last; last;
} }
} }
} }
} }
} # if METHOD eq 2 disk compression
} # if not root
# and some a small portion of paranoia # and some a small portion of paranoia
$ret_root_dev = 'hda1' if !$ret_root_dev; $ret_root_dev = 'hda1' if !$ret_root_dev;

Loading…
Cancel
Save