Author: sandervanderburg
Date: Thu Oct 14 15:02:37 2010
New Revision: 24291
URL: https://svn.nixos.org/websvn/nix/?rev=24291&sc=1
Log:
Moved common checks in the shell scripts into a shared checks file
Added:
disnix/disnix/trunk/scripts/checks
disnix/disnix/trunk/scripts/disnix-copy-closure.in
- copied, changed from r24250,
disnix/disnix/trunk/scripts/disnix-copy-closure
disnix/disnix/trunk/scripts/disnix-env.in
- copied, changed from r24250, disnix/disnix/trunk/scripts/disnix-env
Deleted:
disnix/disnix/trunk/scripts/disnix-copy-closure
disnix/disnix/trunk/scripts/disnix-env
Modified:
disnix/disnix/trunk/configure.ac
disnix/disnix/trunk/scripts/Makefile.am
disnix/disnix/trunk/scripts/disnix-gendist-roundrobin.in
disnix/disnix/trunk/scripts/disnix-instantiate.in
disnix/disnix/trunk/scripts/disnix-manifest.in
disnix/disnix/trunk/scripts/disnix-ssh-client
Modified: disnix/disnix/trunk/configure.ac
==============================================================================
--- disnix/disnix/trunk/configure.ac Thu Oct 14 14:57:38 2010 (r24290)
+++ disnix/disnix/trunk/configure.ac Thu Oct 14 15:02:37 2010 (r24291)
@@ -90,6 +90,8 @@
src/visualize/Makefile
scripts/Makefile
data/Makefile
+scripts/disnix-copy-closure
+scripts/disnix-env
scripts/disnix-instantiate
scripts/disnix-manifest
scripts/disnix-gendist-roundrobin
Modified: disnix/disnix/trunk/scripts/Makefile.am
==============================================================================
--- disnix/disnix/trunk/scripts/Makefile.am Thu Oct 14 14:57:38 2010
(r24290)
+++ disnix/disnix/trunk/scripts/Makefile.am Thu Oct 14 15:02:37 2010
(r24291)
@@ -1,3 +1,4 @@
bin_SCRIPTS = disnix-instantiate disnix-manifest disnix-gendist-roundrobin
disnix-copy-closure disnix-env disnix-ssh-client
+pkgdata_SCRIPTS = checks
-EXTRA_DIST = disnix-instantiate.in disnix-manifest.in
disnix-gendist-roundrobin.in disnix-copy-closure disnix-env disnix-ssh-client
+EXTRA_DIST = checks disnix-instantiate.in disnix-manifest.in
disnix-gendist-roundrobin.in disnix-copy-closure.in disnix-env.in
disnix-ssh-client
Added: disnix/disnix/trunk/scripts/checks
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix/trunk/scripts/checks Thu Oct 14 15:02:37 2010 (r24291)
@@ -0,0 +1,117 @@
+#!/bin/bash -e
+# Disnix - A distributed application layer for Nix
+# Copyright (C) 2008-2010 Sander van der Burg
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+
+# Checks the client interface property.
+# If not set it will use the value of the DISNIX_CLIENT_INTERFACE environment
+# variable or else a default value.
+
+checkClientInterface()
+{
+ if [ "$interface" = "" ]
+ then
+ if [ "$DISNIX_CLIENT_INTERFACE" = "" ]
+ then
+ interface="disnix-ssh-client"
+ else
+ interface=$DISNIX_CLIENT_INTERFACE
+ fi
+ fi
+}
+
+# Checks the target property.
+# If not set it will use the value of the DISNIX_TARGET_PROPERTY environment
+# variable or else a default value.
+
+checkTargetProperty()
+{
+ if [ "$targetProperty" = "" ]
+ then
+ if [ "$DISNIX_TARGET_PROPERTY" != "" ]
+ then
+ targetProperty=$DISNIX_TARGET_PROPERTY
+ else
+ targetProperty="hostname";
+ fi
+ fi
+}
+
+# Checks whether a service expression is given. Exits with status 1 if not set.
+
+checkServicesFile()
+{
+ if [ "$servicesFile" = "" ]
+ then
+ echo "ERROR: A services expression must be specified!" >&2
+ exit 1
+ fi
+}
+
+# Checks whether an infrastructure expression is given. Exits with status 1 if
not set.
+
+checkInfrastructureFile()
+{
+ if [ "$infrastructureFile" = "" ]
+ then
+ echo "ERROR: An infrastructure expression must be specified!" >&2
+ exit 1
+ fi
+}
+
+# Checks whether a distribution expression is given. Exits with status 1 if
not set.
+
+checkDistributionFile()
+{
+ if [ "$distributionFile" = "" ]
+ then
+ echo "ERROR: A distribution expression must be specified!" >&2
+ exit 1
+ fi
+}
+
+# Checks whether the --show-trace option is specified and sets the
+# showTraceArg variable.
+
+checkShowTrace()
+{
+ if [ "$showTrace" = "1" ]
+ then
+ showTraceArg="--show-trace"
+ fi
+}
+
+# Checks whether a target is given. Exits with status 1 if not set.
+
+checkTarget()
+{
+ if [ "$target" = "" ]
+ then
+ echo "ERROR: A target address must be specified!" >&2
+ exit 1
+ fi
+}
+
+# Checks whether TMPDIR environment variable is set, if not it is set to
+# a default value.
+
+checkTmpDir()
+{
+ if [ "$TMPDIR" = "" ]
+ then
+ export TMPDIR=/tmp
+ fi
+}
Copied and modified: disnix/disnix/trunk/scripts/disnix-copy-closure.in (from
r24250, disnix/disnix/trunk/scripts/disnix-copy-closure)
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-copy-closure Tue Oct 12 20:53:56
2010 (r24250, copy source)
+++ disnix/disnix/trunk/scripts/disnix-copy-closure.in Thu Oct 14 15:02:37
2010 (r24291)
@@ -30,6 +30,14 @@
echo "-h,--help Shows the usage of this command to the user"
}
+# Autoconf settings
+
+export pref...@prefix@
+
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o t:h -l to,from,target:,interface:,help -- "$@"`
@@ -80,21 +88,9 @@
exit 1
fi
-if [ "$target" = "" ]
-then
- echo "ERROR: A target address must be specified!" >&2
- exit 1
-fi
+checkTarget
-if [ "$interface" = "" ]
-then
- if [ "$DISNIX_CLIENT_INTERFACE" = "" ]
- then
- interface="disnix-ssh-client"
- else
- interface=$DISNIX_CLIENT_INTERFACE
- fi
-fi
+checkClientInterface
if [ "$component" = "" ]
then
@@ -102,10 +98,7 @@
exit 1
fi
-if [ "$TMPDIR" = "" ]
-then
- export TMPDIR=/tmp
-fi
+checkTmpDir
# Execute operation
Copied and modified: disnix/disnix/trunk/scripts/disnix-env.in (from r24250,
disnix/disnix/trunk/scripts/disnix-env)
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-env Tue Oct 12 20:53:56 2010
(r24250, copy source)
+++ disnix/disnix/trunk/scripts/disnix-env.in Thu Oct 14 15:02:37 2010
(r24291)
@@ -36,6 +36,14 @@
echo "-h,--help Shows the usage of this command"
}
+# Autoconf settings
+
+export pref...@prefix@
+
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o s:i:d:p:h -l
services:,infrastructure:,distribution:,interface:,target-property:,profile:,build-on-targets,coordinator-profile-path:,show-trace,help
-- "$@"`
@@ -91,52 +99,18 @@
# Validate the given options
-if [ "$servicesFile" = "" ]
-then
- echo "ERROR: A services expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$infrastructureFile" = "" ]
-then
- echo "ERROR: A infrastructure expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$distributionFile" = "" ]
-then
- echo "ERROR: A distribution expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$interface" = "" ]
-then
- if [ "$DISNIX_CLIENT_INTERFACE" = "" ]
- then
- interface="disnix-ssh-client"
- else
- interface=$DISNIX_CLIENT_INTERFACE
- fi
-fi
-
-if [ "$targetProperty" != "" ]
-then
- targetPropertyArg="--target-property $targetProperty"
-elif [ "$DISNIX_TARGET_PROPERTY" != "" ]
-then
- targetPropertyArg="--target-property $DISNIX_TARGET_PROPERTY"
-fi
-
-if [ "$showTrace" = "1" ]
-then
- showTraceArg="--show-trace"
-fi
+checkServicesFile
+checkInfrastructureFile
+checkDistributionFile
+checkClientInterface
+checkTargetProperty
+checkShowTrace
# Execute operations
if [ "$buildOnTargets" = "1" ]
then
- distributedDerivation=`disnix-instantiate -s $servicesFile -i
$infrastructureFile -d $distributionFile $targetPropertyArg $showTraceArg`
+ distributedDerivation=`disnix-instantiate -s $servicesFile -i
$infrastructureFile -d $distributionFile --target-property $targetProperty
$showTraceArg`
disnix-build --interface $interface $distributedDerivation
fi
Modified: disnix/disnix/trunk/scripts/disnix-gendist-roundrobin.in
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-gendist-roundrobin.in Thu Oct 14
14:57:38 2010 (r24290)
+++ disnix/disnix/trunk/scripts/disnix-gendist-roundrobin.in Thu Oct 14
15:02:37 2010 (r24291)
@@ -32,6 +32,10 @@
export pref...@prefix@
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o s:i:h -l services:,infrastructure:,help -- "$@"`
@@ -66,17 +70,8 @@
# Validate the given options
-if [ "$servicesFile" = "" ]
-then
- echo "ERROR: A services expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$infrastructureFile" = "" ]
-then
- echo "ERROR: A infrastructure expression must be specified!" >&2
- exit 1
-fi
+checkServicesFile
+checkInfrastructureFile
# Build the distribution model
Modified: disnix/disnix/trunk/scripts/disnix-instantiate.in
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-instantiate.in Thu Oct 14 14:57:38
2010 (r24290)
+++ disnix/disnix/trunk/scripts/disnix-instantiate.in Thu Oct 14 15:02:37
2010 (r24291)
@@ -36,6 +36,10 @@
export pref...@prefix@
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o s:i:d:h -l
services:,infrastructure:,distribution:,target-property:,show-trace,help --
"$@"`
@@ -79,38 +83,11 @@
# Validate the given options
-if [ "$servicesFile" = "" ]
-then
- echo "ERROR: A services expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$infrastructureFile" = "" ]
-then
- echo "ERROR: A infrastructure expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$distributionFile" = "" ]
-then
- echo "ERROR: A distribution expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$targetProperty" = "" ]
-then
- if [ "$DISNIX_TARGET_PROPERTY" != "" ]
- then
- targetProperty=$DISNIX_TARGET_PROPERTY
- else
- targetProperty="hostname";
- fi
-fi
-
-if [ "$showTrace" = "1" ]
-then
- showTraceArg="--show-trace"
-fi
+checkServicesFile
+checkInfrastructureFile
+checkDistributionFile
+checkTargetProperty
+checkShowTrace
# Build the distributed derivation file
Modified: disnix/disnix/trunk/scripts/disnix-manifest.in
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-manifest.in Thu Oct 14 14:57:38
2010 (r24290)
+++ disnix/disnix/trunk/scripts/disnix-manifest.in Thu Oct 14 15:02:37
2010 (r24291)
@@ -36,6 +36,10 @@
export pref...@prefix@
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o s:i:d:h -l
services:,infrastructure:,distribution:,target-property:,show-trace,help --
"$@"`
@@ -79,38 +83,11 @@
# Validate the given options
-if [ "$servicesFile" = "" ]
-then
- echo "ERROR: A services expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$infrastructureFile" = "" ]
-then
- echo "ERROR: A infrastructure expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$distributionFile" = "" ]
-then
- echo "ERROR: A distribution expression must be specified!" >&2
- exit 1
-fi
-
-if [ "$targetProperty" = "" ]
-then
- if [ "$DISNIX_TARGET_PROPERTY" != "" ]
- then
- targetProperty=$DISNIX_TARGET_PROPERTY
- else
- targetProperty="hostname";
- fi
-fi
-
-if [ "$showTrace" = "1" ]
-then
- showTraceArg="--show-trace"
-fi
+checkServicesFile
+checkInfrastructureFile
+checkDistributionFile
+checkTargetProperty
+checkShowTrace
# Build the manifest file
Modified: disnix/disnix/trunk/scripts/disnix-ssh-client
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-ssh-client Thu Oct 14 14:57:38
2010 (r24290)
+++ disnix/disnix/trunk/scripts/disnix-ssh-client Thu Oct 14 15:02:37
2010 (r24291)
@@ -37,6 +37,14 @@
echo " {-h | --help}"
}
+# Autoconf settings
+
+export pref...@prefix@
+
+# Import checks
+
+source @datadir@/@PACKAGE@/checks
+
# Parse valid argument options
PARAMS=`getopt -n $0 -o rqp:d -l
import,export,print-invalid,realise,set,query-installed,query-requisites,collect-garbage,activate,deactivate,lock,unlock,target:,localfile,remotefile,profile:,delete-old,type:,arguments:,help
-- "$@"`
@@ -128,11 +136,7 @@
# Validate the given options
-if [ "$target" = "" ]
-then
- echo "ERROR: A target hostname or IP address must be specified!" >&2
- exit 1
-fi
+checkTarget
targetHostname=${target%%:*}
targetPort=${target#*:}
@@ -142,10 +146,7 @@
targetPort=22
fi
-if [ "$TMPDIR" = "" ]
-then
- export TMPDIR=/tmp
-fi
+checkTmpDir
# Execute selected operation
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits