Skip to content

Commit

Permalink
Added extension to source the .env file after it's rewritten. This
Browse files Browse the repository at this point in the history
will make the environment variables in it available to commands running
after that. It also removes the need to rewrite the `.env` file because
it's now being sourced by the shell and so it can just evaluate
environment variables normally.
  • Loading branch information
Daniel Mikusa committed Dec 8, 2014
1 parent 5230482 commit 4f73f86
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ binaries/trusty/*
!binaries/trusty/index*.json
*.pyc
*.swp
env
/env
4 changes: 0 additions & 4 deletions bin/start
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ if __name__ == '__main__':
home = os.environ['HOME']

# Set the locations of data files
envFile = os.path.join(home, '.env')
procFile = os.path.join(home, '.procs')

# Load the environment and update
os.environ.update(utils.load_env(envFile))

# Load processes and setup the ProcessManager
pm = process.ProcessManager()

Expand Down
2 changes: 1 addition & 1 deletion lib/build_pack_utils/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def process(env):
val = val[0]
elif len(val) > 1:
val = os.pathsep.join(val)
envFile.write("%s=%s\n" % (key, val))
envFile.write("export %s=%s\n" % (key, val))
return self

def process_list(self):
Expand Down
Empty file added lib/env/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions lib/env/extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def preprocess_commands(ctx):
return (('source', '$HOME/.env'),)
11 changes: 5 additions & 6 deletions lib/php/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def configure(ctx):


def preprocess_commands(ctx):
return (('$HOME/.bp/bin/rewrite', '"$HOME/php/etc"'),
('$HOME/.bp/bin/rewrite', '"$HOME/.env"'))
return (('$HOME/.bp/bin/rewrite', '"$HOME/php/etc"'),)


def service_commands(ctx):
Expand All @@ -58,12 +57,12 @@ def service_commands(ctx):

def service_environment(ctx):
env = {
'LD_LIBRARY_PATH': '@LD_LIBRARY_PATH:@HOME/php/lib',
'PATH': '@PATH:@HOME/php/bin:@HOME/php/sbin',
'PHPRC': '@HOME/php/etc'
'LD_LIBRARY_PATH': '$LD_LIBRARY_PATH:$HOME/php/lib',
'PATH': '$PATH:$HOME/php/bin:$HOME/php/sbin',
'PHPRC': '$HOME/php/etc'
}
if 'snmp' in ctx['PHP_EXTENSIONS']:
env['MIBDIRS'] = '@HOME/php/mibs'
env['MIBDIRS'] = '$HOME/php/mibs'
return env


Expand Down
2 changes: 2 additions & 0 deletions scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
.from_build_pack('lib/{WEB_SERVER}')
.extension()
.from_build_pack('lib/{PHP_VM}')
.extension()
.from_build_pack('lib/env')
.extensions()
.from_build_pack('extensions')
.extensions()
Expand Down

0 comments on commit 4f73f86

Please sign in to comment.