blob: 26140fcdc7b561e495902815350321fee806d0c7 (
plain) (
blame)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
#!/bin/bash
EXEC_PATH=$(dirname "${BASH_SOURCE[0]}")
source "$EXEC_PATH/cbc_functions.inc"
LOGFILE="monolith.log"
LOGFILE_PREV="$LOGFILE.prev"
TMPDIR=/tmp
start_pos=
PYTHON_VERSION="3.4"
NUMPY_VERSION="1.9"
BRANCH=""
BRANCH_MANIFEST=""
function usage {
echo "usage: $(basename $0) {manifest} [-pnco]
manifest List of recipes to build (in order)
--python -p Version to pass to conda-build
--numpy -n Version to pass to conda-build
--branch -b Build from a branch (or tag)
--branch-manifest List containing git_url patterns
--cbc-recipes -c Path to CBC recipes directory
--cbc-output-dir -o Path to CONDA recipes
"
}
function build_restart {
if [ -f "$LOGFILE" ]; then
echo "Build restarting..."
cp -av "$LOGFILE" $LOGFILE.prev
sync
export start_pos=$(tail -n 1 "$LOGFILE_PREV" | tr -d ' ')
fi
}
function build_prepare {
echo "Translating CBC recipes..."
cbc_build --no-build $(echo $CBC_RECIPES/*/*.ini)
_OK=`success`
if [ $_OK -ne 0 ]; then
echo "Something went wrong with cbc_build..."
exit 1
fi
if [ -n "$BRANCH" ]; then
build_prepare_branch
fi
}
function build_prepare_branch()
{
# This works, mostly. I need to implement a whitelist for git_url entries.
echo Building from branch: $BRANCH
CBC_HOME_ORIG="$CBC_HOME"
export CBC_HOME="$(mktemp -u -d)"
mkdir -pv "$CBC_HOME"
echo "CBC_HOME=$CBC_HOME"
rsync -av "$CBC_HOME_ORIG/" "$CBC_HOME"
# Redundant code alert... ugh (WILL FIX)
if [ -n "$BRANCH_MANIFEST" ]; then
while read pattern
do
for f in `find $CBC_HOME -type f -name "*.yaml"`
do
grep "$pattern" "$f" 2>/dev/null
_OK=`success`
if [ $_OK -eq 0 ]; then
echo "Applying branch: $f"
sed -i 's|git_tag|#git_tag|g' "$f" 2>/dev/null
sed -i "/git_url/ a \ \ \ \ git_tag: '$BRANCH'" "$f" 2>/dev/null
fi
done
done < "$BRANCH_MANIFEST"
else
for f in `find $CBC_HOME -type f -name "*.yaml"`
do
grep "git_url" "$f" 2>/dev/null
_OK=`success`
if [ $_OK -eq 0 ]; then
echo "Applying branch: $f"
sed -i 's|git_tag|#git_tag|g' "$f" 2>/dev/null
sed -i "/git_url/ a \ \ \ \ git_tag: '$BRANCH'" "$f" 2>/dev/null
fi
done
fi
}
function build_cleanup {
if [ -n "$BRANCH" ]; then
if [[ $CBC_RECIPES == *$TMPDIR* ]]; then
echo "Removing temporary branch data..."
rm -rf "$CBC_RECIPES"
fi
fi
}
function build() {
CWD=`pwd`
while read recipe
do
if [ -n "$start_pos" ]; then
if [[ $recipe != $start_pos ]]; then
echo "Skipping: $recipe"
continue
else
# Iterate through remaining recipes
unset start_pos
fi
fi
cd "$CBC_HOME"
conda build \
--no-binstar-upload \
--python $PYTHON_VERSION \
--numpy $NUMPY_VERSION \
--override-channels -c defaults "$recipe"
_OK=`success`
if [ $_OK -ne 0 ]; then
echo
echo "Monolithic build failure..."
echo "Cause:"
echo " $recipe"
cd "$CWD"
exit $_OK
fi
done < "$MANIFEST"
cd "$CWD"
}
function bad_arg {
usage
echo "Bad argument: $@"
exit 1
}
ARGC="${#}"
if [[ ${ARGC} < 1 ]]; then
usage
exit 1
fi
MANIFEST="$1"
if [ ! -f "$MANIFEST" ]; then
echo "\"$MANIFEST\" does not exist."
exit 1
fi
# MAIN
shift
while [ $# -gt 0 ];
do
case "$1" in
'')
usage
exit 1
;;
--python|-p)
PYTHON_VERSION="$2"
if [ -z "$PYTHON_VERSION" ]; then
bad_arg "Missing python version."
fi
shift
;;
--numpy|-n)
NUMPY_VERSION="$2"
if [ -z "$NUMPY_VERSION" ]; then
bad_arg "Missing numpy version."
fi
shift
;;
--branch|-b)
BRANCH="$2"
if [ -z "$BRANCH" ]; then
bad_arg "Missing branch name."
fi
shift
;;
--branch-manifest)
BRANCH_MANIFEST="$2"
if [ -z "$BRANCH_MANIFEST" ]; then
bad_arg "Missing branch manifest filename."
fi
shift
;;
--cbc-recipes|-c)
CBC_RECIPES="$2"
if [ -z "$CBC_RECIPES" ]; then
bad_arg "Missing recipe directory."
fi
shift
;;
--cbc-output-dir|-o)
CBC_HOME="$2"
if [ -z "$CBC_HOME" ]; then
bad_arg "Missing conda recipe directory."
fi
shift
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
shift
done
# DO NOT LOG THIS...
build_prepare
build_restart
# LOG THIS
( build ) 2>&1 | tee "$LOGFILE"
build_cleanup
|