-
Notifications
You must be signed in to change notification settings - Fork 2
/
b2analysis-get
executable file
·75 lines (66 loc) · 2.51 KB
/
b2analysis-get
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
#!/bin/bash
# check for help option
if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo
echo "Usage: `basename $0` directory [username]"
echo
echo "- This command checks out the analysis code at the given directory name."
echo " It also prepares the build system."
echo "- If the analysis repository is in a physics group the directory"
echo " must contain the path, e.g. charm/software/charm_lifetimes for"
echo " https://gitlab.desy.de/belle2/physics/charm/software/charm_lifetimes"
echo "- The optional second argument can be used to specify the user name"
echo " if the analysis code of another user should be obtained that is"
echo " not in a physics group."
echo
exit 0
fi
# check number of arguments
if [ $# -lt 1 -o $# -gt 2 ]; then
echo "Usage: `basename $0` directory [username]" 1>&2
exit 1
fi
# read arguments
DIR=$1
if [ -d $(basename ${DIR}) ]; then
echo "Error: The directory "$(basename ${DIR})" already exists." 1>&2
exit 1
fi
USERNAME=$BELLE2_USER
if [ $# -gt 1 ]; then
USERNAME=$2
fi
# verify that the git repository exists and is an analysis repository
echo ${DIR} | grep / > /dev/null
if [ "$?" == "0" ]; then
ANALYSIS_PROJECT="belle2/physics/${DIR}"
else
ANALYSIS_PROJECT=${BELLE2_ANALYSES_PROJECT}/${USERNAME}_${DIR}
fi
ANALYSIS_REPOSITORY=${BELLE2_GIT_SERVER}${ANALYSIS_PROJECT}.git
REPOSITORY_EXISTS_MASTER=`git ls-remote ${ANALYSIS_REPOSITORY} master 2> /dev/null | wc -l`
REPOSITORY_EXISTS_MAIN=`git ls-remote ${ANALYSIS_REPOSITORY} main 2> /dev/null | wc -l`
if [ "${REPOSITORY_EXISTS_MASTER}" = "0" ] && [ "${REPOSITORY_EXISTS_MAIN}" = "0" ]; then
echo "Error: The analysis git repository https://gitlab.desy.de/${ANALYSIS_PROJECT} does not exist." 1>&2
exit 1
fi
# check out the analysis directory
DIR=$(basename ${DIR})
git clone ${ANALYSIS_REPOSITORY} ${DIR}
if [ "$?" != "0" ]; then
echo "Error: The checkout of the analysis repository ${ANALYSIS_REPOSITORY} failed." 1>&2
exit 1
fi
# check whether the release exists
RELEASE=`cat ${DIR}/.analysis`
if [ ! -d ${VO_BELLE2_SW_DIR}/releases/${RELEASE} ]; then
echo "Warning: The central release ${RELEASE} required by this analysis does not exist." 1>&2
fi
# get site-scons
pushd ${DIR} > /dev/null
ln -s ${VO_BELLE2_SW_DIR}/releases/${RELEASE}/site_scons .
ln -s site_scons/SConstruct .
popd > /dev/null
# inform user about successful completion
echo "Analysis ${ANALYSIS_PROJECT} for release ${RELEASE} checked out at: ${DIR}"
echo "-> change to the new directory and set up the environment: cd ${DIR}; b2setup"