1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#!/bin/sh
# -*- sh-basic-offset: 2 -*-
##
# Copyright (c) 2005-2017 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)";
#
# Usage
#
clean="false";
usage () {
program="$(basename "$0")";
if [ "${1--}" != "-" ]; then
echo "$@";
echo;
fi;
echo "Usage: ${program} [-hFfn] destination";
echo "Options:";
echo " -h Print this help and exit";
echo " -F Clean and force setup to run";
echo " -f Force setup to run";
echo " -n Do not run setup";
if [ "${1-}" = "-" ]; then
return 0;
fi;
exit 64;
}
parse_options () {
local OPTIND=1;
while getopts "hFfn" option; do
case "${option}" in
'?') usage; ;;
'h') usage -; exit 0; ;;
'F') do_setup="true" ; force_setup="true" ; clean="true" ; ;;
'f') do_setup="true" ; force_setup="true" ; clean="false"; ;;
'n') do_setup="false"; force_setup="false"; clean="false"; ;;
esac;
done;
shift $((${OPTIND} - 1));
if [ $# -le 0 ]; then
usage "No desination provided.";
fi;
destination="$1"; shift;
if [ $# != 0 ]; then
usage "Unrecognized arguments:" "$@";
fi;
}
main () {
. "${wd}/bin/_build.sh";
parse_options "$@";
#
# Build everything
#
if "${clean}"; then
develop_clean;
fi;
install -d "${destination}";
local destination="$(cd "${destination}" && pwd)";
init_build;
dev_roots="${destination}/roots";
py_virtualenv="${destination}/virtualenv";
py_bindir="${py_virtualenv}/bin";
py_ve_tools="${dev_home}/ve_tools";
# This results in permissions errors on macOS with SIP
# virtualenv_opts="--always-copy";
virtualenv_opts="";
c_dependencies;
py_dependencies;
install -d "${destination}/bin";
install -d "${destination}/lib";
cd "${destination}/bin";
find ../virtualenv/bin \
"(" -name "caldavd" -o -name 'calendarserver_*' -o -name "python" ")" \
-exec ln -fs "{}" . ";" \
;
for executable in \
"memcached/bin/memcached" \
"OpenLDAP/bin/ldapsearch" \
"openssl/bin/openssl" \
"PostgreSQL/bin/initdb" \
"PostgreSQL/bin/pg_ctl" \
"PostgreSQL/bin/psql" \
; do
if [ -e "../roots/${executable}" ]; then
ln -s "../roots/${executable}" .;
else
echo "No executable: ${executable}";
fi;
done;
cd "${destination}/lib";
find "../roots" "(" -type f -o -type l ")" \
"(" \
-name '*.so' -o \
-name '*.so.*' -o \
-name '*.dylib' \
")" -print0 \
| xargs -0 -I % ln -s % .;
# Write out environment.sh
local dst="${destination}";
cat > "${dst}/environment.sh" << __EOF__
export PATH="${dst}/bin:\${PATH}";
export C_INCLUDE_PATH="${dst}/include:\${C_INCLUDE_PATH:-}";
export LD_LIBRARY_PATH="${dst}/lib:${dst}/lib64:\${LD_LIBRARY_PATH:-}:\$ORACLE_HOME";
export CPPFLAGS="-I${dst}/include \${CPPFLAGS:-} ";
export LDFLAGS="-L${dst}/lib -L${dst}/lib64 \${LDFLAGS:-} ";
export DYLD_LIBRARY_PATH="${dst}/lib:${dst}/lib64:\${DYLD_LIBRARY_PATH:-}:\$ORACLE_HOME";
__EOF__
# Install CalendarServer into venv
cd ${wd}
${python} setup.py install
}
main "$@";
|