[GRASS-SVN] r65402 - grass/branches/releasebranch_7_0/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 7 07:49:53 PDT 2015


Author: martinl
Date: 2015-06-07 07:49:53 -0700 (Sun, 07 Jun 2015)
New Revision: 65402

Modified:
   grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.html
   grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.py
Log:
g.extension: check if target directory is writable
             manual: extended
             (merge r65389, r65394, r65399)


Modified: grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.html
===================================================================
--- grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.html	2015-06-07 12:22:21 UTC (rev 65401)
+++ grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.html	2015-06-07 14:49:53 UTC (rev 65402)
@@ -1,36 +1,59 @@
 <h2>DESCRIPTION</h2>
 
+<!-- TODO: the use of Addon and extension is not coherent -->
+
 <em>g.extension</em> downloads and installs, removes or updates
-extensions from
-<a href="http://svn.osgeo.org/grass/grass-addons/grass7/">GRASS Addons SVN repository</a> into the local GRASS GIS installation.
+extensions (Addons) from the
+<a href="http://svn.osgeo.org/grass/grass-addons/grass7/">GRASS GIS Addons repository</a>
+into the local GRASS GIS installation.
 
-<p>Re-running <em>g.extension</em> on an installed GRASS Addons
+<p>Re-running <em>g.extension</em> on an installed GRASS GIS Addon
 extension re-installs the requested extension which may include
-updates. All locally installed GRASS Addons extensions can be
-re-installed
-by <em><a href="g.extension.all.html">g.extension.all</a></em>.
+updates.
+<p>
+In order to bulk-update all locally installed GRASS GIS extensions, they can
+be re-installed altogether by the
+<em><a href="g.extension.all.html">g.extension.all</a></em> module.
 
+<h2>NOTES</h2>
+    
+GRASS GIS extensions are installed by <tt>g.extension</tt> into a dedicated 
+directory (GRASS_ADDON_BASE). The default on GNU/Linux is
+<tt>$HOME/.grass7/addons</tt>, on MS-Windows it is
+<tt>$APPDATA\GRASS7\addons</tt>.
+<p>
+The flag <b>-s</b> changes this install target directory to the GRASS GIS
+installation directory (GISBASE, e.g. <tt>/usr/</tt>) rather than the
+default GRASS_ADDON_BASE directory (see also <a href="variables.html">variables</a>).
+<em>g.extension</em> checks if the user has permission to write to
+GISBASE or GRASS_ADDON_BASE.
+<p>
+On MS-Windows systems, <em>g.extension</em> downloads an executable from
+the GRASS GIS project server. On all other operating systems, it downloads the
+source code of the requested Addon and compiles it locally.
+
 <h2>EXAMPLES</h2>
 
+<h3>Download and install of an extension</h3>
 Download and install <em>r.stream.distance</em> into current GRASS installation
 
 <div class="code"><pre>
 g.extension extension=r.stream.distance
 </pre></div>
 
-Remove locally installed extension
+<h3>Removal of a locally installed extension</h3>
 
 <div class="code"><pre>
 g.extension extension=r.stream.distance operation=remove
 </pre></div>
 
-List all available extensions from GRASS Addons SVN repository
+<h3>List all available extensions from GRASS Addons SVN repository</h3>
 
 <div class="code"><pre>
 g.extension -l
 </pre></div>
 
-List all locally installed extensions
+<h3>List all locally installed extensions</h3>
 
 <div class="code"><pre>
 g.extension -a
@@ -43,7 +66,9 @@
 </em>
 
 <p>
-See also <a href="http://grasswiki.osgeo.org/wiki/GRASS_AddOns">GRASS Addons</a> wiki page.
+<a href="http://grass.osgeo.org/grass70/manuals/addons/">GRASS GIS 7 Addons Manual pages</a>
+<br>
+<a href="http://grasswiki.osgeo.org/wiki/GRASS_AddOns">GRASS Addons</a> wiki page.
 
 <h2>AUTHORS</h2>
 

Modified: grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.py	2015-06-07 12:22:21 UTC (rev 65401)
+++ grass/branches/releasebranch_7_0/scripts/g.extension/g.extension.py	2015-06-07 14:49:53 UTC (rev 65402)
@@ -1034,6 +1034,7 @@
     # define path
     if flags['s']:
         options['prefix'] = os.environ['GISBASE']
+    
     if options['prefix'] == '$GRASS_ADDON_BASE':
         if not os.getenv('GRASS_ADDON_BASE'):
             grass.warning(_("GRASS_ADDON_BASE is not defined, "
@@ -1041,6 +1042,12 @@
             options['prefix'] = os.path.join(os.environ['HOME'], '.grass%s' % version[0], 'addons')
         else:
             options['prefix'] = os.environ['GRASS_ADDON_BASE']
+
+    if not os.access(options['prefix'], os.W_OK):
+        grass.fatal(_("You don't have permission to install extension to <{}>. "
+                      "Try to run {} with administrator rights"
+                      "(su or sudo).").format(options['prefix'], 'g.extension'))
+
     if 'svn.osgeo.org/grass/grass-addons/grass7' in options['svnurl']:
         # use pregenerated modules XML file
         xmlurl = "http://grass.osgeo.org/addons/grass%s" % version[0]



More information about the grass-commit mailing list