-
Notifications
You must be signed in to change notification settings - Fork 1
/
oebb.sh
executable file
·468 lines (391 loc) · 15 KB
/
oebb.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
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
#!/bin/bash
# Original script done by Don Darling
# Later changes by Koen Kooi and Brijesh Singh
# Revision history:
# 20090902: download from twiki
# 20090903: Weakly assign MACHINE and DISTRO
# 20090904: * Don't recreate local.conf is it already exists
# * Pass 'unknown' machines to OE directly
# 20090918: Fix /bin/env location
# Don't pass MACHINE via env if it's not set
# Changed 'build' to 'bitbake' to prepare people for non-scripted usage
# Print bitbake command it executes
# 20091012: Add argument to accept commit id.
# 20091202: Fix proxy setup
#
# For further changes consult 'git log' or browse to:
# http://git.angstrom-distribution.org/cgi-bin/cgit.cgi/setup-scripts/
# to see the latest revision history
# Use this till we get a maintenance branch based of the release tag
umask 0002
###############################################################################
# User specific vars like proxy servers
###############################################################################
#PROXYHOST=wwwgate.ti.com
#PROXYPORT=80
PROXYHOST=""
###############################################################################
# OE_BASE - The root directory for all OE sources and development.
###############################################################################
OE_BASE=${PWD}
# incremement this to force recreation of config files
BASE_VERSION=5
OE_ENV_FILE=~/.oe/environment-angstromv2012.05
if ! git help log | grep -q no-abbrev ; then
echo "Your installed version of git is too old, it lacks --no-abbrev. Please install 1.7.6 or newer"
exit 1
fi
###############################################################################
# CONFIG_OE() - Configure OpenEmbedded
###############################################################################
function config_oe()
{
MACHINE="${CL_MACHINE}"
#--------------------------------------------------------------------------
# Write out the OE bitbake configuration file.
#--------------------------------------------------------------------------
mkdir -p ${OE_BUILD_DIR}/conf
# There's no need to rewrite site.conf when changing MACHINE
if [ ! -e ${OE_BUILD_DIR}/conf/site.conf ]; then
cat > ${OE_BUILD_DIR}/conf/site.conf <<_EOF
SCONF_VERSION = "1"
# Where to store sources
DL_DIR = "${OE_SOURCE_DIR}/downloads"
# Where to save shared state
SSTATE_DIR = "${OE_BUILD_DIR}/build/sstate-cache"
# Which files do we want to parse:
BBFILES ?= "${OE_SOURCE_DIR}/openembedded-core/meta/recipes-*/*/*.bb"
TMPDIR = "${OE_BUILD_TMPDIR}"
# Go through the Firewall
#HTTP_PROXY = "http://${PROXYHOST}:${PROXYPORT}/"
_EOF
fi
if [ ! -e ${OE_BUILD_DIR}/conf/auto.conf ]; then
cat > ${OE_BUILD_DIR}/conf/auto.conf <<_EOF
MACHINE ?= "${MACHINE}"
_EOF
else
eval "sed -i -e 's/^MACHINE.*$/MACHINE ?= \"${MACHINE}\"/g' ${OE_BUILD_DIR}/conf/auto.conf"
fi
}
###############################################################################
# SET_ENVIRONMENT() - Setup environment variables for OE development
###############################################################################
function set_environment()
{
# Workaround for differences between yocto bitbake and vanilla bitbake
export BBFETCH2=True
export TAG
#--------------------------------------------------------------------------
# If an env already exists, use it, otherwise generate it
#--------------------------------------------------------------------------
if [ -e ${OE_ENV_FILE} ] ; then
. ${OE_ENV_FILE}
fi
if [ x"${BASE_VERSION}" != x"${SCRIPTS_BASE_VERSION}" ] ; then
echo "BASE_VERSION mismatch, recreating ${OE_ENV_FILE}"
rm -f ${OE_ENV_FILE} ${OE_BUILD_DIR}/conf/site.conf
fi
if [ -e ${OE_ENV_FILE} ] ; then
. ${OE_ENV_FILE}
else
mkdir -p ~/.oe/
#--------------------------------------------------------------------------
# Specify distribution information
#--------------------------------------------------------------------------
DISTRO=$(grep DISTRO conf/local.conf | grep -v '^#' | awk -F\" '{print $2}')
DISTRO_DIRNAME=`echo $DISTRO | sed s#[.-]#_#g`
echo "export SCRIPTS_BASE_VERSION=${BASE_VERSION}" > ${OE_ENV_FILE}
echo "export BBFETCH2=True" >> ${OE_ENV_FILE}
echo "export DISTRO=\"${DISTRO}\"" >> ${OE_ENV_FILE}
echo "export DISTRO_DIRNAME=\"${DISTRO_DIRNAME}\"" >> ${OE_ENV_FILE}
#--------------------------------------------------------------------------
# Specify the root directory for your OpenEmbedded development
#--------------------------------------------------------------------------
OE_BUILD_DIR=${OE_BASE}
OE_BUILD_TMPDIR="${OE_BUILD_DIR}/build/tmp-${DISTRO_DIRNAME}"
OE_SOURCE_DIR=${OE_BASE}/sources
export BUILDDIR=${OE_BUILD_DIR}
mkdir -p ${OE_BUILD_DIR}
mkdir -p ${OE_SOURCE_DIR}
export OE_BASE
echo "export OE_BUILD_DIR=\"${OE_BUILD_DIR}\"" >> ${OE_ENV_FILE}
echo "export BUILDDIR=\"${OE_BUILD_DIR}\"" >> ${OE_ENV_FILE}
echo "export OE_BUILD_TMPDIR=\"${OE_BUILD_TMPDIR}\"" >> ${OE_ENV_FILE}
echo "export OE_SOURCE_DIR=\"${OE_SOURCE_DIR}\"" >> ${OE_ENV_FILE}
echo "export OE_BASE=\"${OE_BASE}\"" >> ${OE_ENV_FILE}
#--------------------------------------------------------------------------
# Include up-to-date bitbake in our PATH.
#--------------------------------------------------------------------------
export PATH=${OE_SOURCE_DIR}/openembedded-core/scripts:${OE_SOURCE_DIR}/bitbake/bin:${PATH}
echo "export PATH=\"${PATH}\"" >> ${OE_ENV_FILE}
#--------------------------------------------------------------------------
# Make sure Bitbake doesn't filter out the following variables from our
# environment.
#--------------------------------------------------------------------------
export BB_ENV_EXTRAWHITE="BB_NUMBER_THREADS PARALLEL_MAKE MACHINE DISTRO TCLIBC TCMODE GIT_PROXY_COMMAND http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS"
echo "export BB_ENV_EXTRAWHITE=\"${BB_ENV_EXTRAWHITE}\"" >> ${OE_ENV_FILE}
#--------------------------------------------------------------------------
# Specify proxy information
#--------------------------------------------------------------------------
if [ "x$PROXYHOST" != "x" ] ; then
export http_proxy=http://${PROXYHOST}:${PROXYPORT}/
export ftp_proxy=http://${PROXYHOST}:${PROXYPORT}/
export SVN_CONFIG_DIR=${OE_BUILD_DIR}/subversion_config
export GIT_CONFIG_DIR=${OE_BUILD_DIR}/git_config
echo "export http_proxy=\"${http_proxy}\"" >> ${OE_ENV_FILE}
echo "export ftp_proxy=\"${ftp_proxy}\"" >> ${OE_ENV_FILE}
echo "export SVN_CONFIG_DIR=\"${SVN_CONFIG_DIR}\"" >> ${OE_ENV_FILE}
echo "export GIT_CONFIG_DIR=\"${GIT_CONFIG_DIR}\"" >> ${OE_ENV_FILE}
echo "export GIT_PROXY_COMMAND=\"\${GIT_CONFIG_DIR}/git-proxy.sh\"" >> ${OE_ENV_FILE}
config_svn_proxy
config_git_proxy
fi
#--------------------------------------------------------------------------
# Set up the bitbake path to find the OpenEmbedded recipes.
#--------------------------------------------------------------------------
export BBPATH=${OE_BUILD_DIR}:${OE_SOURCE_DIR}/openembedded-core/meta${BBPATH_EXTRA}
echo "export BBPATH=\"${BBPATH}\"" >> ${OE_ENV_FILE}
#--------------------------------------------------------------------------
# Look for dash
#--------------------------------------------------------------------------
if [ "$(readlink /bin/sh)" = "dash" ] ; then
echo "/bin/sh is a symlink to dash, please point it to bash instead"
exit 1
fi
echo "There now is a sourceable script in ~/.oe/enviroment. You can do '. ${OE_ENV_FILE}' and run 'bitbake something' without using $0 as wrapper"
fi # if -e ${OE_ENV_FILE}
if ! [ -e ${OE_BUILD_DIR}/conf/site.conf ] ; then
config_oe
fi
}
###############################################################################
# UPDATE_ALL() - Make sure everything is up to date
###############################################################################
function update_all()
{
set_environment
update_oe
}
###############################################################################
# CLEAN_OE() - Delete TMPDIR
###############################################################################
function clean_oe()
{
set_environment
echo "Cleaning ${OE_BUILD_TMPDIR}"
rm -rf ${OE_BUILD_TMPDIR}
}
###############################################################################
# OE_BUILD() - Build an OE package or image
###############################################################################
function oe_build()
{
if [ ! -e ${OE_BUILD_DIR}/conf/auto.conf ] ; then
if [ -z $MACHINE ] ; then
echo "No config found, please run $0 config <machine> first"
else
CL_MACHINE=$MACHINE
set_environment
config_oe && update_all
fi
fi
set_environment
if [ -e ${OE_ENV_FILE} ] ; then
echo "Using ${OE_ENV_FILE} to setup needed variables. It is recommended to do '. ${OE_ENV_FILE}' and run 'bitbake something' without using $0 as wrapper"
fi
cd ${OE_BUILD_DIR}
if [ -z $MACHINE ] ; then
echo "Executing: bitbake" $*
bitbake $*
else
echo "Executing: MACHINE=${MACHINE} bitbake" $*
MACHINE=${MACHINE} bitbake $*
fi
}
###############################################################################
# OE_CONFIG() - Configure OE for a target
###############################################################################
function oe_config()
{
set_environment
config_oe
update_all
echo ""
echo "Setup for ${CL_MACHINE} completed"
}
###############################################################################
# UPDATE_OE() - Update OpenEmbedded distribution.
###############################################################################
function update_oe()
{
if [ "x$PROXYHOST" != "x" ] ; then
config_git_proxy
fi
#manage meta-openembedded and meta-angstrom with layerman
env gawk -v command=update -f ${OE_BASE}/scripts/layers.awk ${OE_SOURCE_DIR}/layers.txt
}
###############################################################################
# CONFIG_SVN_PROXY() - Configure subversion proxy information
###############################################################################
function config_svn_proxy()
{
if [ ! -f ${SVN_CONFIG_DIR}/servers ]
then
mkdir -p ${SVN_CONFIG_DIR}
cat >> ${SVN_CONFIG_DIR}/servers <<_EOF
[global]
http-proxy-host = ${PROXYHOST}
http-proxy-port = ${PROXYPORT}
_EOF
fi
}
###############################################################################
# CONFIG_GIT_PROXY() - Configure GIT proxy information
###############################################################################
function config_git_proxy()
{
if [ ! -f ${GIT_CONFIG_DIR}/git-proxy.sh ]
then
mkdir -p ${GIT_CONFIG_DIR}
cat > ${GIT_CONFIG_DIR}/git-proxy.sh <<_EOF
if [ -x /bin/env ] ; then
exec /bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
else
exec /usr/bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
fi
_EOF
chmod +x ${GIT_CONFIG_DIR}/git-proxy.sh
export GIT_PROXY_COMMAND=${GIT_CONFIG_DIR}/git-proxy.sh
fi
}
###############################################################################
# tag_layers - Tag all layers with a given tag
###############################################################################
function tag_layers()
{
set_environment
env gawk -v command=tag -v commandarg=$TAG -f ${OE_BASE}/scripts/layers.awk ${OE_SOURCE_DIR}/layers.txt
echo $TAG >> ${OE_BASE}/tags
}
###############################################################################
# changelog - Display changelog for all layers with a given tag
###############################################################################
function changelog()
{
set_environment
env gawk -v command=changelog -v commandarg=$TAG -f ${OE_BASE}/scripts/layers.awk ${OE_SOURCE_DIR}/layers.txt
}
###############################################################################
# layer_info - Get layer info
###############################################################################
function layer_info()
{
set_environment
rm -f ${OE_SOURCE_DIR}/info.txt
env gawk -v command=info -f ${OE_BASE}/scripts/layers.awk ${OE_SOURCE_DIR}/layers.txt
echo
echo "Showing contents of ${OE_SOURCE_DIR}/info.txt:"
echo
cat ${OE_SOURCE_DIR}/info.txt
echo
}
###############################################################################
# checkout - Checkout all layers with a given tag
###############################################################################
function checkout()
{
set_environment
env gawk -v command=checkout -v commandarg=$TAG -f ${OE_BASE}/scripts/layers.awk ${OE_SOURCE_DIR}/layers.txt
}
###############################################################################
# Build the specified OE packages or images.
###############################################################################
# FIXME: convert to case/esac
if [ $# -gt 0 ]
then
if [ $1 = "update" ]
then
update_all
exit 0
fi
if [ $1 = "info" ]
then
layer_info
exit 0
fi
if [ $1 = "tag" ]
then
if [ -n "$2" ] ; then
TAG="$2"
else
TAG="$(date -u +'%Y%m%d-%H%M')"
fi
tag_layers $TAG
exit 0
fi
if [ $1 = "changelog" ]
then
if [ -z $2 ] ; then
echo "Changelog needs an argument"
exit 1
else
TAG="$2"
fi
changelog
exit 0
fi
if [ $1 = "checkout" ]
then
if [ -z $2 ] ; then
echo "Checkout needs an argument"
exit 1
else
TAG="$2"
fi
checkout
exit 0
fi
if [ $1 = "bitbake" ]
then
shift
oe_build $*
exit $?
fi
if [ $1 = "config" ]
then
shift
CL_MACHINE=$1
shift
oe_config $*
exit 0
fi
if [ $1 = "clean" ]
then
clean_oe
exit 0
fi
fi
# Help Screen
echo ""
echo "Usage: $0 config <machine>"
echo " $0 update"
echo " $0 tag [tagname]"
echo " $0 changelog <tagname>"
echo " $0 checkout <tagname>"
echo " $0 clean"
echo ""
echo " Not recommended, but also possible:"
echo " $0 bitbake <bitbake target>"
echo " It is recommended to do '. ${OE_ENV_FILE}' and run 'bitbake something' inside ${BUILDDIR} without using oebb.sh as wrapper"
echo ""
echo "You must invoke \"$0 config <machine>\" and then \"$0 update\" prior"
echo "to your first bitbake command"
echo ""
echo "The <machine> argument can be one of the following"
echo " beagleboard: BeagleBoard"
echo " qemuarm Emulated ARM machine"
echo " qemumips: Emulated MIPS machine"
echo " fri2-noemgd: Intel FRI2 machine without graphics"
echo ""
echo "Other machines are valid as well, but listing those would make this message way too long"