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

michael-guest at alioth.debian.org michael-guest at alioth.debian.org
Sun Nov 11 10:19:49 UTC 2007


Author: michael-guest
Date: 2007-11-11 10:19:49 +0000 (Sun, 11 Nov 2007)
New Revision: 4702

Removed:
   people/michael/features/setup_harddisks_2/implementation/shdd2-lib
Modified:
   people/michael/features/setup_harddisks_2/implementation/Makefile
   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-fstab
   people/michael/features/setup_harddisks_2/implementation/shdd2-init
   people/michael/features/setup_harddisks_2/implementation/shdd2-parser
   people/michael/features/setup_harddisks_2/implementation/shdd2-volumes
Log:
changed the formatting, removed shdd2-lib (moved in_path to the parser,
print_hash has long ago be replaced by Data::Dumper), no more perl tidy


Modified: people/michael/features/setup_harddisks_2/implementation/Makefile
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/Makefile	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/Makefile	2007-11-11 10:19:49 UTC (rev 4702)
@@ -1,5 +1,3 @@
-.PHONY: tidy move
-
 DESTDIR=/srv/fai/nfsroot/live/filesystem.dir
 DEST=$(DESTDIR)/usr/lib/perl/5.8
 
@@ -8,17 +6,10 @@
 	shdd2-exec \
 	shdd2-fstab \
 	shdd2-init \
-	shdd2-lib \
 	shdd2-parser \
 	shdd2-sizes \
 	shdd2-volumes
 
-tidy:
-	perltidy -bl -i=2 $(FILES) $(BIN)
-
-move:
-	for i in shdd2*.tdy ; do mv $$i `echo $$i | sed 's/.tdy//'` ; done
-
 install:
 	install -d $(DEST)
 	install -m 444 $(FILES) $(DEST) 

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2	2007-11-11 10:19:49 UTC (rev 4702)
@@ -72,11 +72,11 @@
 our ( $opt_X, $opt_f );
 
 # parse the command line
-&getopts('Xf:') || die "
+&getopts('Xf:') || die <<EOF;
 USAGE: [-X]                     no test, your harddisks will be formated
                                 default: only test, no real formating
        [-f<config-filename>]    default: parse classes
-";
+EOF
 
 # $disklist must be provided by the environment
 defined( $ENV{disklist} ) or die "Environment variable disklist is not set";
@@ -104,16 +104,13 @@
 my $config_file = undef;
 
 # use the config file, if given
-if ($opt_f)
-{
+if ($opt_f) {
   open( $config_file, $opt_f ) or die "Failed to open config file $opt_f\n";
 }
 
 # see which class file to use
-else
-{
-  foreach my $classfile ( reverse split( /\s+/, $ENV{"classes"} ) )
-  {
+else {
+  foreach my $classfile ( reverse split( /\s+/, $ENV{"classes"} ) ) {
     next unless ( -r "$ENV{'FAI'}/disk_config/$classfile" );
     open( $config_file, "$ENV{'FAI'}/disk_config/$classfile" );
     last;
@@ -143,8 +140,7 @@
 use Data::Dumper;
 
 # debugging only: print the current contents of $FAI::current_config
-if ($FAI::debug)
-{
+if ($FAI::debug) {
   print "Current disk layout\n";
 
   # make sure perl doesn't warn about it being used only once
@@ -170,8 +166,7 @@
 &FAI::compute_lv_sizes;
 
 # debugging only: print the current contents of $FAI::configs
-if ($FAI::debug)
-{
+if ($FAI::debug) {
   print "Desired disk layout\n";
   print Dumper \%FAI::configs;
 }
@@ -195,9 +190,7 @@
 ($FAI::debug) and print "$_\n" foreach (@fstab);
 
 # write the proposed contents of fstab to $LOGDIR/fstab, if $FAI::no_dry_run is set
-if ($FAI::no_dry_run)
-{
-
+if ($FAI::no_dry_run) {
   # write fstab to $LOGDIR/fstab
   open( FSTAB, ">$ENV{LOGDIR}/fstab" )
     or die "Failed to open $ENV{LOGDIR}/fstab for writing\n";

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-commands
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-commands	2007-11-11 10:19:49 UTC (rev 4702)
@@ -45,23 +45,17 @@
 # The command is added @FAI::commands
 #
 ################################################################################
-sub build_mkfs_commands
-{
+sub build_mkfs_commands {
   my ( $device, $partition ) = @_;
 
   defined( $partition->{"filesystem"} )
     or die "INTERNAL ERROR: filesystem is undefined\n";
 
-  if ( $partition->{"filesystem"} eq "-" )
-  {
+  if ( $partition->{"filesystem"} eq "-" ) {
     return;
-  }
-  elsif ( $partition->{"filesystem"} eq "swap" )
-  {
+  } elsif ( $partition->{"filesystem"} eq "swap" ) {
     push @FAI::commands, "mkswap " . $partition->{"fs_options"} . " $device";
-  }
-  else
-  {
+  } else {
     push @FAI::commands,
       "mkfs."
       . $partition->{"filesystem"} . " "
@@ -78,15 +72,12 @@
 # The list is @FAI::commands
 #
 ################################################################################
-sub build_raid_commands
-{
-
+sub build_raid_commands {
   # TODO: do we need to stop anything before we continue? Do we need to issue
   # mdadm --misc --zero-superblock /dev/hdx?
 
   # loop through all configs
-  foreach my $config ( keys %FAI::configs )
-  {
+  foreach my $config ( keys %FAI::configs ) {
 
     # no LVM here
     next if ( $config =~ /^VG_(.+)$/ );
@@ -98,8 +89,7 @@
     ( $config eq "RAID" ) or die "INTERNAL ERROR: Invalid config\n";
 
     # create all raid devices
-    foreach my $id ( sort keys %{ $FAI::configs{$config}{"volumes"} } )
-    {
+    foreach my $id ( sort keys %{ $FAI::configs{$config}{"volumes"} } ) {
 
       # the desired RAID level
       my $level = $FAI::configs{$config}{"volumes"}{$id}{"mode"};
@@ -111,8 +101,7 @@
       my @devs = keys %{ $FAI::configs{$config}{"volumes"}{$id}{"devices"} };
 
       # set proper partition types for RAID
-      foreach my $d (@devs)
-      {
+      foreach my $d (@devs) {
         # skip devices marked missing
         next if( 1 ==
           $FAI::configs{$config}{"volumes"}{$id}{"devices"}{$d}{"missing"} );
@@ -128,9 +117,7 @@
         # as that may be created later on
         ( -b $disk ) or die "Specified disk $disk does not exist in this system!\n";
         # set the raid flag
-        push @FAI::commands,
-          "$FAI::system_commands{'parted'} $disk set "
-          . $part_no . " raid on";
+        push @FAI::commands, "parted -s $disk set $part_no raid on";
       }
       # wait for udev to set up all devices
       push @FAI::commands, "udevsettle --timeout=10";
@@ -157,8 +144,7 @@
 # The list is @FAI::commands
 #
 ################################################################################
-sub erase_lvm_signature
-{
+sub erase_lvm_signature {
     my( $devices_aref ) = @_;
       # first remove the dm_mod module to prevent ghost lvm volumes 
       # from existing
@@ -183,13 +169,9 @@
 # The list is @FAI::commands
 #
 ################################################################################
-sub build_lvm_commands
-{
-
+sub build_lvm_commands {
   # loop through all configs
-  foreach my $config ( keys %FAI::configs )
-  {
-
+  foreach my $config ( keys %FAI::configs ) {
     # no physical devices here
     next if ( $config =~ /^PHY_(.+)$/ );
 
@@ -204,8 +186,7 @@
 
     # find volumes that should be preserved or resized and ensure that they
     # already exist
-    foreach my $lv ( keys %{ $FAI::configs{$config}{"volumes"} } )
-    {
+    foreach my $lv ( keys %{ $FAI::configs{$config}{"volumes"} } ) {
       next
         unless ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"preserve"} == 1
         || $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"resize"} == 1 );
@@ -216,8 +197,7 @@
     }
 
     # set proper partition types for LVM
-    foreach my $d (keys %{ $FAI::configs{$config}{"devices"} })
-    {
+    foreach my $d (keys %{ $FAI::configs{$config}{"devices"} }) {
       # only match physical partitions (this string of matchings is hopefully complete)
       next unless( $d =~
         m{^/dev/(cciss/c\dd\dp|ida/c\dd\dp|rd/c\dd\dp|ataraid/d\dp|sd[a-t]|hd[a-t])(\d+)$} );
@@ -230,17 +210,13 @@
       # as that may be created later on
       ( -b $disk ) or die "Specified disk $disk does not exist in this system!\n";
       # set the lvm flag
-      push @FAI::commands,
-        "$FAI::system_commands{'parted'} $disk set "
-        . $part_no . " lvm on";
+      push @FAI::commands, "parted -s $disk set $part_no lvm on";
     }
     # wait for udev to set up all devices
     push @FAI::commands, "udevsettle --timeout=10";
 
     # create the volume group, if it doesn't exist already
-    if ( !defined( $FAI::current_lvm_config{$vg} ) )
-    {
-
+    if ( !defined( $FAI::current_lvm_config{$vg} ) ) {
       # create all the devices
       my @devices = keys %{ $FAI::configs{$config}{"devices"} };
       &FAI::erase_lvm_signature(\@devices);
@@ -253,8 +229,7 @@
 
     # otherwise add or remove the devices for the volume group, run pvcreate
     # where needed (using pvdisplay <bla> || pvcreate <bla>)
-    else
-    {
+    else {
 
       # the list of devices to be created
       my %new_devs = ();
@@ -290,36 +265,27 @@
 
     # remove, resize, create the logical volumes
     # remove all volumes that do not exist anymore or need not be preserved
-    foreach my $lv ( keys %{ $FAI::current_lvm_config{$vg}{"volumes"} } )
-    {
-
+    foreach my $lv ( keys %{ $FAI::current_lvm_config{$vg}{"volumes"} } ) {
       # skip preserved/resized volumes
-      next
-        if (
-        defined( $FAI::configs{$config}{"volumes"}{$lv} )
+      next if ( defined( $FAI::configs{$config}{"volumes"}{$lv} )
         && ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"preserve"} == 1
-          || $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"resize"} )
-        );
+          || $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"resize"} ));
 
       # remove $lv
       push @FAI::commands, "lvremove -f $vg/$lv";
     }
 
     # now create or resize the configured logical volumes
-    foreach my $lv ( keys %{ $FAI::configs{$config}{"volumes"} } )
-    {
-
+    foreach my $lv ( keys %{ $FAI::configs{$config}{"volumes"} } ) {
       # skip preserved partitions, but ensure that they exist
-      if ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"preserve"} == 1 )
-      {
+      if ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"preserve"} == 1 ) {
         defined( $FAI::current_lvm_config{$vg}{"volumes"}{$lv} )
           or die "Preserved volume $vg/$lv does not exist\n";
         next;
       }
 
       # resize the volume
-      if ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"resize"} == 1 )
-      {
+      if ( $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"resize"} == 1 ) {
         defined( $FAI::current_lvm_config{$vg}{"volumes"}{$lv} )
           or die "Resized volume $vg/$lv does not exist\n";
 
@@ -331,8 +297,7 @@
       }
 
       # create a new volume
-      else
-      {
+      else {
         push @FAI::commands,
           "lvcreate -n $lv -L "
           . $FAI::configs{$config}{"volumes"}{$lv}{"size"}{"eff_size"} . " $vg";
@@ -354,13 +319,9 @@
 # The list is @FAI::commands
 #
 ################################################################################
-sub build_disk_commands
-{
-
+sub build_disk_commands {
   # loop through all configs
-  foreach my $config ( keys %FAI::configs )
-  {
-
+  foreach my $config ( keys %FAI::configs ) {
     # no RAID devices here
     next if ( $config eq "RAID" );
 
@@ -374,24 +335,16 @@
     my $disk = $1;
 
     # create partitions on non-virtual configs
-    if ( $FAI::configs{$config}{"virtual"} == 0 )
-    {
-
+    if ( $FAI::configs{$config}{"virtual"} == 0 ) {
       # the list of partitions that must be preserved
       my @to_preserve = ();
 
       # find partitions that should be preserved or resized
-      foreach
-        my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-      {
+      foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } ) {
+        next unless (
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} == 1
+          || $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} == 1 );
 
-        next
-          unless (
-          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} ==
-          1
-          || $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} ==
-          1 );
-
         # preserved or resized partitions must exist already
         defined( $FAI::current_config{$disk}{"partitions"}{$part_id} )
           or die "$part_id can't be preserved, it does not exist.\n";
@@ -411,47 +364,30 @@
 
       # add the extended partition as well, if logical partitions must be
       # preserved; and mark it as resize
-      if ( $FAI::configs{$config}{"disklabel"} eq "msdos" )
-      {
-
+      if ( $FAI::configs{$config}{"disklabel"} eq "msdos" ) {
         # we assume there are no logical partitions
         my $has_logical = 0;
         my $extended    = -1;
 
         # now check all entries; the array is sorted
-        foreach my $part_id (@to_preserve)
-        {
-
+        foreach my $part_id (@to_preserve) {
           # the extended partition may already be listed; then, the id of the
           # extended partition must not change
-          if ( $FAI::current_config{$disk}{"partitions"}{$part_id}
-            {"is_extended"} == 1 )
-          {
-            (
-              defined(
-                $FAI::configs{$config}{"partitions"}{$extended}{"size"}
-                  {"extended"}
-                )
-                && defined(
-                $FAI::current_config{$disk}{"partitions"}{$extended}
-                  {"is_extended"}
-                )
-                && $FAI::configs{$config}{"partitions"}{$extended}{"size"}
-                {"extended"} == 1
-                && $FAI::current_config{$disk}{"partitions"}{$extended}
-                {"is_extended"} == 1
-            ) or die "ID of extended partition changes\n";
+          if ( $FAI::current_config{$disk}{"partitions"}{$part_id}{"is_extended"} == 1 ) {
+            ( defined( $FAI::configs{$config}{"partitions"}{$extended}{"size"}{"extended"})
+                && defined( $FAI::current_config{$disk}{"partitions"}{$extended}{"is_extended"})
+                && $FAI::configs{$config}{"partitions"}{$extended}{"size"}{"extended"} == 1
+                && $FAI::current_config{$disk}{"partitions"}{$extended}{"is_extended"} == 1 ) 
+                or die "ID of extended partition changes\n";
 
             # make sure resize is set
-            $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} =
-              1;
+            $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} = 1;
             $extended = $part_id;
             last;
           }
 
           # there is some logical partition
-          if ( $part_id > 4 )
-          {
+          if ( $part_id > 4 ) {
             $has_logical = 1;
             last;
           }
@@ -459,23 +395,15 @@
 
         # if the extended partition is not listed yet, find and add it now; note
         # that we need to add the existing one
-        if ( 1 == $has_logical && -1 == $extended )
-        {
-          foreach my $part_id (
-            sort keys %{ $FAI::current_config{$disk}{"partitions"} } )
-          {
+        if ( 1 == $has_logical && -1 == $extended ) {
+          foreach my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } ) {
 
             # no extended partition
-            next
-              unless ( $FAI::current_config{$disk}{"partitions"}{$part_id}
-              {"is_extended"} == 1 );
+            next unless ( $FAI::current_config{$disk}{"partitions"}{$part_id}{"is_extended"} == 1 );
 
             # find the configured extended partition to set the mapping
-            foreach
-              my $p ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-            {
-              next
-                unless (
+            foreach my $p ( sort keys %{ $FAI::configs{$config}{"partitions"} } ) {
+              next unless (
                 $FAI::configs{$config}{"partitions"}{$p}{"size"}{"extended"} ==
                 1 );
 
@@ -504,23 +432,19 @@
 
         # a sanity check: if there are logical partitions, they extended must
         # have been added
-        ( 0 == $has_logical || -1 != $extended )
-          or die
-"INTERNAL ERROR: Required extended partition not detected for preserve\n";
+        ( 0 == $has_logical || -1 != $extended ) or die
+          "INTERNAL ERROR: Required extended partition not detected for preserve\n";
       }
 
       # A new disk label may only be written if no partitions need to be
       # preserved
-      (
-        (
-          $FAI::configs{$config}{'disklabel'} eq
-            $FAI::current_config{$disk}{'disklabel'}
-        )
-          || ( scalar(@to_preserve) == 0 )
-      ) or die "Can't change disklabel, partitions are to be preserved\n";
+      ( ( $FAI::configs{$config}{'disklabel'} eq
+            $FAI::current_config{$disk}{'disklabel'})
+          || ( scalar(@to_preserve) == 0 ) ) 
+          or die "Can't change disklabel, partitions are to be preserved\n";
 
       # write the disklabel to drop the previous partition table
-      push @FAI::commands, "$FAI::system_commands{'parted'} $disk mklabel "
+      push @FAI::commands, "parted -s $disk mklabel "
         . $FAI::configs{$config}{'disklabel'};
 
       # once we rebuild partitions, their ids are likely to change; this counter
@@ -528,9 +452,7 @@
       my $part_nr = 0;
 
       # now rebuild all preserved partitions
-      foreach my $part_id (@to_preserve)
-      {
-
+      foreach my $part_id (@to_preserve) {
         # get the existing id
         my $mapped_id =
           $FAI::configs{$config}{"partitions"}{$part_id}{"maps_to_existing"};
@@ -543,17 +465,12 @@
 
         # the type of the partition defaults to primary
         my $part_type = "primary";
-        if ( $FAI::configs{$config}{"disklabel"} eq "msdos" )
-        {
+        if ( $FAI::configs{$config}{"disklabel"} eq "msdos" ) {
 
           # change the partition type to extended or logical as appropriate
-          if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-            {"extended"} == 1 )
-          {
+          if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"extended"} == 1 ) {
             $part_type = "extended";
-          }
-          elsif ( $part_id > 4 )
-          {
+          } elsif ( $part_id > 4 ) {
             $part_type = "logical";
             $part_nr = 4 if ( $part_nr < 4 );
           }
@@ -567,9 +484,7 @@
 
         # build a parted command to create the partition
         push @FAI::commands,
-          "$FAI::system_commands{'parted'} $disk mkpart "
-          . "$part_type $start" . "B "
-          . $end . "B";
+          "parted -s $disk mkpart $part_type ${start}B ${end}B";
       }
 
       # resize partitions; first we shrink partitions, then grow others;
@@ -579,24 +494,18 @@
       my @grow_list   = ();
 
       # iterate over the worklists
-      foreach my $part_id (@shrink_list)
-      {
-
+      foreach my $part_id (@shrink_list) {
         # anything to be done?
-        next
-          unless (
-          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} ==
-          1 );
+        next unless (
+          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} == 1 );
 
         # get the existing id
         my $mapped_id =
           $FAI::configs{$config}{"partitions"}{$part_id}{"maps_to_existing"};
 
         # if partition is to be grown, move it to then grow_list
-        if (
-          $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} >
-          $FAI::current_config{$disk}{"partitions"}{$mapped_id}{"count_byte"} )
-        {
+        if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"eff_size"} >
+          $FAI::current_config{$disk}{"partitions"}{$mapped_id}{"count_byte"} ) {
           unshift @grow_list, $part_id;
           next;
         }
@@ -605,79 +514,61 @@
         my $p = $FAI::current_config{$disk}{"partitions"}{$mapped_id}{"new_id"};
 
         # get the new starts and ends
-        my $start =
-          $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
+        my $start = $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
         my $end = $FAI::configs{$config}{"partitions"}{$part_id}{"end_byte"};
 
         # build an appropriate command
-        push @FAI::commands,
-          "$FAI::system_commands{'parted'} $disk resize $p $start" . "B " . $end
-          . "B";
+        push @FAI::commands, "parted -s $disk resize $p ${start}B ${end}B";
       }
 
       # grow the remaining partitions
-      foreach my $part_id (@grow_list)
-      {
+      foreach my $part_id (@grow_list) {
 
         # get the existing id
-        my $mapped_id =
-          $FAI::configs{$config}{"partitions"}{$part_id}{"maps_to_existing"};
+        my $mapped_id = $FAI::configs{$config}{"partitions"}{$part_id}{"maps_to_existing"};
 
         # get the new partition id
         my $p = $FAI::current_config{$disk}{"partitions"}{$mapped_id}{"new_id"};
 
         # get the new starts and ends
-        my $start =
-          $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
+        my $start = $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
         my $end = $FAI::configs{$config}{"partitions"}{$part_id}{"end_byte"};
 
         # build an appropriate command
         push @FAI::commands,
-          "$FAI::system_commands{'parted'} $disk resize $p $start" . "B " . $end
-          . "B";
+          "parted -s $disk resize $p ${start}B ${end}B";
       }
 
       # write the disklabel again to drop the partition table
-      push @FAI::commands, "$FAI::system_commands{'parted'} $disk mklabel "
-        . $FAI::configs{$config}{'disklabel'};
+      push @FAI::commands, "parted -s $disk mklabel " . $FAI::configs{$config}{'disklabel'};
 
       # generate the commands for creating all partitions
-      foreach
-        my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-      {
+      foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } ) {
 
         # get the new starts and ends
-        my $start =
-          $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
+        my $start = $FAI::configs{$config}{"partitions"}{$part_id}{"start_byte"};
         my $end = $FAI::configs{$config}{"partitions"}{$part_id}{"end_byte"};
 
         # the type of the partition defaults to primary
         my $part_type = "primary";
-        if ( $FAI::configs{$config}{"disklabel"} eq "msdos" )
-        {
+        if ( $FAI::configs{$config}{"disklabel"} eq "msdos" ) {
 
           # change the partition type to extended or logical as appropriate
-          if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}
-            {"extended"} == 1 )
-          {
+          if ( $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"extended"} == 1 ) {
             $part_type = "extended";
-          }
-          elsif ( $part_id > 4 )
-          {
+          } elsif ( $part_id > 4 ) {
             $part_type = "logical";
           }
         }
 
         # build a parted command to create the partition
         push @FAI::commands,
-          "$FAI::system_commands{'parted'} $disk mkpart "
-          . "$part_type $start" . "B "
-          . $end . "B";
+          "parted -s $disk mkpart $part_type ${start}B ${end}B";
       }
 
       # set the bootable flag, if requested at all
       push @FAI::commands,
-        "$FAI::system_commands{'parted'} $disk set "
+        "parted -s $disk set "
         . $FAI::configs{$config}{"bootable"}
         . " boot on"
         if ( $FAI::configs{$config}{"bootable"} > -1 );
@@ -687,12 +578,10 @@
     }
 
     # generate the commands for creating all filesystems
-    foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
-    {
+    foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } ) {
 
       # skip preserved/resized/extended partitions
-      next
-        if (
+      next if (
         $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} == 1
         || $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} == 1
         || $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"extended"} ==
@@ -710,50 +599,36 @@
 # @brief Whatever happened, write the previous partition table to the disk again
 #
 ################################################################################
-sub restore_partition_table
-{
+sub restore_partition_table {
 
   # loop through all existing configs
-  foreach my $disk ( keys %FAI::current_config )
-  {
+  foreach my $disk ( keys %FAI::current_config ) {
 
     # write the disklabel again to drop the partition table
-    &FAI::execute_command( "$FAI::system_commands{'parted'} $disk mklabel "
+    &FAI::execute_command( "parted -s $disk mklabel "
         . $FAI::current_config{$disk}{'disklabel'} );
 
     # generate the commands for creating all partitions
-    foreach
-      my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } )
-    {
+    foreach my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } ) {
 
       # get the starts and ends
-      my $start =
-        $FAI::current_config{$disk}{"partitions"}{$part_id}{"begin_byte"};
+      my $start = $FAI::current_config{$disk}{"partitions"}{$part_id}{"begin_byte"};
       my $end = $FAI::current_config{$disk}{"partitions"}{$part_id}{"end_byte"};
 
       # the type of the partition defaults to primary
       my $part_type = "primary";
-      if ( $FAI::current_config{$disk}{"disklabel"} eq "msdos" )
-      {
+      if ( $FAI::current_config{$disk}{"disklabel"} eq "msdos" ) {
 
         # change the partition type to extended or logical as appropriate
-        if (
-          $FAI::current_config{$disk}{"partitions"}{$part_id}{"is_extended"} ==
-          1 )
-        {
+        if ( $FAI::current_config{$disk}{"partitions"}{$part_id}{"is_extended"} == 1 ) {
           $part_type = "extended";
-        }
-        elsif ( $part_id > 4 )
-        {
+        } elsif ( $part_id > 4 ) {
           $part_type = "logical";
         }
       }
 
       # build a parted command to create the partition
-      &FAI::execute_command( "$FAI::system_commands{'parted'} $disk mkpart "
-          . "$part_type $start" . "B "
-          . $end
-          . "B" );
+      &FAI::execute_command( "parted -s $disk mkpart $part_type ${start}B ${end}B" );
     }
     warn "Partition table of disk $disk has been restored\n";
   }

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-exec
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-exec	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-exec	2007-11-11 10:19:49 UTC (rev 4702)
@@ -114,8 +114,7 @@
 # @return our interpretation of the error as string
 #
 ################################################################################
-sub get_error_message
-{
+sub get_error_message {
   my ($error) = @_;
   my @treffer = grep { $_->{error} eq "$error" } @$FAI::error_codes;
 
@@ -133,8 +132,7 @@
 # @return the associated value
 #
 ################################################################################
-sub get_error
-{
+sub get_error {
   my ( $error, $field ) = @_;
   my @treffer = grep { $_->{error} eq "$error" } @$FAI::error_codes;
 
@@ -158,12 +156,10 @@
 # @return the identifier of the error
 #
 ################################################################################
-sub execute_command_std    #execute command with standard error handling
-{
+sub execute_command_std {
   my ( $command, $stdout_ref, $stderr_ref ) = @_;
   my $err = &execute_command( $command, $stdout_ref, $stderr_ref );
-  if ( $err ne "" )
-  {
+  if ( $err ne "" ) {
     my $response = &get_error( $err, "response" );
     my $message  = &get_error( $err, "message" );
 
@@ -194,8 +190,7 @@
 # @return the identifier of the error
 #
 ################################################################################
-sub execute_command
-{
+sub execute_command {
   my ( $command, $stdout_ref, $stderr_ref ) = @_;
 
   my @stderr      = ();
@@ -208,17 +203,14 @@
   ( my $stdout_fh, my $stdout_filename ) = File::Temp::tempfile( UNLINK => 1 );
 
   # do only execute the given command, when in no_dry_mode
-  if ($FAI::no_dry_run)
-  {
+  if ($FAI::no_dry_run) {
 
     ($FAI::debug)
       and print "(CMD) $command 1> $stdout_filename 2> $stderr_filename\n";
 
     # execute the bash command, write stderr and stdout into the testfiles
     `$command 1> $stdout_filename 2> $stderr_filename`;
-  }
-  else
-  {
+  } else {
     print "would run command $command; to have them executed, use -X \n";
   }
 
@@ -246,18 +238,13 @@
   @$stderr_ref = @stderr if ( 'ARRAY' eq ref($stderr_ref) );
 
   #get the error, if there was any
-  foreach my $err (@$FAI::error_codes)
-  {
-    if (
-      (
+  foreach my $err (@$FAI::error_codes) {
+    if ( (
         $err->{'stdout_regex'} eq "" || $stdout_line =~ /$err->{'stdout_regex'}/
-      )
-      && ( $err->{'stderr_regex'} eq ""
+      ) && ( $err->{'stderr_regex'} eq ""
         || $stderr_line =~ /$err->{'stderr_regex'}/ )
       && ( $err->{'program'} eq "" || $command =~ /.*$err->{'program'}.*/ )
-      )
-    {
-
+      ) {
       return $err->{'error'};
     }
   }

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-fstab	2007-11-11 10:19:49 UTC (rev 4702)
@@ -46,8 +46,7 @@
 # @return list of fstab lines
 #
 ################################################################################
-sub generate_fstab
-{
+sub generate_fstab {
 
   # config structure is the only input
   my ($config) = @_;
@@ -57,12 +56,10 @@
 
   # walk through all configured parts
   # the order of entries is most likely wrong, it is fixed at the end
-  foreach my $c ( keys %$config )
-  {
+  foreach my $c ( keys %$config ) {
 
     # entry is a physical device
-    if ( $c =~ /^PHY_(.+)$/ )
-    {
+    if ( $c =~ /^PHY_(.+)$/ ) {
       my $device = $1;
 
       # make sure the desired fstabkey is defined at all
@@ -70,8 +67,7 @@
         or die "INTERNAL ERROR: fstabkey undefined\n";
 
       # create a line in the output file for each partition
-      foreach my $p ( sort keys %{ $config->{$c}->{"partitions"} } )
-      {
+      foreach my $p ( sort keys %{ $config->{$c}->{"partitions"} } ) {
 
         # keep a reference to save some typing
         my $p_ref = $config->{$c}->{"partitions"}->{$p};
@@ -105,19 +101,13 @@
           \@label, 0 );
 
         # using the fstabkey value the desired device entry is defined
-        if ( $config->{$c}->{"fstabkey"} eq "uuid" )
-        {
+        if ( $config->{$c}->{"fstabkey"} eq "uuid" ) {
           chomp( $uuid[0] );
           push @fstab_line, "UUID=" . $uuid[0];
-        }
-        elsif ( $config->{$c}->{"fstabkey"} eq "label" && scalar(@label) == 1 )
-        {
+        } elsif ( $config->{$c}->{"fstabkey"} eq "label" && scalar(@label) == 1 ) {
           chomp( $label[0] );
           push @fstab_line, "LABEL=" . $label[0];
-        }
-        else
-        {
-
+        } else {
           # otherwise, use the usual device path
           push @fstab_line, $device . $p_ref->{"number"};
         }
@@ -138,7 +128,7 @@
         push @fstab_line, 2;
         $fstab_line[-1] = 1 if ( $p_ref->{"mountpoint"} eq "/" );
 
-   # join the columns of one line with tabs, and push it to our fstab line array
+        # join the columns of one line with tabs, and push it to our fstab line array
         push @fstab, join( "\t", @fstab_line );
 
         # set the ROOT_PARTITION variable, if this is the mountpoint for /
@@ -149,14 +139,11 @@
         $FAI::disk_var{"SWAPLIST"} .= " " . $device . $p_ref->{"number"}
           if ( $p_ref->{"filesystem"} eq "swap" );
       }
-    }
-    elsif ( $c =~ /^VG_(.+)$/ )
-    {
+    } elsif ( $c =~ /^VG_(.+)$/ ) {
       my $device = $1;
 
       # create a line in the output file for each logical volume
-      foreach my $l ( sort keys %{ $config->{$c}->{"volumes"} } )
-      {
+      foreach my $l ( sort keys %{ $config->{$c}->{"volumes"} } ) {
 
         # keep a reference to save some typing
         my $l_ref = $config->{$c}->{"volumes"}->{$l};
@@ -195,7 +182,7 @@
         push @fstab_line, 2;
         $fstab_line[-1] = 1 if ( $l_ref->{"mountpoint"} eq "/" );
 
-   # join the columns of one line with tabs, and push it to our fstab line array
+        # join the columns of one line with tabs, and push it to our fstab line array
         push @fstab, join( "\t", @fstab_line );
 
         # set the ROOT_PARTITION variable, if this is the mountpoint for /
@@ -206,13 +193,10 @@
         $FAI::disk_var{"SWAPLIST"} .= " " . $fstab_line[0]
           if ( $l_ref->{"filesystem"} eq "swap" );
       }
-    }
-    elsif ( $c eq "RAID" )
-    {
+    } elsif ( $c eq "RAID" ) {
 
       # create a line in the output file for each device
-      foreach my $r ( sort keys %{ $config->{$c}->{"volumes"} } )
-      {
+      foreach my $r ( sort keys %{ $config->{$c}->{"volumes"} } ) {
 
         # keep a reference to save some typing
         my $r_ref = $config->{$c}->{"volumes"}->{$r};
@@ -242,7 +226,7 @@
         push @fstab_line, 2;
         $fstab_line[-1] = 1 if ( $r_ref->{"mountpoint"} eq "/" );
 
-   # join the columns of one line with tabs, and push it to our fstab line array
+        # join the columns of one line with tabs, and push it to our fstab line array
         push @fstab, join( "\t", @fstab_line );
 
         # set the ROOT_PARTITION variable, if this is the mountpoint for /
@@ -253,9 +237,7 @@
         $FAI::disk_var{"SWAPLIST"} .= " /dev/md$r"
           if ( $r_ref->{"filesystem"} eq "swap" );
       }
-    }
-    else
-    {
+    } else {
       die "INTERNAL ERROR: Unexpected key $c\n";
     }
   }
@@ -267,8 +249,7 @@
   $FAI::disk_var{"SWAPLIST"} = '"' . $FAI::disk_var{"SWAPLIST"} . '"';
 
   # sort the lines in @fstab to enable all sub mounts
-  for ( my $i = 0 ; $i < scalar(@fstab) ; $i++ )
-  {
+  for ( my $i = 0 ; $i < scalar(@fstab) ; $i++ ) {
 
     # take out the mountpoint
     ( $_, my $mp_1 ) = split( "\t", $fstab[$i] );
@@ -276,8 +257,7 @@
     # partitions without a mountpoint are fine
     next if ( $mp_1 eq "none" );
 
-    for ( my $j = $i + 1 ; $j < scalar(@fstab) ; $j++ )
-    {
+    for ( my $j = $i + 1 ; $j < scalar(@fstab) ; $j++ ) {
 
       # take out the other mountpoint
       ( $_, my $mp_2 ) = split( "\t", $fstab[$j] );
@@ -286,8 +266,7 @@
       $mp_2 =~ s/\/$//;
 
       # $mp_1 depends on $mp_2 being mounted, swap them
-      if ( $mp_1 =~ /^\Q$mp_2\E\// )
-      {
+      if ( $mp_1 =~ /^\Q$mp_2\E\// ) {
         my $line_i = $fstab[$i];
         $fstab[$i] = $fstab[$j];
         $fstab[$j] = $line_i;

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-init
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-init	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-init	2007-11-11 10:19:49 UTC (rev 4702)
@@ -176,17 +176,5 @@
 ################################################################################
 @FAI::commands = ();
 
-################################################################################
-#
-# @brief A map of commands
-#
-# checks for availability within $PATH are performed from within the parser
-#
-################################################################################
-%FAI::system_commands = (
-  "mdadm"  => "mdadm",
-  "parted" => "parted -s"
-);
-
 1;
 

Deleted: people/michael/features/setup_harddisks_2/implementation/shdd2-lib
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-lib	2007-11-11 10:19:49 UTC (rev 4702)
@@ -1,110 +0,0 @@
-#!/usr/bin/perl -w
-
-#*********************************************************************
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# A copy of the GNU General Public License is available as
-# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
-# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
-# can also obtain it by writing to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#*********************************************************************
-
-use strict;
-
-################################################################################
-#
-# @file shdd2-lib
-#
-# @brief A small library of utility functions possibly useful in various places
-#
-# $Id$
-#
-# @author Christian Kern, Michael Tautschnig
-# @date Sun Jul 23 16:09:36 CEST 2006
-#
-################################################################################
-
-package FAI;
-
-################################################################################
-#
-# @brief Test, whether @ref $cmd is available on the system using $PATH
-#
-# @param $cmd Command that is to be found in $PATH
-#
-# @return 1, if the command is found, else 0
-#
-################################################################################
-sub in_path
-{
-
-  # initialize the parameter
-  my ($cmd) = @_;
-
-  # split $PATH into its components, search all of its components
-  foreach my $p ( split( ":", $ENV{"PATH"} ) )
-  {
-
-    # and test for $cmd being executable
-    ( -x "$p/$cmd" ) and return 1;
-  }
-  return 0;
-}
-
-################################################################################
-#
-# @brief The structure, in which we hold informations about existing partitions
-# and partitions we want to create a hold in hash of hashes. This debug function
-# allows to recursivly print such a hash with all keys und subhashes
-#
-# @param hash_ref the reference to the hash, where we want to start printing
-# the hash recursively
-#
-# @param k A helper variable, is only to be used for the recursion. The caller
-# caller shoudn't set this one
-#
-################################################################################
-sub print_hash
-{
-
-  # This function is for debugging purposes only
-  ( $FAI::debug > 0 ) or return 0;
-
-  # get the function parameters
-  my ( $hash_ref, $k ) = @_;
-
-  # append a > for showing the depth in the hash of hashes
-  $k = "$k>";
-
-  # print all keys
-  foreach my $key ( keys %$hash_ref )
-  {
-
-    # if there is another hash, recursively call the function with this hash
-    if ( ref( $hash_ref->{$key} ) eq 'ARRAY' )
-    {
-      print "$k KEY: $key VAL: " . join( " ", @{ $hash_ref->{$key} } ) . "\n";
-    }
-    elsif ( ref( $hash_ref->{$key} ) )
-    {
-      print "$k KEY: $key VAL: hash\n";
-      &print_hash( $hash_ref->{$key}, $k );
-    }
-    else
-    {
-      print "$k KEY: $key VAL: $hash_ref->{$key}\n";
-    }
-  }
-}
-
-1;
-

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-parser
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-parser	2007-11-11 10:19:49 UTC (rev 4702)
@@ -130,6 +130,27 @@
 
 ################################################################################
 #
+# @brief Test, whether @ref $cmd is available on the system using $PATH
+#
+# @param $cmd Command that is to be found in $PATH
+#
+# @return 1, if the command is found, else 0
+#
+################################################################################
+sub in_path {
+
+  # initialize the parameter
+  my ($cmd) = @_;
+
+  # split $PATH into its components, search all of its components
+  # and test for $cmd being executable
+  ( -x "$_/$cmd" ) and return 1 foreach ( split( ":", $ENV{"PATH"} ) );
+  # return 0 otherwise
+  return 0;
+}
+
+################################################################################
+#
 # @brief Initialise a new entry in @ref $FAI::configs for a physical disk.
 #
 # Besides creating the entry in the hash, the fully path of the device is
@@ -141,15 +162,13 @@
 # name, such as sdb, in which case /dev/ is prepended.
 #
 ################################################################################
-sub init_disk_config
-{
+sub init_disk_config {
 
   # Initialise $disk
   my ($disk) = @_;
 
   # test $disk for being numeric
-  if ( $disk =~ /^\d+$/ )
-  {
+  if ( $disk =~ /^\d+$/ ) {
 
     # $disk-1 must be a valid index in the map of all disks in the system
     ( scalar(@FAI::disks) >= $disk )
@@ -190,8 +209,7 @@
 # @param $type The type of the partition. It must be either primary or logical.
 #
 ################################################################################
-sub init_part_config
-{
+sub init_part_config {
 
   # the type of the partition to be created
   my ($type) = @_;
@@ -211,22 +229,17 @@
   my $part_number = 0;
 
   # create a primary partition
-  if ( $type eq "primary" )
-  {
+  if ( $type eq "primary" ) {
 
     # find all previously defined primary partitions
-    foreach
-      my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } )
-    {
+    foreach my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } ) {
 
       # break, if the partition has not been created by init_part_config
       defined( $FAI::configs{$FAI::device}{"partitions"}{$part_id}{"size"}
-          {"extended"} )
-        or last;
+          {"extended"} ) or last;
 
       # on msdos disklabels we cannot have more than 4 primary partitions
-      last
-        if ( $part_id > 4
+      last if ( $part_id > 4
         && $FAI::configs{$FAI::device}{"disklabel"} eq "msdos" );
 
       # store the latest index found
@@ -239,17 +252,13 @@
     # msdos disk labels don't allow for more than 4 primary partitions
     ( $part_number < 5 || $FAI::configs{$FAI::device}{"disklabel"} ne "msdos" )
       or die "$part_number are too many primary partitions\n";
-  }
-  else
-  {
+  } else {
 
     # no further checks for the disk label being msdos have to be performed in
     # this branch, it has been ensured above
 
-# find the index of the new partition, initialise it to the highest current index
-    foreach
-      my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } )
-    {
+    # find the index of the new partition, initialise it to the highest current index
+    foreach my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } ) {
 
       # skip primary partitions
       next if ( $part_id < 5 );
@@ -268,22 +277,18 @@
 
     # if this is the first logical partition, the index must be set to 5 and an
     # extended partition  must be created
-    if ( $part_number <= 5 )
-    {
+    if ( $part_number <= 5 ) {
       $part_number = 5;
 
       # the proposed index of the extended partition
       my $extended = 0;
 
       # find all previously defined primary partitions
-      foreach
-        my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } )
-      {
+      foreach my $part_id ( sort keys %{ $FAI::configs{$FAI::device}{"partitions"} } ) {
 
         # break, if the partition has not been created by init_part_config
         defined( $FAI::configs{$FAI::device}{"partitions"}{$part_id}{"size"}
-            {"extended"} )
-          or last;
+            {"extended"} ) or last;
 
         # we cannot have more than 4 primary partitions
         last if ( $part_id > 4 );
@@ -300,14 +305,11 @@
         or die "Too many primary partitions while creating extended\n";
 
       # mark the entry as an extended partition
-      $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}{"extended"} =
-        1;
+      $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}{"extended"} = 1;
 
       # add the preserve = 0 flag, if it doesn't exist already
-      defined( $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}
-          {"preserve"} )
-        or $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}
-        {"preserve"} = 0;
+      defined( $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}{"preserve"} )
+        or $FAI::configs{$FAI::device}{"partitions"}{$extended}{"size"}{"preserve"} = 0;
 
       # add the resize = 0 flag, if it doesn't exist already
       defined(
@@ -355,30 +357,13 @@
 sub convert_unit
 {
   my ($val) = @_;
-  $val =~ /(\d+)([kMGTP%]?)/;
-  unless ( $2 eq "%" )
-  {
-    if ( $2 eq "k" )
-    {
-      $val = $1 * ( 1 / 1024 );
-    }
-    elsif ( $2 eq "M" )
-    {
-      $val = $1;
-    }
-    elsif ( $2 eq "G" )
-    {
-      $val = $1 * 1024;
-    }
-    elsif ( $2 eq "T" )
-    {
-      $val = $1 * ( 1024 * 1024 );
-    }
-    elsif ( $2 eq "P" )
-    {
-      $val = $1 * ( 1024 * 1024 * 1024 );
-    }
-  }
+  ( $val =~ /^(\d+)([kMGTP%]?)(B)?\s*$/ ) or die "INTERNAL ERROR (convert_unit)\n";
+  $val = $1 * ( 1 / 1024 ) if ( $2 eq "k" );
+  $val = $1 if ( $2 eq "M" );
+  $val = $1 * 1024 if ( $2 eq "G" );
+  $val = $1 * ( 1024 * 1024 ) if ( $2 eq "T" );
+  $val = $1 * ( 1024 * 1024 * 1024 ) if ( $2 eq "P" );
+  # % is returned as is
   return $val;
 }
 
@@ -717,8 +702,7 @@
 # @param IN file handle for input file, may be STDIN
 #
 ################################################################################
-sub run_parser
-{
+sub run_parser {
   my ($IN) = @_;
 
   # read <$IN> to a single string (not a list), thus $/ has to be unset

Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-volumes
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-volumes	2007-11-11 10:18:55 UTC (rev 4701)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-volumes	2007-11-11 10:19:49 UTC (rev 4702)
@@ -41,15 +41,13 @@
 # in $FAI::disks and $FAI::configs{PHY_<disk>}
 #
 ################################################################################
-sub get_current_disks
-{
+sub get_current_disks {
 
   # backup value of $FAI::no_dry_run
   my $no_dry_run = $FAI::no_dry_run;
 
   # obtain the current state of all disks
-  foreach my $disk (@FAI::disks)
-  {
+  foreach my $disk (@FAI::disks) {
 
     # create full paths
     ( $disk =~ m{^/} ) or $disk = "/dev/$disk";
@@ -69,35 +67,25 @@
     # try to obtain the partition table for $disk
     # it might fail with parted_2 in case the disk has no partition table
     my $error =
-      &FAI::execute_command_std(
-      $FAI::system_commands{"parted"} . " $disk unit TiB print",
-      \@parted_print, 0 );
+      &FAI::execute_command_std( "parted -s $disk unit TiB print", \@parted_print, 0 );
 
     # reset no_dry_run
     $FAI::no_dry_run = $no_dry_run;
 
     # parted_2 happens when the disk has no disk label, because parted then
     # provides no information about the disk
-    if ( $error eq "parted_2" )
-    {
+    if ( $error eq "parted_2" ) {
 
       # if there is no disk configuration, write an msdos disklabel
-      if ( !defined( $FAI::configs{"PHY_$disk"}{"disklabel"} ) )
-      {
+      if ( !defined( $FAI::configs{"PHY_$disk"}{"disklabel"} ) ) {
 
         # write the disk label as configured
-        $error =
-          &FAI::execute_command(
-          $FAI::system_commands{"parted"} . " $disk mklabel msdos" );
-      }
-      else
-      {
+        $error = &FAI::execute_command( "parted -s $disk mklabel msdos" );
+      } else {
 
         # write the disk label as configured
         $error =
-          &FAI::execute_command( $FAI::system_commands{"parted"}
-            . " $disk mklabel "
-            . $FAI::configs{"PHY_$disk"}{"disklabel"} );
+          "parted -s $disk mklabel " . $FAI::configs{"PHY_$disk"}{"disklabel"} );
       }
 
       # set no_dry_run to perform read-only commands always
@@ -105,17 +93,14 @@
 
       # retry partition-table print
       $error =
-        &FAI::execute_command(
-        $FAI::system_commands{"parted"} . " $disk unit TiB print",
-        \@parted_print, 0 );
+        &FAI::execute_command( "parted -s $disk unit TiB print", \@parted_print, 0 );
 
       # reset no_dry_run
       $FAI::no_dry_run = $no_dry_run;
     }
 
     # check, whether there is still an error
-    if ( $error ne "" )
-    {
+    if ( $error ne "" ) {
       my $response = &FAI::get_error( $error, "response" );
       ( $response eq "die" ) and die &FAI::get_error( $error, "message" );
       ( $response eq "warn" ) and warn &FAI::get_error( $error, "message" );
@@ -167,37 +152,29 @@
     my %cols = ();
 
     # Parse the output line by line
-    foreach my $line (@parted_print)
-    {
+    foreach my $line (@parted_print) {
 
       # now we test line by line - some of them may be ignored
-      if ( $line =~ /^Disk /
+      next if ( $line =~ /^Disk /
         || $line =~ /^\s*$/
-        || $line =~ /^WARNING: You are not superuser/ )
-      {
-        next;
-      }
+        || $line =~ /^WARNING: You are not superuser/ );
 
       # determine the logical sector size
-      elsif ( $line =~ /^Sector size \(logical\/physical\): (\d+)B\/(\d+)B$/ )
-      {
+      if ( $line =~ /^Sector size \(logical\/physical\): (\d+)B\/(\d+)B$/ ) {
         $FAI::current_config{$disk}{"sector_size"} = $1;
       }
 
       # read and store the current disk label
-      elsif ( $line =~ /^Partition Table: (.+)$/ )
-      {
+      elsif ( $line =~ /^Partition Table: (.+)$/ ) {
         $FAI::current_config{$disk}{"disklabel"} = $1;
       }
 
       # the line containing the table headers
-      elsif ( $line =~ /^(Number\s+)(\S+\s+)+/ )
-      {
+      elsif ( $line =~ /^(Number\s+)(\S+\s+)+/ ) {
         my $col_start = 0;
 
         # check the length of each heading; note that they might contain spaces
-        while ( $line =~ /^(\S+( [a-z]\S+)?\s*)([A-Z].*)?$/ )
-        {
+        while ( $line =~ /^(\S+( [a-z]\S+)?\s*)([A-Z].*)?$/ ) {
           my $heading = $1;
 
           # set the line to the remainder
@@ -219,8 +196,7 @@
       }
 
       # one of the partitions
-      else
-      {
+      else {
 
         # we must have seen the header, otherwise probably the format has
         # changed
@@ -265,9 +241,7 @@
 
     # obtain the partition table using bytes as units
     $error =
-      &FAI::execute_command_std(
-      "$FAI::system_commands{'parted'} $disk unit B print free",
-      \@parted_print, 0 );
+      &FAI::execute_command_std( "parted -s $disk unit B print free", \@parted_print, 0 );
 
     # reset no_dry_run
     $FAI::no_dry_run = $no_dry_run;
@@ -282,12 +256,10 @@
     # }
 
     # Parse the output of the byte-wise partition table
-    foreach my $line (@parted_print)
-    {
+    foreach my $line (@parted_print) {
 
       # the disk size line (Disk /dev/hda: 82348277759B)
-      if ( $line =~ /Disk \Q$disk\E: (\d+)B$/ )
-      {
+      if ( $line =~ /Disk \Q$disk\E: (\d+)B$/ ) {
         $FAI::current_config{$disk}{"begin_byte"} = 0;
         $FAI::current_config{$disk}{"end_byte"}   = ( $1 - 1 );
         $FAI::current_config{$disk}{"size"}       = $1;
@@ -311,7 +283,7 @@
       $FAI::current_config{$disk}{"partitions"}{$1}{"is_extended"} = 0;
 
       # but may be true/1 on msdos disk labels
-      (      ( $FAI::current_config{$disk}{"disklabel"} eq "msdos" )
+      ( ( $FAI::current_config{$disk}{"disklabel"} eq "msdos" )
           && ( $6 eq "extended" ) )
         and $FAI::current_config{$disk}{"partitions"}{$1}{"is_extended"} = 1;
     }
@@ -325,22 +297,19 @@
     # obtain the partition table using bytes as units
     $error =
       &FAI::execute_command_std(
-      "$FAI::system_commands{'parted'} $disk unit chs print free",
-      \@parted_print, 0 );
+      "parted $disk unit chs print free", \@parted_print, 0 );
 
     # reset no_dry_run
     $FAI::no_dry_run = $no_dry_run;
 
     # Parse the output of the CHS partition table
-    foreach my $line (@parted_print)
-    {
+    foreach my $line (@parted_print) {
 
    # find the BIOS geometry that looks like this:
    # BIOS cylinder,head,sector geometry: 10011,255,63.  Each cylinder is 8225kB.
       if ( $line =~
-/^BIOS cylinder,head,sector geometry:\s*(\d+),(\d+),(\d+)\.\s*Each cylinder is \d+kB\.$/
-        )
-      {
+        /^BIOS cylinder,head,sector geometry:\s*(\d+),(\d+),(\d+)\.\s*Each cylinder is \d+kB\.$/
+        ) {
         $FAI::current_config{$disk}{"bios_cylinders"}         = $1;
         $FAI::current_config{$disk}{"bios_heads"}             = $2;
         $FAI::current_config{$disk}{"bios_sectors_per_track"} = $3;
@@ -366,8 +335,7 @@
 # @brief Collect the current LVM configuration
 #
 ################################################################################
-sub get_current_lvm
-{
+sub get_current_lvm {
 
   # backup value of $FAI::no_dry_run
   my $no_dry_run = $FAI::no_dry_run;
@@ -388,8 +356,7 @@
   #   "XENU" 453.36 MB [451.93 MB used / 1.43 MB free]
 
   # parse the output line by line and call vgdisplay -v <VG>
-  foreach my $line (@vgdisplay_print)
-  {
+  foreach my $line (@vgdisplay_print) {
     ( 
       # example output with an empty vg:
       #   "my_pv" 267476.00 MB [0 MB      used / 267476.00 MB free]
@@ -470,8 +437,7 @@
     my $lv_name = "";
 
     # do the line-wise parsing
-    foreach my $line_v (@vgdisplay_v_print)
-    {
+    foreach my $line_v (@vgdisplay_v_print) {
       $mode = "vg" if ( $line_v =~ /^\s*--- Volume group ---\s*$/ );
       $mode = "lv" if ( $line_v =~ /^\s*--- Logical volume ---\s*$/ );
       $mode = "pv" if ( $line_v =~ /^\s*--- Physical volumes ---\s*$/ );
@@ -479,16 +445,13 @@
       next if ( $mode eq "" );
 
       # Now select the interesting information for each mode
-      if ( $mode eq "vg" )
-      {
+      if ( $mode eq "vg" ) {
 
         # for a volume group only the size is needed
         # extract the floatingpoint value
         $FAI::current_lvm_config{$vg}{"size"} = $1
           if ( $line_v =~ /^\s*Alloc PE \/ Size\s+\d+ \/ (\d+\.\d+) MB\s*$/ );
-      }
-      elsif ( $mode eq "lv" )
-      {
+      } elsif ( $mode eq "lv" ) {
 
         # we need the name and the size of each existing logical volume
         $lv_name = $1
@@ -498,9 +461,7 @@
         # extract the floatingpoint value
         $FAI::current_lvm_config{$vg}{"volumes"}{$lv_name}{"size"} = $1
           if ( $line_v =~ /^\s*LV Size\s+(\d+\.\d+) MB\s*$/ );
-      }
-      elsif ( $mode eq "pv" )
-      {
+      } elsif ( $mode eq "pv" ) {
 
         # get the physical devices that are part of this volume group
         push @{ $FAI::current_lvm_config{$vg}{"physical_volumes"} }, $1
@@ -520,8 +481,7 @@
 # currently active in the system
 #
 ################################################################################
-sub get_current_raid
-{
+sub get_current_raid {
 
   # backup value of $FAI::no_dry_run
   my $no_dry_run = $FAI::no_dry_run;
@@ -548,15 +508,11 @@
   my $id;
 
   # parse the output line by line
-  foreach my $line (@mdadm_print)
-  {
-    if ( $line =~ /^ARRAY \/dev\/md(\d+) level=(\S+) num-devices=\d+ UUID=/ )
-    {
+  foreach my $line (@mdadm_print) {
+    if ( $line =~ /^ARRAY \/dev\/md(\d+) level=(\S+) num-devices=\d+ UUID=/ ) {
       $id = $1;
       $FAI::current_raid_config{$id}{"mode"} = $2;
-    }
-    elsif ( $line =~ /^\s*devices=(\S+)$/ )
-    {
+    } elsif ( $line =~ /^\s*devices=(\S+)$/ ) {
       @{ $FAI::current_raid_config{$id}{"devices"} } = split( ",", $1 );
     }
   }




More information about the Fai-commit mailing list