[Fai-commit] r6598 - branches/experimental/patches
Michael Tautschnig
mt at alioth.debian.org
Thu Jul 14 19:02:03 UTC 2011
Author: mt
Date: 2011-07-14 19:02:03 +0000 (Thu, 14 Jul 2011)
New Revision: 6598
Modified:
branches/experimental/patches/setup-storage_more-verbose-parser
branches/experimental/patches/setup-storage_preserve-in-place
Log:
Fixed broken :resize, :preserve handling
Thanks Edgar Fu?\195?\159 for the patch and further suggestions
Modified: branches/experimental/patches/setup-storage_more-verbose-parser
===================================================================
--- branches/experimental/patches/setup-storage_more-verbose-parser 2011-07-12 22:29:40 UTC (rev 6597)
+++ branches/experimental/patches/setup-storage_more-verbose-parser 2011-07-14 19:02:03 UTC (rev 6598)
@@ -6,7 +6,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Parser.pm
+++ trunk/lib/setup-storage/Parser.pm
-@@ -616,12 +616,15 @@
+@@ -650,12 +650,15 @@
}
$FAI::configs{$FAI::device}{preserveparts} = 1;
}
Modified: branches/experimental/patches/setup-storage_preserve-in-place
===================================================================
--- branches/experimental/patches/setup-storage_preserve-in-place 2011-07-12 22:29:40 UTC (rev 6597)
+++ branches/experimental/patches/setup-storage_preserve-in-place 2011-07-14 19:02:03 UTC (rev 6598)
@@ -1,13 +1,54 @@
2011-04-15 Michael Tautschnig <mt at debian.org>
* setup-storage/Parser.pm: Permit :preserve_* after size specification to
- specify preserving a partition in place.
+ specify preserving a partition in place. Thanks Edgar Fuß for the patch.
* setup-storage.8: Update grammar.
Index: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk.orig/lib/setup-storage/Parser.pm
+++ trunk/lib/setup-storage/Parser.pm
-@@ -862,7 +862,7 @@
+@@ -372,6 +372,40 @@
+ return $val;
+ }
+
++################################################################################
++#
++# @brief Fill the "size" key of a partition or volume entry
++#
++# @param $range Actual size
++# @param $options Additional options such as preserve or resize
++#
++################################################################################
++sub set_volume_size
++{
++ my ($range, $options) = @_;
++
++ # convert the units, if necessary
++ my ($min, $max) = split (/-/, $range);
++ $min .= "MiB" if ($min =~ /\d\s*$/);
++ $min = &FAI::convert_unit($min);
++ $max .= "MiB" if ($max =~ /\d\s*$/);
++ $max = &FAI::convert_unit($max);
++ # enter the range into the hash
++ $FAI::partition_pointer->{size}->{range} = "$min-$max";
++ # set the resize or preserve flag, if required
++ if (defined ($options)) {
++ $FAI::configs{$FAI::device}{preserveparts} = 1;
++ $FAI::partition_pointer->{size}->{resize} = 1 if ($options =~ /^:resize/);
++ $FAI::partition_pointer->{size}->{preserve} = 1 if ($options =~ /^:preserve_always/);
++ $FAI::partition_pointer->{size}->{preserve} = 1
++ if ($FAI::reinstall && $options =~ /^:preserve_reinstall/);
++ if ($options =~ /^:preserve_lazy/) {
++ $FAI::configs{$FAI::device}{preserveparts} = 2;
++ $FAI::partition_pointer->{size}->{preserve} = 2;
++ }
++ }
++}
++
+ # have RecDescent do proper error reporting
+ $::RD_HINT = 1;
+
+@@ -862,7 +896,7 @@
1;
}
@@ -16,50 +57,52 @@
{
# complete the size specification to be a range in all cases
my $range = $1;
-@@ -887,13 +887,20 @@
- $range = "$min-$max";
- # enter the range into the hash
- $FAI::partition_pointer->{size}->{range} = $range;
+@@ -876,41 +910,14 @@
+ {
+ # range has no upper limit, assume the whole disk
+ $range = "${range}100%";
+- }
+-
+- # convert the units, if necessary
+- my ($min, $max) = split (/-/, $range);
+- $min .= "MiB" if ($min =~ /\d\s*$/);
+- $min = &FAI::convert_unit($min);
+- $max .= "MiB" if ($max =~ /\d\s*$/);
+- $max = &FAI::convert_unit($max);
+- $range = "$min-$max";
+- # enter the range into the hash
+- $FAI::partition_pointer->{size}->{range} = $range;
- # set the resize flag, if required
-+ # set the resize or preserve flag, if required
- if (defined ($5)) {
+- if (defined ($5)) {
- $FAI::partition_pointer->{size}->{resize} = 1;
- $FAI::configs{$FAI::device}{preserveparts} = 1;
-+ $FAI::partition_pointer->{size}->{resize} = 1 if ($5 =~ /^:resize/);
-+ $FAI::partition_pointer->{size}->{preserve} = 1 if ($5 =~ /^:preserve_always/);
-+ $FAI::partition_pointer->{size}->{preserve} = 1
-+ if ($FAI::reinstall && $5 =~ /^:preserve_reinstall/);
-+ if ($5 =~ /^:preserve_lazy/) {
-+ $FAI::configs{$FAI::device}{preserveparts} = 2;
-+ $FAI::partition_pointer->{size}->{preserve} = 2;
-+ }
+- $FAI::configs{$FAI::device}{preserveparts} = 1;
}
++
++ &FAI::set_volume_size($range, $5);
}
- | /^(-(RAM:\d+%|\d+[kKMGTP%iB]*))(:resize)?\s+/
+ | /^(-(RAM:\d+%|\d+[kKMGTP%iB]*))(:resize|:preserve_(always|reinstall|lazy))?\s+/
{
# complete the range by assuming 0 as the lower limit
- my $range = "0$1";
-@@ -906,10 +913,17 @@
- $range = "$min-$max";
- # enter the range into the hash
- $FAI::partition_pointer->{size}->{range} = $range;
+- my $range = "0$1";
+- # convert the units, if necessary
+- my ($min, $max) = split (/-/, $range);
+- $min .= "MiB" if ($min =~ /\d\s*$/);
+- $min = &FAI::convert_unit($min);
+- $max .= "MiB" if ($max =~ /\d\s*$/);
+- $max = &FAI::convert_unit($max);
+- $range = "$min-$max";
+- # enter the range into the hash
+- $FAI::partition_pointer->{size}->{range} = $range;
- # set the resize flag, if required
-+ # set the resize or preserve flag, if required
- if (defined ($3)) {
+- if (defined ($3)) {
- $FAI::partition_pointer->{size}->{resize} = 1;
- $FAI::configs{$FAI::device}{preserveparts} = 1;
-+ $FAI::partition_pointer->{size}->{resize} = 1 if ($3 =~ /^:resize/);
-+ $FAI::partition_pointer->{size}->{preserve} = 1 if ($3 =~ /^:preserve_always/);
-+ $FAI::partition_pointer->{size}->{preserve} = 1
-+ if ($FAI::reinstall && $3 =~ /^:preserve_reinstall/);
-+ if ($3 =~ /^:preserve_lazy/) {
-+ $FAI::configs{$FAI::device}{preserveparts} = 2;
-+ $FAI::partition_pointer->{size}->{preserve} = 2;
-+ }
- }
+- $FAI::configs{$FAI::device}{preserveparts} = 1;
+- }
++ &FAI::set_volume_size("0$1", $3);
}
| <error: invalid partition size near "$text">
+
Index: trunk/man/setup-storage.8
===================================================================
--- trunk.orig/man/setup-storage.8
More information about the Fai-commit
mailing list