|
@ -2915,43 +2915,105 @@ else { |
|
|
|
|
|
|
|
|
sub device2 { |
|
|
sub device2 { |
|
|
|
|
|
|
|
|
my $device_size = (split(/\s+/,`df $mnt`))[8]; |
|
|
my $fs_type = (split(/\s/,$main::makefs))[0]; |
|
|
my $root_image_size = (stat($container[ROOT_FS]))[12]/2; |
|
|
|
|
|
my $remain_root = $device_size - $root_image_size; |
|
|
|
|
|
|
|
|
|
|
|
if ($remain_root =~ /^-+\d+$/) { |
|
|
# Time to do a little calculations |
|
|
error_window("gBootRoot: ERROR: Not enough room: root stuff = $root_image_size k, device = $device_size k"); |
|
|
my $device_size; |
|
|
} |
|
|
if ( $fs_type ne "genext2fs" ) { |
|
|
else { |
|
|
$device_size = (split(/\s+/,`df $mnt`))[8]; |
|
|
$entry5->set_text("$remain_root k"); |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
if ( !$root_device_size ) { |
|
|
|
|
|
$device_size = $container[SIZE]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$device_size = $root_device_size; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
my $root_image_size = (stat($container[ROOT_FS]))[12]/2; |
|
|
|
|
|
my $remain_root = $device_size - $root_image_size; |
|
|
|
|
|
|
|
|
info(0, "Copy over the compressed filesystem\n"); |
|
|
if ($remain_root =~ /^-+\d+$/) { |
|
|
return if errrm(sys("rmdir $mnt/lost+found")) == 2; |
|
|
error_window("gBootRoot: ERROR: Not enough room: root stuff = $root_image_size k, device = $device_size k"); |
|
|
my $broot_image = basename($container[ROOT_FS]); |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$entry5->set_text("$remain_root k"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
my $FS = "filesystem"; |
|
|
info(0, "Copy over the compressed filesystem\n"); |
|
|
my $line_count = `wc -l < $container[ROOT_FS]`; chomp $line_count; |
|
|
if ( $fs_type ne "genext2fs" ) { |
|
|
my $half_line_count = $line_count/2; |
|
|
return if errrm(sys("rmdir $mnt/lost+found")) == 2; |
|
|
my $count = 1; |
|
|
} |
|
|
open(CF, ">$mnt/$broot_image") or error_window( |
|
|
my $broot_image = basename($container[ROOT_FS]); |
|
|
"gBootRoot: ERROR: Could not copy over the root filesystem") and return; |
|
|
|
|
|
|
|
|
|
|
|
open(CR, "$container[ROOT_FS]") or error_window( |
|
|
# Status output, use FH, or genext2fs to create disk. |
|
|
"gBootRoot: ERROR: Could not copy over the root filesystem") and return; |
|
|
#---------------------------------------------------- |
|
|
|
|
|
my $FS = "filesystem"; |
|
|
|
|
|
my $line_count = `wc -l < $container[ROOT_FS]`; chomp $line_count; |
|
|
|
|
|
my $half_line_count = $line_count/2; |
|
|
|
|
|
my $count = 1; |
|
|
|
|
|
|
|
|
while (<CR>) { |
|
|
if ( $fs_type ne "genext2fs" ) { |
|
|
print CF $_; |
|
|
open(CF, ">$mnt/$broot_image") or error_window( |
|
|
pb($FS,$count,$line_count) if $count < $half_line_count; |
|
|
"gBootRoot: ERROR: Could not copy over the root filesystem") and return; |
|
|
$count++; |
|
|
|
|
|
} |
|
|
open(CR, "$container[ROOT_FS]") or error_window( |
|
|
close(CF); close(CR); |
|
|
"gBootRoot: ERROR: Could not copy over the root filesystem") and return; |
|
|
|
|
|
|
|
|
|
|
|
while (<CR>) { |
|
|
|
|
|
print CF $_; |
|
|
|
|
|
pb($FS,$count,$line_count) if $count < $half_line_count; |
|
|
|
|
|
$count++; |
|
|
|
|
|
} |
|
|
|
|
|
close(CF); |
|
|
|
|
|
close(CR); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# genext2fs |
|
|
|
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
my $error; |
|
|
|
|
|
|
|
|
|
|
|
# If genext2fs is being used clean $tmp/rootdisk if any garbage is |
|
|
|
|
|
# found. |
|
|
|
|
|
if ( $fs_type eq "genext2fs" ) { |
|
|
|
|
|
if (-d "$tmp/rootdisk") { |
|
|
|
|
|
sys("rm -rf $tmp/rootdisk"); |
|
|
|
|
|
} |
|
|
|
|
|
if (!-d "$tmp/rootdisk") { |
|
|
|
|
|
return if errmk(sys("mkdir $tmp/rootdisk")) == 2; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return if errcp( sys("cp -a $container[ROOT_FS] $tmp/rootdisk") ) == 2; |
|
|
|
|
|
|
|
|
|
|
|
for ( $count .. $half_line_count ) { |
|
|
|
|
|
pb($FS,$count,$line_count) if $count < $half_line_count; |
|
|
|
|
|
$count++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
sys("/usr/lib/bootroot/$main::makefs -b $device_size -d $tmp/rootdisk $entry_advanced[3]") !~ |
|
|
|
|
|
/^0$/ ) { |
|
|
|
|
|
info( 0, "/usr/lib/bootroot/$main::makefs -b $device_size -d $tmp/rootdisk $entry_advanced[3]\n"); |
|
|
|
|
|
$error = error("Cannot $fs_type filesystem.\n"); |
|
|
|
|
|
return "ERROR" if $error && $error eq "ERROR"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
#------------------------------------------------------ |
|
|
|
|
|
|
|
|
|
|
|
if ( $fs_type ne "genext2fs" ) { |
|
|
|
|
|
return if |
|
|
|
|
|
err_custom("umount $mnt", |
|
|
|
|
|
"gBootRoot: ERROR: Root disk did not properly umount") == 2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return if |
|
|
pb($FS,$count,$line_count); |
|
|
err_custom("umount $mnt", |
|
|
info(0, "Finished!\n"); |
|
|
"gBootRoot: ERROR: Root disk did not properly umount") == 2; |
|
|
|
|
|
pb($FS,$count,$line_count); |
|
|
|
|
|
info(0, "Finished!\n"); |
|
|
|
|
|
|
|
|
|
|
|
} # end sub device 2 |
|
|
} # end sub device 2 |
|
|
|
|
|
|
|
|