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

fai-commit at lists.alioth.debian.org fai-commit at lists.alioth.debian.org
Sat Jul 22 17:13:34 UTC 2006


Author: michael-guest
Date: 2006-07-22 17:13:33 +0000 (Sat, 22 Jul 2006)
New Revision: 3618

Modified:
   people/michael/features/setup_harddisks_2/implementation/Makefile
   people/michael/features/setup_harddisks_2/implementation/shdd2-commands
   people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
   people/michael/features/setup_harddisks_2/implementation/shdd2-lib
   people/michael/features/setup_harddisks_2/implementation/shdd2-parser
   people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
Log:
fixed indentions


Modified: people/michael/features/setup_harddisks_2/implementation/Makefile
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/Makefile	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/Makefile	2006-07-22 17:13:33 UTC (rev 3618)
@@ -1,7 +1,7 @@
 .PHONY: tidy move
 
 tidy:
-	perltidy -bl shdd2-*
+	perltidy -bl -i=2 shdd2-*
 
 move:
 	for i in shdd2*.tdy ; do mv $$i `echo $$i | sed 's/.tdy//'` ; done

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-commands
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2006-07-22 17:13:33 UTC (rev 3618)
@@ -4,5 +4,21 @@
 
 package FAI;
 
+foreach my $config ( keys %FAI::configs )
+{
+  if ( $config eq "RAID" || $config =~ /^VG_/ )
+  {
+
+    # compute the sizes of lvms
+    next;
+  }
+  elsif ( $config =~ /^PHY_(.*)$/ )
+  {
+    foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+    {
+    }
+  }
+}
+
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 17:13:33 UTC (rev 3618)
@@ -7,71 +7,71 @@
 #call this function only with one parameter (generate_fstab($hash_ref)). The rest is used for recursion
 sub generate_fstab
 {
-    my ( $hash_ref, $modus, $device, $listref, $call_count ) = @_;
+  my ( $hash_ref, $modus, $device, $listref, $call_count ) = @_;
 
-    if ( !$listref )
-    {
-        my @newlist = ();
-        $listref = \@newlist;
-    }
+  if ( !$listref )
+  {
+    my @newlist = ();
+    $listref = \@newlist;
+  }
 
-    if ( !$call_count )
+  if ( !$call_count )
+  {
+    $call_count = 1;
+  }
+  else
+  {
+    $call_count++;
+  }
+
+  foreach my $key ( keys %$hash_ref )
+  {
+
+    if ( ref( $hash_ref->{$key} ) && $key =~ /^PHY_(.*)$/ )
     {
-        $call_count = 1;
+      $modus  = "PHY";
+      $device = $1;
     }
-    else
-    {
-        $call_count++;
-    }
 
-    foreach my $key ( keys %$hash_ref )
+    if ( ref( $hash_ref->{$key} ) && $key eq "partitions" )
     {
 
-        if ( ref( $hash_ref->{$key} ) && $key =~ /^PHY_(.*)$/ )
+      foreach my $partition ( keys %{ $hash_ref->{$key} } )
+      {
+        my $p_ref = $hash_ref->{$key}->{$partition};
+        if ( !$p_ref->{'size'}->{'extended'} )
         {
-            $modus  = "PHY";
-            $device = $1;
+          my @fstab_line = ();
+          push @fstab_line, $device . $partition;
+          push @fstab_line, $p_ref->{'mountpoint'};
+          push @fstab_line, $p_ref->{'filesystem'};
+          push @fstab_line, $p_ref->{'mount_options'};
+          push @fstab_line, 0;
+          if ( $p_ref->{'mountpoint'} eq "/root" )
+          {
+            push @fstab_line, 1;
+          }
+          else
+          {
+            push @fstab_line, 2;
+          }
+          push @$listref, join( "\t", @fstab_line );
         }
 
-        if ( ref( $hash_ref->{$key} ) && $key eq "partitions" )
-        {
+      }
 
-            foreach my $partition ( keys %{ $hash_ref->{$key} } )
-            {
-                my $p_ref = $hash_ref->{$key}->{$partition};
-                if ( !$p_ref->{'size'}->{'extended'} )
-                {
-                    my @fstab_line = ();
-                    push @fstab_line, $device . $partition;
-                    push @fstab_line, $p_ref->{'mountpoint'};
-                    push @fstab_line, $p_ref->{'filesystem'};
-                    push @fstab_line, $p_ref->{'mount_options'};
-                    push @fstab_line, 0;
-                    if ( $p_ref->{'mountpoint'} eq "/root" )
-                    {
-                        push @fstab_line, 1;
-                    }
-                    else
-                    {
-                        push @fstab_line, 2;
-                    }
-                    push @$listref, join( "\t", @fstab_line );
-                }
-
-            }
-
-        }
-        if ( ref( $hash_ref->{$key} ) )
-        {
-            &generate_fstab( $hash_ref->{$key}, $modus, $device, $listref,
-                $call_count );
-        }
-
     }
-    if ( $call_count eq 1 )
+    if ( ref( $hash_ref->{$key} ) )
     {
-        return @$listref;
+      &generate_fstab( $hash_ref->{$key}, $modus, $device, $listref,
+        $call_count );
     }
+
+  }
+  if ( $call_count eq 1 )
+  {
+    return @$listref;
+  }
 }
 
 1;

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-lib
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2006-07-22 17:13:33 UTC (rev 3618)
@@ -6,18 +6,18 @@
 
 sub in_path
 {
-    my ($filesystem) = @_;
+  my ($filesystem) = @_;
 
-    my @path_list = split( ":", $ENV{"PATH"} );
+  my @path_list = split( ":", $ENV{"PATH"} );
 
-    foreach my $p (@path_list)
+  foreach my $p (@path_list)
+  {
+    if ( -x $p . "/mkfs.$filesystem" )
     {
-        if ( -x $p . "/mkfs.$filesystem" )
-        {
-            return 1;
-        }
+      return 1;
     }
-    return 0;
+  }
+  return 0;
 }
 
 1;

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-parser
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2006-07-22 17:13:33 UTC (rev 3618)
@@ -91,7 +91,7 @@
 $FAI::partition_logical_counter = 0;
 
 my $Parser = Parse::RecDescent->new(
-    q{
+  q{
     file: line(s?) /\Z/
     line: <skip: qr/[ \t]*/> "\\n"
         | <skip: qr/[ \t]*/> comment "\\n"
@@ -352,23 +352,21 @@
 
 sub print_hash
 {
-    my ( $hash_ref, $k ) = @_;
-    $k = $k . ">";
-    foreach my $key ( keys %$hash_ref )
+  my ( $hash_ref, $k ) = @_;
+  $k = $k . ">";
+  foreach my $key ( keys %$hash_ref )
+  {
+    if ( ref( $hash_ref->{$key} ) )
     {
-        if ( ref( $hash_ref->{$key} ) )
-        {
-            print "$k Schluessel: " . $key . " Wert: " . "Hash" . "\n";
-            &print_hash( $hash_ref->{$key}, $k );
-        }
-        else
-        {
-            print "$k Schluessel: " . $key
-              . " Wert: "
-              . $hash_ref->{$key} . "\n";
-        }
-
+      print "$k Schluessel: " . $key . " Wert: " . "Hash" . "\n";
+      &print_hash( $hash_ref->{$key}, $k );
     }
+    else
+    {
+      print "$k Schluessel: " . $key . " Wert: " . $hash_ref->{$key} . "\n";
+    }
+
+  }
 }
 
 my $ifs = $/;
@@ -383,7 +381,7 @@
 my @fstab = &FAI::generate_fstab( \%FAI::configs );
 foreach my $line (@fstab)
 {
-    printf $line. "\n";
+  printf $line. "\n";
 }
 
 1;

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-sizes	2006-07-22 17:08:08 UTC (rev 3617)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-sizes	2006-07-22 17:13:33 UTC (rev 3618)
@@ -10,262 +10,244 @@
 
 foreach my $disk (@FAI::disks)
 {
-    if ( !( $disk =~ m{^/} ) )
-    {
-        $disk = "/dev/" . $disk;
-    }
-    $FAI::current_config{$disk}{"partitions"} = {};
+  if ( !( $disk =~ m{^/} ) )
+  {
+    $disk = "/dev/" . $disk;
+  }
+  $FAI::current_config{$disk}{"partitions"} = {};
 
-    my @parted_print    = split( "\n", `/sbin/parted -s $disk unit TB print` );
-    my $parted_fs_start = 0;
-    my $parted_fs_end   = 0;
+  my @parted_print    = split( "\n", `/sbin/parted -s $disk unit TB print` );
+  my $parted_fs_start = 0;
+  my $parted_fs_end   = 0;
 
-    foreach my $line (@parted_print)
+  foreach my $line (@parted_print)
+  {
+    if ( $line =~ /^Disk geometry/ )
     {
-        if ( $line =~ /^Disk geometry/ )
+      next;
+    }
+    elsif ( $line =~ /^Disk label type: (.*)$/ )
+    {
+      $FAI::current_config{$disk}{"disklabel"} = $1;
+      next;
+    }
+    elsif ( $line =~ /^Number/ )
+    {
+      $parted_fs_start = 0;
+      $parted_fs_end   = 0;
+      my @chars = split( "", $line );
+      foreach my $char (@chars)
+      {
+        $parted_fs_end++;
+        if ( $char eq "F" )
         {
-            next;
+          $parted_fs_start = $parted_fs_end;
         }
-        elsif ( $line =~ /^Disk label type: (.*)$/ )
+        elsif ( $char eq "m" && $parted_fs_start > 0 )
         {
-            $FAI::current_config{$disk}{"disklabel"} = $1;
-            next;
+          last;
         }
-        elsif ( $line =~ /^Number/ )
-        {
-            $parted_fs_start = 0;
-            $parted_fs_end   = 0;
-            my @chars = split( "", $line );
-            foreach my $char (@chars)
-            {
-                $parted_fs_end++;
-                if ( $char eq "F" )
-                {
-                    $parted_fs_start = $parted_fs_end;
-                }
-                elsif ( $char eq "m" && $parted_fs_start > 0 )
-                {
-                    last;
-                }
-            }
-            $parted_fs_start--;
-            $parted_fs_end -= $parted_fs_start;
-        }
-        else
-        {
-            $line =~ /^(\d+)/;
-            my $id = $1;
-            $line =~ /^.{$parted_fs_start}(.{$parted_fs_end})/;
-            my $fs = $1;
-            $FAI::current_config{$disk}{"partitions"}{$id}{"filesystem"} = $fs;
-        }
+      }
+      $parted_fs_start--;
+      $parted_fs_end -= $parted_fs_start;
     }
+    else
+    {
+      $line =~ /^(\d+)/;
+      my $id = $1;
+      $line =~ /^.{$parted_fs_start}(.{$parted_fs_end})/;
+      my $fs = $1;
+      $FAI::current_config{$disk}{"partitions"}{$id}{"filesystem"} = $fs;
+    }
+  }
 
-    @parted_print = split( "\n", `/sbin/parted -s $disk unit B print` );
+  @parted_print = split( "\n", `/sbin/parted -s $disk unit B print` );
+  {
+    foreach my $line (@parted_print)
     {
-        foreach my $line (@parted_print)
-        {
-            if ( $line =~ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B/i )
-            {
+      if ( $line =~ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B/i )
+      {
 
-                $FAI::current_config{$disk}{"partitions"}{$1}{"begin_byte"} =
-                  $2;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"end_byte"} = $3;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"count_byte"} =
-                  $4;
-            }
+        $FAI::current_config{$disk}{"partitions"}{$1}{"begin_byte"} = $2;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"end_byte"}   = $3;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"count_byte"} = $4;
+      }
 
-            if ( $line =~ /^Disk geometry for.*(\d+)B - (\d+)B/i )
-            {
-                $FAI::current_config{$disk}{"begin_byte"} = $1;
-                $FAI::current_config{$disk}{"end_byte"}   = $2;
-            }
-        }
+      if ( $line =~ /^Disk geometry for.*(\d+)B - (\d+)B/i )
+      {
+        $FAI::current_config{$disk}{"begin_byte"} = $1;
+        $FAI::current_config{$disk}{"end_byte"}   = $2;
+      }
     }
+  }
 
-    @parted_print = split( "\n", `/sbin/parted -s $disk unit chs print` );
+  @parted_print = split( "\n", `/sbin/parted -s $disk unit chs print` );
+  {
+    foreach my $line (@parted_print)
     {
-        foreach my $line (@parted_print)
-        {
 
-            if ( $line =~ /^(\d+)\s+(\d+),(\d+),(\d+)\s+(\d+),(\d+),(\d+)/i )
-            {
-                $FAI::current_config{$disk}{"partitions"}{$1}
-                  {"begin_cylinder"} = $2;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"begin_head"} =
-                  $3;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"begin_sector"} =
-                  $4;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"end_cylinder"} =
-                  $5;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"end_head"} = $6;
-                $FAI::current_config{$disk}{"partitions"}{$1}{"end_sector"} =
-                  $7;
-            }
+      if ( $line =~ /^(\d+)\s+(\d+),(\d+),(\d+)\s+(\d+),(\d+),(\d+)/i )
+      {
+        $FAI::current_config{$disk}{"partitions"}{$1}{"begin_cylinder"} = $2;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"begin_head"}     = $3;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"begin_sector"}   = $4;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"end_cylinder"}   = $5;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"end_head"}       = $6;
+        $FAI::current_config{$disk}{"partitions"}{$1}{"end_sector"}     = $7;
+      }
 
-            if ( $line =~
-                /^Disk geometry for.*(\d+),(\d+),(\d+) - (\d+),(\d+),(\d+)/i )
-            {
-                $FAI::current_config{$disk}{"begin_cylinder"} = $1;
-                $FAI::current_config{$disk}{"begin_head"}     = $2;
-                $FAI::current_config{$disk}{"begin_sector"}   = $3;
-                $FAI::current_config{$disk}{"end_cylinder"}   = $4;
-                $FAI::current_config{$disk}{"end_head"}       = $5;
-                $FAI::current_config{$disk}{"end_sector"}     = $6;
-            }
-        }
+      if (
+        $line =~ /^Disk geometry for.*(\d+),(\d+),(\d+) - (\d+),(\d+),(\d+)/i )
+      {
+        $FAI::current_config{$disk}{"begin_cylinder"} = $1;
+        $FAI::current_config{$disk}{"begin_head"}     = $2;
+        $FAI::current_config{$disk}{"begin_sector"}   = $3;
+        $FAI::current_config{$disk}{"end_cylinder"}   = $4;
+        $FAI::current_config{$disk}{"end_head"}       = $5;
+        $FAI::current_config{$disk}{"end_sector"}     = $6;
+      }
     }
+  }
 }
 
 # &print_hash( \%FAI::current_config );
 
 foreach my $config ( keys %FAI::configs )
 {
-    if ( $config eq "RAID" || $config =~ /^VG_/ )
-    {
+  if ( $config eq "RAID" || $config =~ /^VG_/ )
+  {
 
-        # compute the sizes of lvms
-        next;
-    }
-    elsif ( $config =~ /^PHY_(.*)$/ )
-    {
-        my $extended      = -1;
-        my $disk          = $1;
-        my $redist_space  = 0;
-        my $min_req_space = 0;
+    # compute the sizes of lvms
+    next;
+  }
+  elsif ( $config =~ /^PHY_(.*)$/ )
+  {
+    my $extended      = -1;
+    my $disk          = $1;
+    my $redist_space  = 0;
+    my $min_req_space = 0;
 
-        foreach
-          my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+    foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+    {
+      if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"extended"} ==
+        1 )
+      {
+        ( $extended == -1 ) or warn "more than 1 extended partition\n";
+        ( $part_id <= 4 )
+          or warn "extended partition won't be a primary one\n";
+        $extended = $part_id;
+        $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} = 0;
+      }
+      elsif (
+        $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} ==
+        0 )
+      {
+        if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"range"} =~
+          /^(\d+%?)-(\d+%?)$/ )
         {
-            if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                {"extended"} == 1 )
-            {
-                ( $extended == -1 ) or warn "more than 1 extended partition\n";
-                ( $part_id <= 4 )
-                  or warn "extended partition won't be a primary one\n";
-                $extended = $part_id;
-                $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                  {"eff_size"} = 0;
-            }
-            elsif ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                {"preserve"} == 0 )
-            {
-                if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                    {"range"} =~ /^(\d+%?)-(\d+%?)$/ )
-                {
-                    my $start = $1;
-                    my $end   = $2;
-                    if ( $start =~ /^(\d+)%$/ )
-                    {
-                        $start =
-                          POSIX::floor(
-                            $FAI::current_config{$disk}{"end_byte"} * $1 /
-                              100 );
-                    }
-                    else
-                    {
-                        $start = $start * 1024.0 * 1024.0;
-                    }
-                    if ( $end =~ /^(\d+)%$/ )
-                    {
-                        $end =
-                          POSIX::ceil(
-                            $FAI::current_config{$disk}{"end_byte"} * $1 /
-                              100 );
-                    }
-                    else
-                    {
-                        $end = $end * 1024.0 * 1024.0;
-                    }
-                    $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                      {"range"} = $start . "-" . $end;
-                    if ( $end == $start )
-                    {
-                        $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                          {"eff_size"} = $start;
-                    }
-                    else
-                    {
-                        $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                          {"eff_size"} = -1;
-                        $redist_space += $end - $start;
-                    }
-                    $min_req_space += $start;
-                }
-                else
-                {
-                    warn "invalid range\n";
-                }
-            }
-            else
-            {
-                $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                  {"eff_size"} =
-                  $FAI::current_config{$disk}{"partitions"}{$part_id}
-                  {"count_byte"};
-                $min_req_space +=
-                  $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                  {"eff_size"};
-            }
+          my $start = $1;
+          my $end   = $2;
+          if ( $start =~ /^(\d+)%$/ )
+          {
+            $start =
+              POSIX::floor(
+              $FAI::current_config{$disk}{"end_byte"} * $1 / 100 );
+          }
+          else
+          {
+            $start = $start * 1024.0 * 1024.0;
+          }
+          if ( $end =~ /^(\d+)%$/ )
+          {
+            $end =
+              POSIX::ceil( $FAI::current_config{$disk}{"end_byte"} * $1 / 100 );
+          }
+          else
+          {
+            $end = $end * 1024.0 * 1024.0;
+          }
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"range"} =
+            $start . "-" . $end;
+          if ( $end == $start )
+          {
+            $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
+              $start;
+          }
+          else
+          {
+            $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
+              -1;
+            $redist_space += $end - $start;
+          }
+          $min_req_space += $start;
         }
-
-        if ( $min_req_space > $FAI::current_config{$disk}{"end_byte"} )
+        else
         {
-            warn "Disk is too small - at least $min_req_space is required\n";
+          warn "invalid range\n";
         }
+      }
+      else
+      {
+        $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
+          $FAI::current_config{$disk}{"partitions"}{$part_id}{"count_byte"};
+        $min_req_space +=
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"};
+      }
+    }
 
-        my $redist_factor =
-          ( $FAI::current_config{$disk}{"end_byte"} - $min_req_space ) /
-          $redist_space;
-        print "redist factor is $redist_factor\n";
+    if ( $min_req_space > $FAI::current_config{$disk}{"end_byte"} )
+    {
+      warn "Disk is too small - at least $min_req_space is required\n";
+    }
 
-        foreach
-          my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-        {
-            if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                {"eff_size"} == -1 )
-            {
-                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
-                {
-                    warn "invalid range\n";
-                }
-            }
-        }
+    my $redist_factor =
+      ( $FAI::current_config{$disk}{"end_byte"} - $min_req_space ) /
+      $redist_space;
+    print "redist factor is $redist_factor\n";
 
-        if ( $FAI::configs{$config}{"disklabel"} ne "msdos" && $extended > -1 )
+    foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+    {
+      if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} ==
+        -1 )
+      {
+        if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"range"} =~
+          /^(\d+%?)-(\d+%?)$/ )
         {
-            warn "extended partitions are not supported by this disklabel\n";
+          my $start = $1;
+          my $end   = $2;
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} =
+            POSIX::floor( $start + ( ( $end - $start ) * $redist_factor ) );
         }
-
-        if ( $FAI::configs{$config}{"disklabel"} eq "msdos" && $extended > -1 )
+        else
         {
-            my $extended_size = 0;
-            foreach my $part_id (
-                sort keys %{ $FAI::configs{$config}{"partitions"} } )
-            {
-                next if ( $part_id <= 4 );
-                $extended_size +=
-                  $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-                  {"eff_size"};
-            }
-            $FAI::configs{$config}{"partitions"}{$extended}{"size"}
-              {"eff_size"} = $extended_size;
+          warn "invalid range\n";
         }
+      }
     }
-    else
+
+    if ( $FAI::configs{$config}{"disklabel"} ne "msdos" && $extended > -1 )
     {
-        warn "Internal error (invalid config entry $config).\n";
+      warn "extended partitions are not supported by this disklabel\n";
     }
+
+    if ( $FAI::configs{$config}{"disklabel"} eq "msdos" && $extended > -1 )
+    {
+      my $extended_size = 0;
+      foreach
+        my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+      {
+        next if ( $part_id <= 4 );
+        $extended_size +=
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"};
+      }
+      $FAI::configs{$config}{"partitions"}{$extended}{"size"}{"eff_size"} =
+        $extended_size;
+    }
+  }
+  else
+  {
+    warn "Internal error (invalid config entry $config).\n";
+  }
 }
 
 &print_hash( \%FAI::configs );




More information about the Fai-commit mailing list