Browse Source

orrected bugs in sub norm_root_device

master
cretzu 25 years ago
parent
commit
fa082738aa
  1. 193
      gBootRoot

193
gBootRoot

@ -33,31 +33,40 @@ init Gtk;
# If you want gBootRoot to do it's stuff somewhere else, change the
# value for $tmp1.
my $tmp1 = "/tmp"; # tmp should be default - Cristian
my $tmp1 = "/tmp"; # tmp should be default - Cristian
my $lilo_conf = "/etc/lilo.conf";
# CHANGES
# 1.0.3 - 08.09.2000
# * Tmp and mnt are now created on the fly,
# along with a new error function for mkdir(),
# Gtk clean-up for this, and clean-up by signal handler
# which should please Perlish and helpful Cristian.
# 1.0.3a - 08.23.2000
# * corrected bugs in norm_root_device (returned always 'hda1')
# a) now closes LIL
# b) chomps all lines in one go
# c) the 'default' value is just a label, not a dev
# d) sane regexp magic
# e) "there's one more bug(tm)": does not cope with multiple
# root device occurences (which might be present in each
# 'image=' block
# 1.0.3 - 08.09.2000
# * Tmp and mnt are now created on the fly,
# along with a new error function for mkdir(),
# Gtk clean-up for this, and clean-up by signal handler
# which should please Perlish and helpful Cristian.
#
# 1.0.2 - 08.06.2000
# * Changed logic slightly in submit() with returns rather
# than a scalar to resolve a minor bug caused by some
# changes in the previous version.
# 1.0.2 - 08.06.2000
# * Changed logic slightly in submit() with returns rather
# than a scalar to resolve a minor bug caused by some
# changes in the previous version.
#
# 1.0.1 - 08.05.2000
# * Zas provided a correction for a Perl 5.6 error complaint.
# * Zas found some unecessary GDK lines causing some Gtk
# warnings; these were commented out.
# * Cristian Ionescu-Idbohrn found a bug caused by putting
# the Kernel or RootImage below the mount point. An error
# check and error dialog were added.
# 1.0.1 - 08.05.2000
# * Zas provided a correction for a Perl 5.6 error complaint.
# * Zas found some unecessary GDK lines causing some Gtk
# warnings; these were commented out.
# * Cristian Ionescu-Idbohrn found a bug caused by putting
# the Kernel or RootImage below the mount point. An error
# check and error dialog were added.
#
# 1.0.0 - 08.02.2000
# * First public release
# 1.0.0 - 08.02.2000
# * First public release
#
#######################################################################
@ -92,9 +101,9 @@ my $norm_root_device;
# My own creation - the roots touch the ground if three lines are added.
my @xpm_data = (
"32 45 3 1",
" c None",
". c SaddleBrown",
"X c black",
" c None",
". c SaddleBrown",
"X c black",
" ... ... ",
" ... ... ",
" ... ... ",
@ -347,27 +356,32 @@ sub signal {
# Cristian's idea - bug 111579 enh for brlilo
sub norm_root_device {
if (!-d $lilo_conf) {
if (-e $lilo_conf) {
my $root_dev = 'hda1';
if (!-d $lilo_conf) {
if (-e $lilo_conf) {
open(LIL, $lilo_conf);
my @lilo_lines = <LIL>;
for (@lilo_lines) {
if ( m<^\s*[^#]+\s*default\s*=\s*/dev/([\w\d]+)\s*.*$> ) {
chomp, return $1;
}
}
for (@lilo_lines) {
if ( m<^\s*[^#]+\s*root\s*=\s*/dev/([\w\d]+)\s*.*$> ) {
chomp, return $1;
}
close(LIL);
chomp(@lilo_lines);
for (@lilo_lines) {
next if m/^\s*[#]/;
if (m#\s*root\s*=\s*/dev/(.+)\s*#) {
$root_dev = $1;
last;
}
}
}
}
}
}
open(VFN, ">> $verbosefn") or die "Oops! Can't open $verbosefn,";
print VFN "Root device found: $root_dev\n";
close(VFN);
return "hda1";
return $root_dev;
}
} # end sub norm_root_device
sub create_text {
@ -434,9 +448,9 @@ sub create_text {
$button->show();
}
if (!visible $text_window) {
show $text_window;
show $text_window;
} else {
destroy $text_window;
destroy $text_window;
}
} # end sub create_text
@ -457,16 +471,16 @@ sub fileselect {
if (not defined $file_dialog) {
# Create a new file selection widget
$file_dialog = new Gtk::FileSelection( "$name" );
$file_dialog->signal_connect( "destroy",
$file_dialog = new Gtk::FileSelection( "$name" );
$file_dialog->signal_connect( "destroy",
\&destroy_window, \$file_dialog);
$file_dialog->signal_connect( "delete_event",
$file_dialog->signal_connect( "delete_event",
\&destroy_window, \$file_dialog);
# Connect the ok_button to file_ok_sel function
$file_dialog->ok_button->signal_connect( "clicked",
\&file_ok_sel,
$file_dialog,$ent,$order);
$file_dialog->ok_button->signal_connect( "clicked",
\&file_ok_sel,
$file_dialog,$ent,$order);
# Connect the cancel_button to destroy the widget
$file_dialog->cancel_button->signal_connect( "clicked",
@ -496,8 +510,8 @@ sub file_ok_sel {
# auto-detect compression if system has file
if ($container[2]) {
my $file = system "which file > /dev/null 2>&1";
if ($file == 0) {
open(F,"file $container[2]|"); # no error check here
if ($file == 0) {
open(F,"file $container[2]|"); # no error check here
while (<F>) {
if (/gzip/) {
$gz_toggle->set_active( $true );
@ -555,7 +569,7 @@ sub entry {
if (defined $num) {
my $todo;
if ($num == 1) {
$todo = "the Kernel";
$todo = "the Kernel";
}
elsif ($num == 2) {
$todo = "the Compressed Filesystem";
@ -656,7 +670,7 @@ elsif (defined $container[0] && defined $container[1]
return;
}
if (defined $container[4]) {
$size = $container[4];
$size = $container[4];
}
# pretty unlikely
@ -678,19 +692,19 @@ elsif (defined $container[0] && defined $container[1] &&
splice(@temp_container,1,1);
my %diff;
grep($diff{$_}++,@temp_container);
my @diff = grep(!$diff{$_},@original_container);
my @diff = grep(!$diff{$_},@original_container);
if ($#diff >= 0) {
# unlink initrd_image.gz, do initrd()
$ok = 1;
$initrd = "initrd_image";
$ok = 1;
$initrd = "initrd_image";
}
else {
$ok = 0;
}
}
else {
$ok = 2; # this is actually first (1 = diff, 0 = same)
$initrd = "initrd_image";
$ok = 2; # this is actually first (1 = diff, 0 = same)
$initrd = "initrd_image";
}
# reset
@original_container = ($container[0],$root_image,$device,$size,$compress);
@ -910,7 +924,7 @@ sub lilo_put_it_together {
pb($B,7);
chdir("$mnt"); #"boot_root: ERROR: Could not change directories\n";
if (err_custom("lilo -v -C brlilo.conf -r $mnt",
"gBootRoot: ERROR: lilo failed") == 2) {
"gBootRoot: ERROR: lilo failed") == 2) {
chdir($pwd); return;
}
$remain_boot = $remain_boot - (stat("$mnt/boot/map"))[12]/2;
@ -967,7 +981,7 @@ sub device2 {
open(CR, "$root_image") or error_window(
"gBootRoot: ERROR: Could not copy over the root filesystem") and return;
while (<CR>) {
print CF $_;
print CF $_;
pb($FS,$count,$line_count) if $count < $half_line_count;
$count++;
}
@ -1043,10 +1057,10 @@ sub pb {
# Will have to count by hand
if ($_[0] eq "initrd") {
$pbar->configure( 10, 0, 10 );
$pbar->configure( 10, 0, 10 );
}
elsif ($_[0] eq "boot") {
$pbar->configure( 10, 0, 10 );
$pbar->configure( 10, 0, 10 );
}
elsif ($_[0] eq "filesystem") {
$pbar->configure($_[2], 0, $_[2]);
@ -1195,14 +1209,14 @@ sub mtab{
my $dialog = "BOOTDISK:\n"
."Press OK when the drive and its storage medium is ready.\n"
."The Boot Disk will now be made. All data already on\n"
."the storage medium will be erased.";
."the storage medium will be erased.";
mtab_window($dialog,1,$_[0],1);
}
elsif ($_[0] == 1) {
my $dialog = "ROOTDISK:\n"
."Press OK when the drive and its storage medium is ready.\n"
."Press OK when the drive and its storage medium is ready.\n"
."The Root Disk will now be made. All data already on\n"
."the storage medium will be erased.";
."the storage medium will be erased.";
mtab_window($dialog,1,$_[0],1);
}
@ -1423,60 +1437,3 @@ Little things you may want to know:
HELP
}

Loading…
Cancel
Save