-
Notifications
You must be signed in to change notification settings - Fork 0
/
postflight
executable file
·85 lines (71 loc) · 2.18 KB
/
postflight
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
#!/bin/bash
#
# Copyright 2012 Google 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.
#
# Install postflight script
#
# Note: this script ends up running from the directory that the installer
# was invoked from, e.g. maybe / from the GUI, or a /Volumes/blah if
# invoked from CLI
set -e
set -x
function die() {
echo ERROR "$@" >&2
exit 1
}
export PATH="$PATH:/usr/bin"
PKG="$1"
DEFAULT_PATH="$2"
TARGET_PATH="$3"
RESOURCES="${PKG}/Contents/Resources"
BASETMPDIR="${TARGET_PATH}/tmp/"
OSX=$(sw_vers -productVersion | cut -d. -f1-2)
VERSION="0.8.2"
PACKAGE_DEPS="setuptools python-dateutil>=1.4,<2 pyyaml google_apputils"
EZ="/usr/bin/easy_install"
### set up sane logging
d=$(date '+%Y%m%d%H%M')
LOGFILE="${BASETMPDIR}/postflight.${d}.$$.log"
exec 1> "${LOGFILE}"
exec 2>&1
echo postflight BEGIN
### create temp work directory
TMPDIR=$(mktemp -d ${BASETMPDIR}/postflightXXXXXX)
ORIGPWD="${PWD}"
trap "rm -rf ${TMPDIR}" EXIT
### install supplied eggs, like M2Crypto.
[ -x "${EZ}" ] || die "Cannot execute ${EZ}"
for egg in ${RESOURCES}/*-${OSX}-*.egg ; do
if [ -r "${egg}" ]; then
${EZ} -N "${egg}"
fi
done
### install dependencies
# setuptools does not like to upgrade some packages automatically
# when running setup.py below, e.g. python-dateutil from 1.2 to 1.4.
# so, just upgrade them all in advance. :(
for package in ${PACKAGE_DEPS}; do
${EZ} -U "${package}"
done
### install main source package
tar -zxf "${RESOURCES}/cauliflowervest-${VERSION}.tar.gz" -C "${TMPDIR}"
cd "${TMPDIR}/cauliflowervest-${VERSION}"
mkdir -p src/tests # fake out google test
python setup.py install 2>&1
cd "${ORIGPWD}"
### END, remove our debug log
exec 1> /dev/null
exec 2>&1
rm -f "${LOGFILE}"