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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 13 06:10:45 EDT 2011


Author: hamish
Date: 2011-05-13 03:10:44 -0700 (Fri, 13 May 2011)
New Revision: 46259

Modified:
   grass/branches/develbranch_6/scripts/g.extension/description.html
   grass/branches/develbranch_6/scripts/g.extension/g.extension
Log:
add new -u flag to support systems using sudo;
remove do-nothing curly brackets;
add bug warning to man page


Modified: grass/branches/develbranch_6/scripts/g.extension/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/g.extension/description.html	2011-05-13 09:35:51 UTC (rev 46258)
+++ grass/branches/develbranch_6/scripts/g.extension/description.html	2011-05-13 10:10:44 UTC (rev 46259)
@@ -5,7 +5,11 @@
 <p>
 Re-running the script on an installed GRASS Addon re-installs
 the requested extension which may include updates.
+<P>
+If your GRASS_ADDON_PATH contains more than one path, the default
+action is to use the first directory in the list.
 
+
 <h2>EXAMPLES</h2>
 
 Download and install <em>i.landsat.toar</em> into current GRASS installation:
@@ -13,8 +17,17 @@
 g.extension extension=i.landsat.toar
 </pre></div>
 
+
+<h2>BUGS</h2>
+This is a new module and obtaining successful behavior on all platforms
+is rather tricky.  Please report any problems to the GRASS bug tracker.
+If this automatic build fails, instructions for compiling both the GRASS
+source code and GRASS addons by hand can be found in the GRASS wiki.
+
+
 <h2>AUTHOR</h2>
 
 Markus Neteler
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/branches/develbranch_6/scripts/g.extension/g.extension
===================================================================
--- grass/branches/develbranch_6/scripts/g.extension/g.extension	2011-05-13 09:35:51 UTC (rev 46258)
+++ grass/branches/develbranch_6/scripts/g.extension/g.extension	2011-05-13 10:10:44 UTC (rev 46259)
@@ -62,6 +62,10 @@
 #% key: s
 #% description: Install system-wide (may need system administrator rights)
 #%end
+#%flag
+#% key: u
+#% description: Install system-wide using sudo
+#%end
 
 
 if  [ -z "$GISBASE" ] ; then
@@ -218,9 +222,14 @@
 	GRASS_ADDON_PATH1=`echo "$GRASS_ADDON_PATH" | cut -f1 -d:`
     fi
     PREFIX="$GRASS_ADDON_PATH1"
-elif [ "$PREFIX" = '$GISBASE' ] || [ $GIS_FLAG_S -eq 1 ] ; then
+elif [ "$PREFIX" = '$GISBASE' ] || [ $GIS_FLAG_S -eq 1 ] || [ $GIS_FLAG_U -eq 1 ] ; then
    SYSADMIN=1
    PREFIX="$GISBASE"
+
+   # just to make later tests happy
+   if [ $GIS_FLAG_S -eq 0 ] && [ $GIS_FLAG_U -eq 1 ] ; then
+      GIS_FLAG_S=1
+   fi
 fi
 
 
@@ -288,29 +297,39 @@
       PROGTYPE=bin
    fi
    # can we write? Install dir present?
-   if test ! -d "${MYINST_DIR}" ; then
-      mkdir -p "${MYINST_DIR}"
+   if test ! -d "$MYINST_DIR" ; then
+      mkdir -p "$MYINST_DIR"
    fi
-   if test ! -d "${MYINST_DIR}/$PROGTYPE" ; then
-      mkdir -p "${MYINST_DIR}/$PROGTYPE"
+   if test ! -d "$MYINST_DIR/$PROGTYPE" ; then
+      mkdir -p "$MYINST_DIR/$PROGTYPE"
    fi
-   if test ! -d "${MYINST_DIR}/docs/html" ; then
-      mkdir -p "${MYINST_DIR}/docs/html"
+   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"
+   if test ! -d "$MYINST_DIR/man/man1" ; then
+      mkdir -p "$MYINST_DIR/man/man1"
    fi
 
    if [ $SYSADMIN -eq 1 ] ; then
-      if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
-         g.message "You need to enter the root password to remove the previous version of ${MODULE}:"
-         su -c "rm -f \"${MYINST_DIR}/$PROGTYPE/${MODULE}\""
+      if test -f "$MYINST_DIR/$PROGTYPE/$MODULE" ; then
+         if [ $GIS_FLAG_U -eq 1 ] ; then
+            g.message "You may need to enter your password to remove an earlier copy of $MODULE:"
+            sudo rm -f "$MYINST_DIR/$PROGTYPE/$MODULE"
+         else
+            g.message "You need to enter the root password to remove an earlier copy of $MODULE:"
+            su -c "rm -f \"$MYINST_DIR/$PROGTYPE/$MODULE\""
+         fi
       fi
-      g.message "You need to enter the root password next to install ${MODULE}:"
-      su -c "make MODULE_TOPDIR=\"$GISBASE\" ARCH_DISTDIR=\"$TMPDIR/dist\" INST_DIR=\"$MYINST_DIR\" install"
+      if [ $GIS_FLAG_U -eq 1 ] ; then
+         g.message "You may need to enter your password to install $MODULE:"
+         sudo make MODULE_TOPDIR="$GISBASE" ARCH_DISTDIR="$TMPDIR/dist" INST_DIR="$MYINST_DIR" install
+      else
+         g.message "You need to enter the root password to install $MODULE:"
+         su -c "make MODULE_TOPDIR=\"$GISBASE\" ARCH_DISTDIR=\"$TMPDIR/dist\" INST_DIR=\"$MYINST_DIR\" install"
+      fi
    else
-      if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
-         rm -f "${MYINST_DIR}/$PROGTYPE/${MODULE}"
+      if test -f "$MYINST_DIR/$PROGTYPE/$MODULE" ; then
+         rm -f "$MYINST_DIR/$PROGTYPE/$MODULE"
       fi
       make MODULE_TOPDIR="$GISBASE" ARCH_DISTDIR="$TMPDIR/dist" INST_DIR="$MYINST_DIR" install
    fi
@@ -321,7 +340,7 @@
       exit 1
    fi
 
-   if [ ! -x "${MYINST_DIR}/$PROGTYPE/${MODULE}" ] ; then
+   if [ ! -x "$MYINST_DIR/$PROGTYPE/$MODULE" ] ; then
      g.message -e "Module did not install properly"
      cleanup
      exit 1



More information about the grass-commit mailing list