Updating euca.sh include generation and rc generation to generate better includes for this

This commit is contained in:
Joshua Harlow 2012-03-27 16:49:50 -07:00
parent 59bded15cb
commit 25b484e8b8
3 changed files with 14 additions and 12 deletions

View File

@ -56,6 +56,15 @@ EXP_PAT = re.compile("^\s*export\s+(.*?)=(.*?)$", re.IGNORECASE)
# How we unquote a string (simple edition)
QUOTED_PAT = re.compile(r"^\s*[\"](.*)[\"]\s*$")
# Allow external includes via this template
EXTERN_TPL = """
# Allow local overrides of env variables using {fn}
if [ -f "{fn}" ]; then
source "{fn}"
fi
"""
EXTERN_INCLUDES = ['localrc', 'eucarc']
class RcWriter(object):
def __init__(self, cfg, pw_gen, root_dir):
@ -244,16 +253,10 @@ class RcWriter(object):
def _generate_extern_inc(self):
lines = list()
lines.append('# External includes stuff')
extern_tpl = """
# Allow local overrides of env variables
if [ -f "{localrc_fn}" ]; then
source "{localrc_fn}"
fi
"""
extern_inc = extern_tpl.format(localrc_fn=sh.abspth(settings.LOCALRC_FN))
lines.append(extern_inc.strip())
for inc_fn in EXTERN_INCLUDES:
extern_inc = EXTERN_TPL.format(fn=inc_fn)
lines.append(extern_inc.strip())
lines.append('')
lines.append("")
return lines

View File

@ -44,7 +44,6 @@ COMPONENT_CONFIG_DIR = "config"
# RC files generated / used
RC_FN_TEMPL = "os-%s.rc"
LOCALRC_FN = RC_FN_TEMPL % ('local')
OSRC_FN = RC_FN_TEMPL % ('core')
# Where the configs and templates should be at.

View File

@ -17,7 +17,7 @@ fi
# Find the other rc files
RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
CORE_RC="os-core.rc"
EC2_RC="os-ec2.rc"
EC2_RC="eucarc"
if [ ! -f $RC_DIR/$CORE_RC ];
then