[Fai-commit] r6709 - in trunk: bin lib/setup-storage man
Michael Tautschnig
mt at alioth.debian.org
Sat Oct 22 12:51:30 UTC 2011
Author: mt
Date: 2011-10-22 12:51:29 +0000 (Sat, 22 Oct 2011)
New Revision: 6709
Modified:
trunk/bin/setup-storage
trunk/lib/setup-storage/Init.pm
trunk/lib/setup-storage/Parser.pm
trunk/man/setup-storage.8
Log:
setup-storage: added new option -s to perform syntax check only
* setup-storage: added option -s to perform syntax check only
(closes: #627913)
* setup-storage/{Init.pm,Parser.pm}: ignore several checks if doing syntax
check only.
* setup-storage.8: updated man page.
Closes: #627913
Modified: trunk/bin/setup-storage
===================================================================
--- trunk/bin/setup-storage 2011-10-22 12:41:58 UTC (rev 6708)
+++ trunk/bin/setup-storage 2011-10-22 12:51:29 UTC (rev 6709)
@@ -59,14 +59,15 @@
use Getopt::Std;
$main::VERSION = $version;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
-our ($opt_X, $opt_f, $opt_h, $opt_d); # the variables for getopt
-(&getopts('Xf:hd') && !$opt_h) || die <<EOF;
+our ($opt_X, $opt_f, $opt_h, $opt_d, $opt_s); # the variables for getopt
+(&getopts('Xf:hds') && !$opt_h) || die <<EOF;
setup-storage version $version
USAGE: [-X] no test, your harddisks will be formated
default: only test, no real formating
[-f<config-filename>] default: parse classes
[-d] enable debug output (equivalent to debug=1)
+ [-s] perform syntax check only and exit
[-h] print this help message
EOF
@@ -87,6 +88,9 @@
$opt_X and $FAI::no_dry_run = 1;
warn "setup-storage is running in test-only mode\n" unless ($FAI::no_dry_run);
+# syntactic checks only
+$opt_s and $FAI::check_only = 1;
+
# Find out whether $LOGDIR is usable or default to /tmp/fai
if (! -d $FAI::DATADIR) {
defined ($ENV{LOGDIR}) and die
@@ -137,6 +141,12 @@
# make sure there are no empty disk_config stanzas
&FAI::check_config;
+if ($FAI::check_only)
+{
+ print "Syntax ok\n";
+ exit 0;
+}
+
# first find the proper way to tell udev to settle
$FAI::udev_settle = "udevadm settle --timeout=10" if (&FAI::in_path("udevadm"));
$FAI::udev_settle = "udevsettle --timeout=10" if (&FAI::in_path("udevsettle"));
Modified: trunk/lib/setup-storage/Init.pm
===================================================================
--- trunk/lib/setup-storage/Init.pm 2011-10-22 12:41:58 UTC (rev 6708)
+++ trunk/lib/setup-storage/Init.pm 2011-10-22 12:51:29 UTC (rev 6709)
@@ -64,6 +64,13 @@
################################################################################
#
+# @brief Perform syntactic checks only if set to 1
+#
+################################################################################
+$FAI::check_only = 0;
+
+################################################################################
+#
# @brief The command to tell udev to settle (udevsettle or udevadm settle)
#
################################################################################
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2011-10-22 12:41:58 UTC (rev 6708)
+++ trunk/lib/setup-storage/Parser.pm 2011-10-22 12:51:29 UTC (rev 6709)
@@ -61,6 +61,9 @@
# initialize the parameter
my ($cmd) = @_;
+ # ignored in syntax-check mode
+ return 1 if ($FAI::check_only);
+
# 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}));
@@ -82,9 +85,11 @@
sub resolve_disk_shortname {
my ($disk) = @_;
+ $disk = "sdx" . chr(ord('a') + $disk - 1)
+ if ($FAI::check_only && $disk =~ /^\d+$/);
+
# test $disk for being numeric
if ($disk =~ /^\d+$/) {
-
# $disk-1 must be a valid index in the map of all disks in the system
(scalar(@FAI::disks) >= $disk)
or die "this system does not have a physical disk $disk\n";
Modified: trunk/man/setup-storage.8
===================================================================
--- trunk/man/setup-storage.8 2011-10-22 12:41:58 UTC (rev 6708)
+++ trunk/man/setup-storage.8 2011-10-22 12:51:29 UTC (rev 6709)
@@ -9,6 +9,7 @@
[\fB\-f\fP \fIfilename\fP]
[\fB\-d\fP]
[\fB\-h\fP]
+[\fB\-s\fP]
.SH DESCRIPTION
Using FAI disk_config files,
\fBsetup-storage\fP
@@ -61,6 +62,9 @@
.IR debug
set to a non-zero value. See below for further details.
+.TP
+\fB\-s\fP
+Perform syntax check of disk_config file only and exit.
.TP
\fB\-h\fP
More information about the Fai-commit
mailing list