[Fai-commit] r6703 - in trunk: lib/setup-storage man
Michael Tautschnig
mt at alioth.debian.org
Sat Oct 22 12:35:25 UTC 2011
Author: mt
Date: 2011-10-22 12:35:25 +0000 (Sat, 22 Oct 2011)
New Revision: 6703
Modified:
trunk/lib/setup-storage/Parser.pm
trunk/man/setup-storage.8
Log:
setup-storage: preserve_* now supported for each partition in place
* setup-storage/Parser.pm: Permit :preserve_* after size specification to
specify preserving a partition in place.
* setup-storage.8: Update grammar.
Thanks: Edgar Fu?\195?\159
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2011-10-22 12:32:05 UTC (rev 6702)
+++ trunk/lib/setup-storage/Parser.pm 2011-10-22 12:35:25 UTC (rev 6703)
@@ -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;
}
- size: /^((RAM:\d+%|\d+[kKMGTP%iB]*)(-(RAM:\d+%|\d+[kKMGTP%iB]*)?)?)(:resize)?/
+ size: /^((RAM:\d+%|\d+[kKMGTP%iB]*)(-(RAM:\d+%|\d+[kKMGTP%iB]*)?)?)(:resize|:preserve_(always|reinstall|lazy))?/
{
# complete the size specification to be a range in all cases
my $range = $1;
@@ -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
- if (defined ($5)) {
- $FAI::partition_pointer->{size}->{resize} = 1;
- $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";
- # 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
- if (defined ($3)) {
- $FAI::partition_pointer->{size}->{resize} = 1;
- $FAI::configs{$FAI::device}{preserveparts} = 1;
- }
+ &FAI::set_volume_size("0$1", $3);
}
| <error: invalid partition size near "$text">
Modified: trunk/man/setup-storage.8
===================================================================
--- trunk/man/setup-storage.8 2011-10-22 12:32:05 UTC (rev 6702)
+++ trunk/man/setup-storage.8 2011-10-22 12:35:25 UTC (rev 6703)
@@ -596,13 +596,13 @@
* multiplier */
-size ::= <sizespec>(-(<sizespec>)?)?(:resize)?
+size ::= <sizespec>(-(<sizespec>)?)?(:resize|:preserve_(always|reinstall|lazy))?
.br
/* size, possibly given as a range; physical partitions or lvm logical
.br
* volumes only */
.br
- | -<sizespec>(:resize)?
+ | -<sizespec>(:resize|:preserve_(always|reinstall|lazy))?
.br
/* size given as upper limit; physical partitions or lvm logical
.br
@@ -663,7 +663,8 @@
and bootable. preserve_always is equivalent to the previous preserveX option,
whereas preserve_reinstall preserves the partition unless "initial" is given as
one of the FAI_FLAGS. preserve_lazy allows to preserve partitions only if these
-exist already. Otherwise they are created.
+exist already. Otherwise they are created. Yet, all preserve_* options may also
+be given with the size specification, as in: 200M:preserve_lazy.
.IP \(bu
The "always_format" option overrides preserving filesystems (via one of the
"preserveX" options), like the "format" option in setup_harddisks.
More information about the Fai-commit
mailing list