[CalendarServer-changes] [9372] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 18 17:23:14 PDT 2012
Revision: 9372
http://trac.macosforge.org/projects/calendarserver/changeset/9372
Author: glyph at apple.com
Date: 2012-06-18 17:23:13 -0700 (Mon, 18 Jun 2012)
Log Message:
-----------
Update the development checkout script preamble so that all necessary
environment variables are propagated. Especially, `$PATH`, which needs to be
set properly for anything that wants a data store to run out of the box.
So, you can now type, e.g.::
$ ./bin/calendarserver_shell
at your prompt, and it will work even if no server is running and you have
sourced no shell configuration. (However, you will still need a config file, so
you probably want to `./run` at least once.)
Modified Paths:
--------------
CalendarServer/trunk/bin/_calendarserver_preamble.py
CalendarServer/trunk/run
CalendarServer/trunk/support/build.sh
Property Changed:
----------------
CalendarServer/trunk/
Modified: CalendarServer/trunk/bin/_calendarserver_preamble.py
===================================================================
--- CalendarServer/trunk/bin/_calendarserver_preamble.py 2012-06-18 18:24:20 UTC (rev 9371)
+++ CalendarServer/trunk/bin/_calendarserver_preamble.py 2012-06-19 00:23:13 UTC (rev 9372)
@@ -22,6 +22,8 @@
"""
import sys
+import os
+
from os.path import dirname, abspath, join, split, exists
from subprocess import Popen, PIPE
@@ -39,11 +41,16 @@
# attempt to run the run script.
return
- child = Popen((run, "-p"), stdout=PIPE)
- path, stderr = child.communicate()
+ child = Popen((run, "-e"), stdout=PIPE)
+ stdout, stderr = child.communicate()
+ stdout = stdout.rstrip("\n")
- path = path.rstrip("\n")
+ evars = dict(line.split("=", 1) for line in stdout.split("\n"))
+ os.environ.update(evars)
+ # PYTHONPATH needs special treatment, because Python has already processed
+ # its environment variables by now.
+ path = evars['PYTHONPATH']
if child.wait() == 0:
sys.path[0:0] = path.split(":")
Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run 2012-06-18 18:24:20 UTC (rev 9371)
+++ CalendarServer/trunk/run 2012-06-19 00:23:13 UTC (rev 9372)
@@ -53,6 +53,7 @@
echo " -f Force setup to run";
echo " -n Do not run setup";
echo " -p Print PYTHONPATH value for server and exit";
+ echo " -e Print =-separated environment variables required to run and exit";
echo " -d Run caldavd as a daemon";
echo " -k Stop caldavd";
echo " -r Restart caldavd";
@@ -75,7 +76,7 @@
# functions in build.sh.
parse_options () {
OPTIND=1;
- while getopts "ahvgsfnpdkrK:i:I:b:t:S:P:R:" option; do
+ while getopts "ahvgsfnpedkrK:i:I:b:t:S:P:R:" option; do
case "${option}" in
'?') usage; ;;
'h') usage -; exit 0; ;;
@@ -94,6 +95,10 @@
'p')
do_get="false"; do_setup="false"; do_run="false"; print_path="true";
;;
+ 'e')
+ do_get="false"; do_setup="false"; do_run="false"; print_path="true";
+ print_environment="true";
+ ;;
'i')
do_get="true";
do_setup="true";
@@ -131,7 +136,6 @@
# Actually run the server. (Or, exit, if things aren't sufficiently set up in
# order to do that.)
run () {
- echo "";
echo "Using ${python} as Python";
if "${do_run}"; then
@@ -223,7 +227,11 @@
# Now that all the dependencies are set up, let's see if we're just being
# asked to print the path.
if "${print_path}"; then
- echo "${PYTHONPATH}";
+ if "${print_environment}"; then
+ env;
+ else
+ echo "${PYTHONPATH}";
+ fi;
exit 0;
fi;
Modified: CalendarServer/trunk/support/build.sh
===================================================================
--- CalendarServer/trunk/support/build.sh 2012-06-18 18:24:20 UTC (rev 9371)
+++ CalendarServer/trunk/support/build.sh 2012-06-19 00:23:13 UTC (rev 9372)
@@ -18,6 +18,18 @@
. "${wd}/support/py.sh";
+echo_header () {
+ if ! "${print_path}"; then
+ echo "$@";
+ echo "";
+ fi;
+}
+
+using_system () {
+ local name="$1"; shift;
+ echo_header "Using system version of ${name}.";
+}
+
# Provide a default value: if the variable named by the first argument is
# empty, set it to the default in the second argument.
conditional_set () {
@@ -36,23 +48,24 @@
# Initialize all the global state required to use this library.
init_build () {
- verbose="";
- do_get="true";
- do_setup="true";
- do_run="true";
- do_bundle="false";
- force_setup="false";
- disable_setup="false";
- print_path="false";
- install="";
- daemonize="-X -L";
- kill="false";
- restart="false";
- plugin_name="caldav";
- service_type="Combined";
- read_key="";
- profile="";
- reactor="";
+ verbose="";
+ do_get="true";
+ do_setup="true";
+ do_run="true";
+ do_bundle="false";
+ force_setup="false";
+ disable_setup="false";
+ print_path="false";
+ print_environment="false";
+ install="";
+ daemonize="-X -L";
+ kill="false";
+ restart="false";
+ plugin_name="caldav";
+ service_type="Combined";
+ read_key="";
+ profile="";
+ reactor="";
# These variables are defaults for things which might be configured by
# environment; only set them if they're un-set.
@@ -375,7 +388,7 @@
local optional="$1"; shift;
if "${do_setup}"; then
- echo "Building ${name}...";
+ echo_header "Building ${name}...";
cd "${path}";
if ! "${python}" ./setup.py -q build \
--build-lib "build/${py_platform_libdir}" "$@"; then
@@ -459,16 +472,13 @@
local srcdir="${top}/${distribution}"
- if ! "${print_path}"; then
- echo "";
- fi;
if "${override}" || ! py_have_module ${version} "${module}"; then
"${get_type}_get" ${f_hash} "${name}" "${srcdir}" "${get_uri}" "${revision}"
if [ -n "${inplace}" ]; then
if "${do_setup}" && "${override}" && ! "${skip_egg}"; then
echo;
if py_have_module setuptools; then
- echo "Building ${name}... [overrides system, building egg-info only]";
+ echo_header "Building ${name}... [overrides system, building egg-info only]";
cd "${srcdir}";
"${python}" ./setup.py -q egg_info 2>&1 | (
grep -i -v 'Unrecognized .svn/entries' || true);
@@ -496,9 +506,7 @@
export PATH="${add_path}:${PATH}";
fi;
else
- if ! "${print_path}"; then
- echo "Using system version of ${name}.";
- fi;
+ using_system "${name}";
fi;
}
@@ -621,8 +629,7 @@
fi;
if type -P memcached > /dev/null; then
- echo "Using system memcached.";
- echo "";
+ using_system "memcached";
else
local le="libevent-2.0.17-stable";
local mc="memcached-1.4.13";
@@ -635,8 +642,7 @@
fi;
if type -P postgres > /dev/null; then
- echo "Using system Postgres.";
- echo "";
+ using_system "Postgres";
else
local pgv="9.1.2";
local pg="postgresql-${pgv}";
@@ -655,8 +661,7 @@
fi;
if find_header ldap.h; then
- echo "Using system OpenLDAP.";
- echo "";
+ using_system "OpenLDAP";
else
c_dependency -m "ec63f9c2add59f323a0459128846905b" \
"OpenLDAP" "openldap-2.4.25" \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120618/e4f6d9d5/attachment.html>
More information about the calendarserver-changes
mailing list