[GRASS-SVN] r38221 - in grass-addons/general: . g.extension.add

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jul 5 05:50:34 EDT 2009


Author: neteler
Date: 2009-07-05 05:50:33 -0400 (Sun, 05 Jul 2009)
New Revision: 38221

Added:
   grass-addons/general/g.extension.add/
   grass-addons/general/g.extension.add/Makefile
   grass-addons/general/g.extension.add/description.html
   grass-addons/general/g.extension.add/g.extension.add
Log:
replacement for GEM; usable from 6.4.0RC5 onwards

Added: grass-addons/general/g.extension.add/Makefile
===================================================================
--- grass-addons/general/g.extension.add/Makefile	                        (rev 0)
+++ grass-addons/general/g.extension.add/Makefile	2009-07-05 09:50:33 UTC (rev 38221)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../../../grass
+
+PGM = g.extension.add
+
+LIBES = $(GISLIB)
+DEPENDENCIES = $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd


Property changes on: grass-addons/general/g.extension.add/Makefile
___________________________________________________________________
Added: svn:eol-style
   + native

Added: grass-addons/general/g.extension.add/description.html
===================================================================
--- grass-addons/general/g.extension.add/description.html	                        (rev 0)
+++ grass-addons/general/g.extension.add/description.html	2009-07-05 09:50:33 UTC (rev 38221)
@@ -0,0 +1,17 @@
+<h2>DESCRIPTION</h2>
+
+<em>g.extension.add</em> downloads and installs extensions from 
+GRASS Addons SVN repository into the local GRASS installation.
+
+<h2>EXAMPLES</h2>
+
+Download and install i.landsat.toar into current GRASS installation:
+<div class="code"><pre>
+  g.extension.add extension=i.landsat.toar
+</pre></div>
+
+<h2>AUTHOR</h2>
+
+Markus Neteler
+
+<p><i>Last changed: $Date: 2008-06-28 04:37:22 -0500 (Sat, 28 Jun 2008) $</i>

Added: grass-addons/general/g.extension.add/g.extension.add
===================================================================
--- grass-addons/general/g.extension.add/g.extension.add	                        (rev 0)
+++ grass-addons/general/g.extension.add/g.extension.add	2009-07-05 09:50:33 UTC (rev 38221)
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE:       g.extension.add
+# AUTHOR(S):   	Markus Neteler
+# PURPOSE:      tool to download and install extensions from GRASS Addons SVN into 
+#               local GRASS installation
+# COPYRIGHT:    (C) 2009 by the Markus Neteler, GRASS Development Team
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+# TODO: add sudo support where needed (i.e. check first permission to write into
+#       $GISBASE directory)
+#############################################################################
+
+
+#%Module
+#%  description: Tool to download and install extensions from GRASS Addons SVN repository into local GRASS installation.
+#%  keywords: installation, extensions
+#%End
+
+#%option
+#% key: extension
+#% type: string
+#% key_desc : name
+#% description: Name of extension to install from GRASS Addons SVN repository
+#% required : yes
+#%end
+
+if  [ -z "$GISBASE" ] ; then
+    echo "You must be in GRASS GIS to run this program." >&2
+    exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+  exec g.parser "$0" "$@"
+fi
+
+# definitions
+SVNURL_ADDONS=https://svn.osgeo.org/grass/grass-addons/
+MYTMP=/tmp
+
+expand_module_class_name()
+{
+# $1: module class
+ if [ "$1" = "d" ]  ; then 
+    echo "display"  
+  elif [ "$1" = "db" ] ; then 
+    echo "database" 
+  elif [ "$1" = "g" ]  ; then 
+    echo "general" 
+  elif [ "$1" = "i" ]  ; then 
+    echo "imagery" 
+  elif [ "$1" = "m" ]  ; then 
+    echo "misc" 
+  elif [ "$1" = "ps" ] ; then 
+    echo "postscript" 
+  elif [ "$1" = "p" ]  ; then 
+    echo "paint" 
+  elif [ "$1" = "r" ]  ; then 
+    echo "raster" 
+  elif [ "$1" = "r3" ]  ; then 
+    echo "raster3D" 
+  elif [ "$1" = "s" ]  ; then 
+    echo "sites" 
+  elif [ "$1" = "v" ]  ; then 
+    echo "vector" 
+  else 
+    echo "$1"
+ fi
+}
+
+MODULE=$GIS_OPT_EXTENSION
+CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
+MODULECLASS=`expand_module_class_name $CLASSCHAR`
+
+cleanup(){
+ cd ${MYTMP}
+ rm -rf ${MYTMP}/${MODULE}
+}
+
+cd ${MYTMP}
+g.message message="Fetching ${MODULE} from GRASS-Addons SVN (be patient)..."
+svn co ${SVNURL_ADDONS}/${MODULECLASS}/${MODULE}
+
+if [ $? -ne 0 ] ; then
+   g.message -e message="GRASS Addon ${MODULE} not found in repository"
+   exit 1
+else
+   cd ${MYTMP}/${MODULE}
+   g.message message="Compiling ${MODULE}..."
+   make MODULE_TOPDIR=${GISBASE}
+   if [ $? -ne 0 ] ; then
+      g.message -e message="Compilation failed, sorry. Please check above error messages."
+      cleanup
+      exit 1
+   else
+      g.message message="Installing ${MODULE}..."
+      # can we write?
+      touch ${GISBASE}/$0.$$
+      if [ $? -ne 0 ] ; then
+         sudo make MODULE_TOPDIR=${GISBASE} install
+      else
+         make MODULE_TOPDIR=${GISBASE} install
+      fi
+      if [ $? -ne 0 ] ; then
+         g.message -e message="Installation failed, sorry. Please check above error messages."
+         cleanup
+         exit 1
+      fi
+   fi
+
+   cleanup
+fi
+
+g.message message="Installation of ${MODULE} successfully finished."
+exit 0


Property changes on: grass-addons/general/g.extension.add/g.extension.add
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list