[Fai-commit] r6699 - branches/experimental/patches

Michael Tautschnig mt at alioth.debian.org
Sat Oct 22 07:59:42 UTC 2011


Author: mt
Date: 2011-10-22 07:59:42 +0000 (Sat, 22 Oct 2011)
New Revision: 6699

Added:
   branches/experimental/patches/setup-storage_keep-flags
Modified:
   branches/experimental/patches/fix-eval_cmdline
   branches/experimental/patches/logtail
   branches/experimental/patches/make-fai-nfsroot_add-keys
   branches/experimental/patches/series
Log:
Added patch to make setup-storage retain partition flags, match current trunk


Modified: branches/experimental/patches/fix-eval_cmdline
===================================================================
--- branches/experimental/patches/fix-eval_cmdline	2011-10-21 22:59:54 UTC (rev 6698)
+++ branches/experimental/patches/fix-eval_cmdline	2011-10-22 07:59:42 UTC (rev 6699)
@@ -7,7 +7,7 @@
 ===================================================================
 --- trunk.orig/lib/subroutines
 +++ trunk/lib/subroutines
-@@ -704,10 +704,14 @@
+@@ -712,10 +712,14 @@
  
      echo -n "Kernel currently running: "
      uname -rsmo

Modified: branches/experimental/patches/logtail
===================================================================
--- branches/experimental/patches/logtail	2011-10-21 22:59:54 UTC (rev 6698)
+++ branches/experimental/patches/logtail	2011-10-22 07:59:42 UTC (rev 6699)
@@ -32,7 +32,7 @@
 ===================================================================
 --- trunk.orig/lib/subroutines
 +++ trunk/lib/subroutines
-@@ -119,7 +119,11 @@
+@@ -124,7 +124,11 @@
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  save_dmesg() {
  
@@ -45,7 +45,7 @@
  }
  # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  umount_csspace() {
-@@ -481,6 +485,7 @@
+@@ -489,6 +493,7 @@
  task_savelog() {
  
      mkdir -p $FAI_ROOT/var/{lib,log}/fai

Modified: branches/experimental/patches/make-fai-nfsroot_add-keys
===================================================================
--- branches/experimental/patches/make-fai-nfsroot_add-keys	2011-10-21 22:59:54 UTC (rev 6698)
+++ branches/experimental/patches/make-fai-nfsroot_add-keys	2011-10-22 07:59:42 UTC (rev 6699)
@@ -7,7 +7,7 @@
 ===================================================================
 --- trunk.orig/bin/make-fai-nfsroot
 +++ trunk/bin/make-fai-nfsroot
-@@ -394,6 +394,15 @@
+@@ -409,6 +409,15 @@
      mount -t devpts devpts $NFSROOT/dev/pts
      /usr/lib/fai/mkramdisk $NFSROOT/var/lib/dpkg
      mkdir $NFSROOT/etc/mdadm; touch $NFSROOT/etc/mdadm/mdadm.conf # stop mdadm from calling mkconf
@@ -22,7 +22,7 @@
 +
      $ROOTCMD apt-get update
      $ROOTCMD aptitude -Rfy install fai-nfsroot
- 
+     $ROOTCMD apt-get -y dist-upgrade
 Index: trunk/man/make-fai-nfsroot.8
 ===================================================================
 --- trunk.orig/man/make-fai-nfsroot.8

Modified: branches/experimental/patches/series
===================================================================
--- branches/experimental/patches/series	2011-10-21 22:59:54 UTC (rev 6698)
+++ branches/experimental/patches/series	2011-10-22 07:59:42 UTC (rev 6699)
@@ -23,3 +23,4 @@
 setup-storage_udevsettle-before-vol-id
 setup-storage_gpt-100-bugfix
 setup-storage_wipefs
+setup-storage_keep-flags

Added: branches/experimental/patches/setup-storage_keep-flags
===================================================================
--- branches/experimental/patches/setup-storage_keep-flags	                        (rev 0)
+++ branches/experimental/patches/setup-storage_keep-flags	2011-10-22 07:59:42 UTC (rev 6699)
@@ -0,0 +1,169 @@
+2011-10-22  Michael Tautschnig  <mt at debian.org>
+
+	* setup-storage/{Volumes.pm,Commands.pm}: retain partition flags of preserved
+		partitions.
+Index: trunk/lib/setup-storage/Commands.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Commands.pm
++++ trunk/lib/setup-storage/Commands.pm
+@@ -165,14 +165,14 @@
+ 
+ ################################################################################
+ #
+-# @brief Set the partition type $t on a device $d. This is a no-op if $d is not
++# @brief Set the partition flag $t on a device $d. This is a no-op if $d is not
+ # a physical device
+ #
+ # @param $d Device name
+-# @param $t Type (e.g., lvm or raid)
++# @param $t Flag (e.g., lvm or raid)
+ #
+ ################################################################################
+-sub set_partition_type_on_phys_dev {
++sub set_partition_flag_on_phys_dev {
+ 
+   my ($d, $t) = @_;
+   my ($i_p_d, $disk, $part_no) = &FAI::phys_dev($d);
+@@ -185,12 +185,12 @@
+     (defined($FAI::configs{"PHY_$disk"}) && $FAI::configs{"PHY_$disk"}{virtual}));
+   my $pre = "exist_$d";
+   $pre .= ",cleared2_$disk" if (defined($FAI::configs{"PHY_$disk"}));
+-  &FAI::push_command( "parted -s $disk set $part_no $t on", $pre, "type_${t}_$d" );
++  &FAI::push_command( "parted -s $disk set $part_no $t on", $pre, "flag_${t}_$d" );
+   if (defined($FAI::partition_table_deps{$disk}) &&
+     $FAI::partition_table_deps{$disk} ne "") {
+-    $FAI::partition_table_deps{$disk} .= ",type_${t}_$d";
++    $FAI::partition_table_deps{$disk} .= ",flag_${t}_$d";
+   } else {
+-    $FAI::partition_table_deps{$disk} = "type_${t}_$d";
++    $FAI::partition_table_deps{$disk} = "flag_${t}_$d";
+   }
+   return 1;
+ }
+@@ -349,7 +349,7 @@
+           $pre_req .= ($i_p_d && defined($FAI::configs{"PHY_$disk"})) ?
+             ",pt_complete_$disk" :
+             ",exist_$d";
+-        } elsif (&FAI::set_partition_type_on_phys_dev($d, "raid")) {
++        } elsif (&FAI::set_partition_flag_on_phys_dev($d, "raid")) {
+           $pre_req .= defined($FAI::configs{"PHY_$disk"}) ?
+             ",pt_complete_$disk" :
+             ",exist_$d";
+@@ -432,7 +432,7 @@
+       my $pre = "exist_$d";
+       my ($i_p_d, $disk, $part_no) = &FAI::phys_dev($d);
+       $pre .= ",pt_complete_$disk"
+-        if (&FAI::set_partition_type_on_phys_dev($d, "lvm") &&
++        if (&FAI::set_partition_flag_on_phys_dev($d, "lvm") &&
+           defined($FAI::configs{"PHY_$disk"}));
+ 
+       &FAI::push_command( "pvcreate -ff -y $pv_create_options $d",
+@@ -484,7 +484,7 @@
+     my $pre = "exist_$dev";
+     my ($i_p_d, $disk, $part_no) = &FAI::phys_dev($dev);
+     $pre .= ",pt_complete_$disk"
+-      if (&FAI::set_partition_type_on_phys_dev($dev, "lvm") &&
++      if (&FAI::set_partition_flag_on_phys_dev($dev, "lvm") &&
+         defined($FAI::configs{"PHY_$disk"}));
+ 
+     &FAI::push_command( "pvcreate -ff -y $pv_create_options $dev",
+@@ -1169,30 +1169,24 @@
+     $cmd = "losetup -o $start $dn $disk" if ((&FAI::loopback_dev($disk))[0]);
+     &FAI::push_command($cmd, "prep2_$dn", "exist_$dn");
+ 
++    # (re-)set all flags
++    my $flags = "";
++    $flags = $FAI::current_config{$disk}{partitions}{$mapped_id}{flags}
++      if ($part->{size}->{preserve} || $part->{size}->{resize});
++    # set the bootable flag, if requested at all
++    $flags .= ",boot" if($FAI::configs{$config}{bootable} == $part_id);
++    # set the bios_grub flag on BIOS compatible GPT tables
++    $flags .= ",bios_grub" if($FAI::configs{$config}{disklabel} eq "gpt-bios"
++      && $FAI::configs{$config}{gpt_bios_part} == $part_id);
++    &FAI::set_partition_flag_on_phys_dev($dn, $_)
++      foreach (split(',', $flags));
++
+     $prev_id = $part_id;
+   }
+ 
+   ($prev_id > -1) or &FAI::internal_error("No partitions created");
+   $FAI::partition_table_deps{$disk} = "cleared2_$disk,exist_"
+     . &FAI::make_device_name($disk, $prev_id);
+-
+-  # set the bootable flag, if requested at all
+-  if ($FAI::configs{$config}{bootable} > -1) {
+-    &FAI::push_command( "parted -s $disk set " .
+-      $FAI::configs{$config}{bootable} . " boot on", "exist_" .
+-      &FAI::make_device_name($disk, $FAI::configs{$config}{bootable}),
+-      "boot_set_$disk" );
+-    $FAI::partition_table_deps{$disk} .= ",boot_set_$disk";
+-  }
+-
+-  # set the bios_grub flag on BIOS compatible GPT tables
+-  if ($FAI::configs{$config}{disklabel} eq "gpt-bios") {
+-    &FAI::push_command( "parted -s $disk set " .
+-      $FAI::configs{$config}{gpt_bios_part} . " bios_grub on", "exist_" .
+-      &FAI::make_device_name($disk, $FAI::configs{$config}{gpt_bios_part}),
+-      "bios_grub_set_$disk" );
+-    $FAI::partition_table_deps{$disk} .= ",bios_grub_set_$disk";
+-  }
+ }
+ 
+ 
+@@ -1293,6 +1287,10 @@
+ 
+       # build a parted command to create the partition
+       &FAI::execute_command("parted -s $disk mkpart $part_type \"$fs\" ${start}B ${end}B");
++
++      # re-set all flags
++      &FAI::execute_command("parted -s $disk set $part_id $_ on")
++        foreach (split(',', $curr_part->{flags}));
+     }
+     warn "Partition table of disk $disk has been restored\n";
+   }
+Index: trunk/lib/setup-storage/Volumes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Volumes.pm
++++ trunk/lib/setup-storage/Volumes.pm
+@@ -249,6 +249,11 @@
+           };
+           $col_start += $col_width;
+         }
++
++        defined ($cols{"Flags"}{"start"})
++          or &FAI::internal_error("Column Flags not found in parted output");
++        ($col_start == $cols{"Flags"}{"start"} + $cols{"Flags"}{"length"})
++          or &FAI::internal_error("Flags column is not last");
+       } else { # one of the partitions
+ 
+         # we must have seen the header, otherwise probably the format has
+@@ -264,6 +269,9 @@
+         my $fs_cols_before = $cols{"File system"}{"start"};
+         my $fs_col_width   = $cols{"File system"}{"length"};
+ 
++        # the info for the flags column
++        my $flags_cols_before = $cols{"Flags"}{"start"};
++
+         # get the partition number, if any
+         $line =~ /^.{$num_cols_before}(.{$num_col_width})/;
+         my $id = $1;
+@@ -290,6 +298,19 @@
+ 
+         # store the information in the hash
+         $FAI::current_config{$disk}{partitions}{$id}{filesystem} = $fs;
++
++        # extract the file system information
++        my $flags = "";
++        if (length ($line) > $flags_cols_before) {
++          $line =~ /^.{$flags_cols_before}(.+)$/;
++          $flags = $1;
++        }
++
++        # remove any space
++        $flags =~ s/\s//g;
++
++        # store the information in the hash
++        $FAI::current_config{$disk}{partitions}{$id}{flags} = $flags;
+       }
+     }
+ 




More information about the Fai-commit mailing list