createmodule: Treat variables that end in DIRS, FILES, or PATH as path variables; parse exported functions
This commit is contained in:
parent
65074b215d
commit
8ab02627e6
@ -19,7 +19,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import os,sys
|
import os,sys,re
|
||||||
from subprocess import *
|
from subprocess import *
|
||||||
|
|
||||||
# Handle options
|
# Handle options
|
||||||
@ -48,13 +48,22 @@ def getenv(cmd = ':'):
|
|||||||
print "WARNING: initscript sent the following to stderr:"
|
print "WARNING: initscript sent the following to stderr:"
|
||||||
print stderr
|
print stderr
|
||||||
# Parse the output key=value pairs
|
# Parse the output key=value pairs
|
||||||
|
skip = False
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
|
if skip:
|
||||||
|
if line == '}':
|
||||||
|
skip = False
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
(var,value) = line.split('=',1)
|
(var,value) = line.split('=',1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "ERROR: Could not parse output:"
|
print "ERROR: Could not parse output line:"
|
||||||
print stdout
|
print line
|
||||||
exit(1)
|
exit(1)
|
||||||
|
# Exported functions - not handled
|
||||||
|
if value.find('() {') == 0:
|
||||||
|
skip = True
|
||||||
|
else:
|
||||||
env[var] = value
|
env[var] = value
|
||||||
return env
|
return env
|
||||||
|
|
||||||
@ -116,7 +125,7 @@ for key in env1.keys():
|
|||||||
# We're left with new keys in env2
|
# We're left with new keys in env2
|
||||||
for key in env2.keys():
|
for key in env2.keys():
|
||||||
# Use prepend-path for new paths
|
# 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(':')
|
prependpaths = env2[key].strip(':').split(':')
|
||||||
# MANPATH can have system defaults added it it wasn't previously set
|
# MANPATH can have system defaults added it it wasn't previously set
|
||||||
# LICENSE variables often include paths outside install directory
|
# LICENSE variables often include paths outside install directory
|
||||||
|
@ -150,7 +150,7 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
#Use prepend-path for new paths
|
#Use prepend-path for new paths
|
||||||
if [ "${key/PATH/}" != "$key" ]
|
if [ "${key: -4}" = PATH -o "${key: -4}" = DIRS -o "${key: -4}" = FILES ]
|
||||||
then
|
then
|
||||||
# TODO - Need to handle stripping of default MANPATH
|
# TODO - Need to handle stripping of default MANPATH
|
||||||
echo -e "prepend-path\t${key}\t"$(dedup ${env2[$key]})
|
echo -e "prepend-path\t${key}\t"$(dedup ${env2[$key]})
|
||||||
|
Loading…
Reference in New Issue
Block a user