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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 21 06:21:23 EDT 2010


Author: neteler
Date: 2010-10-21 03:21:23 -0700 (Thu, 21 Oct 2010)
New Revision: 43985

Modified:
   grass/branches/develbranch_6/scripts/g.extension/g.extension
Log:
system wide installaton (-s) implemented

Modified: grass/branches/develbranch_6/scripts/g.extension/g.extension
===================================================================
--- grass/branches/develbranch_6/scripts/g.extension/g.extension	2010-10-21 08:56:12 UTC (rev 43984)
+++ grass/branches/develbranch_6/scripts/g.extension/g.extension	2010-10-21 10:21:23 UTC (rev 43985)
@@ -78,6 +78,7 @@
 SVNURL_ADDONS="$GIS_OPT_SVNURL"
 MODULE="$GIS_OPT_EXTENSION"
 PREFIX="$GIS_OPT_PREFIX"
+SYSADMIN=0
 
 #make a temporary directory
 TMPDIR="`g.tempfile pid=$$`"
@@ -216,7 +217,7 @@
     fi
     PREFIX="$GRASS_ADDON_PATH"
 elif [ "$PREFIX" = '$GISBASE' ] || [ $GIS_FLAG_S -eq 1 ] ; then
-   g.message -w "'-s' flag not implemented yet"
+   SYSADMIN=1
    PREFIX="$GISBASE"
 fi
 
@@ -228,7 +229,7 @@
     exit 1
 fi
 
-if [ ! -w "$PREFIX" ] ; then
+if [ ! -w "$PREFIX" -a $SYSADMIN -ne 1 ] ; then
     g.message -e "'$PREFIX' is not writable (are you logged in as the system administator?)"
     exit 1
 fi
@@ -298,19 +299,20 @@
       mkdir -p "${MYINST_DIR}/man/man1"
    fi
 
-   # use `test -w` instead of touch?
-   touch "${MYINST_DIR}/`basename $0`.$$"
-   if [ $? -ne 0 ] ; then
-      g.message -e message="Cannot write to <$MYINST_DIR>, installation failed"
-      exit 1
+   if [ $SYSADMIN -eq 1 ] ; then
+      if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
+         g.message "You need to enter the root password next:"
+         su -c "rm -f \"${MYINST_DIR}/$PROGTYPE/${MODULE}\""
+      fi
+      g.message "You need to enter the root password next:"
+      su -c "make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR" install"
+   else
+      if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
+         rm -f "${MYINST_DIR}/$PROGTYPE/${MODULE}"
+      fi
+      make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR" install
    fi
-   rm -f "${MYINST_DIR}/`basename $0`.$$"
 
-   if test -f "${MYINST_DIR}/$PROGTYPE/${MODULE}" ; then
-      rm -f "${MYINST_DIR}/$PROGTYPE/${MODULE}"
-   fi
-
-   make MODULE_TOPDIR="$GISBASE" INST_DIR="$MYINST_DIR" install
    if [ $? -ne 0 ] ; then
       g.message -e message="Installation failed, sorry. Please check above error messages."
       cleanup
@@ -329,8 +331,6 @@
    fi
 fi
 
-#TODO: implement the $GIS_FLAG_S flag using sudo.
-
 cleanup
 
 g.message message=""



More information about the grass-commit mailing list