Browse Source

* Some tweaks before beginning work on check_root_fs.

master
freesource 24 years ago
parent
commit
9c47087234
  1. 6
      Yard.pm
  2. 19
      YardBox.pm
  3. 182
      gBootRoot

6
Yard.pm

@ -770,7 +770,7 @@ sub create_filesystem {
return "ERROR" if $error && $error eq "ERROR"; return "ERROR" if $error && $error eq "ERROR";
} }
} else { } else {
if (sys("mke2fs -F -m 0 -i $inode_size $device $fs_size") !~ if (sys("mke2fs -m 0 -i $inode_size $device $fs_size") !~
/^0$/ ) { /^0$/ ) {
$error = error("Can not make $fs_type filesystem"); $error = error("Can not make $fs_type filesystem");
return "ERROR" if $error && $error eq "ERROR"; return "ERROR" if $error && $error eq "ERROR";
@ -778,7 +778,7 @@ sub create_filesystem {
} }
if (!-d $mount_point) { if (!-d $mount_point) {
return "ERROR" if errmk(sys("mkdir $mount_point")) == 2; return "ERROR" if errmk(sys("mkdir $mount_point")) == 2;
} }
mount_device($device,$mount_point); mount_device($device,$mount_point);
##### lost+found on a ramdisk is pointless ##### lost+found on a ramdisk is pointless
@ -914,7 +914,7 @@ sub create_filesystem {
## Probably will want to umount here ## Probably will want to umount here
info(0, "\nDone with $PROGRAM_NAME. $Warnings warnings.\n", info(0, "\nDone with $PROGRAM_NAME. $Warnings warnings.\n",
"$device is still mounted on $mount_point\n"); "$device is still mounted on $mount_point\n\n");
} # end sub create_filesystem } # end sub create_filesystem

19
YardBox.pm

@ -385,6 +385,11 @@ sub which_stage {
} }
} # end if one-by-one or continuous } # end if one-by-one or continuous
elsif ($stages_bool eq "user-defined") {
}
for (keys %$continue) { print $_, "=>", $continue->{$_}, "\n"; } for (keys %$continue) { print $_, "=>", $continue->{$_}, "\n"; }
@ -395,7 +400,7 @@ sub continue {
my $thing; my $thing;
# This has to go sequentially, but backwards is o.k. # This has to go sequentially, but backwards is o.k.
if ($stages_bool eq "one-by-one") { if ($stages_bool eq "one-by-one" || $stages_bool eq "continuous") {
if ( $continue->{check} == 0 ) { if ( $continue->{check} == 0 ) {
check(); check();
foreach $thing (@check_boxes) { foreach $thing (@check_boxes) {
@ -407,7 +412,7 @@ sub continue {
$dep->active($true); $dep->active($true);
$dep->show(); $dep->show();
$continue->{check} = 1; $continue->{check} = 1;
return; return if $stages_bool eq "one-by-one";
} }
if ( $continue->{dep} == 0 ) { if ( $continue->{dep} == 0 ) {
links_deps(); links_deps();
@ -420,7 +425,7 @@ sub continue {
$space->active($true); $space->active($true);
$space->show(); $space->show();
$continue->{dep} = 1; $continue->{dep} = 1;
return; return if $stages_bool eq "one-by-one";
} }
if ( $continue->{space} == 0 ) { if ( $continue->{space} == 0 ) {
space_left(); space_left();
@ -433,7 +438,7 @@ sub continue {
$create->active($true); $create->active($true);
$create->show(); $create->show();
$continue->{space} = 1; $continue->{space} = 1;
return; return if $stages_bool eq "one-by-one";
} }
if ( $continue->{create} == 0 ) { if ( $continue->{create} == 0 ) {
create(); create();
@ -446,9 +451,13 @@ sub continue {
$test->active($true); $test->active($true);
$test->show(); $test->show();
$continue->{create} = 1; $continue->{create} = 1;
return; return if $stages_bool eq "one-by-one";
} }
}
elsif ($stages_bool eq "user-defined") {
} }
} }

182
gBootRoot

@ -1961,107 +1961,109 @@ sub initrd {
my($lib,$what,$path,$value,$tool); my($lib,$what,$path,$value,$tool);
my $I = "initrd"; my $I = "initrd";
my $broot_image = basename($root_image); my $broot_image = basename($root_image);
open(LC, ">$tmp/linuxrc") or die "Couldn't write linuxrc to loop device\n"; open(LC, ">$tmp/linuxrc") or die "Couldn't write linuxrc to loop device\n";
print LC initrd_heredoc($broot_image); close(LC); print LC initrd_heredoc($broot_image); close(LC);
pb($I,1); pb($I,1);
my $size_needed = initrd_size((stat("$tmp/linuxrc"))[12]/2); my $size_needed = initrd_size((stat("$tmp/linuxrc"))[12]/2);
unlink("$tmp/linuxrc"); unlink("$tmp/linuxrc");
info(0, "Using loop device to make initrd\n"); info(0, "Using loop device to make initrd\n");
info(0, "Make sure you have loop device capability in your running kernel\n"); info(0, "Make sure you have loop device capability in your running kernel\n");
sys("dd if=/dev/zero of=$tmp/$initrd bs=1024 count=$size_needed"); sys("dd if=/dev/zero of=$tmp/$initrd bs=1024 count=$size_needed");
pb($I,2); pb($I,2);
# no need to enter y every time .. could use -F # no need to enter y every time .. could use -F
my $error; my $error;
open(T,"|mke2fs -m0 -i8192 $tmp/$initrd >/dev/null 2>&1") or open(T,"|mke2fs -m0 -i8192 $tmp/$initrd >/dev/null 2>&1") or
($error = error("Can not make ext2 filesystem on initrd.\n")); ($error = error("Can not make ext2 filesystem on initrd.\n"));
return "ERROR" if $error && $error eq "ERROR"; return "ERROR" if $error && $error eq "ERROR";
print T "y\n"; close(T); print T "y\n"; close(T);
pb($I,3); pb($I,3);
info(0, "Mounting initrd in $tmp/initrd_mnt\n"); info(0, "Mounting initrd in $tmp/initrd_mnt\n");
if (!-d "$tmp/initrd_mnt") { if (!-d "$tmp/initrd_mnt") {
return if errmk(sys("mkdir $tmp/initrd_mnt")) == 2; return if errmk(sys("mkdir $tmp/initrd_mnt")) == 2;
} }
return if errm(sys("mount -o loop -t ext2 $tmp/$initrd $tmp/initrd_mnt")) return if errm(sys("mount -o loop -t ext2 $tmp/$initrd $tmp/initrd_mnt"))
== 2; == 2;
pb($I,4); pb($I,4);
info(0, "Putting everything together\n"); info(0, "Putting everything together\n");
open(LC, ">$tmp/initrd_mnt/linuxrc") or die "Couldn't write linuxrc to loop device\n"; open(LC, ">$tmp/initrd_mnt/linuxrc") or die "Couldn't write linuxrc to loop device\n";
print LC initrd_heredoc($broot_image); close(LC); print LC initrd_heredoc($broot_image); close(LC);
# I could test this but somebody's system may do permissions differently # I could test this but somebody's system may do permissions differently
sys("chmod 755 $tmp/initrd_mnt/linuxrc"); sys("chmod 755 $tmp/initrd_mnt/linuxrc");
sys("rmdir $tmp/initrd_mnt/lost+found"); sys("rmdir $tmp/initrd_mnt/lost+found");
pb($I,5); pb($I,5);
info(0, "... the dirs\n"); info(0, "... the dirs\n");
return if errmk( return if errmk(
sys("mkdir $tmp/initrd_mnt/{bin,dev,etc,lib,mnt,proc,sbin,usr}")) == 2; sys("mkdir $tmp/initrd_mnt/{bin,dev,etc,lib,mnt,proc,sbin,usr}")) == 2;
return if errmk(sys("mkdir $tmp/initrd_mnt/usr/lib")) == 2; return if errmk(sys("mkdir $tmp/initrd_mnt/usr/lib")) == 2;
pb($I,6); pb($I,6);
return if errcp( return if errcp(
sys("cp -a /dev/{console,null,ram0,ram1,tty0} $tmp/initrd_mnt/dev")) == 2; sys("cp -a /dev/{console,null,ram0,ram1,tty0} $tmp/initrd_mnt/dev")) == 2;
return if errcp(sys("cp -a $device $tmp/initrd_mnt/dev")) == 2; return if errcp(sys("cp -a $device $tmp/initrd_mnt/dev")) == 2;
pb($I,7); pb($I,7);
# This and libs should be user accessible # This and libs should be user accessible
info(0, ".. the bins\n"); info(0, ".. the bins\n");
my @initrd_stuff = qw(ash gzip mount umount); my @initrd_stuff = qw(ash gzip mount umount);
foreach (@initrd_stuff) { foreach (@initrd_stuff) {
($path,$value) = stripper(find_file_in_path($_),"bin"); ($path,$value) = stripper(find_file_in_path($_),"bin");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv"); $value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/bin")) == 2; return if errcp(sys("$tool $path $tmp/initrd_mnt/bin")) == 2;
} }
if ($compress eq "bzip2" && -e find_file_in_path($compress)) { if ($compress eq "bzip2" && -e find_file_in_path($compress)) {
($path,$value) = stripper(find_file_in_path($compress),"bin"); ($path,$value) = stripper(find_file_in_path($compress),"bin");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv"); $value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/bin")) == 2; return if errcp(sys("$tool $path $tmp/initrd_mnt/bin")) == 2;
} }
# Testing if init is sufficient for grabbing the correct libraries for the # Testing if init is sufficient for grabbing the correct libraries for the
# executables immediately above. This could be modified to test a # executables immediately above. This could be modified to test a
# list of executables. # list of executables.
info(0, ".. the libs\n"); info(0, ".. the libs\n");
open(L,"ldd /sbin/init|") or die "Oops, no init could be found :)\n"; # safe to use ldd, this is going to be fixed later with library_dependencies open(L,"ldd /sbin/init|") or die "Oops, no init could be found :)\n"; # safe to use ldd, this is going to be fixed later with library_dependencies
while (<L>) { while (<L>) {
$lib = (split(/=>/,$_))[0]; $lib = (split(/=>/,$_))[0];
$lib =~ s/\s+//; $lib =~ s/\s+//;
$lib = basename($lib); $lib = basename($lib);
$lib =~ s/\s+$//; $lib =~ s/\s+$//;
open (SL,"ls -l /lib/$lib|") or die "humm: $!\n"; open (SL,"ls -l /lib/$lib|") or die "humm: $!\n";
while (<SL>) { while (<SL>) {
# symbolic link # symbolic link
if (-l "/lib/$lib") { if (-l "/lib/$lib") {
$what = (split(/\s+/,$_))[10]; $what = (split(/\s+/,$_))[10];
($path,$value) = stripper("/lib/$lib","lib"); ($path,$value) = stripper("/lib/$lib","lib");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv"); $value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2; return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2;
($path,$value) = stripper("/lib/$what","lib"); ($path,$value) = stripper("/lib/$what","lib");
$value == 0 ? ($tool = "cp -a") : ($tool = "mv"); $value == 0 ? ($tool = "cp -a") : ($tool = "mv");
return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2; return if errcp(sys("$tool $path $tmp/initrd_mnt/lib")) == 2;
} }
# no symbolic link # no symbolic link
else { else {
($path,$value) = stripper("/lib/$lib","lib"); ($path,$value) = stripper("/lib/$lib","lib");
return if errcp(sys("cp -a $path $tmp/initrd_mnt/lib")) == 2; return if errcp(sys("cp -a $path $tmp/initrd_mnt/lib")) == 2;
} }
} }
} }
info(0, "Determine run-time link bindings\n"); info(0, "Determine run-time link bindings\n");
# Has a return code of 0 regardless # Has a return code of 0 regardless
sys("ldconfig -r $tmp/initrd_mnt"); # Also, produces false alarms even when it is working.
info(0, "Umounting loop device, and compressing initrd\n"); info(1, "Ignore warnings about missing directories\n");
return if errum(sys("umount $tmp/initrd_mnt")) == 2; sys("ldconfig -v -r $tmp/initrd_mnt");
sys("gzip -f9 $tmp/$initrd"); info(0, "Umounting loop device, and compressing initrd\n");
pb($I,10); # This takes the longest. return if errum(sys("umount $tmp/initrd_mnt")) == 2;
sys("gzip -f9 $tmp/$initrd");
pb($I,10); # This takes the longest.
$initrd = $initrd . ".gz"; $initrd = $initrd . ".gz";
} # end sub initrd } # end sub initrd

Loading…
Cancel
Save