Skip to content
Newer
Older
100755 361 lines (304 sloc) 11.7 KB
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
1 #!/bin/bash
2
3 # Original script done by Don Darling
4 # Later changes by Koen Kooi and Brijesh Singh
5
6 # Revision history:
7 # 20090902: download from twice
8 # 20090903: Weakly assign MACHINE and DISTRO
9 # 20090904: * Don't recreate local.conf is it already exists
10 # * Pass 'unknown' machines to OE directly
11 # 20090918: Fix /bin/env location
12 # Don't pass MACHINE via env if it's not set
13 # Changed 'build' to 'bitbake' to prepare people for non-scripted usage
14 # Print bitbake command it executes
15 # 20091012: Add argument to accept commit id.
16 # 20091202: Fix proxy setup
17
18 ###############################################################################
19 # User specific vars like proxy servers
20 ###############################################################################
21
22 #PROXYHOST=wwwgate.ti.com
23 #PROXYPORT=80
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
24 PROXYHOST=""
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
25
26 ###############################################################################
27 # OE_BASE - The root directory for all OE sources and development.
28 ###############################################################################
29 OE_BASE=${PWD}
30
31 ###############################################################################
32 # SET_ENVIRONMENT() - Setup environment variables for OE development
33 ###############################################################################
34 function set_environment()
35 {
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
36
37 #--------------------------------------------------------------------------
38 # If an env already exists, use it, otherwise generate it
39 #--------------------------------------------------------------------------
40 if [ -e ~/.oe/environment ] ; then
41 . ~/.oe/environment
42 else
43
44 mkdir -p ~/.oe/
45
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
46 #--------------------------------------------------------------------------
47 # Specify distribution information
48 #--------------------------------------------------------------------------
49 DISTRO="angstrom-2008.1"
50 DISTRO_DIRNAME=`echo $DISTRO | sed s#[.-]#_#g`
51
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
52 echo "export DISTRO=\"${DISTRO}\"" > ~/.oe/environment
53 echo "export DISTRO_DIRNAME=\"${DISTRO_DIRNAME}\"" >> ~/.oe/environment
54
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
55 #--------------------------------------------------------------------------
56 # Specify the root directory for your OpenEmbedded development
57 #--------------------------------------------------------------------------
58 OE_BUILD_DIR=${OE_BASE}/build
59 OE_BUILD_TMPDIR="${OE_BUILD_DIR}/tmp-${DISTRO_DIRNAME}"
60 OE_SOURCE_DIR=${OE_BASE}/sources
61 mkdir -p ${OE_BUILD_DIR}
62 mkdir -p ${OE_SOURCE_DIR}
63 export OE_BASE
64
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
65 echo "export OE_BASE=\"${OE_BASE}\"" >> ~/.oe/environment
66
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
67 #--------------------------------------------------------------------------
68 # Include up-to-date bitbake in our PATH.
69 #--------------------------------------------------------------------------
70 export PATH=${OE_SOURCE_DIR}/bitbake/bin:${PATH}
71
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
72 echo "export PATH=\"${PATH}\"" >> ~/.oe/environment
73
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
74 #--------------------------------------------------------------------------
75 # Make sure Bitbake doesn't filter out the following variables from our
76 # environment.
77 #--------------------------------------------------------------------------
78 export BB_ENV_EXTRAWHITE="MACHINE DISTRO http_proxy ftp_proxy no_proxy GIT_PROXY_COMMAND"
79
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
80 echo "export BB_ENV_EXTRAWHITE=\"${BB_ENV_EXTRAWHITE}\"" >> ~/.oe/environment
81
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
82 #--------------------------------------------------------------------------
83 # Specify proxy information
84 #--------------------------------------------------------------------------
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
85 if [ "x$PROXYHOST" != "x" ] ; then
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
86 export http_proxy=http://${PROXYHOST}:${PROXYPORT}/
87 export ftp_proxy=http://${PROXYHOST}:${PROXYPORT}/
88
89 export SVN_CONFIG_DIR=${OE_BUILD_DIR}/subversion_config
90 export GIT_CONFIG_DIR=${OE_BUILD_DIR}/git_config
91
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
92 echo "export http_proxy=\"${http_proxy}\"" >> ~/.oe/environment
93 echo "export ftp_proxy=\"${ftp_proxy}\"" >> ~/.oe/environment
94 echo "export SVN_CONFIG_DIR=\"${SVN_CONFIG_DIR}\"" >> ~/.oe/environment
95 echo "export GIT_CONFIG_DIR=\"${GIT_CONFIG_DIR}\"" >> ~/.oe/environment
96
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
97 config_svn_proxy
98 config_git_proxy
99 fi
100
101 #--------------------------------------------------------------------------
102 # Set up the bitbake path to find the OpenEmbedded recipes.
103 #--------------------------------------------------------------------------
104 export BBPATH=${OE_BUILD_DIR}:${OE_SOURCE_DIR}/org.openembedded.dev${BBPATH_EXTRA}
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
105
106 echo "export BBPATH=\"${BBPATH}\"" >> ~/.oe/environment
107
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
108 #--------------------------------------------------------------------------
109 # Reconfigure dash
110 #--------------------------------------------------------------------------
111 if [ $(readlink /bin/sh) = "dash" ] ; then
112 sudo dpkg-reconfigure dash
113 fi
8f98636 @koenkooi oebb: add usage note for ~/.oe/environment
koenkooi authored Mar 19, 2010
114
115 echo "There now is a sourceable script in ~/.oe/enviroment. You can do '. ~/.oe/environment' and run 'bitbake something' without this script"
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
116 fi # if -e ~/.oe/environment
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
117 }
118
119
120 ###############################################################################
121 # UPDATE_ALL() - Make sure everything is up to date
122 ###############################################################################
123 function update_all()
124 {
125 set_environment
126 update_bitbake
127 update_oe
128 }
129
130
131 ###############################################################################
132 # OE_BUILD() - Build an OE package or image
133 ###############################################################################
134 function oe_build()
135 {
136 set_environment
137 cd ${OE_BUILD_DIR}
138 if [ -z $MACHINE ] ; then
139 echo "Executing: bitbake" $*
140 bitbake $*
141 else
142 echo "Executing: MACHINE=${MACHINE} bitbake" $*
143 MACHINE=${MACHINE} bitbake $*
144 fi
145 }
146
147
148 ###############################################################################
149 # OE_CONFIG() - Configure OE for a target
150 ###############################################################################
151 function oe_config()
152 {
153 set_environment
154 config_oe
155 }
156
157
158 ###############################################################################
159 # UPDATE_BITBAKE() - Update Bitbake distribution
160 ###############################################################################
161 function update_bitbake()
162 {
6a43974 @koenkooi oebb: generate sourceable env file
koenkooi authored Mar 19, 2010
163 if [ "x$PROXYHOST" != "x" ] ; then
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
164 config_git_proxy
165 fi
166
167 if [ ! -d ${OE_SOURCE_DIR}/bitbake ]; then
168 echo Checking out bitbake
169 git clone git://git.openembedded.net/bitbake ${OE_SOURCE_DIR}/bitbake
170 cd ${OE_SOURCE_DIR}/bitbake && git checkout -b 1.8 origin/1.8
171 else
172 cd ${OE_SOURCE_DIR}/bitbake && git pull --rebase
173 fi
174 }
175
176
177 ###############################################################################
178 # UPDATE_OE() - Update OpenEmbedded distribution.
179 ###############################################################################
180 function update_oe()
181 {
e4d6fb8 oebb: protect call to git_proxy setup as well
Gregg Lebovitz authored Mar 23, 2010
182 if [ "x$PROXYHOST" != "x" ] ; then
183 config_git_proxy
184 fi
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
185
186 if [ ! -d ${OE_SOURCE_DIR}/org.openembedded.dev ]; then
187 echo Checking out OpenEmbedded
188 git clone "git://git.openembedded.net/openembedded" ${OE_SOURCE_DIR}/org.openembedded.dev
189 cd ${OE_SOURCE_DIR}/org.openembedded.dev
dea6d19 @koenkooi oebb: clean up variables and local.conf
koenkooi authored Mar 19, 2010
190 if [ ! -r ${OE_COMMIT_ID} ];
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
191 then
dea6d19 @koenkooi oebb: clean up variables and local.conf
koenkooi authored Mar 19, 2010
192 echo "Checkout commit id: ${OE_COMMIT_ID}"
193 git checkout -b install ${OE_COMMIT_ID}
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
194 else
195 git checkout -b org.openembedded.dev origin/org.openembedded.dev
196 fi
197 else
198 echo Updating OpenEmbedded
199 cd ${OE_SOURCE_DIR}/org.openembedded.dev
200 git pull --rebase
201 fi
202 }
203
204
205 ###############################################################################
206 # CONFIG_OE() - Configure OpenEmbedded
207 ###############################################################################
208 function config_oe()
209 {
210 #--------------------------------------------------------------------------
211 # Determine the proper machine name
212 #--------------------------------------------------------------------------
213 case ${CL_MACHINE} in
ab79e04 @jadonk Added aliases for the proper board names.
jadonk authored Mar 8, 2010
214 beagle|beagleboard)
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
215 MACHINE="beagleboard"
216 ;;
ab79e04 @jadonk Added aliases for the proper board names.
jadonk authored Mar 8, 2010
217 dm6446evm|davinci-evm)
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
218 MACHINE="davinci-dvevm"
219 ;;
220 omap3evm)
221 MACHINE="omap3evm"
222 ;;
ab79e04 @jadonk Added aliases for the proper board names.
jadonk authored Mar 8, 2010
223 shiva|omap3517-evm)
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
224 MACHINE="omap3517-evm"
225 ;;
226 *)
227 echo "Unknown machine ${CL_MACHINE}, passing it to OE directly"
228 MACHINE="${CL_MACHINE}"
229 ;;
230 esac
231
232 #--------------------------------------------------------------------------
233 # Write out the OE bitbake configuration file.
234 #--------------------------------------------------------------------------
235 mkdir -p ${OE_BUILD_DIR}/conf
236
237 # There's no need to rewrite local.conf when changing MACHINE
238 if [ ! -e ${OE_BUILD_DIR}/conf/local.conf ]; then
239 cat > ${OE_BUILD_DIR}/conf/local.conf <<_EOF
240 # Where to store sources
241 DL_DIR = "${OE_BUILD_DIR}/downloads"
242
243 INHERIT += "rm_work"
244
245 # Which files do we want to parse:
246 BBFILES := "${OE_SOURCE_DIR}/org.openembedded.dev/recipes/*/*.bb"
247 BBMASK = ""
248
249 # What kind of images do we want?
250 IMAGE_FSTYPES += "tar.bz2"
251
dea6d19 @koenkooi oebb: clean up variables and local.conf
koenkooi authored Mar 19, 2010
252 # Make use of SMP:
253 # PARALLEL_MAKE specifies how many concurrent compiler threads are spawned per bitbake process
254 # BB_NUMBER_THREADS specifies how many concurrent bitbake tasks will be run
255 #PARALLEL_MAKE = "-j2"
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
256 BB_NUMBER_THREADS = "2"
257
258 DISTRO = "${DISTRO}"
259 MACHINE ?= "${MACHINE}"
260
261 # Set TMPDIR instead of defaulting it to $pwd/tmp
262 TMPDIR = "${OE_BUILD_TMPDIR}"
263
264 # Go through the Firewall
265 #HTTP_PROXY = "http://${PROXYHOST}:${PROXYPORT}/"
266
267 _EOF
268 fi
269 }
270
271 ###############################################################################
272 # CONFIG_SVN_PROXY() - Configure subversion proxy information
273 ###############################################################################
274 function config_svn_proxy()
275 {
276 if [ ! -f ${SVN_CONFIG_DIR}/servers ]
277 then
278 mkdir -p ${SVN_CONFIG_DIR}
279 cat >> ${SVN_CONFIG_DIR}/servers <<_EOF
280 [global]
281 http-proxy-host = ${PROXYHOST}
282 http-proxy-port = ${PROXYPORT}
283 _EOF
284 fi
285 }
286
287
288 ###############################################################################
289 # CONFIG_GIT_PROXY() - Configure GIT proxy information
290 ###############################################################################
291 function config_git_proxy()
292 {
293 if [ ! -f ${GIT_CONFIG_DIR}/git-proxy.sh ]
294 then
295 mkdir -p ${GIT_CONFIG_DIR}
296 cat > ${GIT_CONFIG_DIR}/git-proxy.sh <<_EOF
297 if [ -x /bin/env ] ; then
298 exec /bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
299 else
300 exec /usr/bin/env corkscrew ${PROXYHOST} ${PROXYPORT} \$*
301 fi
302 _EOF
303 chmod +x ${GIT_CONFIG_DIR}/git-proxy.sh
304 fi
305 export GIT_PROXY_COMMAND=${GIT_CONFIG_DIR}/git-proxy.sh
306 }
307
308
309 ###############################################################################
310 # Build the specified OE packages or images.
311 ###############################################################################
312 if [ $# -gt 0 ]
313 then
314 if [ $1 = "update" ]
315 then
316 shift
317 if [ ! -r $1 ]; then
318 if [ $1 == "commit" ]
319 then
320 shift
dea6d19 @koenkooi oebb: clean up variables and local.conf
koenkooi authored Mar 19, 2010
321 OE_COMMIT_ID=$1
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
322 fi
323 fi
324 update_all
325 exit 0
326 fi
327
328 if [ $1 = "bitbake" ]
329 then
330 shift
331 oe_build $*
332 exit 0
333 fi
334
335 if [ $1 = "config" ]
336 then
337 shift
338 CL_MACHINE=$1
339 shift
340 oe_config $*
341 exit 0
342 fi
343 fi
344
345 # Help Screen
346 echo ""
347 echo "Usage: $0 config <machine>"
348 echo " $0 update"
349 echo " $0 bitbake <bitbake target>"
350 echo ""
351 echo "You must invoke \"$0 config <machine>\" and then \"$0 update\" prior"
352 echo "to your first bitbake command"
353 echo ""
354 echo "The <machine> argument can be one of the following"
ab79e04 @jadonk Added aliases for the proper board names.
jadonk authored Mar 8, 2010
355 echo " beagleboard: BeagleBoard"
356 echo " davinci-evm: DM6446 EVM"
357 echo " omap3evm: OMAP35x EVM"
dea6d19 @koenkooi oebb: clean up variables and local.conf
koenkooi authored Mar 19, 2010
358 echo " am3517-evm: AM3517 (Shiva) EVM"
f984361 @koenkooi Add first setup script, imported from TI wiki
koenkooi authored Mar 8, 2010
359 echo ""
360 echo "Other machines are valid as well, but listing those would make this message way too long"
Something went wrong with that request. Please try again.