[csw-devel] SF.net SVN: opencsw:[316] gar-wrapper/mgar

skayser at users.sourceforge.net skayser at users.sourceforge.net
Mon Feb 21 23:45:28 CET 2011


Revision: 316
          http://opencsw.svn.sourceforge.net/opencsw/?rev=316&view=rev
Author:   skayser
Date:     2011-02-21 22:45:28 +0000 (Mon, 21 Feb 2011)

Log Message:
-----------
mgar: add check for required tools

Modified Paths:
--------------
    gar-wrapper/mgar

Modified: gar-wrapper/mgar
===================================================================
--- gar-wrapper/mgar	2011-02-21 14:18:27 UTC (rev 315)
+++ gar-wrapper/mgar	2011-02-21 22:45:28 UTC (rev 316)
@@ -15,6 +15,7 @@
 # ----------------------------------------------------------------------------
 #
 # Todos:
+# * Add command to update mgar itself
 # * Recipes: Move from svn:externals to GARTYPE
 # * Integrate the creation of a new package (with sanity check whether
 #   package already exists). Use per-directory Makefile.template files.
@@ -39,12 +40,30 @@
 set -u
 set -e
 
-EDITOR=${EDITOR:-vim}
+EDITOR=${EDITOR:-vi}
 PATH=$PATH:/opt/csw/bin
 DEF_BUILDTREE=~/opencsw
 GAR_REPO=https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/gar/
 PKG_REPO=https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg/
 
+REQ_TOOLS="gfind ggrep gmake mknmz namazu svn"
+REQ_PKGS="findutils ggrep gmake namazu svn"
+
+function assert_required_tools {
+  for tool in $REQ_TOOLS; do
+    for dir in ${PATH/:/ /}; do
+      [ -x $dir/$tool ] && continue 2
+    done
+
+    echo "ERROR: Prerequisite command \"$tool\" not found in your \$PATH."
+    echo "Please make sure that these required packages are installed:"
+    echo
+    echo "  $REQ_PKGS"
+    echo
+    exit 2
+  done
+}
+
 function read_config_value {
   __param=$1
   [ -f ~/.garrc ] || die_config_missing
@@ -282,6 +301,9 @@
 
 [ $# -eq 0 -o "${1:-}" == "help" -o "${1:-}" == "--help" ] && { usage; exit; }
 [ $1 == "-x" ] && { shift; set -x; }
+
+assert_required_tools
+
 [ $1 == "init" ] && { init_buildtree ${2-$DEF_BUILDTREE}; exit; }
 
 BUILDTREE="`read_config_value BUILDTREE`"; eval BUILDTREE="$BUILDTREE"


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list