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

Loading…
Cancel
Save