~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to debian/patches/g.extension.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## g.extension.dpatch by Francesco Paolo Lovergine <frankie@debian.org>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
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
11
 
@@ -26,6 +26,7 @@
12
 
        db.out.ogr \
13
 
        db.test \
14
 
        g.manual \
15
 
+       g.extension \
16
 
        i.fusion.brovey \
17
 
        i.image.mosaic \
18
 
        i.in.spotvgt \
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
22
 
@@ -0,0 +1,7 @@
23
 
+MODULE_TOPDIR = ../..
24
 
+
25
 
+PGM = g.extension
26
 
+
27
 
+include $(MODULE_TOPDIR)/include/Make/Script.make
28
 
+
29
 
+default: script
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
33
 
@@ -0,0 +1,298 @@
34
 
+#!/bin/sh
35
 
+
36
 
+############################################################################
37
 
+#
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
43
 
+#
44
 
+#               This program is free software under the GNU General Public
45
 
+#               License (>=v2). Read the file COPYING that comes with GRASS
46
 
+#               for details.
47
 
+#
48
 
+#############################################################################
49
 
+
50
 
+
51
 
+#%Module
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
55
 
+#%End
56
 
+
57
 
+#%option
58
 
+#% key: extension
59
 
+#% type: string
60
 
+#% key_desc: name
61
 
+#% description: Name of extension to install/remove
62
 
+#% required: no
63
 
+#%end
64
 
+#%option
65
 
+#% key: operation
66
 
+#% type: string
67
 
+#% key_desc: name
68
 
+#% description: Operation to be performed
69
 
+#% required: no
70
 
+#% options: add,remove
71
 
+#% answer: add
72
 
+#%end
73
 
+#%option
74
 
+#% key: svnurl
75
 
+#% type: string
76
 
+#% key_desc: url
77
 
+#% description: SVN Addons repository URL
78
 
+#% required: yes
79
 
+#% answer: https://svn.osgeo.org/grass/grass-addons/
80
 
+#%end
81
 
+#%option
82
 
+#% key: prefix
83
 
+#% type: string
84
 
+#% key_desc: path
85
 
+#% description: Prefix where to install extension
86
 
+#% answer: $GISBASE
87
 
+#% required: yes
88
 
+#%end
89
 
+#%flag
90
 
+#% key: l
91
 
+#% description: List available modules in the GRASS Addons SVN repository
92
 
+#% guisection: Print
93
 
+#%end
94
 
+
95
 
+
96
 
+if  [ -z "$GISBASE" ] ; then
97
 
+    echo "You must be in GRASS GIS to run this program." >&2
98
 
+    exit 1
99
 
+fi
100
 
+
101
 
+if [ "$1" != "@ARGS_PARSED@" ] ; then
102
 
+  exec g.parser "$0" "$@"
103
 
+fi
104
 
+
105
 
+# definitions
106
 
+
107
 
+SVNURL_ADDONS="$GIS_OPT_SVNURL"
108
 
+MODULE="$GIS_OPT_EXTENSION"
109
 
+PREFIX="$GIS_OPT_PREFIX"
110
 
+
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"
115
 
+    exit 1
116
 
+fi
117
 
+rm -f "$TMPDIR"
118
 
+mkdir "$TMPDIR"
119
 
+
120
 
+#TODO: combine all these checks into a single for loop
121
 
+
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."
125
 
+    exit 1
126
 
+fi
127
 
+
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."
131
 
+    exit 1
132
 
+fi
133
 
+
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."
137
 
+    exit 1
138
 
+fi
139
 
+
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"
144
 
+        exit 1
145
 
+    else
146
 
+        g.message -v "Using CURL for downloading data."
147
 
+        USE_CURL=1
148
 
+    fi
149
 
+else
150
 
+    g.message -v "Using WGET for downloading data."
151
 
+    USE_WGET=1
152
 
+fi
153
 
+
154
 
+expand_module_class_name()
155
 
+{
156
 
+# $1: module class
157
 
+ if [ "$1" = "d" ]  ; then
158
 
+    echo "display"
159
 
+  elif [ "$1" = "db" ] ; then
160
 
+    echo "database"
161
 
+  elif [ "$1" = "g" ]  ; then
162
 
+    echo "general"
163
 
+  elif [ "$1" = "i" ]  ; then
164
 
+    echo "imagery"
165
 
+  elif [ "$1" = "m" ]  ; then
166
 
+    echo "misc"
167
 
+  elif [ "$1" = "ps" ] ; then
168
 
+    echo "postscript"
169
 
+#  elif [ "$1" = "p" ]  ; then
170
 
+#    echo "paint"
171
 
+  elif [ "$1" = "r" ]  ; then
172
 
+    echo "raster"
173
 
+  elif [ "$1" = "r3" ]  ; then
174
 
+    echo "raster3D"
175
 
+#  elif [ "$1" = "s" ]  ; then
176
 
+#    echo "sites"
177
 
+  elif [ "$1" = "v" ]  ; then
178
 
+    echo "vector"
179
 
+  else
180
 
+    echo "$1"
181
 
+ fi
182
 
+}
183
 
+
184
 
+if [ `echo "$MODULE" | grep -c '/'` -eq 0 ] ; then
185
 
+   CLASSCHAR=`echo $MODULE | cut -d'.' -f1`
186
 
+   MODULECLASS=`expand_module_class_name $CLASSCHAR`
187
 
+else
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/++"`
192
 
+fi
193
 
+
194
 
+
195
 
+list_available_modules()
196
 
+{
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`
201
 
+     cd "$TMPDIR"
202
 
+     rm -f index.html
203
 
+     if [ "$USE_WGET" ] ; then
204
 
+        wget --quiet -nv "$SVNURL_ADDONS/$MODCLASS"
205
 
+     else
206
 
+        curl -silent --location "$SVNURL_ADDONS/$MODCLASS" -o index.html
207
 
+     fi
208
 
+     grep '<li>' index.html 2> /dev/null | grep -v '\.\.' | \
209
 
+        cut -d'"' -f2 | sed 's+/$++g' >> list_$$.txt
210
 
+     rm -f index.html
211
 
+ done
212
 
+ cat list_$$.txt
213
 
+ rm -f list_$$.txt
214
 
+ # so why save to a file at all instead of cat'ing directly?
215
 
+}
216
 
+
217
 
+##
218
 
+cleanup(){
219
 
+ if  [ -n "$TMPDIR" ] ; then
220
 
+     rm -rf "$TMPDIR"
221
 
+ fi
222
 
+}
223
 
+
224
 
+if [ $GIS_FLAG_L -eq 1 ] ; then
225
 
+   list_available_modules
226
 
+   rmdir "$TMPDIR"
227
 
+   exit 0
228
 
+fi
229
 
+
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"
232
 
+   exit 1
233
 
+fi
234
 
+
235
 
+if [ "$PREFIX" = '$GISBASE' ] ; then
236
 
+   PREFIX="$GISBASE"
237
 
+fi
238
 
+
239
 
+if [ -d "$PREFIX" ] ; then
240
 
+    MYINST_DIR="$PREFIX"
241
 
+else
242
 
+    g.message -e "'$PREFIX' does not exist"
243
 
+    exit 1
244
 
+fi
245
 
+
246
 
+if [ "$GIS_OPT_OPERATION" = "remove" ] ; then
247
 
+   g.message message="Removing <$MODULE>..."
248
 
+
249
 
+   if test -f "${MYINST_DIR}/bin/${MODULE}" ; then
250
 
+       rm -f "${MYINST_DIR}/bin/${MODULE}"
251
 
+   fi
252
 
+   if test -f "${MYINST_DIR}/docs/html/${MODULE}.html" ; then
253
 
+       rm -f "${MYINST_DIR}/docs/html/${MODULE}.html"
254
 
+   fi
255
 
+   if test -f "${MYINST_DIR}/man/man1/${MODULE}.1" ; then
256
 
+       rm -f "${MYINST_DIR}/man/man1/${MODULE}.1"
257
 
+   fi
258
 
+
259
 
+   exit 0
260
 
+fi
261
 
+
262
 
+g.message -d "svn co [$SVNURL_ADDONS]/[$MODULECLASS]/[$MODULE]"
263
 
+
264
 
+cd "$TMPDIR"
265
 
+g.message message="Fetching <$MODULE> from GRASS-Addons SVN (be patient)..."
266
 
+svn co "${SVNURL_ADDONS}/${MODULECLASS}/${MODULE}"
267
 
+
268
 
+if [ $? -ne 0 ] ; then
269
 
+   g.message -e message="GRASS Addon ${MODULE} not found in repository or no network connection or another problem"
270
 
+   exit 1
271
 
+fi
272
 
+
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."
278
 
+   cleanup
279
 
+   exit 1
280
 
+else
281
 
+   g.message message="Installing ${MODULE}..."
282
 
+
283
 
+   # is it a script?
284
 
+   grep "default: script" "$TMPDIR/$MODULE/Makefile" 2>&1 >/dev/null
285
 
+   if [ $? -eq 0 ] ; then
286
 
+      PROGTYPE=scripts
287
 
+   else
288
 
+      PROGTYPE=bin
289
 
+   fi
290
 
+   # can we write? Install dir present?
291
 
+   if test ! -d "${MYINST_DIR}" ; then
292
 
+      mkdir -p "${MYINST_DIR}"
293
 
+   fi
294
 
+   if test ! -d "${MYINST_DIR}/$PROGTYPE" ; then
295
 
+      mkdir -p "${MYINST_DIR}/$PROGTYPE"
296
 
+   fi
297
 
+   if test ! -d "${MYINST_DIR}/docs/html" ; then
298
 
+      mkdir -p "${MYINST_DIR}/docs/html"
299
 
+   fi
300
 
+   if test ! -d "${MYINST_DIR}/man/man1" ; then
301
 
+      mkdir -p "${MYINST_DIR}/man/man1"
302
 
+   fi
303
 
+   touch "${MYINST_DIR}/`basename $0`.$$"
304
 
+   if [ $? -ne 0 ] ; then
305
 
+      g.message -e message="Cannot write to <$MYINST_DIR>, installation failed"
306
 
+      exit 1
307
 
+   else
308
 
+      rm -f "${MYINST_DIR}/`basename $0`.$$"
309
 
+      if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
310
 
+         rm -f "${MYINST_DIR}/$PROGTYPE/${MODULE}"
311
 
+      fi
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."
315
 
+         cleanup
316
 
+         exit 1
317
 
+      fi
318
 
+      if [ ! -x "${MYINST_DIR}/$PROGTYPE/${MODULE}" ] ; then
319
 
+       g.message -e "Module did not install properly"
320
 
+       cleanup
321
 
+       exit 1
322
 
+      fi
323
 
+   fi
324
 
+fi
325
 
+
326
 
+cleanup
327
 
+
328
 
+g.message message=""
329
 
+g.message message="Installation of <$MODULE> in <$MYINST_DIR> successfully finished."
330
 
+
331
 
+exit 0