-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateComponents.sh
executable file
·125 lines (99 loc) · 2.8 KB
/
updateComponents.sh
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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
updateComponent() {
repName=$1 # Repository URL
thisDirWithGit=${repName##*/}
thisDir=${thisDirWithGit%.*}
if [ -d "$thisDir" ]; then
echo -n "$thisDir already exists, will update: "
cd $thisDir
currentUrl=$(git remote get-url origin)
#echo "${currentUrl}"
#echo "${repName}"
if [ "${currentUrl}" = "${repName}" ]; then
echo -n ""
else
echo "Updating ${thisDir} clone_method"
git remote set-url origin ${repName}
git remote -v
fi
#echo "in ${thisDir}"
#currentUrl=$(git remote get-url origin)
#echo "currentUrl = "$currentUrl
#echo "setting to "$repName
#git remote set-url origin ${repName}
# Could do the fetch and merge separately to give more informative errors.
git pull
pullSuccess=${?}
if [ $pullSuccess -gt 0 ]; then
echo >&2 -e ${RED}"There was an error with the fetch or merge of ${thisDir}. Aborting the build."${NC}
exit 1;
fi
cd ..
else
echo "Fetching $thisDir"
#git clone $repName
git clone --depth 1 --recursive $repName
fi
}
main() {
#Do you want to nuke the build directory? default is yes, otherwise do `./updateComponents 0`
NUKE=1
if [ ! -z $1 ]; then
NUKE=$1
fi
WHICH_COMPONENTS=0 #1
if [ ! -z $2 ]
then
WHICH_COMPONENTS=$2
fi
if [ ! -z $3 ]
then
WHICH_COMPONENTS=$3
fi
# Get desired libraries
method=$(head -1 clone_method)
#echo $method
# Create and move to components subdirectory
mkdir -p components
cd components
GH="https://github.com/"
if [ "${method}" = "ssh" ]; then
GH="git@github.com:"
fi
RN=${GH}nichol77
AN=${GH}anitaNeutrino
if [[ $WHICH_COMPONENTS == 1 ]]; then
echo "Will download the AWARE libraries as well"
for repName in $RN/aware.git $AN/anitaTreeMaker.git $AN/anitaTelem.git $AN/anitaAwareFileMaker.git; do
updateComponent $repName
done
fi
if [[ $WHICH_COMPONENTS == 2 ]]; then
echo "Will download the anitaTreeMaker as well"
for repName in $AN/anitaTreeMaker.git; do
updateComponent $repName
done
fi
for repName in $RN/libRootFftwWrapper.git $AN/eventReaderRoot.git $AN/anitaEventCorrelator.git $AN/anitaAnalysisTools.git $AN/anitaMagicDisplay.git $AN/AnitaAnalysisFramework $AN/UCorrelator $AN/icemc; do
updateComponent $repName
done
cd .. # Back to anitaBuildTool directory
docInput=doc/doxygenComponentInput.txt
echo "" > ${docInput}
for comp in $(ls -d components/*); do
echo INPUT += ${comp} >> ${docInput}
echo INPUT += ${comp}/include >> ${docInput}
echo INPUT += ${comp}/src >> ${docInput}
done
### TODO: We should be able to tell if this is necessary or not...
if [ $NUKE -eq 1 ]; then
rm -rf build
fi
return 0;
}
main $@