-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathb2install-release
executable file
·129 lines (114 loc) · 3.74 KB
/
b2install-release
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
#!/bin/bash
set -o pipefail
# check for help option
if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo
echo "Usage: `basename $0` [--debug] [--binary] [version [system]]"
echo
echo "- This command installs the given release or build version of basf2"
echo " in the directory $VO_BELLE2_SW_DIR/releases."
echo "- By default it tries to install the precompiled binary version for"
echo " the current system. A binary version can be selected explicitly"
echo " with the second argument."
echo "- Debug information is removed unless the --debug option is used."
echo "- With the --binary option no compilation of the source will be attempted."
echo "- If no version is given it lists the available versions."
echo
exit 0
fi
# make sure tar uses stdin
unset TAPE
# check for debug option
DEBUG_SELECTION="--anchored --exclude='*/Linux*/debug' --exclude='*/Linux*/*/.debug'"
if [ "$1" = "--debug" ]; then
DEBUG_SELECTION=""
shift
fi
# check for binary option
BINARY_ONLY="no"
if [ "$1" = "--binary" ]; then
BINARY_ONLY="yes"
shift
fi
# check number of arguments
if [ $# -gt 2 ]; then
echo "Usage: `basename $0` [version [system]]" 1>&2
exit 1
fi
# check for software tools setup
if [ -z "${BELLE2_SOFTWARE_REPOSITORY}" -o -z "${VO_BELLE2_SW_DIR}" ]; then
echo "Belle II software environment is not set up." 1>&2
echo "-> source b2setup" 1>&2
exit 1
fi
# list available versions if no argument is given
if [ $# -eq 0 ]; then
git ls-remote ${BELLE2_SOFTWARE_REPOSITORY} | grep "tags/" | grep "release-\|build-\|light-" | grep -v "\^{}$" | awk -F / '{print $NF}'
exit 0
fi
# check whether the given version is already installed
VERSION=$1
DIR=${VO_BELLE2_SW_DIR}/releases/${VERSION}
if [ -d ${DIR} ]; then
echo "Error: The basf2 version ${VERSION} is already installed at ${VO_BELLE2_SW_DIR}/releases." 1>&2
exit 1
fi
# check whether the releases top directory exists and cd to it
if [ ! -d ${VO_BELLE2_SW_DIR}/releases ]; then
echo "The basf2 releases top directory ${VO_BELLE2_SW_DIR}/releases does not exist."
read -p "Would you like to create it (y/n)? " -n 1 REPLY
echo
if [ "$REPLY" = "y" ]; then
mkdir -p ${VO_BELLE2_SW_DIR}/releases
if [ "$?" != 0 ]; then
echo "Error: The creation of the directory ${VO_BELLE2_SW_DIR}/releases failed." 1>&2
exit 1
fi
else
exit 1
fi
fi
cd ${VO_BELLE2_SW_DIR}/releases
# check whether we can write to the releases directory
if [ ! -w ${VO_BELLE2_SW_DIR}/releases ]; then
echo "Error: No write permissions to the directory ${VO_BELLE2_SW_DIR}/releases." 1>&2
exit 1
fi
# try the binary version
SYSTEM=`b2install-print-os | sed "s/ //g"`
if [ $# -gt 1 ]; then
SYSTEM=$2
fi
if [ "${SYSTEM}" != "<unknown><unknown>" ]; then
wget -O - --tries=3 ${BELLE2_DOWNLOAD}/releases/${VERSION}_${SYSTEM}.tgz | tar xz ${DEBUG_SELECTION}
if [ "$?" = "0" ]; then
exit 0
elif [ "${BINARY_ONLY}" = "yes" ]; then
exit 2
fi
fi
# try the source version
wget -O - --tries=3 ${BELLE2_DOWNLOAD}/releases/${VERSION}_src.tgz | tar xz
if [ "$?" != "0" ]; then
# check whether the given version is available in the git repository
VERSION_EXISTS=`git ls-remote ${BELLE2_SOFTWARE_REPOSITORY} ${VERSION} | wc -l`
if [ "${VERSION_EXISTS}" = "0" ]; then
echo "Error: The basf2 version ${VERSION} does not exist." 1>&2
exit 1
fi
git archive --format=tar.gz --prefix=${VERSION}/ --remote=${BELLE2_SOFTWARE_REPOSITORY} ${VERSION} | tar xzv
if [ "$?" != 0 ]; then
echo "Error: The download of ${VERSION} from the git repository failed." 1>&2
exit 2
fi
fi
# build basf2
cd ${VERSION}
echo head > .release
ln -s site_scons/SConstruct .
. ${BELLE2_TOOLS}/b2setup.sh ""
scons
if [ "$?" != 0 ]; then
echo "Error: The compilation of basf2 failed." 1>&2
exit 3
fi