-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpostBuild
executable file
·88 lines (70 loc) · 2.62 KB
/
postBuild
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
#!/bin/bash
#
# Written by Oliver Beckstein, 2016
#
# This script is placed into the Public Domain using the CC0 1.0 Public Domain
# Dedication https://creativecommons.org/publicdomain/zero/1.0/
#
# Install HOLE from http://www.holeprogram.org/
#
# arguments (hard coded for Binder installation on Linux)
# OSNAME : linux | darwin
# PREFIX : "path/to/installdir"
#
# PREFIX can be relative to CWD or an absolute path; it will be created
# and HOLE unpacked under PREFIX (the tar file contains "hole2/...")
#
#
# HOLE is used under the terms of the Apache License, Version 2.0
# (see http://www.holeprogram.org/)
set -o errexit -o nounset
SCRIPT=$(basename $0)
TARFILE_LINUX="hole2-ApacheLicense-2.2.005-Linux-x86_64.tar.gz"
DOWNLOAD_URL_LINUX="http://www.holeprogram.org/downloads/2.2.005/${TARFILE_LINUX}"
# path to dir with executables in the current HOLE distribution
HOLE_EXE_DIR=hole2/exe
function die () {
local msg="$1" err=$2
echo "[${SCRIPT}] ERROR: $msg [$err]"
exit $err
}
function is_native_executable () {
local filename="$1" OSNAME="$2"
file "${filename}" | grep -qi ${OFORMAT}
return $?
}
OSNAME=Linux
OFORMAT=Linux
DOWNLOAD_URL="${DOWNLOAD_URL_LINUX}"
TARFILE=${TARFILE_LINUX}
PREFIX="$HOME"
#------------------------------------------------------------
# start installation
#------------------------------------------------------------
mkdir -p "$PREFIX" && cd "$PREFIX" || die "Failed to create and cd to $PREFIX" 1
if ! test -f ${TARFILE}; then
echo "Downloading ${TARFILE} from ${DOWNLOAD_URL}..."
# fixing curl on travis/anaconda, see http://stackoverflow.com/a/31060428/334357
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
curl -L ${DOWNLOAD_URL} -o ${TARFILE} || \
die "Failed to download ${TARFILE} from ${DOWNLOAD_URL}" 1
fi
# only install the executables in HOLE_EXE_DIR
tar xvf ${TARFILE} ${HOLE_EXE_DIR} || die "Failed 'tar xvf ${TARFILE} ${HOLE_EXE_DIR}'" 1
MDA_HOLE_BINDIR="${PWD}/${HOLE_EXE_DIR}"
HOLE_EXE="${MDA_HOLE_BINDIR}/hole"
test -d "${MDA_HOLE_BINDIR}" || { \
echo "Content of ${PWD}:";
ls -la;
die "no HOLE exe dir ${MDA_HOLE_BINDIR} in $PWD" 2; }
test -f "${HOLE_EXE}" || die "hole executable ${HOLE_EXE} not installed" 2
is_native_executable ${HOLE_EXE} ${OFORMAT} || \
{ file ${HOLE_EXE}; \
die "${HOLE_EXE} will not run on ${OSNAME} (object format ${OFORMAT})" 3; }
# rm build artifacts (looks confusing in binder)
rm -f "${TARFILE}"
echo "HOLE executables were installed into ${MDA_HOLE_BINDIR}"
echo ">>> "
# repeat this line in .travis.yml
export PATH=${PATH}:${MDA_HOLE_BINDIR}
echo "export PATH=${MDA_HOLE_BINDIR}:${PATH}" >> ~/.bashrc