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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 30 15:55:07 EDT 2009


Author: neteler
Date: 2009-07-30 15:55:07 -0400 (Thu, 30 Jul 2009)
New Revision: 38541

Added:
   grass-addons/general/g.extension/
   grass-addons/general/g.extension/g.extension
Removed:
   grass-addons/general/g.extension.add/
   grass-addons/general/g.extension/g.extension.add
Modified:
   grass-addons/general/g.extension/Makefile
   grass-addons/general/g.extension/description.html
Log:
renamed g.extension.add to g.extension; added most new features from GRASS 7 Python version

Modified: grass-addons/general/g.extension/Makefile
===================================================================
--- grass-addons/general/g.extension.add/Makefile	2009-07-30 16:39:41 UTC (rev 38540)
+++ grass-addons/general/g.extension/Makefile	2009-07-30 19:55:07 UTC (rev 38541)
@@ -1,6 +1,6 @@
 MODULE_TOPDIR = ../..
 
-PGM = g.extension.add
+PGM = g.extension
 
 include $(MODULE_TOPDIR)/include/Make/Script.make
 

Modified: grass-addons/general/g.extension/description.html
===================================================================
--- grass-addons/general/g.extension.add/description.html	2009-07-30 16:39:41 UTC (rev 38540)
+++ grass-addons/general/g.extension/description.html	2009-07-30 19:55:07 UTC (rev 38541)
@@ -1,6 +1,6 @@
 <h2>DESCRIPTION</h2>
 
-<em>g.extension.add</em> downloads and installs extensions from 
+<em>g.extension</em> downloads and installs extensions from 
 GRASS Addons SVN repository into the local GRASS installation.
 <p>
 Re-running the script on an installed GRASS Addon re-installs
@@ -8,9 +8,9 @@
 
 <h2>EXAMPLES</h2>
 
-Download and install i.landsat.toar into current GRASS installation:
+Download and install <em>i.landsat.toar</em> into current GRASS installation:
 <div class="code"><pre>
-  g.extension.add extension=i.landsat.toar
+g.extension extension=i.landsat.toar
 </pre></div>
 
 <h2>AUTHOR</h2>

Copied: grass-addons/general/g.extension/g.extension (from rev 38540, grass-addons/general/g.extension.add/g.extension.add)
===================================================================
--- grass-addons/general/g.extension/g.extension	                        (rev 0)
+++ grass-addons/general/g.extension/g.extension	2009-07-30 19:55:07 UTC (rev 38541)
@@ -0,0 +1,214 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE:       g.extension
+# 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.
+#
+#############################################################################
+
+
+#%Module
+#% label: Tool to maintain GRASS extensions in local GRASS installation.
+#% description: Downloads, installs extensions from GRASS Addons SVN repository into local GRASS installation or removes installed extensions.
+#% keywords: installation
+#% keywords: extensions
+#%End
+
+#%option
+#% key: extension
+#% type: string
+#% key_desc: name
+#% description: Name of extension to install/remove
+#% required: no
+#%end
+#%option
+#% key: operation
+#% type: string
+#% key_desc: name
+#% description: Operation to be performed
+#% required: no
+#% options: add
+#% answer: add
+#%end
+#%option
+#% key: svnurl
+#% type: string
+#% key_desc: url
+#% description: SVN Addons repository URL
+#% required: yes
+#% answer: https://svn.osgeo.org/grass/grass-addons/
+#%end
+#%option
+#% key: prefix
+#% type: string
+#% key_desc: path
+#% description: Prefix where to install extension
+#% answer: ${GISBASE}
+#% required: yes
+#%end
+
+#%flag
+#% key: l
+#% description: List available modules in the GRASS Addons SVN repository
+#% guisection: Print
+#%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=${GIS_OPT_SVNURL}
+if [ "$GIS_OPT_PREFIX" = '${GISBASE}' ] ; then
+   MYINST_DIR=${GISBASE}
+else
+   MYINST_DIR=${GIS_OPT_PREFIX}
+fi
+
+#make a temporary directory
+TMPDIR="`g.tempfile pid=$$`"
+if [ $? -ne 0 ] || [ -z "$TMPDIR" ] ; then
+    g.message "Unable to create temporary files"
+    exit 1
+fi
+rm -f "$TMPDIR"
+mkdir "$TMPDIR"
+
+# check if we have the svn client
+if [ ! -x "`which svn`" ] ; then
+    echo "ERROR: svn client required. Please install subversion first." 1>&2
+    exit 1
+fi
+
+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`
+
+list_available_modules()
+{
+ # a very dirty hack
+ g.message message="Fetching list of modules from GRASS-Addons SVN (be patient)..."
+ for d in d db g i m ps p r r3 v ; do
+     MODCLASS=`expand_module_class_name $d`
+     cd $TMPDIR
+     rm -f index.html
+     wget $SVNURL_ADDONS/$MODCLASS > /dev/null 2> /dev/null
+     grep '<li>' index.html 2> /dev/null | grep -v '\.\.' | cut -d'"' -f2 | sed 's+/$++g' >> list.txt
+     rm -f index.html
+ done
+ cat list.txt
+ rm -f list.txt
+}
+
+##
+cleanup(){
+ cd ${TMPDIR}
+ rm -rf ${TMPDIR}/${MODULE}
+ rmdir "$TMPDIR"
+}
+
+if [ $GIS_FLAG_l -eq 1 ] ; then
+   list_available_modules
+   rmdir "$TMPDIR"
+   exit 0
+fi
+
+if [ -z "$GIS_OPT_EXTENSION" -a $GIS_FLAG_l -eq 0 ] ; then
+   g.message message="You need to define an extension name or use -l"
+   exit 1
+fi
+
+
+cd ${TMPDIR}
+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 ${TMPDIR}/${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? Install dir present?
+      if test ! -d ${MYINST_DIR} ; then
+         mkdir -p ${MYINST_DIR}/bin
+         mkdir -p ${MYINST_DIR}/docs/html
+         mkdir -p ${MYINST_DIR}/man/man1
+      fi
+      touch ${MYINST_DIR}/`basename $0`.$$
+      if [ $? -ne 0 ] ; then
+         rm -f ${MYINST_DIR}/`basename $0`.$$
+         if test -f ${MYINST_DIR}/bin/${MODULE} ; then
+            rm -f ${MYINST_DIR}/bin/${MODULE}
+         fi
+         make MODULE_TOPDIR=${GISBASE} INST_DIR=${MYINST_DIR}
+      else
+         rm -f ${MYINST_DIR}/`basename $0`.$$
+         if test -f ${MYINST_DIR}/bin/${MODULE} ; then
+            rm -f ${MYINST_DIR}/bin/${MODULE}
+         fi
+         make MODULE_TOPDIR=${GISBASE} INST_DIR=${MYINST_DIR}
+      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}> in <${MYINST_DIR}> successfully finished."
+exit 0

Deleted: grass-addons/general/g.extension/g.extension.add
===================================================================
--- grass-addons/general/g.extension.add/g.extension.add	2009-07-30 16:39:41 UTC (rev 38540)
+++ grass-addons/general/g.extension/g.extension.add	2009-07-30 19:55:07 UTC (rev 38541)
@@ -1,170 +0,0 @@
-#!/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 : no
-#%end
-#%flag
-#%  key: l
-#%  description: List available modules in the GRASS Addons SVN repository
-#%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/
-
-#make a temporary directory
-TMPDIR="`g.tempfile pid=$$`"
-if [ $? -ne 0 ] || [ -z "$TMPDIR" ] ; then
-    g.message "Unable to create temporary files"
-    exit 1
-fi
-rm -f "$TMPDIR"
-mkdir "$TMPDIR"
-
-# check if we have the svn client
-if [ ! -x "`which svn`" ] ; then
-    echo "ERROR: svn client required. Please install subversion first." 1>&2
-    exit 1
-fi
-
-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`
-
-list_available_modules()
-{
- # a very dirty hack
- g.message message="Fetching list of modules from GRASS-Addons SVN (be patient)..."
- for d in d db g i m ps p r r3 v ; do
-     MODCLASS=`expand_module_class_name $d`
-     cd $TMPDIR
-     rm -f index.html
-     wget $SVNURL_ADDONS/$MODCLASS > /dev/null 2> /dev/null
-     grep '<li>' index.html 2> /dev/null | grep -v '\.\.' | cut -d'"' -f2 | sed 's+/$++g' >> list.txt
-     rm -f index.html
- done
- cat list.txt
- rm -f list.txt
-}
-
-##
-cleanup(){
- cd ${TMPDIR}
- rm -rf ${TMPDIR}/${MODULE}
- rmdir "$TMPDIR"
-}
-
-if [ $GIS_FLAG_l -eq 1 ] ; then
-   list_available_modules
-   rmdir "$TMPDIR"
-   exit 0
-fi
-
-if [ -z "$GIS_OPT_EXTENSION" -a $GIS_FLAG_l -eq 0 ] ; then
-   g.message message="You need to define an extension name or use -l"
-   exit 1
-fi
-
-
-cd ${TMPDIR}
-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 ${TMPDIR}/${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}/`basename $0`.$$
-      if [ $? -ne 0 ] ; then
-         rm -f ${GISBASE}/`basename $0`.$$
-         sudo make MODULE_TOPDIR=${GISBASE} install
-      else
-         rm -f ${GISBASE}/`basename $0`.$$
-         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



More information about the grass-commit mailing list