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

This commit is contained in:
Orion Poplawski 2013-08-29 14:56:14 -06:00
parent 65074b215d
commit 8ab02627e6
2 changed files with 15 additions and 6 deletions

View File

@ -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

View File

@ -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]})