<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12988] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12988">12988</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-03-21 12:51:51 -0700 (Fri, 21 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>obsolete</pre>
<h3>Removed Paths</h3>
<ul>
<li><a href="#CalendarServertrunkrunomgdontusethisitssolastyear">CalendarServer/trunk/run.omg-dont-use-this-its-so-last-year</a></li>
<li><a href="#CalendarServertrunksupportbuildsh">CalendarServer/trunk/support/build.sh</a></li>
<li><a href="#CalendarServertrunksupportpysh">CalendarServer/trunk/support/py.sh</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkrunomgdontusethisitssolastyear"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/run.omg-dont-use-this-its-so-last-year (12987 => 12988)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/run.omg-dont-use-this-its-so-last-year        2014-03-21 19:47:59 UTC (rev 12987)
+++ CalendarServer/trunk/run.omg-dont-use-this-its-so-last-year        2014-03-21 19:51:51 UTC (rev 12988)
</span><span class="lines">@@ -1,250 +0,0 @@
</span><del>-#!/usr/bin/env bash
-# -*- sh-basic-offset: 2 -*-
-
-##
-# Copyright (c) 2005-2014 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.
-##
-
-##
-# WARNING: This script is intended for use by developers working on
-# the Calendar Server code base. It is not intended for use in a
-# deployment configuration.
-#
-# DO NOT use this script as a system startup tool (eg. in /etc/init.d,
-# /Library/StartupItems, launchd plists, etc.)
-#
-# For those uses, install the server properly (eg. with "./run -i
-# /tmp/foo && cd /tmp/foo && pax -pe -rvw . /") and use the caldavd
-# executable to start the server.
-##
-
-set -e;
-set -u;
-
-wd="$(cd "$(dirname "$0")" && pwd)";
-
-# Echo the usage for the main 'run' script, then exit with an error.
-usage () {
- program="$(basename "$0")";
-
- if [ "${1--}" != "-" ]; then
- echo "$@";
- echo;
- fi;
-
- echo "Usage: ${program} [-hvgsfnpdkrR] [-K key] [-iIb dst] [-t type] [-S statsdirectory] [-P plugin]";
- echo "Options:";
- echo "        -h Print this help and exit";
- echo "        -v Be verbose";
- echo "        -g Get dependencies only; don't run setup or run the server.";
- echo "        -s Run setup only; don't run server";
- 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";
- 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 "        -b Perform a bundled install (include all dependencies) 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}]";
-
- if [ "${1-}" == "-" ]; then
- return 0;
- fi;
- exit 64;
-}
-
-# Parse command-line options to set up state which controls the behavior of the
-# functions in build.sh.
-parse_options () {
- OPTIND=1;
- while getopts "ahvgsfnpedkrK:i:I:b: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="-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";
- ;;
- 'e')
- do_get="false"; do_setup="false"; do_run="false"; print_path="true";
- print_environment="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}";
- ;;
- 'b')
- do_bundle="true";
- do_get="true";
- do_setup="true";
- do_run="false";
- install="${OPTARG}";
- install_flag="--root=";
- ;;
- 'n') do_get="false" ; do_setup="false"; ;;
- esac;
- done;
- shift $((${OPTIND} - 1));
- if [ $# != 0 ]; then
- usage "Unrecognized arguments:" "$@";
- fi;
-}
-
-. "${wd}/support/build.sh";
-
-# Actually run the server. (Or, exit, if things aren't sufficiently set up in
-# order to do that.)
-run () {
- echo "Using ${python} as Python";
-
- if "${do_run}"; then
- if [ ! -f "${config}" ]; then
- echo "";
- echo "Missing config file: ${config}";
- echo "You might want to start by copying the test configuration:";
- echo "";
- echo " cp conf/caldavd-test.plist conf/caldavd-dev.plist";
- echo "";
- if [ -t 0 ]; then
- # Interactive shell
- echo -n "Would you like to copy the test configuration now? [y/n]";
- read answer;
- case "${answer}" in
- y|yes|Y|YES|Yes)
- echo "Copying test cofiguration...";
- cp "${wd}/conf/caldavd-test.plist" "${wd}/conf/caldavd-dev.plist";
- ;;
- *)
- exit 1;
- ;;
- esac;
- else
- exit 1;
- fi;
- fi;
-
- cd "${wd}";
- if [ ! -d "${wd}/data" ]; then
- mkdir "${wd}/data";
- fi;
-
- echo "";
- echo "Starting server...";
- exec ${caldavd_wrapper_command} \
- "${caldav}/bin/caldavd" ${daemonize} \
- -f "${config}" \
- -P "${plugin_name}" \
- -t "${service_type}" \
- ${reactor} \
- ${profile};
- cd /;
- fi;
-}
-
-
-# The main-point of the 'run' script: parse all options, decide what to do,
-# then do it.
-run_main () {
- parse_options "$@";
-
- # If we've been asked to read a configuration key, just read it and exit.
- if [ -n "${read_key}" ]; then
- value="$("${caldav}/bin/calendarserver_config" "${read_key}")";
- IFS="="; set ${value}; echo "$2"; unset IFS;
- exit $?;
- fi;
-
- if "${kill}" || "${restart}"; then
- pidfile="$("${caldav}/bin/calendarserver_config" "PIDFile")";
- # Split key and value on "=" and just grab the value
- IFS="="; set ${pidfile}; pidfile="$2"; unset IFS;
- 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;
-
- # About to do something for real; let's enumerate (and depending on options,
- # possibly download and/or install) the dependencies.
- dependencies;
-
- # 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
- if "${print_environment}"; then
- "${PYTHON}" -c "import os; print repr(dict(os.environ))"
- else
- echo "${PYTHONPATH}";
- fi;
- exit 0;
- fi;
-
- # If we're installing, install the calendar server itself.
- py_install "Calendar Server" "${caldav}";
-
- if [ -n "${install_home:-}" ]; then
- do_home_install;
- fi;
-
- if "${do_bundle}"; then
- write_environment;
- fi;
-
- # Finally, run the server.
- run;
-}
-
-
-run_main "$@";
-
</del></span></pre></div>
<a id="CalendarServertrunksupportbuildsh"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/support/build.sh (12987 => 12988)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/support/build.sh        2014-03-21 19:47:59 UTC (rev 12987)
+++ CalendarServer/trunk/support/build.sh        2014-03-21 19:51:51 UTC (rev 12988)
</span><span class="lines">@@ -1,971 +0,0 @@
</span><del>-# -*- sh-basic-offset: 2 -*-
-
-##
-# Copyright (c) 2005-2014 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.
-##
-
-set -e
-set -u
-
-. "${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 () {
- local var="$1"; shift;
- local default="$1"; shift;
- if [ -z "$(eval echo "\${${var}:-}")" ]; then
- eval "${var}=\${default:-}";
- fi;
-}
-
-# Checks for presence of a C header, optionally with a version comparison.
-# With only a header file name, try to include it, returning nonzero if absent.
-# With 3 params, also attempt a version check, returning nonzero if too old.
-# Param 2 is a minimum acceptable version number
-# Param 3 is a #define from the source that holds the installed version number
-# Examples:
-# Assert that ldap.h is present
-# find_header "ldap.h"
-# Assert that ldap.h is present with a version >= 20344
-# find_header "ldap.h" 20344 "LDAP_VENDOR_VERSION"
-find_header () {
- sys_header="$1"; shift;
- if [ $# -ge 1 ]; then
- min_version="$1"; shift;
- version_macro="$1"; shift;
- fi;
-
- # No min_version given:
- # Check for presence of a header. We use the "-c" cc option because we don't
- # need to emit a file; cc exits nonzero if it can't find the header
- if [ -z "${min_version:-}" ]; then
- echo "#include <${sys_header}>" | cc -x c -c - -o /dev/null 2> /dev/null;
- return "$?";
- fi;
-
- # Check for presence of a header of specified version
- found_version="$(printf "#include <${sys_header}>\n${version_macro}\n" | cc -x c -E - | tail -1)";
-
- if [ "${found_version}" == "${version_macro}" ]; then
- # Macro was not replaced
- return 1;
- fi;
-
- if cmp_version "${min_version}" "${found_version}"; then
- return 0;
- else
- return 1;
- fi;
-};
-
-# 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";
- 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.
- conditional_set wd "$(pwd)";
- conditional_set config "${wd}/conf/caldavd-dev.plist";
- conditional_set caldav "${wd}";
- conditional_set CALENDARSERVER_BUILD_DEPS "${caldav}/..";
-
- if [ -z "${CALENDARSERVER_CACHE_DEPS-}" ]; then
- cache_deps="${wd}/.dependencies";
- else
- cache_deps="${CALENDARSERVER_CACHE_DEPS}";
- fi;
-
- mkdir -p "${CALENDARSERVER_BUILD_DEPS}";
- top="$(cd "${CALENDARSERVER_BUILD_DEPS}" && pwd -L)";
-
- 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;
-
- patches="${caldav}/lib-patches";
-
- # Find some hashing commands
- # sha1() = sha1 hash, if available
- # md5() = md5 hash, if available
- # hash() = default hash function
- # $hash = name of the type of hash used by hash()
-
- hash="";
-
- if type -ft openssl > /dev/null; then
- if [ -z "${hash}" ]; then hash="md5"; fi;
- md5 () { "$(type -p openssl)" dgst -md5 "$@"; }
- elif type -ft md5 > /dev/null; then
- if [ -z "${hash}" ]; then hash="md5"; fi;
- md5 () { "$(type -p md5)" "$@"; }
- elif type -ft md5sum > /dev/null; then
- if [ -z "${hash}" ]; then hash="md5"; fi;
- md5 () { "$(type -p md5sum)" "$@"; }
- fi;
-
- if type -ft sha1sum > /dev/null; then
- if [ -z "${hash}" ]; then hash="sha1sum"; fi;
- sha1 () { "$(type -p sha1sum)" "$@"; }
- fi;
- if type -ft shasum > /dev/null; then
- if [ -z "${hash}" ]; then hash="sha1"; fi;
- sha1 () { "$(type -p shasum)" "$@"; }
- fi;
-
- if [ "${hash}" == "sha1" ]; then
- hash () { sha1 "$@"; }
- elif [ "${hash}" == "md5" ]; then
- hash () { md5 "$@"; }
- 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 () { echo "INTERNAL ERROR: No hash function."; exit 1; }
- 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 "";
- if [ -e "${path}/setup.py" ]; then
- 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;
- fi;
-}
-
-
-# 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 md5="";
- local sha1="";
-
- OPTIND=1;
- while getopts "m:s:" option; do
- case "${option}" in
- 'm') md5="${OPTARG}"; ;;
- 's') sha1="${OPTARG}"; ;;
- esac;
- done;
- shift $((${OPTIND} - 1));
-
- 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|')";
-
- untar () { tar -xvf -; }
- unzipstream () { tmp="$(mktemp -t ccsXXXXX)"; cat > "${tmp}"; unzip "${tmp}"; rm "${tmp}"; }
- case "${ext}" in
- gz|tgz) decompress="gzip -d -c"; unpack="untar"; ;;
- bz2) decompress="bzip2 -d -c"; unpack="untar"; ;;
- tar) decompress="untar"; unpack="untar"; ;;
- zip) decompress="cat"; unpack="unzipstream"; ;;
- *)
- echo "Error in www_get of URL ${url}: Unknown extension ${ext}";
- exit 1;
- ;;
- esac;
-
- echo "";
-
- if [ -n "${cache_deps}" ] && [ -n "${hash}" ]; then
- mkdir -p "${cache_deps}";
-
- local cache_basename="$(echo ${name} | tr '[ ]' '_')-$(echo "${url}" | hash)-$(basename "${url}")";
- local cache_file="${cache_deps}/${cache_basename}";
-
- check_hash () {
- local file="$1"; shift;
-
- local sum="$(md5 "${file}" | perl -pe 's|^.*([0-9a-f]{32}).*$|\1|')";
- if [ -n "${md5}" ]; then
- echo "Checking MD5 sum for ${name}...";
- if [ "${md5}" != "${sum}" ]; then
- echo "ERROR: MD5 sum for downloaded file is wrong: ${sum} != ${md5}";
- return 1;
- fi;
- else
- echo "MD5 sum for ${name} is ${sum}";
- fi;
-
- local sum="$(sha1 "${file}" | perl -pe 's|^.*([0-9a-f]{40}).*$|\1|')";
- if [ -n "${sha1}" ]; then
- echo "Checking SHA1 sum for ${name}...";
- if [ "${sha1}" != "${sum}" ]; then
- echo "ERROR: SHA1 sum for downloaded file is wrong: ${sum} != ${sha1}";
- return 1;
- fi;
- else
- echo "SHA1 sum for ${name} is ${sum}";
- fi;
- }
-
- if [ ! -f "${cache_file}" ]; then
- echo "No cache file: ${cache_file}";
-
- echo "Downloading ${name}...";
-
- local pkg_host="static.calendarserver.org";
- local pkg_path="/pkg";
-
- #
- # Try getting a copy from calendarserver.org.
- #
- local tmp="$(mktemp "/tmp/${cache_basename}.XXXXXX")";
- curl -L "http://${pkg_host}${pkg_path}/${cache_basename}" -o "${tmp}" || true;
- echo "";
- if [ ! -s "${tmp}" ] || grep '<title>404 Not Found</title>' "${tmp}" > /dev/null; then
- rm -f "${tmp}";
- echo "${name} is not available from calendarserver.org; trying upstream source.";
- elif ! check_hash "${tmp}"; then
- rm -f "${tmp}";
- echo "${name} from calendarserver.org is invalid; trying upstream source.";
- fi;
-
- #
- # That didn't work. Try getting a copy from the upstream source.
- #
- if [ ! -f "${tmp}" ]; then
- curl -L "${url}" -o "${tmp}";
- echo "";
-
- if [ ! -s "${tmp}" ] || grep '<title>404 Not Found</title>' "${tmp}" > /dev/null; then
- rm -f "${tmp}";
- echo "${name} is not available from upstream source: ${url}";
- exit 1;
- elif ! check_hash "${tmp}"; then
- rm -f "${tmp}";
- echo "${name} from upstream source is invalid: ${url}";
- exit 1;
- fi;
-
- if egrep "^${pkg_host}" "${HOME}/.ssh/known_hosts" > /dev/null 2>&1; then
- echo "Copying cache file up to ${pkg_host}.";
- if ! scp "${tmp}" "${pkg_host}:/var/www/static${pkg_path}/${cache_basename}"; then
- echo "Failed to copy cache file up to ${pkg_host}.";
- fi;
- echo ""
- fi;
- fi;
-
- #
- # OK, we should be good
- #
- mv "${tmp}" "${cache_file}";
- else
- #
- # We have the file cached, just verify hash
- #
- if ! check_hash "${cache_file}"; then
- exit 1;
- fi;
- 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} | ${unpack};
- 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 "Current working copy (${path}) is from the wrong URI: ${wc_uri} != ${uri}";
- rm -rf "${path}";
- svn_get "${name}" "${path}" "${uri}" "${revision}";
- return $?;
- fi;
-
- 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 "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 "Updating ${name}...";
- svn update -r "${revision}" "${path}";
-
- apply_patches "${name}" "${path}";
- fi;
- fi;
- fi;
- fi;
- else
- checkout () {
- echo "Checking out ${name}...";
- svn checkout -r "${revision}" "${uri}@${revision}" "${path}";
- }
-
- if [ "${revision}" != "HEAD" ] && \
- [ -n "${cache_deps}" ] && \
- [ -n "${hash}" ] \
- ; then
- local cacheid="${name}-$(echo "${uri}" | hash)";
- local cache_file="${cache_deps}/${cacheid}@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_header "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}";
- if "${do_bundle}"; then
- # Since we've built our own Python, an option-free installation is the
- # best bet.
- "${python}" ./setup.py install;
- else
- "${python}" ./setup.py install "${install_flag}${install}";
- fi;
- cd /;
- fi;
-}
-
-
-# Declare a dependency on a Python project.
-py_dependency () {
- local optional="false"; # Is this dependency optional?
- local override="false"; # Do I need to get this dependency even if the system
- # already has it?
- local inplace=""; # Do development in-place; don't run setup.py to
- # build, and instead add the source directory plus the
- # given relative path directly to sys.path.
- local skip_egg="false"; # Skip even the 'egg_info' step, because nothing needs
- # to be built.
- local revision="0"; # Revision (if svn)
- local get_type="www"; # Protocol to use
- local version=""; # Minimum version required
- local f_hash=""; # Checksum flag
-
- OPTIND=1;
- while getopts "ofi:er:v:m:s:" option; do
- case "${option}" in
- 'o') optional="true"; ;;
- 'f') override="true"; ;;
- 'e') skip_egg="true"; ;;
- 'r') get_type="svn"; revision="${OPTARG}"; ;;
- 'v') version="-v ${OPTARG}"; ;;
- 'm') f_hash="-m ${OPTARG}"; ;;
- 's') f_hash="-s ${OPTARG}"; ;;
- 'i')
- if [ -z "${OPTARG}" ]; then
- inplace=".";
- else
- inplace="${OPTARG}";
- fi;
- ;;
- esac;
- done;
- shift $((${OPTIND} - 1));
-
- # 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_uri="$1"; shift; # what URL should be fetched?
-
- local srcdir="${top}/${distribution}"
-
- 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_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);
- cd /;
- fi;
- fi;
- else
- py_build "${name}" "${srcdir}" "${optional}";
- fi;
- py_install "${name}" "${srcdir}";
-
- if [ -n "${inplace}" ]; then
- if [ "${inplace}" == "." ]; then
- local add_pythonpath="${srcdir}";
- else
- local add_pythonpath="${srcdir}/${inplace}";
- fi;
- local add_path="${srcdir}/bin";
- else
- local add_pythonpath="${srcdir}/build/${py_platform_libdir}";
- local add_path="${srcdir}/build/${py_platform_scripts}";
- fi;
- export PYTHONPATH="${add_pythonpath}:${PYTHONPATH:-}";
- if [ -d "${add_path}" ]; then
- export PATH="${add_path}:${PATH}";
- fi;
- else
- using_system "${name}";
- fi;
-}
-
-# Run 'make' with the given command line, prepending a -j option appropriate to
-# the number of CPUs on the current machine, if that can be determined.
-jmake () {
- case "$(uname -s)" in
- Darwin|Linux)
- ncpu="$(getconf _NPROCESSORS_ONLN)";
- ;;
- FreeBSD)
- ncpu="$(sysctl hw.ncpu)";
- ncpu="${ncpu##hw.ncpu: }";
- ;;
- esac;
-
- if [ -n "${ncpu:-}" ] && [[ "${ncpu}" =~ ^[0-9]+$ ]]; then
- make -j "${ncpu}" "$@";
- else
- make "$@";
- fi;
-}
-
-# Declare a dependency on a C project built with autotools.
-c_dependency () {
- local f_hash="";
-
- OPTIND=1;
- while getopts "m:s:" option; do
- case "${option}" in
- 'm') f_hash="-m ${OPTARG}"; ;;
- 's') f_hash="-s ${OPTARG}"; ;;
- esac;
- done;
- shift $((${OPTIND} - 1));
-
- local name="$1"; shift;
- local path="$1"; shift;
- local uri="$1"; shift;
-
- # Extra arguments are processed below, as arguments to './configure'.
-
- if "${do_bundle}"; then
- local dstroot="${install}";
- srcdir="${install}/src/${path}";
- else
- srcdir="${top}/${path}";
- local dstroot="${srcdir}/_root";
- fi;
-
- www_get ${f_hash} "${name}" "${srcdir}" "${uri}";
-
- export PATH="${dstroot}/bin:${PATH}";
- export C_INCLUDE_PATH="${dstroot}/include:${C_INCLUDE_PATH:-}";
- export LD_LIBRARY_PATH="${dstroot}/lib:${dstroot}/lib64:${LD_LIBRARY_PATH:-}";
- export CPPFLAGS="-I${dstroot}/include ${CPPFLAGS:-} ";
- export LDFLAGS="-L${dstroot}/lib -L${dstroot}/lib64 ${LDFLAGS:-} ";
- export DYLD_LIBRARY_PATH="${dstroot}/lib:${dstroot}/lib64:${DYLD_LIBRARY_PATH:-}";
- export PKG_CONFIG_PATH="${dstroot}/lib/pkgconfig:${PKG_CONFIG_PATH:-}";
-
- if "${do_setup}"; then
- if "${force_setup}" || "${do_bundle}" || [ ! -d "${dstroot}" ]; then
- echo "Building ${name}...";
- cd "${srcdir}";
- ./configure --prefix="${dstroot}" "$@";
- jmake;
- jmake install;
- else
- echo "Using built ${name}.";
- echo "";
- fi;
- fi;
-}
-
-# Used only when bundling: write out, into the bundle, an 'environment.sh' file
-# that contains all the environment variables necessary to invoke commands in
-# the deployed bundle.
-
-write_environment () {
- local dstroot="${install}";
- cat > "${dstroot}/environment.sh" << __EOF__
-export PATH="${dstroot}/bin:\${PATH}";
-export C_INCLUDE_PATH="${dstroot}/include:\${C_INCLUDE_PATH:-}";
-export LD_LIBRARY_PATH="${dstroot}/lib:${dstroot}/lib64:\${LD_LIBRARY_PATH:-}:\$ORACLE_HOME";
-export CPPFLAGS="-I${dstroot}/include \${CPPFLAGS:-} ";
-export LDFLAGS="-L${dstroot}/lib -L${dstroot}/lib64 \${LDFLAGS:-} ";
-export DYLD_LIBRARY_PATH="${dstroot}/lib:${dstroot}/lib64:\${DYLD_LIBRARY_PATH:-}:\$ORACLE_HOME";
-__EOF__
-}
-
-
-#
-# 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 () {
-
- #
- # Dependencies compiled from C source code
- #
-
-
- if "${do_bundle}"; then
- # First a bit of bootstrapping: fill out the standard directory structure.
- for topdir in bin lib include share src; do
- mkdir -p "${install}/${topdir}";
- done;
-
- # Normally we depend on the system Python, but a bundle install should be as
- # self-contained as possible.
- local pyfn="Python-2.7.5";
- c_dependency -m "6334b666b7ff2038c761d7b27ba699c1" \
- "Python" "${pyfn}" \
- "http://www.python.org/ftp/python/2.7.5/${pyfn}.tar.bz2" \
- --enable-shared;
- # Be sure to use the Python we just built.
- export PYTHON="$(type -p python)";
- init_py;
- fi;
-
- if type -P memcached > /dev/null; then
- using_system "memcached";
- else
- local le="libevent-2.0.21-stable";
- local mc="memcached-1.4.16";
- c_dependency -m "b2405cc9ebf264aa47ff615d9de527a2" \
- "libevent" "${le}" \
- "http://github.com/downloads/libevent/libevent/${le}.tar.gz";
- c_dependency -m "1c5781fecb52d70b615c6d0c9c140c9c" \
- "memcached" "${mc}" \
- "http://www.memcached.org/files/${mc}.tar.gz";
- # "http://memcached.googlecode.com/files/${mc}.tar.gz";
- fi;
-
- if type -P postgres > /dev/null; then
- using_system "Postgres";
- else
- local v="9.3.1";
- local n="postgresql";
- local p="${n}-${v}";
-
- if type -P dtrace > /dev/null; then
- local enable_dtrace="--enable-dtrace";
- else
- local enable_dtrace="";
- fi;
-
- c_dependency -m "c003d871f712d4d3895956b028a96e74" \
- "PostgreSQL" "${p}" \
- "http://ftp.postgresql.org/pub/source/v${v}/${p}.tar.bz2" \
- --with-python ${enable_dtrace};
- fi;
-
- if find_header ldap.h 20428 LDAP_VENDOR_VERSION; then
- using_system "OpenLDAP";
- else
- local v="2.4.38";
- local n="openldap";
- local p="${n}-${v}";
- c_dependency -m "39831848c731bcaef235a04e0d14412f" \
- "OpenLDAP" "${p}" \
- "http://www.openldap.org/software/download/OpenLDAP/${n}-release/${p}.tgz" \
- --disable-bdb --disable-hdb;
- fi;
-
- if find_header ffi/ffi.h; then
- using_system "libffi";
- else
- c_dependency -m "45f3b6dbc9ee7c7dfbbbc5feba571529" \
- "libffi" "libffi-3.0.13" \
- "ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz"
- fi;
-
- #
- # Python dependencies
- #
-
- # First, let's make sure that we ourselves are on PYTHONPATH, in case some
- # code (like, let's say, trial) decides to chdir somewhere.
- export PYTHONPATH="${wd}:${PYTHONPATH:-}";
-
- # Sourceforge mirror hostname.
- local sf="superb-sea2.dl.sourceforge.net";
- local st="setuptools-1.4";
- local pypi="http://pypi.python.org/packages/source";
-
- py_dependency -v 1 -m "5710464bc5a61d75f5087f15ce63cfe0" \
- "setuptools" "setuptools" "${st}" \
- "$pypi/s/setuptools/${st}.tar.gz";
-
- local v="0.6";
- local n="cffi";
- local p="${n}-${v}";
- py_dependency -v "0.6" -m "5be33b1ab0247a984d42b27344519337" \
- "${n}" "${n}" "${p}" \
- "${pypi}/c/${n}/${p}.tar.gz";
-
- local v="2.10";
- local n="pycparser";
- local p="${n}-${v}";
- py_dependency -v "0.6" -m "d87aed98c8a9f386aa56d365fe4d515f" \
- "${n}" "${n}" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
-
- local v="4.0.5";
- local n="zope.interface";
- local p="${n}-${v}";
- py_dependency -v 4 -m "caf26025ae1b02da124a58340e423dfe" \
- "Zope Interface" "${n}" "${p}" \
- "http://pypi.python.org/packages/source/z/${n}/${p}.zip";
-
- local v="0.12";
- local n="pyOpenSSL";
- local p="${n}-${v}";
- py_dependency -v 0.12 -m "60a7bbb6160950823eddcbba2cbcb0d6" \
- "${n}" "OpenSSL" "${p}" \
- "http://pypi.python.org/packages/source/p/${n}/${p}.tar.gz";
-
- local n="PyKerberos";
- if type -P krb5-config > /dev/null; then
- local v="9409";
- local p="${n}-${v}";
- py_dependency -r "${v}" \
- "${n}" "kerberos" "${p}" \
- "${svn_uri_base}/${n}/trunk";
- fi;
-
- local v="0.6.4";
- local n="xattr";
- local p="${n}-${v}";
- py_dependency -v 0.6 -m "1bef31afb7038800f8d5cfa2f4562b37" \
- "${n}" "${n}" "${p}" \
- "${pypi}/x/${n}/${n}-${v}.tar.gz";
-
- if [ -n "${ORACLE_HOME:-}" ]; then
- local v="5.1.2";
- local n="cx_Oracle";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "462f309e00f7bff7100e2077fc43172c" \
- "${n}" "${n}" "${p}" \
- "http://${sf}/project/cx-oracle/${v}/${p}.tar.gz";
- fi;
-
- local v="4.1.1";
- local n="PyGreSQL";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "71d0b8c5a382f635572eb52fee47cd08" \
- "${n}" "pgdb" "${p}" \
- "${pypi}/P/${n}/${p}.tgz";
-
- local v="0.1.2";
- local n="sqlparse";
- local p="${n}-${v}";
- py_dependency -v "${v}" -s "978874e5ebbd78e6d419e8182ce4fb3c30379642" \
- "SQLParse" "${n}" "${p}" \
- "http://python-sqlparse.googlecode.com/files/${p}.tar.gz";
-
- local v="2.6.1";
- local n="pycrypto";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "55a61a054aa66812daf5161a0d5d7eda" \
- "PyCrypto" "Crypto" "${p}" \
- "http://ftp.dlitz.net/pub/dlitz/crypto/${n}/${p}.tar.gz";
-
- local v="0.1.7";
- local n="pyasn1";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "2cbd80fcd4c7b1c82180d3d76fee18c8" \
- "${n}" "${n}" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
-
- local v="13.2.0";
- local n="Twisted";
- local p="${n}-${v}";
- py_dependency -v 13.2 -m "83fe6c0c911cc1602dbffb036be0ba79" \
- "${n}" "twisted" "${p}" \
- "${pypi}/T/${n}/${p}.tar.bz2";
-
- local v="12414";
- local n="twext";
- local p="${n}-${v}";
- py_dependency -fe -r "${v}" \
- "${n}" "${n}" "${p}" \
- "${svn_uri_base}/${n}/trunk";
-
- local v="1.5";
- local n="python-dateutil";
- local p="${n}-${v}";
- py_dependency -m "35f3732db3f2cc4afdc68a8533b60a52" \
- "${n}" "dateutil" "${p}" \
- "http://www.labix.org/download/${n}/${p}.tar.gz";
-
- local v="1.2.0";
- local n="psutil";
- local p="${n}-${v}";
- py_dependency -m "f8ae906249e65db21f17d873ae07e584" \
- "${n}" "${n}" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
-
- local v="2.4.13";
- local n="python-ldap";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "74b7b50267761540451eade44b2049ee" \
- "Python-LDAP" "ldap" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
-
- local v="12724";
- local n="PyCalendar";
- local p="${n}-${v}";
- py_dependency -fe -i "src" -r "${v}" \
- "${n}" "pycalendar" "${p}" \
- "${svn_uri_base}/${n}/trunk";
-
- # Can't add "-v 2011g" to args because the version check expects numbers.
- local v="2013.8";
- local n="pytz";
- local p="${n}-${v}";
- py_dependency -m "37750ca749ed3a52523b9682b0b7e381" \
- "${n}" "${n}" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
-
- #
- # Tool dependencies. The code itself doesn't depend on these, but
- # they are useful to developers.
- #
-
- if type -P pyflakes > /dev/null; then
- using_system "PyFlakes";
- else
- local v="0.6.1";
- local n="pyflakes";
- local p="${n}-${v}";
- py_dependency -v "${v}" -m "00debd2280b962e915dfee552a675915" \
- "Pyflakes" "${n}" "${p}" \
- "${pypi}/p/${n}/${p}.tar.gz";
- fi;
-
- local v="12068";
- local n="CalDAVClientLibrary";
- local p="${n}-${v}";
- py_dependency -o -r "${v}" \
- "${n}" "caldavclientlibrary" "${p}" \
- "${svn_uri_base}/${n}/trunk";
-
- local v="1.1.8";
- local n="setproctitle";
- local p="${n}-${v}";
- py_dependency -v "1.0" -m "728f4c8c6031bbe56083a48594027edd" \
- "${n}" "${n}" "${p}" \
- "${pypi}/s/${n}/${p}.tar.gz";
-
- svn_get "CalDAVTester" "${top}/CalDAVTester" \
- "${svn_uri_base}/CalDAVTester/trunk" HEAD;
-
- local v="3.0.1";
- local n="epydoc";
- local p="${n}-${v}";
- py_dependency -o -m "36407974bd5da2af00bf90ca27feeb44" \
- "Epydoc" "${n}" "${p}" \
- "${pypi}/e/${n}/${p}.tar.gz";
-
- local v="0.10.0";
- local n="Nevow";
- local p="${n}-${v}";
- py_dependency -o -m "66dda2ad88f42dea05911add15f4d1b2" \
- "${n}" "nevow" "${p}" \
- "${pypi}/N/${n}/${p}.tar.gz";
-
- local v="0.5b1";
- local n="pydoctor";
- local p="${n}-${v}";
- py_dependency -o -m "c4fb33672f37624116cc7a0606f74f28" \
- "${n}" "${n}" "${p}" \
- "{$pypi}/p/${n}/${p}.tar.gz";
-
- if "${do_setup}"; then
- cd "${caldav}";
- echo "Building our own extension modules...";
- "${python}" setup.py build_ext --inplace;
- fi;
-}
-
-# Actually do the initialization, once all functions are defined.
-init_build;
</del></span></pre></div>
<a id="CalendarServertrunksupportpysh"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/support/py.sh (12987 => 12988)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/support/py.sh        2014-03-21 19:47:59 UTC (rev 12987)
+++ CalendarServer/trunk/support/py.sh        2014-03-21 19:51:51 UTC (rev 12988)
</span><span class="lines">@@ -1,205 +0,0 @@
</span><del>-# -*- sh-basic-offset: 2 -*-
-##
-# Copyright (c) 2005-2014 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.
-##
-
-set -e
-set -u
-
-# 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 () {
- local v;
- local p;
- for v in "2.7" "2.6" ""
- 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 version=""; # Minimum version required
-
- OPTIND=1;
- while getopts "v:" option; do
- case "${option}" in
- 'v') version="${OPTARG}"; ;;
- esac;
- done;
- shift $((${OPTIND} - 1));
-
- local module="$1"; shift;
-
- if ! "${python}" -c "import ${module}" > /dev/null 2>&1; then
- return 1;
- fi;
-
- local result=0;
-
- if [ -n "${version}" ]; then
- local symbol;
- for symbol in "xxxx" "__version__" "version"; do
- if module_version="$(
- "${python}" -c \
- 'print __import__("'"${module}"'").'"$symbol"';' \
- 2>/dev/null
- )"; then
- break;
- fi;
- done;
-
- if [ -z "${module_version}" ]; then
- module_version=$("${python}" -c 'import pkg_resources; print pkg_resources.get_distribution("'"${module}"'").version;');
- fi;
- if [ -z "${module_version}" ]; then
- if ! "${print_path}"; then
- echo "Unable to determine version for ${module}.";
- fi;
- result=1;
- elif ! cmp_version "${version}" "${module_version}"; then
- if ! "${print_path}"; then
- echo "A system version of ${module} exists, but version is ${module_version} (< ${version}).";
- fi;
- result=1;
- fi;
- fi;
-
- return ${result};
-}
-
-# Compare version numbers
-
-cmp_version () {
- local v="$1"; shift;
- local mv="$1"; shift;
-
- local result;
-
- while true; do
- vh="${v%%.*}"; # Get highest-order segment
- mvh="${mv%%.*}";
-
- if [ "${vh}" -gt "${mvh}" ]; then
- result=1;
- break;
- fi;
-
- if [ "${vh}" -lt "${mvh}" ]; then
- result=0;
- break;
- fi;
-
- if [ "${v}" == "${v#*.}" ]; then
- # No dots left, so we're ok
- result=0;
- break;
- fi;
-
- if [ "${mv}" == "${mv#*.}" ]; then
- # No dots left, so we're not gonna match
- result=1;
- break;
- fi;
-
- v="${v#*.}";
- mv="${mv#*.}";
- done;
-
- return ${result};
-}
-
-# 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 () {
- # First, detect the appropriate version of Python to use, based on our version
- # requirements and the environment. Note that all invocations of python in
- # our build scripts should therefore be '"${python}"', not 'python'; this is
- # important on systems with older system pythons (2.4 or earlier) with an
- # alternate install of Python, or alternate python installation mechanisms
- # like virtualenv.
- python="$(detect_python_version)";
-
- # Set the $PYTHON environment variable to an absolute path pointing at the
- # appropriate python executable, a standard-ish mechanism used by certain
- # non-distutils things that need to find the "right" python. For instance,
- # the part of the PostgreSQL build process which builds pl_python. Note that
- # detect_python_version, above, already honors $PYTHON, so if this is already
- # set it won't be stomped on, it will just be re-set to the same value.
- export PYTHON="$(type -p ${python})";
-
- if [ -z "${python:-}" ]; then
- echo "No suitable python found. Python 2.6 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_platform_scripts="scripts-${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;
</del></span></pre>
</div>
</div>
</body>
</html>