[GRASS-SVN] r38945 -
grass/branches/develbranch_6/scripts/g.extension
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 2 09:58:21 EDT 2009
Author: hamish
Date: 2009-09-02 09:58:21 -0400 (Wed, 02 Sep 2009)
New Revision: 38945
Modified:
grass/branches/develbranch_6/scripts/g.extension/g.extension
Log:
- add -a flag to send to GRASS_ADDON_PATH if it exists
(ugly hack, hopefully something better can be done in python)
- allow extention names like vector/v.module and vector/adehabitat/...
Modified: grass/branches/develbranch_6/scripts/g.extension/g.extension
===================================================================
--- grass/branches/develbranch_6/scripts/g.extension/g.extension 2009-09-02 09:01:03 UTC (rev 38944)
+++ grass/branches/develbranch_6/scripts/g.extension/g.extension 2009-09-02 13:58:21 UTC (rev 38945)
@@ -54,13 +54,17 @@
#% answer: ${GISBASE}
#% 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
#%end
+
if [ -z "$GISBASE" ] ; then
echo "You must be in GRASS GIS to run this program." >&2
exit 1
@@ -73,16 +77,26 @@
# definitions
SVNURL_ADDONS=${GIS_OPT_SVNURL}
-if [ "$GIS_OPT_PREFIX" = '${GISBASE}' ] ; then
- MYINST_DIR=${GISBASE}
+
+if [ $GIS_FLAG_A -eq 0 ] ; then
+ if [ "$GIS_OPT_PREFIX" = '${GISBASE}' ] ; then
+ MYINST_DIR=${GISBASE}
+ else
+ MYINST_DIR=${GIS_OPT_PREFIX}
+ fi
else
- MYINST_DIR=${GIS_OPT_PREFIX}
+ 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
- g.message "Unable to create temporary files"
+ g.message -e "Unable to create temporary files"
exit 1
fi
rm -f "$TMPDIR"
@@ -90,13 +104,13 @@
# check if we have the svn client
if [ ! -x "`which svn`" ] ; then
- echo "ERROR: svn client required. Please install subversion first." 1>&2
+ g.message -e "svn client required. Please install Subversion first."
exit 1
fi
# check if we have the make program
if [ ! -x "`which make`" ] ; then
- echo "ERROR: 'make' program required. Please install first." 1>&2
+ g.message -e "'make' program required. Please install first."
exit 1
fi
@@ -138,16 +152,25 @@
# elif [ "$1" = "s" ] ; then
# echo "sites"
elif [ "$1" = "v" ] ; then
- echo "vector"
+ echo "vector"
else
echo "$1"
fi
}
-MODULE=$GIS_OPT_EXTENSION
-CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
-MODULECLASS=`expand_module_class_name $CLASSCHAR`
+MODULE="$GIS_OPT_EXTENSION"
+if [ `echo "$MODULE" | grep -c '/'` -eq 0 ] ; then
+ CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
+ MODULECLASS=`expand_module_class_name $CLASSCHAR`
+else
+ # handle vector/adehabitat/ or just vector/v.module ...
+ TOPLEVEL=`echo $MODULE | cut -d'/' -f1`
+ MODULECLASS="$TOPLEVEL"
+ MODULE=`echo "$MODULE" | sed -e "s+^$MODULECLASS/++"`
+fi
+
+
list_available_modules()
{
# a very dirty hack
@@ -186,6 +209,7 @@
exit 1
fi
+g.message -d "svn co [$SVNURL_ADDONS]/[$MODULECLASS]/[$MODULE]"
cd ${TMPDIR}
g.message message="Fetching <$MODULE> from GRASS-Addons SVN (be patient)..."
@@ -207,8 +231,15 @@
g.message message="Installing ${MODULE}..."
# can we write? Install dir present?
if test ! -d ${MYINST_DIR} ; then
+ mkdir -p ${MYINST_DIR}
+ fi
+ if test ! -d ${MYINST_DIR}/bin ; then
mkdir -p ${MYINST_DIR}/bin
+ fi
+ if test ! -d ${MYINST_DIR}/docs/html ; then
mkdir -p ${MYINST_DIR}/docs/html
+ fi
+ if test ! -d ${MYINST_DIR}/man/man1 ; then
mkdir -p ${MYINST_DIR}/man/man1
fi
touch "${MYINST_DIR}/`basename $0`.$$"
@@ -226,10 +257,15 @@
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
cleanup
+g.message message=""
g.message message="Installation of <${MODULE}> in <${MYINST_DIR}> successfully finished."
exit 0
More information about the grass-commit
mailing list