forked from GENIVI/genivi-dev-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript
More file actions
executable file
·306 lines (242 loc) · 7.72 KB
/
script
File metadata and controls
executable file
·306 lines (242 loc) · 7.72 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/bash -e
# (C) 2017 Gunnar Andersson
# LICENSE: MPLv2
# User warning!
# A casual user will need to read the script to understand what the first
# parameter shall be to make it run:
#
if [[ "$1" != CI_FLAG ]]; then
cat <<EOT
READ THIS: This script was not designed for personal use.
If you still use it, you hereby agree to any applicable End-User License
Agreement (EULA) of the corresponding BSPs that are used.
It is still a useful script but a few things could be destructive if you use
this in your development environment instead of a "throw-away" environment like
CI.
Please make sure you read the script to understand what it does!
After that I hope you enjoy using it.
EOT
exit 2
fi
# ---- General settings ----
# Fixed cache location on all agents that support this.
AGENT_STANDARD_DL_DIR="/var/cache/yocto/downloads"
AGENT_STANDARD_SSTATE_DIR="/var/cache/yocto/sstate"
AGENT_STANDARD_SGX_LOCATION="/var/go/sgx_bin"
AGENT_STANDARD_SGX_GEN3_LOCATION="/var/go/sgx_bin_gen3"
# ---- Helper functions ----
# This is some trickery, but quite useful
deref() { eval echo \$$1 ; }
ensure_var_is_defined() {
var_name=$1
current_value=$(deref $var_name)
if [[ -z "$current_value" ]]; then
echo "Please define environment var_name \$$var_name (found empty value)"
fail=true # We want all the errors reported, so don't halt yet.
fi
}
define_with_default() {
var_name=$1
default="$2"
current_value=$(deref $var_name)
if [[ -z "$current_value" ]]; then
eval $var_name="$default"
fi
}
stop_if_failure() {
if [[ "$fail" == "true" ]] ; then
exit 1
fi
}
stop_immediately() {
echo "Fatal error occurred - stopping ci-build script"
exit 2
}
append_local_conf() {
LOCAL_CONF="$BASEDIR/gdp-src-build/conf/local.conf"
if [[ -f "$LOCAL_CONF" ]]; then
echo -n "Appending to local.conf: "
cat <<EOT | tee -a "$LOCAL_CONF"
$1
EOT
else
echo "Fatal: Did not find local.conf where expected"
stop_immediately
fi
}
stage_artifact() {
mkdir -p staging
cmd=$1
shift
if [[ -z "$1" ]] ; then
echo "Skipped an artifact pattern that matched nothing"
return
fi
for f in $@ ; do # <- could be empty glob list
if [[ -e "$f" ]] ; then
if [[ $cmd == cp && -d "$f" ]] ; then
flag=-a
elif [[ $cmd == cp ]] ; then
flag=--preserve=all
fi
$cmd $flag "$f" staging/
else
echo "Skipping non-existing (or already moved) artifact: $f"
fi
done
}
# ---- Main program ----
D=$(dirname "$0")
cd "$D"
BASEDIR=$(readlink -f "$PWD/..")
# The user must define this
ensure_var_is_defined TARGET
stop_if_failure
# The values can be overridden by defining environment variables
# If no value given, use this default:
define_with_default BUILD_SDK false
define_with_default RM_WORK false
define_with_default REUSE_STANDARD_DL_DIR true
define_with_default REUSE_STANDARD_SSTATE_DIR true
define_with_default SGX_DRIVERS $AGENT_STANDARD_SGX_LOCATION
define_with_default SGX_GEN_3_DRIVERS $AGENT_STANDARD_SGX_GEN3_LOCATION
stop_if_failure
git_gdp="https://github.com/GENIVI/genivi-dev-platform"
branch="master"
# For copying graphics
if [[ "$TARGET" == "koelsch" ]]; then
GFX_MACHINE=porter
else
GFX_MACHINE=$TARGET
fi
# cd workingdir
MACHINE="$TARGET" # For most boards - exceptions handled below
if [[ "$TARGET" == "r-car-m3-starter-kit" ]]; then
MACHINE="m3ulcb"
fi
ensure_var_is_defined MACHINE
export MACHINE
if [[ "$REUSE_STANDARD_DL_DIR" == "true" ]]; then
DL_DIR="$AGENT_STANDARD_DL_DIR"
fi
if [[ "$REUSE_STANDARD_SSTATE_DIR" == "true" ]]; then
SSTATE_DIR="$AGENT_STANDARD_SSTATE_DIR"
fi
echo Configuration:
echo
echo "TARGET = $TARGET"
echo "BRANCH = $BRANCH"
echo "COMMIT = $COMMIT"
echo "RELEASE = $RELEASE"
echo "BUILD_SDK = $BUILD_SDK"
echo "SGX_DRIVERS = $SGX_DRIVERS"
echo "SGX_GEN_3_DRIVERS = $SGX_GEN_3_DRIVERS"
echo "REUSE_STANDARD_DL_DIR = $REUSE_STANDARD_DL_DIR"
echo "REUSE_STANDARD_SSTATE_DIR = $REUSE_STANDARD_SSTATE_DIR"
echo "DL_DIR = $DL_DIR"
echo "SSTATE_DIR = $DL_DIR"
echo "RM_WORK = $RM_WORK"
# build steps
cd "$BASEDIR/gdp-src-build"
# If DL/SSTATE are to be reused it is only through. the use of
# REUSE_STANDARD_DL_DIR and REUSE_STANDARD_SSTATE_DIR - I.e. if any are left
# in the build directory we assume they shall be wiped out and not reused.
rm -rf tmp downloads cache sstate-cache
cd "$BASEDIR"
# Need to set an identity for some git patching done by recipes
git config user.name "CI build -- ignore"
git config user.email no_email@genivigo.com
# Normally the material (source code) is defined in the pipeline itself in the
# CIAT system but there are multiple ways to override it provided here.
if [[ -n "$FORK" ]]; then
echo "***** NOTE: OVERRIDING REPOSITORY WITH \$FORK DEFINITION *****"
git remote set-url origin "$FORK"
git fetch
# V *danger* V. One reason why you should not use this script if it's not in CI
git reset origin/master --hard
# After this, submodule sync/update will be done by init.sh
# this may need some further testing!
git checkout $BRANCH # <- note this should be ok even if $BRANCH is an empty value
fi
if [[ -n "$BRANCH" ]]; then
echo "***** NOTE: OVERRIDING CHOSEN COMMIT USING \$BRANCH DEFINITION *****"
git checkout $BRANCH
fi
if [[ -n "$TAG" ]]; then
echo "***** NOTE: OVERRIDING CHOSEN COMMIT USING \$TAG DEFINITION *****"
git checkout $TAG
fi
if [[ -n "$COMMIT" ]]; then
echo "***** NOTE: OVERRIDING CHOSEN COMMIT USING \$COMMIT DEFINITION *****"
git checkout $COMMIT
fi
# Remind us exactly what submodules hashes are used (this is already stated by
# go.cd when fetching materials, but materials can be overriden by FORK /
# BRANCH / TAG / COMMIT
echo "Submodules:"
git submodule
# Deal with special setup, copy binary drivers etc.
set -x
if [[ "$TARGET" == "r-car-m3-starter-kit" ]]; then
cd renesas-rcar-gen3
meta-rcar-gen3/docs/sample/copyscript/copy_evaproprietary_softwares.sh /var/go/sgx_bin_gen3/
cd -
fi
if [[ "$GFX_MACHINE" == "porter" || "$GFX_MACHINE" == silk ]]; then
cd meta-renesas/meta-rcar-gen2
./copy_gfx_software_$GFX_MACHINE.sh /var/go/sgx_bin
./copy_mm_software_lcb.sh /var/go/sgx_bin/
cd -
fi
set +x
# INIT
cd "$BASEDIR"
echo "Running init.sh"
if [[ "$TARGET" == "dragonboard-410c" ]]; then
source ./init.sh $TARGET accept-eula -f
else
source ./init.sh $TARGET -f
fi
# LOCAL CONF MODIFICATIONS
if [[ "$RM_WORK" == "true" ]]; then
append_local_conf 'INHERIT += "rm_work"'
fi
if [[ -n "$DL_DIR" ]]; then
append_local_conf "DL_DIR = \"$DL_DIR\""
fi
if [[ -n "$SSTATE_DIR" ]]; then
append_local_conf "SSTATE_DIR = \"$SSTATE_DIR\""
fi
if [[ -n "$BB_NUMBER_THREADS" ]]; then
append_local_conf "BB_NUMBER_THREADS = \"$BB_NUMBER_THREADS\""
fi
if [[ -n "$PARALLEL_MAKE" ]]; then
echo $PARALLEL_MAKE | egrep -q '^-j' || PARALLEL_MAKE="-j$PARALLEL_MAKE"
append_local_conf "PARALLEL_MAKE = \"$PARALLEL_MAKE\""
fi
if [[ "$BUILD_SDK" != "true" ]]; then
bitbake genivi-dev-platform
fi
if [[ "$BUILD_SDK" == "true" ]]; then
bitbake genivi-dev-platform-sdk
fi
if [[ "$BUILD_SDK" == "true" ]]; then
bitbake meta-ide-support
fi
rm -f logs.tar logs.tar.gz
find gdp-src-build/tmp/work \( -name "*.log" -o -name "log.*" -o -name "run.*" \) -print0 | xargs -0 tar uf logs.tar || true
gzip logs.tar || true
cd "$BASEDIR"
rm -rf staging
shopt -s nullglob
stage_artifact mv gdp-src-build/tmp/deploy/licenses
stage_artifact mv gdp-src-build/tmp/deploy/licenses/genivi-dev-platform*/license.manifest
stage_artifact mv gdp-src-build/tmp/deploy/sdk*
stage_artifact cp gdp-src-build/tmp/deploy/images/*/*
stage_artifact cp gdp-src-build/tmp/deploy/images/*
stage_artifact cp gdp-src-build/conf/*.conf
stage_artifact cp logs.tar.gz
mkdir -p staging/images
mv staging/{*201*ext*,*201*rootfs*,*sdimg*,*hddimg*,bzImage*201*} staging/images/ 2>/dev/null || true
echo Artifacts in staging/
ls -R staging/