[Fai-commit] r3638 - people/michael/features/setup_harddisks_2/implementation

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Sun Jul 23 00:11:03 UTC 2006


Author: michael-guest
Date: 2006-07-23 00:11:03 +0000 (Sun, 23 Jul 2006)
New Revision: 3638

Modified:
   people/michael/features/setup_harddisks_2/implementation/shdd2
   people/michael/features/setup_harddisks_2/implementation/shdd2-commands
   people/michael/features/setup_harddisks_2/implementation/shdd2-exec
   people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
Log:
backup


Modified: people/michael/features/setup_harddisks_2/implementation/shdd2
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2	2006-07-23 00:08:22 UTC (rev 3637)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2	2006-07-23 00:11:03 UTC (rev 3638)
@@ -25,7 +25,7 @@
 foreach my $cmd (@FAI::commands)
 {
   print $cmd . "\n";
-  &FAI::execute_command($cmd);
+  # &FAI::execute_command($cmd);
 }
 
 my @fstab = &FAI::generate_fstab( \%FAI::configs );

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-commands
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2006-07-23 00:08:22 UTC (rev 3637)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2006-07-23 00:11:03 UTC (rev 3638)
@@ -99,7 +99,6 @@
       foreach
         my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
       {
-        print "testing $part_id\n";
         if (
           $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} ==
           1 )

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-exec
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-exec	2006-07-23 00:08:22 UTC (rev 3637)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-exec	2006-07-23 00:11:03 UTC (rev 3638)
@@ -6,85 +6,85 @@
 package FAI;
 
 %FAI::ErrorHash = (
-"parted_1" => "Parted produced error. Couldn't remove Partition", 
-"parted_2" => "Parted produced error. Could not read disk label."
-"parted_3" => "Parted produced error. Could not open disk."
+  "parted_1" => "Parted produced error. Couldn't remove Partition",
+  "parted_2" => "Parted produced error. Could not read disk label.",
+  "parted_3" => "Parted produced error. Could not open disk."
 );
 
 #my @stdout = ();
 #my $ewr;
 #my $error = &execute_command("cat --help", $ewr ,\@stdout);
 
-
 #foreach my $line (@stdout)
 #{
 #  printf $line."\n";
 #}
 
-
 sub execute_command
-{ 
-  my ($command, $stdout_ref, $stderr_ref) = @_;
+{
+  my ( $command, $stdout_ref, $stderr_ref ) = @_;
 
-  my @stderr = ();
-  my @stdout = ();
+  my @stderr      = ();
+  my @stdout      = ();
   my $stderr_line = "";
   my $stdout_line = "";
 
- 
-  (my $stderr_fh, my $stderr_filename) = File::Temp::tempfile();
-  (my $stdout_fh, my $stdout_filename) = File::Temp::tempfile();
-  `$command 1> $stdout_filename 2> $stderr_filename` ;
+  ( my $stderr_fh, my $stderr_filename ) = File::Temp::tempfile();
+  ( my $stdout_fh, my $stdout_filename ) = File::Temp::tempfile();
+  `$command 1> $stdout_filename 2> $stderr_filename`;
 
-  while(<$stderr_fh>)
+  while (<$stderr_fh>)
   {
     push @stderr, $_;
   }
 
-  while(<$stdout_fh>)
+  while (<$stdout_fh>)
   {
-    push @stdout, $_; 
+    push @stdout, $_;
   }
 
   close($stderr_fh);
   close($stdout_fh);
 
-
-  if(scalar(@stderr)>0)
+  if ( scalar(@stderr) > 0 )
   {
     $stderr_line = $stderr[0];
   }
 
-  if(scalar(@stdout)>0)
+  if ( scalar(@stdout) > 0 )
   {
     $stdout_line = $stdout[0];
   }
-  
-  @$stdout_ref = @stdout; 
-  @$stderr_ref = @stderr; 
 
+  @$stdout_ref = @stdout;
+  @$stderr_ref = @stderr;
+
   foreach my $line (@$stderr_ref)
   {
-    printf $line."\n";
+    printf $line. "\n";
   }
 
-if ( $command =~ /.*parted.*/ && $stderr_line =~ /.*Error: Could not stat device rm - No such file or directory.*/)
+  if ( $command =~ /.*parted.*/
+    && $stderr_line =~
+    /.*Error: Could not stat device rm - No such file or directory.*/ )
   {
     return "parted_1";
   }
 
-  if( $command =~ /.*parted.*/ && $stderr_line =~ /.*Error: Unable to open .* - unrecognised disk label.*/)
+  if ( $command =~ /.*parted.*/
+    && $stderr_line =~
+    /.*Error: Unable to open .* - unrecognised disk label.*/ )
   {
     return "parted_2";
   }
 
-  if( $command =~ /.*parted.*/ && $stderr_line =~ /.*Error: Could not stat device .* - No such file or directory.*/)
+  if ( $command =~ /.*parted.*/
+    && $stderr_line =~
+    /.*Error: Could not stat device .* - No such file or directory.*/ )
   {
     return "parted_3";
   }
 }
 
-
-
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-sizes	2006-07-23 00:08:22 UTC (rev 3637)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-sizes	2006-07-23 00:11:03 UTC (rev 3638)
@@ -17,23 +17,24 @@
     $FAI::current_config{$disk}{"partitions"} = {};
 
     my @parted_print = ();
-    
-    while(1)
+
+    while (1)
     {
-      my $error = &FAI::execute_command("/sbin/parted -s $disk unit TB print", \@parted_std_out, 0);
+      my $error = &FAI::execute_command( "/sbin/parted -s $disk unit TB print",
+        \@parted_std_out, 0 );
 
-      if ($error eq "parted_2")
+      if ( $error eq "parted_2" )
       {
-        $error = &FAI::execute_command("/sbin/parted -s $disk mklabel msdos"); 
+        $error = &FAI::execute_command("/sbin/parted -s $disk mklabel msdos");
         next;
       }
 
-      if ($error eq "parted_3")
+      if ( $error eq "parted_3" )
       {
         die $FAI::ErrorHash{"parted_3"};
       }
 
-      if ($error eq "parted_1")
+      if ( $error eq "parted_1" )
       {
         die $FAI::ErrorHash{"parted_1"};
       }
@@ -170,10 +171,14 @@
     }
     elsif ( $config =~ /^PHY_(.*)$/ )
     {
-      my $extended      = -1;
-      my $disk          = $1;
-      my $redist_space  = 0;
-      my $min_req_space = 0;
+      my $extended            = -1;
+      my $disk                = $1;
+      my $redist_space        = 0;
+      my $min_req_space       = 0;
+      my $min_req_total_space = 0;
+      my @redist_list         = ();
+      my $redist_factor       = 0;
+      my $range_start         = 0;
 
       foreach
         my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
@@ -184,7 +189,7 @@
         {
           ( $extended == -1 ) or die "more than 1 extended partition\n";
           ( $part_id <= 4 )
-            or die "extended partition won't be a primary one\n";
+            or die "extended partition wouldn't be a primary one\n";
           $extended = $part_id;
           $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
             0;
@@ -232,7 +237,8 @@
                 {"eff_size"} = -1;
               $redist_space += $end - $start;
             }
-            $min_req_space += $start;
+            $min_req_space       += $start;
+            $min_req_total_space += $start;
           }
           else
           {
@@ -247,28 +253,60 @@
           }
           $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
             $FAI::current_config{$disk}{"partitions"}{$part_id}{"count_byte"};
-          $min_req_space +=
+          $min_req_total_space +=
             $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"};
+
+          if ( scalar(@redist_list) > 0 )
+          {
+            my $redist_factor =
+              ( $FAI::current_config{$disk}{"partitions"}{$part_id}
+                {"begin_byte"} - 1 - $range_start - $min_req_space ) /
+              $redist_space;
+            print "redist factor is $redist_factor\n";
+
+            foreach my $part_id (@redist_list)
+            {
+              ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
+                  {"eff_size"} == -1 )
+                or die "internal error\n";
+              if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
+                {"range"} =~ /^(\d+%?)-(\d+%?)$/ )
+              {
+                my $start = $1;
+                my $end   = $2;
+                $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
+                  {"eff_size"} =
+                  POSIX::floor(
+                  $start + ( ( $end - $start ) * $redist_factor ) );
+              }
+              else
+              {
+                die "invalid range\n";
+              }
+            }
+          }
+
+          @redist_list = ();
+          $range_start =
+            $FAI::current_config{$disk}{"partitions"}{$part_id}{"end_byte"} + 1;
+          $redist_space  = 0;
+          $min_req_space = 0;
+
         }
       }
 
-      if ( $min_req_space > $FAI::current_config{$disk}{"end_byte"} )
+      if ( scalar(@redist_list) > 0 )
       {
-        die "Disk is too small - at least $min_req_space is required\n";
-      }
+        my $redist_factor =
+          ( $FAI::current_config{$disk}{"end_byte"} - 1 - $range_start -
+            $min_req_space ) / $redist_space;
+        print "redist factor is $redist_factor\n";
 
-      my $redist_factor =
-        ( $FAI::current_config{$disk}{"end_byte"} - $min_req_space ) /
-        $redist_space;
-      print "redist factor is $redist_factor\n";
-
-      foreach
-        my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-      {
-        if (
-          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} ==
-          -1 )
+        foreach my $part_id (@redist_list)
         {
+          ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
+              {"eff_size"} == -1 )
+            or die "internal error\n";
           if (
             $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"range"} =~
             /^(\d+%?)-(\d+%?)$/ )
@@ -285,6 +323,11 @@
         }
       }
 
+      if ( $min_req_total_space > $FAI::current_config{$disk}{"end_byte"} )
+      {
+        die "Disk is too small - at least $min_req_space is required\n";
+      }
+
       if ( $FAI::configs{$config}{"disklabel"} ne "msdos" && $extended > -1 )
       {
         die "extended partitions are not supported by this disklabel\n";




More information about the Fai-commit mailing list