[environment-modules] createmodule: Treat variables that end in DIRS, FILES, or PATH as path variables; parse exported fun

Orion Poplawski orion at fedoraproject.org
Wed Sep 4 15:41:56 UTC 2013


commit 8ab02627e6d7b44ea806f74914deb5543d874c1b
Author: Orion Poplawski <orion at nwra.com>
Date:   Thu Aug 29 14:56:14 2013 -0600

    createmodule: Treat variables that end in DIRS, FILES, or PATH as path variables; parse exported functions

 createmodule.py |   19 ++++++++++++++-----
 createmodule.sh |    2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/createmodule.py b/createmodule.py
index 60c6ba7..2588333 100755
--- a/createmodule.py
+++ b/createmodule.py
@@ -19,7 +19,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from optparse import OptionParser
-import os,sys
+import os,sys,re
 from subprocess import *
 
 # Handle options
@@ -48,14 +48,23 @@ def getenv(cmd = ':'):
         print "WARNING: initscript sent the following to stderr:"
         print stderr
     # Parse the output key=value pairs
+    skip = False
     for line in stdout.splitlines():
+        if skip:
+            if line == '}':
+                skip = False
+            continue
         try:
             (var,value) = line.split('=',1)
         except ValueError:
-            print "ERROR: Could not parse output:"
-            print stdout
+            print "ERROR: Could not parse output line:"
+            print line
             exit(1)
-        env[var] = value
+        # Exported functions - not handled
+        if value.find('() {') == 0:
+            skip = True
+        else:
+            env[var] = value
     return env
 
 #Record initial environment
@@ -116,7 +125,7 @@ for key in env1.keys():
 # We're left with new keys in env2
 for key in env2.keys():
     # Use prepend-path for new paths
-    if ('PATH' in key) or (':' in env2[key]):
+    if (re.search('(DIRS|FILES|PATH)$',key)) or (':' in env2[key]):
         prependpaths = env2[key].strip(':').split(':')
         # MANPATH can have system defaults added it it wasn't previously set
         # LICENSE variables often include paths outside install directory
diff --git a/createmodule.sh b/createmodule.sh
index b44cf05..5a37b3e 100755
--- a/createmodule.sh
+++ b/createmodule.sh
@@ -150,7 +150,7 @@ do
     continue
   fi
   #Use prepend-path for new paths
-  if [ "${key/PATH/}" != "$key" ]
+  if [ "${key: -4}" = PATH -o "${key: -4}" = DIRS -o "${key: -4}" = FILES ]
   then
     # TODO - Need to handle stripping of default MANPATH
     echo -e "prepend-path\t${key}\t"$(dedup ${env2[$key]})


More information about the scm-commits mailing list