[Fai-commit] r3617 - 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:08:08 UTC 2006


Author: michael-guest
Date: 2006-07-22 17:08:08 +0000 (Sat, 22 Jul 2006)
New Revision: 3617

Added:
   people/michael/features/setup_harddisks_2/implementation/Makefile
Modified:
   people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
   people/michael/features/setup_harddisks_2/implementation/shdd2-init
   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:
perltidy


Added: people/michael/features/setup_harddisks_2/implementation/Makefile
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/Makefile	2006-07-22 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/Makefile	2006-07-22 17:08:08 UTC (rev 3617)
@@ -0,0 +1,8 @@
+.PHONY: tidy move
+
+tidy:
+	perltidy -bl 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-fstab
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2006-07-22 17:08:08 UTC (rev 3617)
@@ -4,80 +4,75 @@
 
 package FAI;
 
-
-
 #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)
-  {
-    $call_count = 1; 
-  }
-  else
-  {
-    $call_count++;
-  }
-
-  foreach my $key (keys %$hash_ref)
-  {
-
-    if (ref($hash_ref->{$key}) && $key  =~ /^PHY_(.*)$/  )
+    if ( !$call_count )
     {
-      $modus = "PHY";
-      $device = $1;
+        $call_count = 1;
     }
+    else
+    {
+        $call_count++;
+    }
 
-
-    if (ref($hash_ref->{$key}) && $key eq "partitions")
+    foreach my $key ( keys %$hash_ref )
     {
 
-      foreach my $partition (keys %{$hash_ref->{$key}})
-      {
-        my $p_ref = $hash_ref->{$key}->{$partition};
-        if(!$p_ref->{'size'}->{'extended'})
+        if ( ref( $hash_ref->{$key} ) && $key =~ /^PHY_(.*)$/ )
         {
-          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);
+            $modus  = "PHY";
+            $device = $1;
         }
 
-      }
+        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 (ref($hash_ref->{$key}))
+    if ( $call_count eq 1 )
     {
-      &generate_fstab($hash_ref->{$key},$modus,$device,$listref,$call_count);
+        return @$listref;
     }
-
-  }
-  if($call_count eq 1)
-  {
-    return @$listref; 
-  }
 }
 
-
-
-
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-init
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-init	2006-07-22 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-init	2006-07-22 17:08:08 UTC (rev 3617)
@@ -14,7 +14,7 @@
 ################
 #
 
- at FAI::disks = split(/\n/, $ENV{disklist});
+ at FAI::disks = split( /\n/, $ENV{disklist} );
 
 1;
 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-lib
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2006-07-22 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2006-07-22 17:08:08 UTC (rev 3617)
@@ -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)
-  {
-    if( -x $p."/mkfs.$filesystem")
+    foreach my $p (@path_list)
     {
-      return 1;
+        if ( -x $p . "/mkfs.$filesystem" )
+        {
+            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 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2006-07-22 17:08:08 UTC (rev 3617)
@@ -6,14 +6,14 @@
 
 #
 # file ::= <lines> EOF
-# 
+#
 # lines ::= EOL
 #           /* empty lines or whitespace only */
 #           | <comment> EOL
 #           | <config> EOL
-# 
+#
 # comment ::= #.*
-# 
+#
 # config ::= disk_config lvm
 #            | disk_config raid
 #            | disk_config end
@@ -22,7 +22,7 @@
 #            /* fully qualified device-path or short form, like hda, whereby full
 #             * path is assumed to be /dev/hda */
 #            | <volume>
-# 
+#
 # option ::= /* empty */
 #            | preserve:[[:digit:]]+(,[[:digit:]]+)*
 #            /* preserve partitions */
@@ -34,11 +34,11 @@
 #            /* mark a partition bootable, default is / */
 #            | virtual
 #            /* do not assume the disk to be a physical device, use with xen */
-# 
+#
 # volume ::= <type> <mountpoint> <size> <filesystem> <mount_options> <fs_options>
 #            | vg <name> <size>
 #            /* lvm vg */
-# 
+#
 # type ::= primary
 #          /* for physical disks only */
 #          | logical
@@ -47,35 +47,35 @@
 #          /* raid level */
 #          | [^/[:space:]]+-[^/[:space:]]+
 #          /* lvm logical volume: vg name and lv name*/
-# 
+#
 # mountpoint ::= -
 #                /* do not mount */
 #                | swap
 #                /* swap space */
 #                | /[^[:space:]]*
 #                /* fully qualified path */
-# 
+#
 # name ::= [^/[:space:]]+
 #          /* lvm volume group name */
-# 
+#
 # size ::= [[:digit:]]+%?(-([[:digit:]]+%?)?)?(:resize)?
 #          /* size in megabytes or %, possibly given as a range; physical
 #           * partitions or lvm logical volumes only */
 #          | -[[:digit:]]+%?(:resize)?
-#          /* size in megabytes or % given as upper limit; physical partitions 
+#          /* size in megabytes or % given as upper limit; physical partitions
 #           * or lvm logical volumes only */
 #          | preserve[[:digit:]]+
 #          /* do not modify this partition */
 #          | [^,:[:space:]]+(:(spare|missing))*(,[^,:[:space:]]+(:(spare|missing))*)*
 #          /* devices and options for a raid or lvm vg */
-#     
+#
 # mount_options ::= [^[:space:]]+
-# 
+#
 # filesystem ::= -
 #                | swap
 #                | [^[:space:]]
 #                /* mkfs.xxx must exist */
-# 
+#
 # fs_options ::= .*
 #                /* options appended to mkfs.xxx call */
 #
@@ -86,13 +86,12 @@
 
 %FAI::configs = ();
 
-$FAI::device = "";
+$FAI::device                    = "";
 $FAI::partition_primary_counter = 0;
 $FAI::partition_logical_counter = 0;
 
-
-
-my $Parser = Parse::RecDescent->new(q{
+my $Parser = Parse::RecDescent->new(
+    q{
     file: line(s?) /\Z/
     line: <skip: qr/[ \t]*/> "\\n"
         | <skip: qr/[ \t]*/> comment "\\n"
@@ -348,29 +347,30 @@
         {
           $FAI::partition_pointer->{ "fs_options" } = $item[ 1 ];
         }
-});
+}
+);
 
-
 sub print_hash
 {
-  my ($hash_ref, $k) = @_;
-  $k=$k.">";
-  foreach my $key (keys %$hash_ref)
-  {
-    if (ref($hash_ref->{$key}))
+    my ( $hash_ref, $k ) = @_;
+    $k = $k . ">";
+    foreach my $key ( keys %$hash_ref )
     {
-      print "$k Schluessel: ". $key." Wert: "."Hash" ."\n";
-      &print_hash($hash_ref->{$key}, $k);
+        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";
+        }
+
     }
-    else
-    {
-      print "$k Schluessel: ". $key." Wert: ".$hash_ref->{$key}."\n";
-    }
-
-  }
 }
 
-
 my $ifs = $/;
 undef $/;
 my $input = <STDIN>;
@@ -378,12 +378,12 @@
 
 print "Input was:\n" . $input;
 
-defined $Parser->file( $input ) or die "Syntax error\n";
+defined $Parser->file($input) or die "Syntax error\n";
 
-my @fstab = &FAI::generate_fstab(\%FAI::configs);
+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 14:46:18 UTC (rev 3616)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-sizes	2006-07-22 17:08:08 UTC (rev 3617)
@@ -8,230 +8,267 @@
 
 %FAI::current_config = ();
 
-foreach my $disk ( @FAI::disks )
+foreach my $disk (@FAI::disks)
 {
-  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;
-
-  foreach my $line ( @parted_print )
-  {
-    if( $line =~ /^Disk geometry/ )
+    if ( !( $disk =~ m{^/} ) )
     {
-      next;
+        $disk = "/dev/" . $disk;
     }
-    elsif( $line =~ /^Disk label type: (.*)$/ )
+    $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;
+
+    foreach my $line (@parted_print)
     {
-      $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" )
+        if ( $line =~ /^Disk geometry/ )
         {
-          $parted_fs_start = $parted_fs_end;
+            next;
         }
-        elsif( $char eq "m" && $parted_fs_start > 0 )
+        elsif ( $line =~ /^Disk label type: (.*)$/ )
         {
-          last;
+            $FAI::current_config{$disk}{"disklabel"} = $1;
+            next;
         }
-      }
-      $parted_fs_start--;
-      $parted_fs_end -= $parted_fs_start;
+        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;
+        }
     }
-    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` );
-  {
-    foreach my $line ( @parted_print )
+    @parted_print = split( "\n", `/sbin/parted -s $disk unit B print` );
     {
-      if( $line =~ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B/i )
-      {
+        foreach my $line (@parted_print)
+        {
+            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` );
-  {
-    foreach my $line ( @parted_print )
+    @parted_print = split( "\n", `/sbin/parted -s $disk unit chs 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_/ )
-  {
-    # 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" } } )
+    if ( $config eq "RAID" || $config =~ /^VG_/ )
     {
-      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+%?)$/ )
+
+        # 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"} } )
         {
-          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 ( $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"};
+            }
         }
-        else
+
+        if ( $min_req_space > $FAI::current_config{$disk}{"end_byte"} )
         {
-          warn "invalid range\n";
+            warn "Disk is too small - at least $min_req_space is required\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" };
-      }
-    }
 
-    if( $min_req_space > $FAI::current_config{ $disk }{ "end_byte" } )
-    {
-      warn "Disk is too small - at least $min_req_space is required\n";
-    }
+        my $redist_factor =
+          ( $FAI::current_config{$disk}{"end_byte"} - $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 )
-      {
-        if( $FAI::configs{ $config }{ "partitions" }{ $part_id }{ "size" }{ "range" } =~ /^(\d+%?)-(\d+%?)$/ )
+        foreach
+          my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
         {
-          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}{"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";
+                }
+            }
         }
-        else
+
+        if ( $FAI::configs{$config}{"disklabel"} ne "msdos" && $extended > -1 )
         {
-          warn "invalid range\n";
+            warn "extended partitions are not supported by this disklabel\n";
         }
-      }
-    }
 
-    if( $FAI::configs{ $config }{ "disklabel" } ne "msdos" && $extended > -1 )
-    {
-      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;
+        }
     }
-    
-    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 "Internal error (invalid config entry $config).\n";
     }
-  }
-  else
-  {
-    warn "Internal error (invalid config entry $config).\n";
-  }
 }
 
-&print_hash(\%FAI::configs);
+&print_hash( \%FAI::configs );
 
 1;
 




More information about the Fai-commit mailing list