-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup-env
472 lines (405 loc) · 13.7 KB
/
setup-env
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
#!/bin/sh
# -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# Copyright (C) 2012, 2013, 2016 O.S. Systems Software LTDA.
# Authored-by: Otavio Salvador <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Add options for the script
# Copyright (C) 2013 Freescale Semiconductor, Inc.
PROGNAME="setup-env"
if [ -z "$ZSH_NAME" ] && echo "$0" | grep -q "$PROGNAME"; then
echo "ERROR: This script needs to be sourced."
SCRIPT_PATH=`readlink -f $0`
if [ "`readlink $SHELL`" = "dash" ];then
echo "Try run command \"set -- -h; . $SCRIPT_PATH\" to get help."
else
echo "Try run command \". $SCRIPT_PATH -h\" to get help."
fi
unset SCRIPT_PATH PROGNAME
exit
else
if [ -n "$BASH_SOURCE" ]; then
ROOTDIR="`readlink -f $BASH_SOURCE | xargs dirname`"
elif [ -n "$ZSH_NAME" ]; then
ROOTDIR="`readlink -f $0 | xargs dirname`"
else
ROOTDIR="`readlink -f $PWD | xargs dirname`"
fi
if ! [ -e "$ROOTDIR/$PROGNAME" ];then
echo "Go to where $PROGNAME locates, then run: . $PROGNAME <args>"
unset ROOTDIR PROGNAME
return
fi
fi
# Check if current user is root
if [ "$(whoami)" = "root" ]; then
echo "ERROR: Do not use the BSP as root. Exiting..."
unset ROOTDIR PROGNAME
return
fi
OEROOTDIR=${ROOTDIR}/sources/poky
if [ -e ${ROOTDIR}/sources/oe-core ]; then
OEROOTDIR=${ROOTDIR}/sources/oe-core
fi
FSLROOTDIR=${ROOTDIR}/sources/meta-freescale
PROJECT_DIR=${ROOTDIR}/build_${MACHINE}
prompt_message () {
local i=''
echo "Welcome to Freescale QorIQ SDK (Reference Distro)
The Yocto Project has extensive documentation about OE including a
reference manual which can be found at:
http://yoctoproject.org/documentation
For more information about OpenEmbedded see their website:
http://www.openembedded.org/
You can now run 'bitbake <target>'
ifc14xx-image
ifc14xx-toolchain
cct-image
cct-toolchain
"
echo "To return to this build environment later please run:"
echo " . $PROJECT_DIR/SOURCE_THIS"
}
clean_up()
{
unset PROGNAME ROOTDIR OEROOTDIR FSLROOTDIR PROJECT_DIR \
EULA EULA_FILE LAYER_LIST MACHINE FSLDISTRO EXTRAROOTDIR \
OLD_OPTIND CPUS JOBS THREADS DOWNLOADS CACHES DISTRO \
setup_flag setup_h setup_j setup_t setup_g setup_l setup_builddir \
setup_download setup_sstate setup_error layer append_layer \
valid_machine valid_num
unset -f usage prompt_message
}
usage() {
echo "Usage: . $PROGNAME -m <machine>"
echo -e "\n Supported machines:
`find ${ROOTDIR}/sources/meta-{ess,fsl,freescale,qoriq-demos,intel}*/conf/machine \
-name *.conf 2>/dev/null \
|egrep "/(mpc|b4|bsc|c29|p1|p2|p3|p4|p5|t1|t2|t4|ls|ifc|intel|cct).*conf$" |sort \
|xargs echo |sed -e 's,[^ ]*/,,g;s,.conf,,g'`
"
echo " Optional parameters:
* [-m machine]: the target machine to be built.
* [-j jobs]: number of jobs for make to spawn during the compilation stage.
* [-t tasks]: number of BitBake tasks that can be issued in parallel.
* [-b path]: non-default path of project build folder.
* [-d path]: non-default path of DL_DIR (downloaded source)
* [-c path]: non-default path of SSTATE_DIR (shared state Cache)
* [-h]: help
"
if [ "`readlink $SHELL`" = "dash" ];then
echo "
You are using dash which does not pass args when being sourced.
To workaround this limitation, use \"set -- args\" prior to
sourcing this script. For exmaple:
\$ set -- -m ls1088ardb -j 3 -t 2
\$ . $ROOTDIR/$PROGNAME
"
fi
}
# parse the parameters
OLD_OPTIND=$OPTIND
while getopts "m:j:t:b:d:c:h" setup_flag
do
case $setup_flag in
m) MACHINE="$OPTARG";
;;
j) setup_j="$OPTARG";
;;
t) setup_t="$OPTARG";
;;
b) setup_builddir="$OPTARG";
;;
d) setup_download="$OPTARG";
;;
c) setup_sstate="$OPTARG";
;;
h) setup_h='true';
;;
?) setup_error='true';
;;
esac
done
OPTIND=$OLD_OPTIND
# check the "-h" and other not supported options
if test $setup_error || test $setup_h; then
usage && clean_up && return
fi
# Check the machine type specified
valid_machine=false
if [ -n "${MACHINE}" ];then
valid_num=`find ${ROOTDIR}/sources/meta-*/conf/machine \
-name ${MACHINE}.conf 2>/dev/null |wc -l`
if [ "1" -lt "$valid_num" ];then
echo "ERROR: possible error may occur due to duplicate ${MACHINE}.conf exist:"
find ${ROOTDIR}/sources/meta-*/conf/machine \
-name ${MACHINE}.conf 2>/dev/null
echo "Please remove the useless layer under ${ROOTDIR}/sources"
clean_up && return
elif [ "0" = "$valid_num" ];then
echo "$MACHINE is not supported by this build setup."
usage && clean_up && return
fi
else
usage && clean_up && return
fi
echo "Configuring for ${MACHINE} ..."
LAYER_LIST=" \
meta-openembedded/meta-oe \
meta-openembedded/meta-multimedia \
meta-openembedded/meta-python \
meta-openembedded/meta-networking \
meta-openembedded/meta-gnome \
meta-openembedded/meta-filesystems \
meta-openembedded/meta-webserver \
meta-openembedded/meta-perl \
meta-virtualization \
meta-cloud-services \
meta-security \
\
meta-freescale \
meta-freescale-distro \
meta-qoriq-demos \
meta-ess \
meta-intel \
"
EULA_FILE="$FSLROOTDIR/EULA"
if echo "$MACHINE" | egrep -q "^ifc"; then
DISTRO="ifc14xx"
fi
if echo "$MACHINE" | egrep -q "^cct"; then
DISTRO="cct"
fi
if echo "$MACHINE" | egrep -q "^intel"; then
DISTRO="poky"
fi
# set default jobs and threads
CPUS=`grep -c processor /proc/cpuinfo`
JOBS="4"
THREADS="4"
# check optional jobs and threads
if echo "$setup_j" | egrep -q "^[0-9]+$"; then
JOBS=$setup_j
fi
if echo "$setup_t" | egrep -q "^[0-9]+$"; then
THREADS=$setup_t
fi
# set project folder location and name
if [ -n "$setup_builddir" ]; then
if echo $setup_builddir |grep -q ^/;then
PROJECT_DIR="${setup_builddir}"
else
PROJECT_DIR="`pwd`/${setup_builddir}"
fi
else
PROJECT_DIR=${ROOTDIR}/build_${MACHINE}
fi
mkdir -p $PROJECT_DIR
if [ -n "$setup_download" ]; then
if echo $setup_download |grep -q ^/;then
DOWNLOADS="${setup_download}"
else
DOWNLOADS="`pwd`/${setup_download}"
fi
else
DOWNLOADS="$ROOTDIR/downloads"
fi
mkdir -p $DOWNLOADS
DOWNLOADS=`readlink -f "$DOWNLOADS"`
if [ -n "$setup_sstate" ]; then
if echo $setup_sstate |grep -q ^/;then
CACHES="${setup_sstate}"
else
CACHES="`pwd`/${setup_sstate}"
fi
else
CACHES="$ROOTDIR/sstate-cache"
fi
mkdir -p $CACHES
CACHES=`readlink -f "$CACHES"`
# check if project folder was created before
if [ -e "$PROJECT_DIR/SOURCE_THIS" ]; then
echo "$PROJECT_DIR was created before."
. $PROJECT_DIR/SOURCE_THIS
echo "Nothing is changed."
clean_up && return
fi
# source oe-init-build-env to init build env
cd $OEROOTDIR
set -- $PROJECT_DIR
. ./oe-init-build-env > /dev/null
# if conf/local.conf not generated, no need to go further
if [ ! -e conf/local.conf ]; then
echo "ERROR: the local.conf is not created, Exit ..."
clean_up && cd $ROOTDIR && return
fi
# Remove comment lines and empty lines
sed -i -e '/^#.*/d' -e '/^$/d' conf/local.conf
# Change settings according to the environment
sed -e "s,MACHINE ??=.*,MACHINE ??= '$MACHINE',g" \
-e "s,DISTRO ?=.*,DISTRO ?= '$DISTRO',g" \
-i conf/local.conf
# Remove debug-tweaks
sed -e "s,EXTRA_IMAGE_FEATURES ?=.*,EXTRA_IMAGE_FEATURES ?= \"\",g" -i conf/local.conf
# Clean up PATH, because if it includes tokens to current directories somehow,
# wrong binaries can be used instead of the expected ones during task execution
export PATH="`echo $PATH | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//'`"
# add layers
for layer in $(eval echo $LAYER_LIST); do
append_layer=""
if [ -e ${ROOTDIR}/sources/${layer} ]; then
append_layer="${ROOTDIR}/sources/${layer}"
fi
if [ -n "${append_layer}" ]; then
append_layer=`readlink -f $append_layer`
awk '/ \"/ && !x {print "'" ${append_layer}"' \\"; x=1} 1' \
conf/bblayers.conf > conf/bblayers.conf~
mv conf/bblayers.conf~ conf/bblayers.conf
fi
done
cat >> conf/local.conf <<-EOF
# Parallelism Options
BB_NUMBER_THREADS = "$THREADS"
PARALLEL_MAKE = "-j $JOBS"
DL_DIR = "$DOWNLOADS"
SSTATE_DIR = "$CACHES"
# Add iocuser
INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "\
groupadd -g 1042 -f iocgroup; \
useradd -P vaha23neca -g iocgroup -u 1042 -G sudo,dialout iocuser;"
BBMASK = " lxc"
ACCEPT_FSL_EULA = "1"
hostname_pn-base-files = ""
# Use shared-state files from artifactory
SSTATE_MIRRORS ?= "\
file://.* https://artifactory.esss.lu.se/artifactory/yocto/sstate/PATH"
# Create tarballs of all git repos in download dir
BB_GENERATE_MIRROR_TARBALLS = "1"
DISTRO_FEATURES_append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
# Setup mirrors
# 1. Yocto will look in local downloads/ dir
# 2. Yocto will look in artifactory yocto/downloads
# 3. Yocto will use the artifactory mirror repo
# 4. Yocto will use the upstream SRC_URI specified
# 5. Yocto will use the Freescale mirror repo (IFC14XX only)
INHERIT += "own-mirrors"
SOURCE_MIRROR_URL = "https://artifactory.esss.lu.se/artifactory/yocto/downloads"
PREMIRRORS_prepend = "\
git://.*/.* https://artifactory.esss.lu.se/artifactory/yoctoproject-mirror \n \
https://.*/.* https://artifactory.esss.lu.se/artifactory/yoctoproject-mirror \n \
http://.*/.* https://artifactory.esss.lu.se/artifactory/yoctoproject-mirror \n \
ftp://.*/.* https://artifactory.esss.lu.se/artifactory/yoctoproject-mirror \n"
EOF
if echo "$MACHINE" | egrep -q "^ifc"; then
cat >> conf/local.conf <<-EOF
MIRRORS += "\
git://.*/.* http://git.freescale.com/source \n \
https://.*/.* http://git.freescale.com/source \n \
http://.*/.* http://git.freescale.com/source \n \
ftp://.*/.* http://git.freescale.com/source \n"
PACKAGE_FEED_URIS = "https://artifactory.esss.lu.se/artifactory/rpm-ics"
PACKAGE_FEED_BASE_PATHS = "yocto/ioxos"
EOF
fi
if echo "$MACHINE" | egrep -q "^ifc14xx-64b"; then
cat >> conf/local.conf <<-EOF
PACKAGE_FEED_ARCHS = "ifc14xx_64b ppc64e6500 noarch"
EOF
fi
if echo "$MACHINE" | egrep -q "^ifc14xx-rt-64b"; then
cat >> conf/local.conf <<-EOF
PACKAGE_FEED_ARCHS = "ifc14xx_rt_64b ppc64e6500"
EOF
fi
if echo "$MACHINE" | egrep -q "^cct-64"; then
cat >> conf/local.conf <<-EOF
PACKAGE_FEED_URIS = "https://artifactory.esss.lu.se/artifactory/rpm-ics"
PACKAGE_FEED_BASE_PATHS = "yocto/cct"
PACKAGE_FEED_ARCHS = "cct_64 corei7_64 noarch"
EOF
fi
if echo "$MACHINE" | egrep -q "^cct-rt-64"; then
cat >> conf/local.conf <<-EOF
PACKAGE_FEED_URIS = "https://artifactory.esss.lu.se/artifactory/rpm-ics"
PACKAGE_FEED_BASE_PATHS = "yocto/cct"
PACKAGE_FEED_ARCHS = "cct_rt_64 corei7_64"
EOF
fi
for s in $HOME/.oe $HOME/.yocto; do
if [ -e $s/site.conf ]; then
echo "Linking $s/site.conf to conf/site.conf"
ln -s $s/site.conf conf
fi
done
if echo "$MACHINE" |egrep -q "^(b4|p5|t1|t2|t4|ifc)"; then
# disable prelink (for multilib scenario) for now
sed -i s/image-mklibs.image-prelink/image-mklibs/g conf/local.conf
fi
# Handle EULA setting
if [ -z "$EULA" ] && ! grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
EULA='ask'
fi
if [ "$EULA" = "ask" ]; then
cat <<EOF
Proprietary and third party software is subject to agreement and compliance
with, Freescale's End User License Agreement. To have the right to use these
binaries in your images, you must read and accept the following terms. If
there are conflicting terms embedded in the software, the terms embedded in
the Software will control.
In all cases, open source software is licensed under the terms of the
applicable open source license(s), such as the BSD License, Apache License or
the GNU Lesser General Public License. Your use of the open source software
is subject to the terms of each applicable license. You must agree to the
terms of each applicable license, or you cannot use the open source software.
EOF
sleep 5
more -d $EULA_FILE
echo
while [ "$EULA" = "ask" ]; do
echo -n "Do you accept the EULA you just read? (y/n) "
read REPLY
case "$REPLY" in
y|Y)
echo "EULA has been accepted."
EULA="1"
;;
n|N)
echo "EULA has not been accepted."
EULA="0"
;;
esac
done
fi
if grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
sed -i "s/^#*ACCEPT_FSL_EULA\s*=.*/ACCEPT_FSL_EULA = \"$EULA\"/g" conf/local.conf
else
echo "ACCEPT_FSL_EULA = \"$EULA\"" >> conf/local.conf
fi
# make a SOURCE_THIS file
if [ ! -e SOURCE_THIS ]; then
echo "#!/bin/sh" >> SOURCE_THIS
echo "cd $OEROOTDIR" >> SOURCE_THIS
echo "set -- $PROJECT_DIR" >> SOURCE_THIS
echo ". ./oe-init-build-env > /dev/null" >> SOURCE_THIS
echo "echo \"Back to build project $PROJECT_DIR.\"" >> SOURCE_THIS
fi
prompt_message
cd $PROJECT_DIR
clean_up