1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## g.extension.dpatch by Francesco Paolo Lovergine <frankie@debian.org>
4
## All lines beginning with `## DP:' are a description of the patch.
8
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' grass-6.4.0~rc6+42329~/scripts/Makefile grass-6.4.0~rc6+42329/scripts/Makefile
9
--- grass-6.4.0~rc6+42329~/scripts/Makefile 2010-03-15 14:23:54.000000000 +0100
10
+++ grass-6.4.0~rc6+42329/scripts/Makefile 2010-09-21 15:04:43.000000000 +0200
19
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' grass-6.4.0~rc6+42329~/scripts/g.extension/Makefile grass-6.4.0~rc6+42329/scripts/g.extension/Makefile
20
--- grass-6.4.0~rc6+42329~/scripts/g.extension/Makefile 1970-01-01 01:00:00.000000000 +0100
21
+++ grass-6.4.0~rc6+42329/scripts/g.extension/Makefile 2010-09-21 15:04:29.000000000 +0200
23
+MODULE_TOPDIR = ../..
27
+include $(MODULE_TOPDIR)/include/Make/Script.make
30
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' grass-6.4.0~rc6+42329~/scripts/g.extension/g.extension grass-6.4.0~rc6+42329/scripts/g.extension/g.extension
31
--- grass-6.4.0~rc6+42329~/scripts/g.extension/g.extension 1970-01-01 01:00:00.000000000 +0100
32
+++ grass-6.4.0~rc6+42329/scripts/g.extension/g.extension 2010-09-21 15:04:13.000000000 +0200
36
+############################################################################
38
+# MODULE: g.extension
39
+# AUTHOR(S): Markus Neteler
40
+# PURPOSE: Tool to download and install extensions from GRASS Addons SVN into
41
+# local GRASS installation
42
+# COPYRIGHT: (C) 2009-2010 by the Markus Neteler, GRASS Development Team
44
+# This program is free software under the GNU General Public
45
+# License (>=v2). Read the file COPYING that comes with GRASS
48
+#############################################################################
52
+#% label: Tool to maintain GRASS extensions in local GRASS installation.
53
+#% description: Downloads, installs extensions from GRASS Addons SVN repository into local GRASS installation or removes installed extensions.
54
+#% keywords: general, extensions
61
+#% description: Name of extension to install/remove
68
+#% description: Operation to be performed
70
+#% options: add,remove
77
+#% description: SVN Addons repository URL
79
+#% answer: https://svn.osgeo.org/grass/grass-addons/
85
+#% description: Prefix where to install extension
91
+#% description: List available modules in the GRASS Addons SVN repository
96
+if [ -z "$GISBASE" ] ; then
97
+ echo "You must be in GRASS GIS to run this program." >&2
101
+if [ "$1" != "@ARGS_PARSED@" ] ; then
102
+ exec g.parser "$0" "$@"
107
+SVNURL_ADDONS="$GIS_OPT_SVNURL"
108
+MODULE="$GIS_OPT_EXTENSION"
109
+PREFIX="$GIS_OPT_PREFIX"
111
+#make a temporary directory
112
+TMPDIR="`g.tempfile pid=$$`"
113
+if [ $? -ne 0 ] || [ -z "$TMPDIR" ] ; then
114
+ g.message -e "Unable to create temporary files"
120
+#TODO: combine all these checks into a single for loop
122
+# check if we have the svn client
123
+if [ ! -x "`which svn`" ] ; then
124
+ g.message -e "svn client required. Please install Subversion first."
128
+# check if we have the make program
129
+if [ ! -x "`which make`" ] ; then
130
+ g.message -e "The 'make' program is required. Please install first."
134
+# check if we have the "install" program
135
+if [ ! -x "`which install`" ] ; then
136
+ g.message -e "The 'install' program is required. Please install first."
140
+# check if we have wget or curl
141
+if [ ! -x "`which wget`" ] ; then
142
+ if [ ! -x "`which curl`" ] ; then
143
+ g.message -e "Either 'wget' or 'curl' is required, please install one first"
146
+ g.message -v "Using CURL for downloading data."
150
+ g.message -v "Using WGET for downloading data."
154
+expand_module_class_name()
157
+ if [ "$1" = "d" ] ; then
159
+ elif [ "$1" = "db" ] ; then
161
+ elif [ "$1" = "g" ] ; then
163
+ elif [ "$1" = "i" ] ; then
165
+ elif [ "$1" = "m" ] ; then
167
+ elif [ "$1" = "ps" ] ; then
169
+# elif [ "$1" = "p" ] ; then
171
+ elif [ "$1" = "r" ] ; then
173
+ elif [ "$1" = "r3" ] ; then
175
+# elif [ "$1" = "s" ] ; then
177
+ elif [ "$1" = "v" ] ; then
184
+if [ `echo "$MODULE" | grep -c '/'` -eq 0 ] ; then
185
+ CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
186
+ MODULECLASS=`expand_module_class_name $CLASSCHAR`
188
+ # handle vector/adehabitat/ or just vector/v.module ...
189
+ TOPLEVEL=`echo $MODULE | cut -d'/' -f1`
190
+ MODULECLASS="$TOPLEVEL"
191
+ MODULE=`echo "$MODULE" | sed -e "s+^$MODULECLASS/++"`
195
+list_available_modules()
197
+ # a very dirty hack
198
+ g.message message="Fetching list of modules from GRASS-Addons SVN (be patient)..."
199
+ for d in d db g i m ps p r r3 v ; do
200
+ MODCLASS=`expand_module_class_name $d`
203
+ if [ "$USE_WGET" ] ; then
204
+ wget --quiet -nv "$SVNURL_ADDONS/$MODCLASS"
206
+ curl -silent --location "$SVNURL_ADDONS/$MODCLASS" -o index.html
208
+ grep '<li>' index.html 2> /dev/null | grep -v '\.\.' | \
209
+ cut -d'"' -f2 | sed 's+/$++g' >> list_$$.txt
214
+ # so why save to a file at all instead of cat'ing directly?
219
+ if [ -n "$TMPDIR" ] ; then
224
+if [ $GIS_FLAG_L -eq 1 ] ; then
225
+ list_available_modules
230
+if [ -z "$GIS_OPT_EXTENSION" -a $GIS_FLAG_L -eq 0 ] ; then
231
+ g.message message="You need to define an extension name or use -l"
235
+if [ "$PREFIX" = '$GISBASE' ] ; then
239
+if [ -d "$PREFIX" ] ; then
240
+ MYINST_DIR="$PREFIX"
242
+ g.message -e "'$PREFIX' does not exist"
246
+if [ "$GIS_OPT_OPERATION" = "remove" ] ; then
247
+ g.message message="Removing <$MODULE>..."
249
+ if test -f "${MYINST_DIR}/bin/${MODULE}" ; then
250
+ rm -f "${MYINST_DIR}/bin/${MODULE}"
252
+ if test -f "${MYINST_DIR}/docs/html/${MODULE}.html" ; then
253
+ rm -f "${MYINST_DIR}/docs/html/${MODULE}.html"
255
+ if test -f "${MYINST_DIR}/man/man1/${MODULE}.1" ; then
256
+ rm -f "${MYINST_DIR}/man/man1/${MODULE}.1"
262
+g.message -d "svn co [$SVNURL_ADDONS]/[$MODULECLASS]/[$MODULE]"
265
+g.message message="Fetching <$MODULE> from GRASS-Addons SVN (be patient)..."
266
+svn co "${SVNURL_ADDONS}/${MODULECLASS}/${MODULE}"
268
+if [ $? -ne 0 ] ; then
269
+ g.message -e message="GRASS Addon ${MODULE} not found in repository or no network connection or another problem"
273
+cd "$TMPDIR/$MODULE"
274
+g.message message="Compiling <${MODULE}>..."
275
+make MODULE_TOPDIR="$GISBASE"
276
+if [ $? -ne 0 ] ; then
277
+ g.message -e message="Compilation failed, sorry. Please check above error messages."
281
+ g.message message="Installing ${MODULE}..."
284
+ grep "default: script" "$TMPDIR/$MODULE/Makefile" 2>&1 >/dev/null
285
+ if [ $? -eq 0 ] ; then
290
+ # can we write? Install dir present?
291
+ if test ! -d "${MYINST_DIR}" ; then
292
+ mkdir -p "${MYINST_DIR}"
294
+ if test ! -d "${MYINST_DIR}/$PROGTYPE" ; then
295
+ mkdir -p "${MYINST_DIR}/$PROGTYPE"
297
+ if test ! -d "${MYINST_DIR}/docs/html" ; then
298
+ mkdir -p "${MYINST_DIR}/docs/html"
300
+ if test ! -d "${MYINST_DIR}/man/man1" ; then
301
+ mkdir -p "${MYINST_DIR}/man/man1"
303
+ touch "${MYINST_DIR}/`basename $0`.$$"
304
+ if [ $? -ne 0 ] ; then
305
+ g.message -e message="Cannot write to <$MYINST_DIR>, installation failed"
308
+ rm -f "${MYINST_DIR}/`basename $0`.$$"
309
+ if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
310
+ rm -f "${MYINST_DIR}/$PROGTYPE/${MODULE}"
312
+ make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR" install
313
+ if [ $? -ne 0 ] ; then
314
+ g.message -e message="Installation failed, sorry. Please check above error messages."
318
+ if [ ! -x "${MYINST_DIR}/$PROGTYPE/${MODULE}" ] ; then
319
+ g.message -e "Module did not install properly"
328
+g.message message=""
329
+g.message message="Installation of <$MODULE> in <$MYINST_DIR> successfully finished."