[GRASS-SVN] r42019 - grass/branches/develbranch_6/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 24 10:01:48 EDT 2010


Author: martinl
Date: 2010-04-24 10:01:48 -0400 (Sat, 24 Apr 2010)
New Revision: 42019

Modified:
   grass/branches/develbranch_6/scripts/g.extension/g.extension
Log:
g.extension: fix install procedure
             replace 'a' flag by 'prefix' parameter


Modified: grass/branches/develbranch_6/scripts/g.extension/g.extension
===================================================================
--- grass/branches/develbranch_6/scripts/g.extension/g.extension	2010-04-24 13:14:17 UTC (rev 42018)
+++ grass/branches/develbranch_6/scripts/g.extension/g.extension	2010-04-24 14:01:48 UTC (rev 42019)
@@ -4,9 +4,9 @@
 #
 # MODULE:       g.extension
 # AUTHOR(S):   	Markus Neteler
-# PURPOSE:      tool to download and install extensions from GRASS Addons SVN into 
+# 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
+# COPYRIGHT:    (C) 2009-2010 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
@@ -18,8 +18,7 @@
 #%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
+#% keywords: general, extensions
 #%End
 
 #%option
@@ -35,7 +34,7 @@
 #% key_desc: name
 #% description: Operation to be performed
 #% required: no
-#% options: add
+#% options: add,remove
 #% answer: add
 #%end
 #%option
@@ -51,14 +50,10 @@
 #% type: string
 #% key_desc: path
 #% description: Prefix where to install extension
-#% answer: ${GISBASE}
+#% answer: $GRASS_ADDON_PATH
 #% required: yes
 #%end
 #%flag
-#% key: a
-#% description: Install to $GRASS_ADDON_PATH instead of using prefix option
-#%end
-#%flag
 #% key: l
 #% description: List available modules in the GRASS Addons SVN repository
 #% guisection: Print
@@ -77,22 +72,9 @@
 # definitions
 
 SVNURL_ADDONS=${GIS_OPT_SVNURL}
+MODULE="$GIS_OPT_EXTENSION"
+PREFIX="$GIS_OPT_PREFIX"
 
-if [ $GIS_FLAG_A -eq 0 ] ; then
-   if [ "$GIS_OPT_PREFIX" = '${GISBASE}' ] ; then
-      MYINST_DIR=${GISBASE}
-   else
-      MYINST_DIR=${GIS_OPT_PREFIX}
-   fi
-else
-   if [ -d "$GRASS_ADDON_PATH" ] ; then
-      MYINST_DIR="$GRASS_ADDON_PATH"
-   else
-      g.message -e '$GRASS_ADDON_PATH does not exist'
-      exit 1
-   fi
-fi
-
 #make a temporary directory
 TMPDIR="`g.tempfile pid=$$`"
 if [ $? -ne 0 ] || [ -z "$TMPDIR" ] ; then
@@ -158,8 +140,6 @@
  fi
 }
 
-MODULE="$GIS_OPT_EXTENSION"
-
 if [ `echo "$MODULE" | grep -c '/'` -eq 0 ] ; then
    CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
    MODULECLASS=`expand_module_class_name $CLASSCHAR`
@@ -211,6 +191,37 @@
    exit 1
 fi
 
+if [ "$PREFIX" == '$GRASS_ADDON_PATH' ] ; then
+    if [ -z "$GRASS_ADDON_PATH" ] ; then
+        g.message -e "GRASS_ADDON_PATH is not defined"
+        exit 1
+    fi
+    PREFIX=$GRASS_ADDON_PATH
+fi
+
+if [ -d "$PREFIX" ] ; then
+    MYINST_DIR="$PREFIX"
+else
+    g.message -e "'$PREFIX' does not exist"
+    exit 1
+fi
+
+if [ "$GIS_OPT_OPERATION" == "remove" ] ; then
+   g.message message="Removing <$MODULE>..."
+   
+   if test -f "${MYINST_DIR}/bin/${MODULE}" ; then
+       rm -f "${MYINST_DIR}/bin/${MODULE}"
+   fi
+   if test -f "${MYINST_DIR}/docs/html/${MODULE}.html" ; then
+       rm -f "${MYINST_DIR}/docs/html/${MODULE}.html"
+   fi
+   if test -f "${MYINST_DIR}/man/man1/${MODULE}.1" ; then
+       rm -f "${MYINST_DIR}/man/man1/${MODULE}.1"
+   fi
+
+   exit 0
+fi
+
 g.message -d "svn co [$SVNURL_ADDONS]/[$MODULECLASS]/[$MODULE]"
 
 cd "$TMPDIR"
@@ -223,7 +234,7 @@
 fi
 
 cd "$TMPDIR/$MODULE"
-g.message message="Compiling ${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."
@@ -253,7 +264,7 @@
       if test -f "${MYINST_DIR}/bin/${MODULE}" ; then
          rm -f "${MYINST_DIR}/bin/${MODULE}"
       fi
-      make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR"
+      make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR" install
       if [ $? -ne 0 ] ; then
          g.message -e message="Installation failed, sorry. Please check above error messages."
          cleanup
@@ -264,10 +275,6 @@
 	cleanup
 	exit 1
       fi
-      if [ $GIS_FLAG_A -eq 1 ] ; then
-         \mv "${MYINST_DIR}/bin/${MODULE}" "$MYINST_DIR"/
-	 rmdir "${MYINST_DIR}/bin"
-      fi
    fi
 fi
 



More information about the grass-commit mailing list