[CalendarServer-changes] [4626] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 21 15:03:46 PDT 2009
Revision: 4626
http://trac.macosforge.org/projects/calendarserver/changeset/4626
Author: glyph at apple.com
Date: 2009-10-21 15:03:45 -0700 (Wed, 21 Oct 2009)
Log Message:
-----------
Update the 'run' and 'test' scripts to modularize handling of dependencies and PYTHONPATH, and make it more consistent.
Modified Paths:
--------------
CalendarServer/trunk/run
CalendarServer/trunk/test
Added Paths:
-----------
CalendarServer/trunk/support/build.sh
CalendarServer/trunk/support/py.sh
Property Changed:
----------------
CalendarServer/trunk/
Property changes on: CalendarServer/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /CalendarServer/branches/more-deferreds:4446,4462
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/config-separation:4379-4443
+ /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/more-deferreds:4446,4462
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run 2009-10-21 15:06:25 UTC (rev 4625)
+++ CalendarServer/trunk/run 2009-10-21 22:03:45 UTC (rev 4626)
@@ -1,4 +1,5 @@
#!/bin/bash
+# -*- sh-basic-offset: 2 -*-
##
# Copyright (c) 2005-2009 Apple Inc. All rights reserved.
@@ -29,43 +30,22 @@
# executable to start the server.
##
-set -e
-set -u
+set -e;
+set -u;
wd="$(cd "$(dirname "$0")" && pwd)";
-##
-# Command line
-##
+. support/build.sh;
- verbose="";
- do_get="true";
- do_setup="true";
- do_run="true";
- force_setup="false";
-disable_setup="false";
- print_path="false";
- install="";
- daemonize="-X";
- kill="false";
- restart="false";
- plugin_name="caldav";
- service_type="Combined";
- read_key="";
- profile="";
- reactor="";
-if [ -z "${CALENDARSERVER_CACHE_DEPS-}" ]; then
- cache_deps="${wd}/.dependencies";
-else
- cache_deps="${CALENDARSERVER_CACHE_DEPS}";
-fi;
-
-usage ()
-{
+# Echo the usage for the main 'run' script, then exit with an error.
+usage () {
program="$(basename "$0")";
- if [ "${1--}" != "-" ]; then echo "$@"; echo; fi;
+ if [ "${1--}" != "-" ]; then
+ echo "$@";
+ echo;
+ fi;
echo "Usage: ${program} [-hvgsfnpdkrR] [-K key] [-iI dst] [-t type] [-S statsdirectory] [-P plugin]";
echo "Options:";
@@ -76,195 +56,57 @@
echo " -f Force setup to run";
echo " -n Do not run setup";
echo " -p Print PYTHONPATH value for server and exit";
- echo " -d Run caldavd as a daemon";
- echo " -k Stop caldavd";
- echo " -r Restart caldavd";
- echo " -K Print value of configuration key and exit";
- echo " -i Perform a system install into dst; implies -s";
- echo " -I Perform a home install into dst; implies -s";
- echo " -t Select the server process type (Master, Slave or Combined) [${service_type}]";
- echo " -S Write a pstats object for each process to the given directory when the server is stopped.";
+ echo " -d Run caldavd as a daemon";
+ echo " -k Stop caldavd";
+ echo " -r Restart caldavd";
+ echo " -K Print value of configuration key and exit";
+ echo " -i Perform a system install into dst; implies -s";
+ echo " -I Perform a home install into dst; implies -s";
+ echo " -t Select the server process type (Master, Slave or Combined) [${service_type}]";
+ echo " -S Write a pstats object for each process to the given directory when the server is stopped.";
echo " -P Select the twistd plugin name [${plugin_name}]";
- echo " -R Twisted Reactor plugin to execute [${reactor}]";
+ echo " -R Twisted Reactor plugin to execute [${reactor}]";
- if [ "${1-}" == "-" ]; then return 0; fi;
+ if [ "${1-}" == "-" ]; then
+ return 0;
+ fi;
exit 64;
}
-while getopts 'hvgsfnpdkrK:i:I:t:S:P:R:' option; do
- case "$option" in
- '?') usage; ;;
- 'h') usage -; exit 0; ;;
- 'v') verbose="-v"; ;;
- 'f') force_setup="true"; ;;
- 'k') kill="true"; ;;
- 'r') restart="true"; ;;
- 'd') daemonize=""; ;;
- 'P') plugin_name="${OPTARG}"; ;;
- 'R') reactor="-R ${OPTARG}"; ;;
- 't') service_type="${OPTARG}"; ;;
- 'K') read_key="${OPTARG}"; ;;
- 'S') profile="--profiler cprofile -p ${OPTARG}"; ;;
- 'g') do_get="true" ; do_setup="false"; do_run="false"; ;;
- 's') do_get="true" ; do_setup="true" ; do_run="false"; ;;
- 'p') do_get="false"; do_setup="false"; do_run="false"; print_path="true"; ;;
- 'i') do_get="true" ; do_setup="true" ; do_run="false"; install="${OPTARG}"; install_flag="--root="; ;;
- 'I') do_get="true" ; do_setup="true" ; do_run="false"; install="${wd}/build/dst"; install_flag="--root="; install_home="${OPTARG}"; ;;
- esac;
-done;
-shift $((${OPTIND} - 1));
-
-if [ $# != 0 ]; then usage "Unrecognized arguments:" "$@"; fi;
-
-##
-# Set up paths
-##
-
-py_version ()
-{
- local python="$1"; shift;
- echo "$("${python}" -c "from distutils.sysconfig import get_python_version; print get_python_version()")";
-}
-
-try_python ()
-{
- local python="$1"; shift;
-
- if [ -z "${python}" ]; then return 1; fi;
-
- if ! type "${python}" > /dev/null 2>&1; then return 1; fi;
- local py_version="$(py_version "${python}")";
- if [ "${py_version/./}" -lt "25" ]; then return 1; fi;
-
- return 0;
-}
-
-for v in "" "2.6" "2.5"; do
- for p in \
- "${PYTHON:=}" \
- "python${v}" \
- "/usr/local/bin/python${v}" \
- "/usr/local/python/bin/python${v}" \
- "/usr/local/python${v}/bin/python${v}" \
- "/opt/bin/python${v}" \
- "/opt/python/bin/python${v}" \
- "/opt/python${v}/bin/python${v}" \
- "/Library/Frameworks/Python.framework/Versions/${v}/bin/python" \
- "/opt/local/bin/python${v}" \
- "/sw/bin/python${v}" \
- ;
- do
- if try_python "${p}"; then python="${p}"; break; fi;
+# Parse command-line options to set up state which controls the behavior of the
+# functions in build.sh.
+parse_options () {
+ while getopts 'hvgsfnpdkrK:i:I:t:S:P:R:' option; do
+ case "$option" in
+ '?') usage; ;;
+ 'h') usage -; exit 0; ;;
+ 'v') verbose="-v"; ;;
+ 'f') force_setup="true"; ;;
+ 'k') kill="true"; ;;
+ 'r') restart="true"; ;;
+ 'd') daemonize=""; ;;
+ 'P') plugin_name="${OPTARG}"; ;;
+ 'R') reactor="-R ${OPTARG}"; ;;
+ 't') service_type="${OPTARG}"; ;;
+ 'K') read_key="${OPTARG}"; ;;
+ 'S') profile="--profiler cprofile -p ${OPTARG}"; ;;
+ 'g') do_get="true" ; do_setup="false"; do_run="false"; ;;
+ 's') do_get="true" ; do_setup="true" ; do_run="false"; ;;
+ 'p') do_get="false"; do_setup="false"; do_run="false"; print_path="true"; ;;
+ 'i') do_get="true" ; do_setup="true" ; do_run="false"; install="${OPTARG}"; install_flag="--root="; ;;
+ 'I') do_get="true" ; do_setup="true" ; do_run="false"; install="${wd}/build/dst"; install_flag="--root="; install_home="${OPTARG}"; ;;
+ esac;
done;
- if [ -n "${python:-}" ]; then break; fi;
-done;
-
-if [ -z "${python:-}" ]; then
- echo "No suitable python found. Python 2.5 is required.";
- exit 1;
-fi;
-
-if [ -z "${caldav:-}" ]; then
- caldav="${wd}";
-fi;
-
-if [ -z "${caldavd_wrapper_command:-}" ]; then
- if [ "$(uname -s)" == "Darwin" ] && [ "$(uname -r | cut -d . -f 1)" -ge 9 ]; then
- caldavd_wrapper_command="launchctl bsexec /";
- else
- caldavd_wrapper_command="";
+ shift $((${OPTIND} - 1));
+ if [ $# != 0 ]; then
+ usage "Unrecognized arguments:" "$@";
fi;
-fi;
-
- top="$(cd "${caldav}/.." && pwd -L)"
-patches="${caldav}/lib-patches";
-twisted="${top}/Twisted";
- dav="${twisted}/twisted/web2/dav"
-
-if [ -z "${config:-}" ]; then
- config="${wd}/conf/caldavd-dev.plist";
-fi;
-
-conf_read_key ()
-{
- local key="$1"; shift;
-
- # FIXME: This only works for simple values (no arrays, dicts)
- tr '\n' ' ' < "${config}" \
- | xpath "/plist/dict/*[preceding-sibling::key[1]='${key}'" 2> /dev/null \
- | sed -n 's|^<[^<][^<]*>\([^<]*\)</[^<][^<]*>.*$|\1|p';
}
-if [ -n "${read_key}" ]; then
- conf_read_key "${read_key}";
- exit $?;
-fi;
-if "${kill}" || "${restart}"; then
- pidfile="$(conf_read_key "PIDFile")";
- if [ ! -r "${pidfile}" ]; then
- echo "Unreadable PID file: ${pidfile}";
- exit 1;
- fi;
- pid="$(cat "${pidfile}" | head -1)";
- if [ -z "${pid}" ]; then
- echo "No PID in PID file: ${pidfile}";
- exit 1;
- fi;
- echo "Killing process ${pid}";
- kill -TERM "${pid}";
- if ! "${restart}"; then
- exit 0;
- fi;
-fi;
-
-if [ -z "${PYTHONPATH:-}" ]; then
- user_python_path="";
-else
- user_python_path=":${PYTHONPATH}";
-fi;
-
- py_platform="$("${python}" -c "from distutils.util import get_platform; print get_platform()")";
- py_version="$(py_version "${python}")";
-py_platform_libdir="lib.${py_platform}-${py_version}";
-
-if [ -n "${install}" ] && ! echo "${install}" | grep '^/' > /dev/null; then
- install="$(pwd)/${install}";
-fi;
-
-svn_uri_base="$(svn info "${caldav}" --xml 2> /dev/null | sed -n 's|^.*<root>\(.*\)</root>.*$|\1|p')";
-
-if [ -z "${svn_uri_base}" ]; then
- svn_uri_base="http://svn.calendarserver.org/repository/calendarserver";
-fi;
-
-export PYTHONPATH="${caldav}";
-
-# Find a command that can hash up a string for us
-if type -t openssl > /dev/null; then
- hash="hash"; hash () { openssl dgst -md5; }
-elif type -t md5 > /dev/null; then
- hash="md5";
-elif type -t md5sum > /dev/null; then
- hash="md5sum";
-elif type -t cksum > /dev/null; then
- hash="hash"; hash () { cksum | cut -f 1 -d " "; }
-elif type -t sum > /dev/null; then
- hash="hash"; hash () { sum | cut -f 1 -d " "; }
-else
- hash="";
-fi;
-
-##
-# Routines
-##
-
+# Actually run the server. (Or, exit, if things aren't sufficiently set up in
+# order to do that.)
run () {
- if "${print_path}"; then
- echo "${PYTHONPATH}";
- exit 0;
- fi;
-
echo "";
echo "Using ${python} as Python";
@@ -298,477 +140,71 @@
fi;
}
-apply_patches () {
- local name="$1"; shift;
- local path="$1"; shift;
- if [ -d "${patches}/${name}" ]; then
- echo "";
- echo "Applying patches to ${name} in ${path}...";
+# The main-point of the 'run' script: parse all options, decide what to do,
+# then do it.
+run_main () {
+ parse_options "$@";
- cd "${path}";
- find "${patches}/${name}" \
- -type f \
- -name '*.patch' \
- -print \
- -exec patch -p0 --forward -i '{}' ';';
- cd /;
-
+ # If we've been asked to read a configuration key, just read it and exit.
+ if [ -n "${read_key}" ]; then
+ conf_read_key "${read_key}";
+ exit $?;
fi;
- echo ""
- echo "Removing build directory ${path}/build..."
- rm -rf "${path}/build";
- echo "Removing pyc files from ${path}..."
- find "${path}" -type f -name '*.pyc' -print0 | xargs -0 rm -f;
-}
-
-www_get () {
- if ! "${do_get}"; then return 0; fi;
-
- local name="$1"; shift;
- local path="$1"; shift;
- local url="$1"; shift;
-
- if "${force_setup}" || [ ! -d "${path}" ]; then
- local ext="$(echo "${url}" | sed 's|^.*\.\([^.]*\)$|\1|')";
-
- case "${ext}" in
- gz|tgz) decompress="gzip -d -c"; ;;
- bz2) decompress="bzip2 -d -c"; ;;
- tar) decompress="cat"; ;;
- *)
- echo "Unknown extension: ${ext}";
- exit 1;
- ;;
- esac;
-
- echo "";
-
- if [ -n "${cache_deps}" ] && [ -n "${hash}" ]; then
- mkdir -p "${cache_deps}";
-
- cache_file="${cache_deps}/${name}-$(echo "${url}" | "${hash}")-$(basename "${url}")";
-
- if [ ! -f "${cache_file}" ]; then
- echo "Downloading ${name}...";
- curl -L "${url}" -o "${cache_file}";
- fi;
-
- echo "Unpacking ${name} from cache...";
- get () { cat "${cache_file}"; }
- else
- echo "Downloading ${name}...";
- get () { curl -L "${url}"; }
+ if "${kill}" || "${restart}"; then
+ pidfile="$(conf_read_key "PIDFile")";
+ if [ ! -r "${pidfile}" ]; then
+ echo "Unreadable PID file: ${pidfile}";
+ exit 1
fi;
-
- rm -rf "${path}";
- cd "$(dirname "${path}")";
- get | ${decompress} | tar -xvf -;
- apply_patches "${name}" "${path}";
- cd /;
- fi;
-}
-
-svn_get () {
- if ! "${do_get}"; then return 0; fi;
-
- local name="$1"; shift;
- local path="$1"; shift;
- local uri="$1"; shift;
- local revision="$1"; shift;
-
- if [ -d "${path}" ]; then
- local wc_uri="$(svn info --xml "${path}" 2> /dev/null | sed -n 's|^.*<url>\(.*\)</url>.*$|\1|p')";
-
- if "${force_setup}"; then
- # Verify that we have a working copy checked out from the correct URI
- if [ "${wc_uri}" != "${uri}" ]; then
- echo "";
- echo "Current working copy (${path}) is from the wrong URI: ${wc_uri} != ${uri}";
- rm -rf "${path}";
- svn_get "${name}" "${path}" "${uri}" "${revision}";
- return $?;
- fi;
-
- echo "";
-
- echo "Reverting ${name}...";
- svn revert -R "${path}";
-
- echo "Updating ${name}...";
- svn update -r "${revision}" "${path}";
-
- apply_patches "${name}" "${path}";
- else
- if ! "${print_path}"; then
- # Verify that we have a working copy checked out from the correct URI
- if [ "${wc_uri}" != "${uri}" ]; then
- echo "";
- echo "Current working copy (${path}) is from the wrong URI: ${wc_uri} != ${uri}";
- echo "Performing repository switch for ${name}...";
- svn switch -r "${revision}" "${uri}" "${path}";
-
- apply_patches "${name}" "${path}";
- else
- local svnversion="$(svnversion "${path}")";
- if [ "${svnversion%%[M:]*}" != "${revision}" ]; then
- echo "";
- echo "Updating ${name}...";
- svn update -r "${revision}" "${path}";
-
- apply_patches "${name}" "${path}";
- fi;
- fi;
- fi;
+ pid="$(cat "${pidfile}" | head -1)";
+ if [ -z "${pid}" ]; then
+ echo "No PID in PID file: ${pidfile}";
+ exit 1;
fi;
- else
- echo "";
-
- checkout () {
- echo "Checking out ${name}...";
- svn checkout -r "${revision}" "${uri}@${revision}" "${path}";
- }
-
- if [ "${revision}" != "HEAD" ] && [ -n "${cache_deps}" ] && [ -n "${hash}" ]; then
- local cache_file="${cache_deps}/${name}-$(echo "${uri}" | "${hash}")@r${revision}.tgz";
-
- mkdir -p "${cache_deps}";
-
- if [ -f "${cache_file}" ]; then
- echo "Unpacking ${name} from cache...";
- mkdir -p "${path}";
- tar -C "${path}" -xvzf "${cache_file}";
- else
- checkout;
- echo "Caching ${name}...";
- tar -C "${path}" -cvzf "${cache_file}" .;
- fi;
- else
- checkout;
+ echo "Killing process ${pid}";
+ kill -TERM "${pid}";
+ if ! "${restart}"; then
+ exit 0;
fi;
-
- apply_patches "${name}" "${path}";
fi;
-}
-py_build () {
- local name="$1"; shift;
- local path="$1"; shift;
- local optional="$1"; shift;
-
- if "${do_setup}"; then
- echo "";
- echo "Building ${name}...";
- cd "${path}";
- if ! "${python}" ./setup.py -q build --build-lib "build/${py_platform_libdir}" "$@"; then
- if "${optional}"; then
- echo "WARNING: ${name} failed to build.";
- echo "WARNING: ${name} is not required to run the server; continuing without it.";
- else
- return $?;
- fi;
- fi;
- cd /;
- fi;
-}
-
-py_install () {
- local name="$1"; shift;
- local path="$1"; shift;
-
- if [ -n "${install}" ]; then
- echo "";
- echo "Installing ${name}...";
- cd "${path}";
- "${python}" ./setup.py install "${install_flag}${install}";
- cd /;
+ # Prepare to set up PYTHONPATH et. al.
+ if [ -z "${PYTHONPATH:-}" ]; then
+ user_python_path="";
+ else
+ user_python_path=":${PYTHONPATH}";
fi;
-}
-py_have_module () {
- local module="$1"; shift;
+ export PYTHONPATH="${caldav}";
- PYTHONPATH="" "${python}" -c "import ${module}" > /dev/null 2>&1;
-}
+ # About to do something for real; let's enumerate (and depending on options,
+ # possibly download and/or install) the dependencies.
+ dependencies;
-##
-# Download and set up dependancies
-##
-
-#
-# Zope Interface
-#
-
-if ! py_have_module zope.interface; then
- zope="${top}/zope.interface-3.3.0";
-
- www_get "Zope Interface" "${zope}" http://www.zope.org/Products/ZopeInterface/3.3.0/zope.interface-3.3.0.tar.gz;
- py_build "Zope Interface" "${zope}" false;
- py_install "Zope Interface" "${zope}";
-
- export PYTHONPATH="${PYTHONPATH}:${zope}/build/${py_platform_libdir}";
-fi;
-
-#
-# PyXML
-#
-
-if ! py_have_module xml.dom.ext; then
- xml="${top}/PyXML-0.8.4";
-
- www_get "PyXML" "${xml}" http://internap.dl.sourceforge.net/sourceforge/pyxml/PyXML-0.8.4.tar.gz;
- py_build "PyXML" "${xml}" false;
- py_install "PyXML" "${xml}";
-
- export PYTHONPATH="${PYTHONPATH}:${xml}/build/${py_platform_libdir}";
-fi;
-
-#
-# PyOpenSSL
-#
-
-if ! py_have_module OpenSSL; then
- ssl="${top}/pyOpenSSL-0.7";
-
- www_get "PyOpenSSL" "${ssl}" http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.7.tar.gz;
- py_build "PyOpenSSL" "${ssl}" false;
- py_install "PyOpenSSL" "${ssl}";
-
- export PYTHONPATH="${PYTHONPATH}:${ssl}/build/${py_platform_libdir}";
-fi;
-
-#
-# PyKerberos
-#
-
-if type krb5-config > /dev/null; then
- if ! py_have_module kerberos; then
- kerberos="${top}/PyKerberos";
-
- svn_get "PyKerberos" "${kerberos}" "${svn_uri_base}/PyKerberos/trunk" 4241;
- py_build "PyKerberos" "${kerberos}" false; # FIXME: make optional
- py_install "PyKerberos" "${kerberos}";
-
- export PYTHONPATH="${PYTHONPATH}:${kerberos}/build/${py_platform_libdir}";
+ # 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}";
+ exit 0;
fi;
-fi;
-#
-# PyOpenDirectory
-#
+ # If we're installing, install the calendar server itself.
+ py_install "Calendar Server" "${caldav}";
-if [ "$(uname -s)" == "Darwin" ]; then
- if ! py_have_module opendirectory; then
- opendirectory="${top}/PyOpenDirectory";
-
- svn_get "PyOpenDirectory" "${opendirectory}" "${svn_uri_base}/PyOpenDirectory/trunk" 4106;
- py_build "PyOpenDirectory" "${opendirectory}" false;
- py_install "PyOpenDirectory" "${opendirectory}";
-
- export PYTHONPATH="${PYTHONPATH}:${opendirectory}/build/${py_platform_libdir}";
+ if [ -n "${install_home:-}" ]; then
+ do_home_install;
fi;
-fi;
-#
-# xattr
-#
+ # Finish setting up PYTHONPATH (put the user's original path at the *end* so
+ # that CalendarServer takes precedence).
-if ! py_have_module xattr; then
- xattr="${top}/xattr";
+ export PYTHONPATH="${PYTHONPATH}${user_python_path}";
- svn_get "xattr" "${xattr}" http://svn.red-bean.com/bob/xattr/releases/xattr-0.5 1013;
- py_build "xattr" "${xattr}" false;
- py_install "xattr" "${xattr}";
+ # Finally, run the server.
+ run;
+}
- export PYTHONPATH="${PYTHONPATH}:${xattr}/build/${py_platform_libdir}";
-fi;
-#
-# select26
-#
-
-if [ "${py_version}" != "${py_version##2.5}" ] && ! py_have_module select26; then
- select26="${top}/select26-0.1a3"
-
- www_get "select26" "${select26}" http://pypi.python.org/packages/source/s/select26/select26-0.1a3.tar.gz;
- py_build "select26" "${select26}" true;
- py_install "select26" "${select26}";
-
- export PYTHONPATH="${PYTHONPATH}:${select26}/build/${py_platform_libdir}";
-fi;
-
-if ! type memcached >& /dev/null; then
- #
- # libevent
- #
- libevent="${top}/libevent-1.4.8-stable"
-
- www_get "libevent" "${libevent}" http://monkey.org/~provos/libevent-1.4.8-stable.tar.gz
-
- if "${do_setup}" && (
- "${force_setup}" || [ ! -d "${libevent}/_root" ]
- ); then
- echo "";
- echo "Building libevent...";
- cd "${libevent}";
- ./configure --prefix="${libevent}/_root";
- make;
- make install;
- fi;
-
- export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:${libevent}/_root/lib";
- export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}:${libevent}/_root/lib";
-
- #
- # memcached
- #
- memcached="${top}/memcached-1.2.6"
-
- www_get "memcached" "${memcached}" http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz;
-
- if "${do_setup}" && (
- "${force_setup}" || [ ! -d "${memcached}/_root" ]
- ); then
- echo "";
- echo "Building memcached...";
- cd "${memcached}";
- ./configure --prefix="${memcached}/_root" \
- --with-libevent="${libevent}/_root" \
- --enable-threads;
- make;
- make install;
- fi;
-
- export PATH="${PATH}:${top}/memcached-1.2.6/_root/bin";
-fi;
-
-#
-# Twisted
-#
-
-case "${USER}" in
- wsanchez)
- proto="svn+ssh";
- ;;
- *)
- proto="svn";
- ;;
-esac;
-svn_uri="${proto}://svn.twistedmatrix.com/svn/Twisted/branches/dav-take-two-3081-4";
-svn_get "Twisted" "${twisted}" "${svn_uri}" 26969;
-
-py_install "Twisted" "${twisted}";
-py_build "Twisted" "${twisted}" false
-
-# Although we built it to generate distribution metadata, let's add the sources
-# to PYTHONPATH instead so that we can edit them easily.
-
-export PYTHONPATH="${PYTHONPATH}:${twisted}";
-
-# twisted.web2 doesn't get installed by default
-if [ -n "${install}" ]; then
- echo "";
- echo "Installing Twisted.web2...";
- cd "${twisted}";
- "${python}" ./twisted/web2/topfiles/setup.py install "${install_flag}${install}";
- cd /;
-fi;
-
-#
-# dateutil
-#
-
-if ! py_have_module dateutil; then
- dateutil="${top}/python-dateutil-1.4.1";
-
- www_get "dateutil" "${dateutil}" http://www.labix.org/download/python-dateutil/python-dateutil-1.4.1.tar.gz;
- py_install "dateutil" "${dateutil}";
-
- export PYTHONPATH="${PYTHONPATH}:${dateutil}";
-fi;
-
-#
-# vobject
-#
-
-vobject="${top}/vobject";
-
-case "${USER}" in
- cyrusdaboo)
- base="svn+ssh://cdaboo@svn.osafoundation.org/svn";
- ;;
- *)
- base="http://svn.osafoundation.org";
- ;;
-esac;
-svn_uri="${base}/vobject/trunk";
-svn_get "vObject" "${vobject}" "${svn_uri}" 212;
-
-py_install "vObject" "${vobject}";
-
-export PYTHONPATH="${PYTHONPATH}:${vobject}";
-
-#
-# PyDirector
-#
-
-if ! py_have_module pydirector; then
- pydirector="${top}/pydirector-1.0.0";
- www_get "PyDirector" "${pydirector}" http://internap.dl.sourceforge.net/sourceforge/pythondirector/pydirector-1.0.0.tar.gz;
- py_build "PyDirector" "${pydirector}" false;
- py_install "PyDirector" "${pydirector}";
-
- export PYTHONPATH="${PYTHONPATH}:${pydirector}/build/${py_platform_libdir}";
-fi;
-
-#
-# CalDAVTester
-#
-
-caldavtester="${top}/CalDAVTester";
-
-svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 4517;
-
-#
-# PyFlakes
-#
-
-pyflakes="${top}/Pyflakes";
-
-svn_get "Pyflakes" "${pyflakes}" http://divmod.org/svn/Divmod/trunk/Pyflakes 17198;
-
-#
-# Calendar Server
-#
-
-py_install "Calendar Server" "${caldav}";
-
-##
-# Do home install
-# This is a hack, but it's needed because installing with --home doesn't work for python-dateutil.
-##
-
-if [ -n "${install_home:-}" ]; then
- py_prefix="$("${python}" -c "import sys; print sys.prefix;")";
- py_libdir="$("${python}" -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1);")";
-
- install -d "${install_home}";
- install -d "${install_home}/bin";
- install -d "${install_home}/conf";
- install -d "${install_home}/lib/python";
-
- rsync -av "${install}${py_prefix}/bin/" "${install_home}/bin/";
- rsync -av "${install}${py_libdir}/" "${install_home}/lib/python/";
- rsync -av "${install}${py_prefix}/caldavd/" "${install_home}/caldavd/";
-
- rm -rf "${install}";
-fi;
-
-##
-# Run the server
-##
-
-export PYTHONPATH="${PYTHONPATH}${user_python_path}";
-
-run;
+run_main "$@";
Copied: CalendarServer/trunk/support/build.sh (from rev 4625, CalendarServer/branches/egg-info-351/support/build.sh)
===================================================================
--- CalendarServer/trunk/support/build.sh (rev 0)
+++ CalendarServer/trunk/support/build.sh 2009-10-21 22:03:45 UTC (rev 4626)
@@ -0,0 +1,506 @@
+#! /bin/bash
+# -*- sh-basic-offset: 2 -*-
+
+##
+# Copyright (c) 2005-2009 Apple Inc. All rights reserved.
+#
+# Licensed 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.
+##
+
+. support/py.sh;
+
+# 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 () {
+ local var="$1"; shift;
+ local default="$1"; shift;
+ if [ -z "$(eval echo "\${${var}:-}")" ]; then
+ eval "${var}=\${default:-}";
+ fi;
+}
+
+# Read a configuration key from the configuration plist file and print it to
+# stdout.
+conf_read_key ()
+{
+ local key="$1"; shift;
+
+ # FIXME: This only works for simple values (no arrays, dicts)
+ tr '\n' ' ' < "${config}" \
+ | xpath "/plist/dict/*[preceding-sibling::key[1]='${key}'" 2> /dev/null \
+ | sed -n 's|^<[^<][^<]*>\([^<]*\)</[^<][^<]*>.*$|\1|p';
+}
+
+# Initialize all the global state required to use this library.
+init_build () {
+
+ verbose="";
+ do_get="true";
+ do_setup="true";
+ do_run="true";
+ force_setup="false";
+ disable_setup="false";
+ print_path="false";
+ install="";
+ daemonize="-X";
+ 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.
+ conditional_set wd "$(pwd)";
+ conditional_set config "${wd}/conf/caldavd-dev.plist";
+ conditional_set caldav "${wd}";
+
+ if [ -z "${CALENDARSERVER_CACHE_DEPS-}" ]; then
+ cache_deps="${wd}/.dependencies";
+ else
+ cache_deps="${CALENDARSERVER_CACHE_DEPS}";
+ fi;
+
+ if [ -z "${caldavd_wrapper_command:-}" ]; then
+ if [ "$(uname -s)" == "Darwin" ] && [ "$(uname -r | cut -d . -f 1)" -ge 9 ]; then
+ caldavd_wrapper_command="launchctl bsexec /";
+ else
+ caldavd_wrapper_command="";
+ fi;
+ fi;
+
+ top="$(cd "${caldav}/.." && pwd -L)";
+ patches="${caldav}/lib-patches";
+ twisted="${top}/Twisted";
+ dav="${twisted}/twisted/web2/dav";
+
+ # Find a command that can hash up a string for us
+ if type -t openssl > /dev/null; then
+ hash="hash";
+ hash () { openssl dgst -md5; }
+ elif type -t md5 > /dev/null; then
+ hash="md5";
+ elif type -t md5sum > /dev/null; then
+ hash="md5sum";
+ elif type -t cksum > /dev/null; then
+ hash="hash";
+ hash () { cksum | cut -f 1 -d " "; }
+ elif type -t sum > /dev/null; then
+ hash="hash";
+ hash () { sum | cut -f 1 -d " "; }
+ else
+ hash="";
+ fi;
+
+ if [ -n "${install}" ] && ! echo "${install}" | grep '^/' > /dev/null; then
+ install="$(pwd)/${install}";
+ fi;
+
+ svn_uri_base="$(svn info "${caldav}" --xml 2> /dev/null | sed -n 's|^.*<root>\(.*\)</root>.*$|\1|p')";
+
+ conditional_set svn_uri_base "http://svn.calendarserver.org/repository/calendarserver";
+}
+
+
+# This is a hack, but it's needed because installing with --home doesn't work
+# for python-dateutil.
+do_home_install () {
+ install -d "${install_home}";
+ install -d "${install_home}/bin";
+ install -d "${install_home}/conf";
+ install -d "${install_home}/lib/python";
+
+ rsync -av "${install}${py_prefix}/bin/" "${install_home}/bin/";
+ rsync -av "${install}${py_libdir}/" "${install_home}/lib/python/";
+ rsync -av "${install}${py_prefix}/caldavd/" "${install_home}/caldavd/";
+
+ rm -rf "${install}";
+}
+
+
+# Apply patches from lib-patches to the given dependency codebase.
+apply_patches () {
+ local name="$1"; shift;
+ local path="$1"; shift;
+
+ if [ -d "${patches}/${name}" ]; then
+ echo "";
+ echo "Applying patches to ${name} in ${path}...";
+
+ cd "${path}";
+ find "${patches}/${name}" \
+ -type f \
+ -name '*.patch' \
+ -print \
+ -exec patch -p0 --forward -i '{}' ';';
+ cd /;
+
+ fi;
+
+ echo "";
+ echo "Removing build directory ${path}/build...";
+ rm -rf "${path}/build";
+ echo "Removing pyc files from ${path}...";
+ find "${path}" -type f -name '*.pyc' -print0 | xargs -0 rm -f;
+}
+
+
+# If do_get is turned on, get an archive file containing a dependency via HTTP.
+www_get () {
+ if ! "${do_get}"; then return 0; fi;
+
+ local name="$1"; shift;
+ local path="$1"; shift;
+ local url="$1"; shift;
+
+ if "${force_setup}" || [ ! -d "${path}" ]; then
+ local ext="$(echo "${url}" | sed 's|^.*\.\([^.]*\)$|\1|')";
+
+ case "${ext}" in
+ gz|tgz) decompress="gzip -d -c"; ;;
+ bz2) decompress="bzip2 -d -c"; ;;
+ tar) decompress="cat"; ;;
+ *)
+ echo "Unknown extension: ${ext}";
+ exit 1;
+ ;;
+ esac;
+
+ echo "";
+
+ if [ -n "${cache_deps}" ] && [ -n "${hash}" ]; then
+ mkdir -p "${cache_deps}";
+
+ cache_file="${cache_deps}/${name}-$(echo "${url}" | "${hash}")-$(basename "${url}")";
+
+ if [ ! -f "${cache_file}" ]; then
+ echo "Downloading ${name}...";
+ curl -L "${url}" -o "${cache_file}";
+ fi;
+
+ echo "Unpacking ${name} from cache...";
+ get () { cat "${cache_file}"; }
+ else
+ echo "Downloading ${name}...";
+ get () { curl -L "${url}"; }
+ fi;
+
+ rm -rf "${path}";
+ cd "$(dirname "${path}")";
+ get | ${decompress} | tar -xvf -;
+ apply_patches "${name}" "${path}";
+ cd /;
+ fi;
+}
+
+
+# If do_get is turned on, check a name out from SVN.
+svn_get () {
+ if ! "${do_get}"; then
+ return 0;
+ fi;
+
+ local name="$1"; shift;
+ local path="$1"; shift;
+ local uri="$1"; shift;
+ local revision="$1"; shift;
+
+ if [ -d "${path}" ]; then
+ local wc_uri="$(svn info --xml "${path}" 2> /dev/null | sed -n 's|^.*<url>\(.*\)</url>.*$|\1|p')";
+
+ if "${force_setup}"; then
+ # Verify that we have a working copy checked out from the correct URI
+ if [ "${wc_uri}" != "${uri}" ]; then
+ echo "";
+ echo "Current working copy (${path}) is from the wrong URI: ${wc_uri} != ${uri}";
+ rm -rf "${path}";
+ svn_get "${name}" "${path}" "${uri}" "${revision}";
+ return $?;
+ fi;
+
+ echo "";
+
+ echo "Reverting ${name}...";
+ svn revert -R "${path}";
+
+ echo "Updating ${name}...";
+ svn update -r "${revision}" "${path}";
+
+ apply_patches "${name}" "${path}";
+ else
+ if ! "${print_path}"; then
+ # Verify that we have a working copy checked out from the correct URI
+ if [ "${wc_uri}" != "${uri}" ]; then
+ echo "";
+ echo "Current working copy (${path}) is from the wrong URI: ${wc_uri} != ${uri}";
+ echo "Performing repository switch for ${name}...";
+ svn switch -r "${revision}" "${uri}" "${path}";
+
+ apply_patches "${name}" "${path}";
+ else
+ local svnversion="$(svnversion "${path}")";
+ if [ "${svnversion%%[M:]*}" != "${revision}" ]; then
+ echo "";
+ echo "Updating ${name}...";
+ svn update -r "${revision}" "${path}";
+
+ apply_patches "${name}" "${path}";
+ fi;
+ fi;
+ fi;
+ fi;
+ else
+ echo "";
+
+ checkout () {
+ echo "Checking out ${name}...";
+ svn checkout -r "${revision}" "${uri}@${revision}" "${path}";
+ }
+
+ if [ "${revision}" != "HEAD" ] && [ -n "${cache_deps}" ] && [ -n "${hash}" ]; then
+ local cache_file="${cache_deps}/${name}-$(echo "${uri}" | "${hash}")@r${revision}.tgz";
+
+ mkdir -p "${cache_deps}";
+
+ if [ -f "${cache_file}" ]; then
+ echo "Unpacking ${name} from cache...";
+ mkdir -p "${path}";
+ tar -C "${path}" -xvzf "${cache_file}";
+ else
+ checkout;
+ echo "Caching ${name}...";
+ tar -C "${path}" -cvzf "${cache_file}" .;
+ fi;
+ else
+ checkout;
+ fi;
+
+ apply_patches "${name}" "${path}";
+ fi;
+}
+
+
+# (optionally) Invoke 'python setup.py build' on the given python project.
+py_build () {
+ local name="$1"; shift;
+ local path="$1"; shift;
+ local optional="$1"; shift;
+
+ if "${do_setup}"; then
+ echo "";
+ echo "Building ${name}...";
+ cd "${path}";
+ if ! "${python}" ./setup.py -q build --build-lib "build/${py_platform_libdir}" "$@"; then
+ if "${optional}"; then
+ echo "WARNING: ${name} failed to build.";
+ echo "WARNING: ${name} is not required to run the server; continuing without it.";
+ else
+ return $?;
+ fi;
+ fi;
+ cd /;
+ fi;
+}
+
+# If in install mode, install the given package from the given path.
+# (Otherwise do nothing.)
+py_install () {
+ local name="$1"; shift;
+ local path="$1"; shift;
+
+ if [ -n "${install}" ]; then
+ echo "";
+ echo "Installing ${name}...";
+ cd "${path}";
+ "${python}" ./setup.py install "${install_flag}${install}";
+ cd /;
+ fi;
+}
+
+
+# Declare a dependency on a Python project.
+py_dependency () {
+
+ # args
+ local name="$1"; shift; # the name of the package (for display)
+ local module="$1"; shift; # the name of the python module.
+ local distribution="$1"; shift; # the name of the directory to put the distribution into.
+ local get_type="$1"; shift; # what protocol should be used?
+ local get_uri="$1"; shift; # what URL should be fetched?
+ local optional="$1"; shift; # is this dependency optional?
+ local override_system="$1"; shift; # do I need to get this dependency even if
+ # the system already has it?
+ local inplace="$1"; shift; # do development in-place; don't run setup.py to
+ # build, and instead add the source directory
+ # directly to sys.path. twisted and vobject are
+ # developed often enough that this is convenient.
+ local skip_egg="$1"; shift; # skip even the 'egg_info' step, because nothing
+ # needs to be built.
+ local revision="$1"; shift; # what revision to check out (for SVN dependencies)
+ # end args
+ local srcdir="${top}/${distribution}"
+
+ if "${override_system}" || ! py_have_module "${module}"; then
+ "${get_type}_get" "${name}" "${srcdir}" "${get_uri}" "${revision}"
+ if "${inplace}"; then
+ if "${do_setup}" && "${override_system}" && ! "${skip_egg}"; then
+ echo;
+ echo "Building ${name}... [overrides system, building egg-info metadata only]";
+ cd "${srcdir}";
+ "${python}" ./setup.py -q egg_info 2>&1 | grep -v 'Unrecognized .svn/entries';
+ cd /;
+ fi;
+ else
+ py_build "${name}" "${srcdir}" "${optional}";
+ fi;
+ py_install "${name}" "${srcdir}";
+ fi;
+
+ if "$inplace"; then
+ local add_path="${srcdir}";
+ else
+ local add_path="${srcdir}/build/${py_platform_libdir}";
+ fi;
+ export PYTHONPATH="${PYTHONPATH}:${add_path}";
+}
+
+
+# Declare a dependency on a C project built with autotools.
+c_dependency () {
+ local name="$1"; shift;
+ local path="$1"; shift;
+ local uri="$1"; shift;
+
+ # Extra arguments are processed below, as arguments to './configure'.
+
+ srcdir="${top}/${path}";
+
+ www_get "${name}" "${srcdir}" "${uri}";
+
+ if "${do_setup}" && (
+ "${force_setup}" || [ ! -d "${srcdir}/_root" ]); then
+ echo "";
+ echo "Building ${name}...";
+ cd "${srcdir}";
+ ./configure --prefix="${srcdir}/_root" "$@";
+ make;
+ make install;
+ fi;
+
+ export PATH="${PATH}:${srcdir}/_root/bin";
+ export C_INCLUDE_PATH="${C_INCLUDE_PATH:-}:${srcdir}/_root/include";
+ export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:${srcdir}/_root/lib";
+ export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:-}:${srcdir}/_root/lib";
+}
+
+
+# Enumerate all the dependencies with c_dependency and py_dependency; depending
+# on options parsed by ../run:parse_options and on-disk state, this may do as
+# little as update the PATH, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH and PYTHONPATH,
+# or, it may do as much as download and install all dependencies.
+dependencies () {
+
+ if ! type memcached >& /dev/null; then
+ # Dependencies compiled from C source code
+ local le="libevent-1.4.8-stable";
+ c_dependency "libevent" "${le}" \
+ "http://monkey.org/~provos/libevent-1.4.8-stable.tar.gz";
+ c_dependency "memcached" "memcached-1.2.6" \
+ "http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz" \
+ --enable-threads --with-libevent="${top}/${le}/_root";
+ fi;
+
+ # Python dependencies
+ py_dependency "Zope Interface" "zope.interface" "zope.interface-3.3.0" \
+ "www" "http://www.zope.org/Products/ZopeInterface/3.3.0/zope.interface-3.3.0.tar.gz" \
+ false false false false 0;
+ py_dependency "PyXML" "xml.dom.ext" "PyXML-0.8.4" \
+ "www" "http://internap.dl.sourceforge.net/sourceforge/pyxml/PyXML-0.8.4.tar.gz" \
+ false false false false 0;
+ py_dependency "PyOpenSSL" "OpenSSL" "pyOpenSSL-0.7" \
+ "www" "http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.7.tar.gz" \
+ false false false false 0;
+ if type krb5-config > /dev/null; then
+ py_dependency "PyKerberos" "kerberos" "PyKerberos" \
+ "svn" "${svn_uri_base}/PyKerberos/trunk" \
+ false false false false 4241;
+ fi;
+ if [ "$(uname -s)" == "Darwin" ]; then
+ py_dependency "PyOpenDirectory" "opendirectory" "PyOpenDirectory" \
+ "svn" "${svn_uri_base}/PyOpenDirectory/trunk" \
+ false false false false 4106;
+ fi;
+ py_dependency "xattr" "xattr" "xattr" \
+ "svn" "http://svn.red-bean.com/bob/xattr/releases/xattr-0.5" \
+ false false false false 1013;
+ if [ "${py_version}" != "${py_version##2.5}" ] && ! py_have_module select26; then
+ py_dependency "select26" "select26" "select26" \
+ "www" "http://pypi.python.org/packages/source/s/select26/select26-0.1a3.tar.gz" \
+ true false false false 0;
+ fi;
+
+ case "${USER}" in
+ wsanchez)
+ proto="svn+ssh";
+ ;;
+ *)
+ proto="svn";
+ ;;
+ esac;
+
+ py_dependency "Twisted" "twisted" "Twisted" \
+ "svn" "${proto}://svn.twistedmatrix.com/svn/Twisted/branches/dav-take-two-3081-4" \
+ false true true false 26969;
+
+ # twisted.web2 doesn't get installed by default, so in the install phase
+ # let's make sure it does.
+ if [ -n "${install}" ]; then
+ echo "";
+ echo "Installing Twisted.web2...";
+ cd "${twisted}";
+ "${python}" ./twisted/web2/topfiles/setup.py install "${install_flag}${install}";
+ cd /;
+ fi;
+
+ py_dependency "dateutil" "dateutil" "python-dateutil-1.4.1" \
+ "www" "http://www.labix.org/download/python-dateutil/python-dateutil-1.4.1.tar.gz" \
+ false false false false 0;
+
+ case "${USER}" in
+ cyrusdaboo)
+ base="svn+ssh://cdaboo@svn.osafoundation.org/svn";
+ ;;
+ *)
+ base="http://svn.osafoundation.org";
+ ;;
+ esac;
+
+ # XXX actually vObject should be imported in-place.
+ py_dependency "vObject" "vobject" "vobject" \
+ "svn" "${base}/vobject/trunk" \
+ false true true true 212;
+
+ py_dependency "PyDirector" "pydirector" "pydirector-1.0.0" \
+ "www" http://internap.dl.sourceforge.net/sourceforge/pythondirector/pydirector-1.0.0.tar.gz \
+ false false false false 0;
+
+ # Tool dependencies. The code itself doesn't depend on these, but you probably want them.
+ svn_get "CalDAVTester" "${top}/CalDAVTester" "${svn_uri_base}/CalDAVTester/trunk" 4517;
+ svn_get "Pyflakes" "${top}/Pyflakes" http://divmod.org/svn/Divmod/trunk/Pyflakes 17198;
+}
+
+
+# Actually do the initialization, once all functions are defined.
+init_build;
Copied: CalendarServer/trunk/support/py.sh (from rev 4625, CalendarServer/branches/egg-info-351/support/py.sh)
===================================================================
--- CalendarServer/trunk/support/py.sh (rev 0)
+++ CalendarServer/trunk/support/py.sh 2009-10-21 22:03:45 UTC (rev 4626)
@@ -0,0 +1,101 @@
+#! /bin/bash
+# -*- sh-basic-offset: 2 -*-
+
+##
+# Copyright (c) 2005-2009 Apple Inc. All rights reserved.
+#
+# Licensed 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.
+##
+
+# Echo the major.minor version of the given Python interpreter.
+
+py_version () {
+ local python="$1"; shift;
+ echo "$("${python}" -c "from distutils.sysconfig import get_python_version; print get_python_version()")";
+}
+
+# Test if a particular python interpreter is available, given the full path to
+# that interpreter.
+
+try_python () {
+ local python="$1"; shift;
+
+ if [ -z "${python}" ]; then
+ return 1;
+ fi
+ if ! type "${python}" > /dev/null 2>&1; then
+ return 1;
+ fi
+
+ local py_version="$(py_version "${python}")";
+ if [ "${py_version/./}" -lt "25" ]; then
+ return 1;
+ fi
+ return 0;
+}
+
+
+# Detect which version of Python to use, then print out which one was detected.
+
+detect_python_version () {
+ for v in "" "2.6" "2.5"
+ do
+ for p in \
+ "${PYTHON:=}" \
+ "python${v}" \
+ "/usr/local/bin/python${v}" \
+ "/usr/local/python/bin/python${v}" \
+ "/usr/local/python${v}/bin/python${v}" \
+ "/opt/bin/python${v}" \
+ "/opt/python/bin/python${v}" \
+ "/opt/python${v}/bin/python${v}" \
+ "/Library/Frameworks/Python.framework/Versions/${v}/bin/python" \
+ "/opt/local/bin/python${v}" \
+ "/sw/bin/python${v}" \
+ ;
+ do
+ if try_python "${p}"; then
+ echo "${p}";
+ return 0;
+ fi
+ done
+ done
+ return 1;
+}
+
+# Detect if the given Python module is installed in the system Python configuration.
+py_have_module () {
+ local module="$1"; shift;
+
+ PYTHONPATH="" "${python}" -c "import ${module}" > /dev/null 2>&1;
+}
+
+# Detect which python to use, and store it in the 'python' variable, as well as
+# setting up variables related to version and build configuration.
+
+init_py () {
+ python="$(detect_python_version)";
+
+ if [ -z "${python:-}" ]; then
+ echo "No suitable python found. Python 2.5 is required.";
+ exit 1;
+ fi
+
+ py_platform="$("${python}" -c "from distutils.util import get_platform; print get_platform()")";
+ py_version="$(py_version "${python}")";
+ py_platform_libdir="lib.${py_platform}-${py_version}";
+ py_prefix="$("${python}" -c "import sys; print sys.prefix;")";
+ py_libdir="$("${python}" -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1);")";
+}
+
+init_py;
Modified: CalendarServer/trunk/test
===================================================================
--- CalendarServer/trunk/test 2009-10-21 15:06:25 UTC (rev 4625)
+++ CalendarServer/trunk/test 2009-10-21 22:03:45 UTC (rev 4626)
@@ -16,60 +16,18 @@
# limitations under the License.
##
-set -e
-set -u
+set -e;
+set -u;
- random="--random=$(date "+%s")";
- no_colour="";
-until_fail="";
- coverage="";
+wd="$(cd "$(dirname "$0")" && pwd -L)";
-py_version ()
-{
- local python="$1"; shift
- echo "$("${python}" -c "from distutils.sysconfig import get_python_version; print get_python_version()")";
-}
+. support/py.sh;
-try_python ()
-{
- local python="$1"; shift
+random="--random=$(date "+%s")";
+no_colour="";
+until_fail="";
+coverage="";
- if [ -z "${python}" ]; then return 1; fi;
-
- if ! type "${python}" > /dev/null 2>&1; then return 1; fi;
- local py_version="$(py_version "${python}")";
- if [ "${py_version/./}" -lt "24" ]; then return 1; fi;
-
- return 0;
-}
-
-for v in "" "2.6" "2.5"; do
- for p in \
- "${PYTHON:=}" \
- "python${v}" \
- "/usr/local/bin/python${v}" \
- "/usr/local/python/bin/python${v}" \
- "/usr/local/python${v}/bin/python${v}" \
- "/opt/bin/python${v}" \
- "/opt/python/bin/python${v}" \
- "/opt/python${v}/bin/python${v}" \
- "/Library/Frameworks/Python.framework/Versions/${v}/bin/python" \
- "/opt/local/bin/python${v}" \
- "/sw/bin/python${v}" \
- ;
- do
- if try_python "${p}"; then python="${p}"; break; fi;
- done;
- if [ -n "${python:-}" ]; then break; fi;
-done;
-
-if [ -z "${python:-}" ]; then
- echo "No suitable python found.";
- exit 1;
-else
- echo "Using ${python} as Python";
-fi;
-
usage ()
{
program="$(basename "$0")";
@@ -102,7 +60,6 @@
done;
shift $((${OPTIND} - 1));
- wd="$(cd "$(dirname "$0")" && pwd -L)";
twisted="$(cd "${wd}/.." && pwd -L)/Twisted";
export PYTHONPATH="$("${wd}/run" -p)";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091021/9f1f4b60/attachment-0001.html>
More information about the calendarserver-changes
mailing list