summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2005-08-31 10:47:56 (GMT)
committerRichard Purdie <richard@openedhand.com>2005-08-31 10:47:56 (GMT)
commitf54da734eb7b69e8e34de505bd89a13479e230e0 (patch)
treef796bea6f5683dfe3d591ca5390d12fd78e59c96 /bitbake
parent4b46c1f6e891b1ddd5968536440b888661fade3e (diff)
downloadpoky-f54da734eb7b69e8e34de505bd89a13479e230e0.tar.gz
Initial population
git-svn-id: https://svn.o-hand.com/repos/poky@2 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/AUTHORS5
-rw-r--r--bitbake/ChangeLog35
-rw-r--r--bitbake/MANIFEST27
-rw-r--r--bitbake/TODO18
-rwxr-xr-xbitbake/bin/bbimage154
-rwxr-xr-xbitbake/bin/bitbake927
-rw-r--r--bitbake/bin/bitbakecbin0 -> 27715 bytes
-rwxr-xr-xbitbake/bin/bitdoc529
-rw-r--r--bitbake/classes/base.bbclass79
-rw-r--r--bitbake/conf/bitbake.conf55
-rw-r--r--bitbake/contrib/README1
-rw-r--r--bitbake/contrib/bbdev.sh31
-rw-r--r--bitbake/doc/COPYING.GPL340
-rw-r--r--bitbake/doc/COPYING.MIT17
-rw-r--r--bitbake/doc/manual/Makefile56
-rw-r--r--bitbake/doc/manual/html.css281
-rw-r--r--bitbake/doc/manual/usermanual.xml361
-rw-r--r--bitbake/lib/bb/__init__.py1266
-rw-r--r--bitbake/lib/bb/__init__.pycbin0 -> 29886 bytes
-rw-r--r--bitbake/lib/bb/build.py395
-rw-r--r--bitbake/lib/bb/build.pycbin0 -> 12365 bytes
-rw-r--r--bitbake/lib/bb/data.py580
-rw-r--r--bitbake/lib/bb/data.pycbin0 -> 18362 bytes
-rw-r--r--bitbake/lib/bb/data_dict.pycbin0 -> 6854 bytes
-rw-r--r--bitbake/lib/bb/data_smart.py351
-rw-r--r--bitbake/lib/bb/data_smart.pycbin0 -> 11522 bytes
-rw-r--r--bitbake/lib/bb/event.py210
-rw-r--r--bitbake/lib/bb/event.pycbin0 -> 8226 bytes
-rw-r--r--bitbake/lib/bb/fetch.py656
-rw-r--r--bitbake/lib/bb/fetch.pycbin0 -> 20663 bytes
-rw-r--r--bitbake/lib/bb/make.pycbin0 -> 8013 bytes
-rw-r--r--bitbake/lib/bb/manifest.py144
-rw-r--r--bitbake/lib/bb/manifest.pycbin0 -> 3295 bytes
-rw-r--r--bitbake/lib/bb/parse/BBHandler.pycbin0 -> 10831 bytes
-rw-r--r--bitbake/lib/bb/parse/ConfHandler.pycbin0 -> 6391 bytes
-rw-r--r--bitbake/lib/bb/parse/__init__.py70
-rw-r--r--bitbake/lib/bb/parse/__init__.pycbin0 -> 3254 bytes
-rw-r--r--bitbake/lib/bb/parse/parse_c/bitbakeparser.l288
-rw-r--r--bitbake/lib/bb/parse/parse_c/bitbakeparser.py133
-rw-r--r--bitbake/lib/bb/parse/parse_c/bitbakeparser.y161
-rw-r--r--bitbake/lib/bb/parse/parse_c/lexer.h41
-rw-r--r--bitbake/lib/bb/parse/parse_c/token.h83
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py378
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.pycbin0 -> 10825 bytes
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.py199
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.pycbin0 -> 6673 bytes
-rw-r--r--bitbake/lib/bb/parse/parse_py/__init__.py32
-rw-r--r--bitbake/lib/bb/parse/parse_py/__init__.pycbin0 -> 1185 bytes
-rw-r--r--bitbake/lib/bb/shell.py779
-rw-r--r--bitbake/lib/bb/shell.pycbin0 -> 27748 bytes
-rw-r--r--bitbake/lib/bb/utils.py71
-rw-r--r--bitbake/lib/bb/utils.pycbin0 -> 2313 bytes
-rwxr-xr-xbitbake/setup.py69
53 files changed, 8822 insertions, 0 deletions
diff --git a/bitbake/AUTHORS b/bitbake/AUTHORS
new file mode 100644
index 0000000..4129e4c
--- /dev/null
+++ b/bitbake/AUTHORS
@@ -0,0 +1,5 @@
1Holger Freyther <zecke@handhelds.org>
2Chris Larson <kergoth@handhelds.org>
3Mickey Lauer <mickey@Vanille.de>
4Holger Schurig <holgerschurig@gmx.de>
5Phil Blundell <pb@handhelds.org>
diff --git a/bitbake/ChangeLog b/bitbake/ChangeLog
new file mode 100644
index 0000000..db503ff
--- /dev/null
+++ b/bitbake/ChangeLog
@@ -0,0 +1,35 @@
1Changes in BitBake 1.3.2:
2 - reintegration of make.py into BitBake
3 - bbread is gone, use bitbake -e
4 - lots of shell updates and bugfixes
5 - Introduction of the .= and =. operator
6 - Sort variables, keys and groups in bitdoc
7 - Fix regression in the handling of BBCOLLECTIONS
8 - Update the bitbake usermanual
9
10Changes in BitBake 1.3.0:
11 - add bitbake interactive shell (bitbake -i)
12 - refactor bitbake utility in OO style
13 - kill default arguments in methods in the bb.data module
14 - kill default arguments in methods in the bb.fetch module
15 - the http/https/ftp fetcher will fail if the to be
16 downloaded file was not found in DL_DIR (this is needed
17 to avoid unpacking the sourceforge mirror page)
18 - Switch to a cow like data instance for persistent and non
19 persisting mode (called data_smart.py)
20 - Changed the callback of bb.make.collect_bbfiles to carry
21 additional parameters
22 - Drastically reduced the amount of needed RAM by not holding
23 each data instance in memory when using a cache/persistent
24 storage
25
26Changes in BitBake 1.2.1:
27 The 1.2.1 release is meant as a intermediate release to lay the
28 ground for more radical changes. The most notable changes are:
29
30 - Do not hardcode {}, use bb.data.init() instead if you want to
31 get a instance of a data class
32 - bb.data.init() is a factory and the old bb.data methods are delegates
33 - Do not use deepcopy use bb.data.createCopy() instead.
34 - Removed default arguments in bb.fetch
35
diff --git a/bitbake/MANIFEST b/bitbake/MANIFEST
new file mode 100644
index 0000000..71e3605
--- /dev/null
+++ b/bitbake/MANIFEST
@@ -0,0 +1,27 @@
1AUTHORS
2ChangeLog
3MANIFEST
4setup.py
5bin/bbimage
6bin/bitbake
7lib/bb/__init__.py
8lib/bb/build.py
9lib/bb/data.py
10lib/bb/data_smart.py
11lib/bb/event.py
12lib/bb/fetch.py
13lib/bb/manifest.py
14lib/bb/parse/__init__.py
15lib/bb/parse/parse_py/BBHandler.py
16lib/bb/parse/parse_py/ConfHandler.py
17lib/bb/parse/parse_py/__init__.py
18lib/bb/shell.py
19lib/bb/utils.py
20doc/COPYING.GPL
21doc/COPYING.MIT
22doc/manual/html.css
23doc/manual/Makefile
24doc/manual/usermanual.xml
25contrib/bbdev.sh
26conf/bitbake.conf
27classes/base.bbclass
diff --git a/bitbake/TODO b/bitbake/TODO
new file mode 100644
index 0000000..511fae4
--- /dev/null
+++ b/bitbake/TODO
@@ -0,0 +1,18 @@
1On popular request by popular people a list of tasks to-do:
2
3 -Kill insecure usage of os.system either by properly escaping
4 the strings or a faster replacement not involving /bin/sh
5 -Introduce a -p option to automatically hotshot/profile the
6 run
7 -Cache dependencies separately and invalidate them when any file
8 changed.
9 -...
10
11
12DONE:
13· -On generating the inter package deps do not parse each file multiply
14· times.
15 -We build the lists while parsing the data now
16· (WAS: Do not generate the world dependency tree, only when someone
17· requests it.
18
diff --git a/bitbake/bin/bbimage b/bitbake/bin/bbimage
new file mode 100755
index 0000000..df6caa2
--- /dev/null
+++ b/bitbake/bin/bbimage
@@ -0,0 +1,154 @@
1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# Copyright (C) 2003 Chris Larson
6#
7# This program is free software; you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2 of the License, or (at your option) any later
10# version.
11#
12# This program is distributed in the hope that it will be useful, but WITHOUT
13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along with
17# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18# Place, Suite 330, Boston, MA 02111-1307 USA.
19
20import sys, os
21sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
22import bb
23from bb import *
24
25__version__ = 1.0
26type = "jffs2"
27cfg_bb = data.init()
28cfg_oespawn = data.init()
29
30
31def usage():
32 print "Usage: bbimage [options ...]"
33 print "Creates an image for a target device from a root filesystem,"
34 print "obeying configuration parameters from the BitBake"
35 print "configuration files, thereby easing handling of deviceisms."
36 print ""
37 print " %s\t\t%s" % ("-r [arg], --root [arg]", "root directory (default=${IMAGE_ROOTFS})")
38 print " %s\t\t%s" % ("-t [arg], --type [arg]", "image type (jffs2[default], cramfs)")
39 print " %s\t\t%s" % ("-n [arg], --name [arg]", "image name (override IMAGE_NAME variable)")
40 print " %s\t\t%s" % ("-v, --version", "output version information and exit")
41 sys.exit(0)
42
43def version():
44 print "BitBake Build Tool Core version %s" % bb.__version__
45 print "BBImage version %s" % __version__
46
47def emit_bb(d, base_d = {}):
48 for v in d.keys():
49 if d[v] != base_d[v]:
50 data.emit_var(v, d)
51
52def getopthash(l):
53 h = {}
54 for (opt, val) in l:
55 h[opt] = val
56 return h
57
58import getopt
59try:
60 (opts, args) = getopt.getopt(sys.argv[1:], 'vr:t:e:n:', [ 'version', 'root=', 'type=', 'bbfile=', 'name=' ])
61except getopt.GetoptError:
62 usage()
63
64# handle opts
65opthash = getopthash(opts)
66
67if '--version' in opthash or '-v' in opthash:
68 version()
69 sys.exit(0)
70
71try:
72 cfg_bb = parse.handle(os.path.join('conf', 'bitbake.conf'), cfg_bb)
73except IOError:
74 fatal("Unable to open bitbake.conf")
75
76# sanity check
77if cfg_bb is None:
78 fatal("Unable to open/parse %s" % os.path.join('conf', 'bitbake.conf'))
79 usage(1)
80
81rootfs = None
82extra_files = []
83
84if '--root' in opthash:
85 rootfs = opthash['--root']
86if '-r' in opthash:
87 rootfs = opthash['-r']
88
89if '--type' in opthash:
90 type = opthash['--type']
91if '-t' in opthash:
92 type = opthash['-t']
93
94if '--bbfile' in opthash:
95 extra_files.append(opthash['--bbfile'])
96if '-e' in opthash:
97 extra_files.append(opthash['-e'])
98
99for f in extra_files:
100 try:
101 cfg_bb = parse.handle(f, cfg_bb)
102 except IOError:
103 print "unable to open %s" % f
104
105if not rootfs:
106 rootfs = data.getVar('IMAGE_ROOTFS', cfg_bb, 1)
107
108if not rootfs:
109 bb.fatal("IMAGE_ROOTFS not defined")
110
111data.setVar('IMAGE_ROOTFS', rootfs, cfg_bb)
112
113from copy import copy, deepcopy
114localdata = data.createCopy(cfg_bb)
115
116overrides = data.getVar('OVERRIDES', localdata)
117if not overrides:
118 bb.fatal("OVERRIDES not defined.")
119data.setVar('OVERRIDES', '%s:%s' % (overrides, type), localdata)
120data.update_data(localdata)
121data.setVar('OVERRIDES', overrides, localdata)
122
123if '-n' in opthash:
124 data.setVar('IMAGE_NAME', opthash['-n'], localdata)
125if '--name' in opthash:
126 data.setVar('IMAGE_NAME', opthash['--name'], localdata)
127
128topdir = data.getVar('TOPDIR', localdata, 1) or os.getcwd()
129
130cmd = data.getVar('IMAGE_CMD', localdata, 1)
131if not cmd:
132 bb.fatal("IMAGE_CMD not defined")
133
134outdir = data.getVar('DEPLOY_DIR_IMAGE', localdata, 1)
135if not outdir:
136 bb.fatal('DEPLOY_DIR_IMAGE not defined')
137mkdirhier(outdir)
138
139#depends = data.getVar('IMAGE_DEPENDS', localdata, 1) or ""
140#if depends:
141# bb.note("Spawning bbmake to satisfy dependencies: %s" % depends)
142# ret = os.system('bbmake %s' % depends)
143# if ret != 0:
144# bb.error("executing bbmake to satisfy dependencies")
145
146bb.note("Executing %s" % cmd)
147data.setVar('image_cmd', cmd, localdata)
148data.setVarFlag('image_cmd', 'func', 1, localdata)
149try:
150 bb.build.exec_func('image_cmd', localdata)
151except bb.build.FuncFailed:
152 sys.exit(1)
153#ret = os.system(cmd)
154#sys.exit(ret)
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
new file mode 100755
index 0000000..d327a69
--- /dev/null
+++ b/bitbake/bin/bitbake
@@ -0,0 +1,927 @@
1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# Copyright (C) 2003, 2004 Chris Larson
6# Copyright (C) 2003, 2004 Phil Blundell
7# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
8# Copyright (C) 2005 Holger Hans Peter Freyther
9# Copyright (C) 2005 ROAD GmbH
10#
11# This program is free software; you can redistribute it and/or modify it under
12# the terms of the GNU General Public License as published by the Free Software
13# Foundation; either version 2 of the License, or (at your option) any later
14# version.
15#
16# This program is distributed in the hope that it will be useful, but WITHOUT
17# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License along with
21# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22# Place, Suite 330, Boston, MA 02111-1307 USA.
23
24import sys, os, getopt, glob, copy, os.path, re, time
25sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
26import bb
27from bb import utils, data, parse, debug, event, fatal
28from sets import Set
29import itertools, optparse
30
31parsespin = itertools.cycle( r'|/-\\' )
32bbdebug = 0
33
34__version__ = "1.3.2"
35
36#============================================================================#
37# BBParsingStatus
38#============================================================================#
39class BBParsingStatus:
40 """
41 The initial idea for this status class is to use the data when it is
42 already loaded instead of loading it from various place over and over
43 again.
44 """
45
46 def __init__(self):
47 self.cache_dirty = False
48 self.providers = {}
49 self.bbfile_priority = {}
50 self.bbfile_config_priorities = []
51 self.ignored_depedencies = None
52 self.possible_world = []
53 self.world_target = Set()
54 self.pkg_pn = {}
55 self.pkg_fn = {}
56 self.pkg_pvpr = {}
57 self.pkg_dp = {}
58 self.pn_provides = {}
59 self.all_depends = Set()
60
61 def handle_bb_data(self, file_name, bb_data, cached):
62 """
63 We will fill the dictionaries with the stuff we
64 need for building the tree more fast
65 """
66 if bb_data == None:
67 return
68
69 if not cached:
70 self.cache_dirty = True
71
72 pn = bb.data.getVar('PN', bb_data, True)
73 pv = bb.data.getVar('PV', bb_data, True)
74 pr = bb.data.getVar('PR', bb_data, True)
75 dp = int(bb.data.getVar('DEFAULT_PREFERENCE', bb_data, True) or "0")
76 provides = Set([pn] + (bb.data.getVar("PROVIDES", bb_data, 1) or "").split())
77 depends = (bb.data.getVar("DEPENDS", bb_data, True) or "").split()
78
79
80 # build PackageName to FileName lookup table
81 if pn not in self.pkg_pn:
82 self.pkg_pn[pn] = []
83 self.pkg_pn[pn].append(file_name)
84
85 # build FileName to PackageName lookup table
86 self.pkg_fn[file_name] = pn
87 self.pkg_pvpr[file_name] = (pv,pr)
88 self.pkg_dp[file_name] = dp
89
90 # Build forward and reverse provider hashes
91 # Forward: virtual -> [filenames]
92 # Reverse: PN -> [virtuals]
93 if pn not in self.pn_provides:
94 self.pn_provides[pn] = Set()
95 self.pn_provides[pn] |= provides
96
97 for provide in provides:
98 if provide not in self.providers:
99 self.providers[provide] = []
100 self.providers[provide].append(file_name)
101
102 for dep in depends:
103 self.all_depends.add(dep)
104
105 # Collect files we may need for possible world-dep
106 # calculations
107 if not bb.data.getVar('BROKEN', bb_data, True) and not bb.data.getVar('EXCLUDE_FROM_WORLD', bb_data, True):
108 self.possible_world.append(file_name)
109
110
111#============================================================================#
112# BBStatistics
113#============================================================================#
114class BBStatistics:
115 """
116 Manage build statistics for one run
117 """
118 def __init__(self ):
119 self.attempt = 0
120 self.success = 0
121 self.fail = 0
122 self.deps = 0
123
124 def show( self ):
125 print "Build statistics:"
126 print " Attempted builds: %d" % self.attempt
127 if self.fail:
128 print " Failed builds: %d" % self.fail
129 if self.deps:
130 print " Dependencies not satisfied: %d" % self.deps
131 if self.fail or self.deps: return 1
132 else: return 0
133
134
135#============================================================================#
136# BBOptions
137#============================================================================#
138class BBConfiguration( object ):
139 """
140 Manages build options and configurations for one run
141 """
142 def __init__( self, options ):
143 for key, val in options.__dict__.items():
144 setattr( self, key, val )
145 self.data = data.init()
146
147#============================================================================#
148# BBCooker
149#============================================================================#
150class BBCooker:
151 """
152 Manages one bitbake build run
153 """
154
155 ParsingStatus = BBParsingStatus # make it visible from the shell
156 Statistics = BBStatistics # make it visible from the shell
157
158 def __init__( self ):
159 self.build_cache_fail = []
160 self.build_cache = []
161 self.building_list = []
162 self.build_path = []
163 self.consider_msgs_cache = []
164 self.preferred = {}
165 self.stats = BBStatistics()
166 self.status = None
167
168 self.pkgdata = None
169 self.cache = None
170
171 def tryBuildPackage( self, fn, item, the_data ):
172 """Build one package"""
173 bb.event.fire(bb.event.PkgStarted(item, the_data))
174 try:
175 self.stats.attempt += 1
176 if self.configuration.force:
177 bb.data.setVarFlag('do_%s' % self.configuration.cmd, 'force', 1, the_data)
178 if not self.configuration.dry_run:
179 bb.build.exec_task('do_%s' % self.configuration.cmd, the_data)
180 bb.event.fire(bb.event.PkgSucceeded(item, the_data))
181 self.build_cache.append(fn)
182 return True
183 except bb.build.FuncFailed:
184 self.stats.fail += 1
185 bb.error("task stack execution failed")
186 bb.event.fire(bb.event.PkgFailed(item, the_data))
187 self.build_cache_fail.append(fn)
188 raise
189 except bb.build.EventException, e:
190 self.stats.fail += 1
191 event = e.args[1]
192 bb.error("%s event exception, aborting" % bb.event.getName(event))
193 bb.event.fire(bb.event.PkgFailed(item, the_data))
194 self.build_cache_fail.append(fn)
195 raise
196
197 def tryBuild( self, fn, virtual ):
198 """Build a provider and its dependencies"""
199 if fn in self.building_list:
200 bb.error("%s depends on itself (eventually)" % fn)
201 bb.error("upwards chain is: %s" % (" -> ".join(self.build_path)))
202 return False
203
204 the_data = self.pkgdata[fn]
205 item = self.status.pkg_fn[fn]
206
207 self.building_list.append(fn)
208
209 pathstr = "%s (%s)" % (item, virtual)
210 self.build_path.append(pathstr)
211
212 depends_list = (bb.data.getVar('DEPENDS', the_data, 1) or "").split()
213 if self.configuration.verbose:
214 bb.note("current path: %s" % (" -> ".join(self.build_path)))
215 bb.note("dependencies for %s are: %s" % (item, " ".join(depends_list)))
216
217 try:
218 failed = False
219
220 depcmd = self.configuration.cmd
221 bbdepcmd = bb.data.getVarFlag('do_%s' % self.configuration.cmd, 'bbdepcmd', the_data)
222 if bbdepcmd is not None:
223 if bbdepcmd == "":
224 depcmd = None
225 else:
226 depcmd = bbdepcmd
227
228 if depcmd:
229 oldcmd = self.configuration.cmd
230 self.configuration.cmd = depcmd
231
232 for dependency in depends_list:
233 if dependency in self.status.ignored_dependencies:
234 continue
235 if not depcmd:
236 continue
237 if self.buildProvider( dependency ) == 0:
238 bb.error("dependency %s (for %s) not satisfied" % (dependency,item))
239 failed = True
240 if self.configuration.abort:
241 break
242
243 if depcmd:
244 self.configuration.cmd = oldcmd
245
246 if failed:
247 self.stats.deps += 1
248 return False
249
250 if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data):
251 self.build_cache.append(fn)
252 return True
253
254 return self.tryBuildPackage( fn, item, the_data )
255
256 finally:
257 self.building_list.remove(fn)
258 self.build_path.remove(pathstr)
259
260 def findBestProvider( self, pn, pkg_pn = None):
261 """
262 If there is a PREFERRED_VERSION, find the highest-priority bbfile
263 providing that version. If not, find the latest version provided by
264 an bbfile in the highest-priority set.
265 """
266 if not pkg_pn:
267 pkg_pn = self.status.pkg_pn
268
269 files = pkg_pn[pn]
270 priorities = {}
271 for f in files:
272 priority = self.status.bbfile_priority[f]
273 if priority not in priorities:
274 priorities[priority] = []
275 priorities[priority].append(f)
276 p_list = priorities.keys()
277 p_list.sort(lambda a, b: a - b)
278 tmp_pn = []
279 for p in p_list:
280 tmp_pn = [priorities[p]] + tmp_pn
281
282 preferred_file = None
283
284 preferred_v = bb.data.getVar('PREFERRED_VERSION_%s' % pn, self.configuration.data, 1)
285 if preferred_v:
286 m = re.match('(.*)_(.*)', preferred_v)
287 if m:
288 preferred_v = m.group(1)
289 preferred_r = m.group(2)
290 else:
291 preferred_r = None
292
293 for file_set in tmp_pn:
294 for f in file_set:
295 pv,pr = self.status.pkg_pvpr[f]
296 if preferred_v == pv and (preferred_r == pr or preferred_r == None):
297 preferred_file = f
298 preferred_ver = (pv, pr)
299 break
300 if preferred_file:
301 break;
302 if preferred_r:
303 pv_str = '%s-%s' % (preferred_v, preferred_r)
304 else:
305 pv_str = preferred_v
306 if preferred_file is None:
307 bb.note("preferred version %s of %s not available" % (pv_str, pn))
308 else:
309 bb.debug(1, "selecting %s as PREFERRED_VERSION %s of package %s" % (preferred_file, pv_str, pn))
310
311 # get highest priority file set
312 files = tmp_pn[0]
313 latest = None
314 latest_p = 0
315 latest_f = None
316 for file_name in files:
317 pv,pr = self.status.pkg_pvpr[file_name]
318 dp = self.status.pkg_dp[file_name]
319
320 if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pv, pr)) < 0)) or (dp > latest_p):
321 latest = (pv, pr)
322 latest_f = file_name
323 latest_p = dp
324 if preferred_file is None:
325 preferred_file = latest_f
326 preferred_ver = latest
327
328 return (latest,latest_f,preferred_ver, preferred_file)
329
330 def showVersions( self ):
331 pkg_pn = self.status.pkg_pn
332 preferred_versions = {}
333 latest_versions = {}
334
335 # Sort by priority
336 for pn in pkg_pn.keys():
337 (last_ver,last_file,pref_ver,pref_file) = self.findBestProvider(pn)
338 preferred_versions[pn] = (pref_ver, pref_file)
339 latest_versions[pn] = (last_ver, last_file)
340
341 pkg_list = pkg_pn.keys()
342 pkg_list.sort()
343
344 for p in pkg_list:
345 pref = preferred_versions[p]
346 latest = latest_versions[p]
347
348 if pref != latest:
349 prefstr = pref[0][0] + "-" + pref[0][1]
350 else:
351 prefstr = ""
352
353 print "%-30s %20s %20s" % (p, latest[0][0] + "-" + latest[0][1],
354 prefstr)
355
356 def showEnvironment( self ):
357 """Show the outer or per-package environment"""
358 if self.configuration.buildfile:
359 try:
360 self.configuration.data, fromCache = self.load_bbfile( self.configuration.buildfile )
361 except IOError, e:
362 fatal("Unable to read %s: %s" % ( self.configuration.buildfile, e ))
363 except Exception, e:
364 fatal("%s" % e)
365 # emit variables and shell functions
366 try:
367 data.update_data( self.configuration.data )
368 data.emit_env(sys.__stdout__, self.configuration.data, True)
369 except Exception, e:
370 fatal("%s" % e)
371 # emit the metadata which isnt valid shell
372 for e in self.configuration.data.keys():
373 if data.getVarFlag( e, 'python', self.configuration.data ):
374 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, self.configuration.data, 1)))
375
376 def buildProvider( self, item ):
377 fn = None
378
379 discriminated = False
380
381 if item not in self.status.providers:
382 bb.error("Nothing provides %s" % item)
383 return 0
384
385 all_p = self.status.providers[item]
386
387 for p in all_p:
388 if p in self.build_cache:
389 bb.debug(1, "already built %s in this run\n" % p)
390 return 1
391
392 eligible = []
393 preferred_versions = {}
394
395 # Collate providers by PN
396 pkg_pn = {}
397 for p in all_p:
398 pn = self.status.pkg_fn[p]
399 if pn not in pkg_pn:
400 pkg_pn[pn] = []
401 pkg_pn[pn].append(p)
402
403 bb.debug(1, "providers for %s are: %s" % (item, pkg_pn.keys()))
404
405 for pn in pkg_pn.keys():
406 preferred_versions[pn] = self.findBestProvider(pn, pkg_pn)[2:4]
407 eligible.append(preferred_versions[pn][1])
408
409 for p in eligible:
410 if p in self.build_cache_fail:
411 bb.debug(1, "rejecting already-failed %s" % p)
412 eligible.remove(p)
413
414 if len(eligible) == 0:
415 bb.error("no eligible providers for %s" % item)
416 return 0
417
418 # look to see if one of them is already staged, or marked as preferred.
419 # if so, bump it to the head of the queue
420 for p in all_p:
421 the_data = self.pkgdata[p]
422 pn = bb.data.getVar('PN', the_data, 1)
423 pv = bb.data.getVar('PV', the_data, 1)
424 pr = bb.data.getVar('PR', the_data, 1)
425 tmpdir = bb.data.getVar('TMPDIR', the_data, 1)
426 stamp = '%s/stamps/%s-%s-%s.do_populate_staging' % (tmpdir, pn, pv, pr)
427 if os.path.exists(stamp):
428 (newvers, fn) = preferred_versions[pn]
429 if not fn in eligible:
430 # package was made ineligible by already-failed check
431 continue
432 oldver = "%s-%s" % (pv, pr)
433 newver = '-'.join(newvers)
434 if (newver != oldver):
435 extra_chat = "; upgrading from %s to %s" % (oldver, newver)
436 else:
437 extra_chat = ""
438 if self.configuration.verbose:
439 bb.note("selecting already-staged %s to satisfy %s%s" % (pn, item, extra_chat))
440 eligible.remove(fn)
441 eligible = [fn] + eligible
442 discriminated = True
443 break
444
445 prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % item, self.configuration.data, 1)
446 if prefervar:
447 self.preferred[item] = prefervar
448
449 if item in self.preferred:
450 for p in eligible:
451 pn = self.status.pkg_fn[p]
452 if self.preferred[item] == pn:
453 if self.configuration.verbose:
454 bb.note("selecting %s to satisfy %s due to PREFERRED_PROVIDERS" % (pn, item))
455 eligible.remove(p)
456 eligible = [p] + eligible
457 discriminated = True
458 break
459
460 if len(eligible) > 1 and discriminated == False:
461 if item not in self.consider_msgs_cache:
462 providers_list = []
463 for fn in eligible:
464 providers_list.append(self.status.pkg_fn[fn])
465 bb.note("multiple providers are available (%s);" % ", ".join(providers_list))
466 bb.note("consider defining PREFERRED_PROVIDER_%s" % item)
467 self.consider_msgs_cache.append(item)
468
469
470 # run through the list until we find one that we can build
471 for fn in eligible:
472 bb.debug(2, "selecting %s to satisfy %s" % (fn, item))
473 if self.tryBuild(fn, item):
474 return 1
475
476 bb.note("no buildable providers for %s" % item)
477 return 0
478
479 def buildDepgraph( self ):
480 all_depends = self.status.all_depends
481 pn_provides = self.status.pn_provides
482
483 def calc_bbfile_priority(filename):
484 for (regex, pri) in self.status.bbfile_config_priorities:
485 if regex.match(filename):
486 return pri
487 return 0
488
489 # Handle PREFERRED_PROVIDERS
490 for p in (bb.data.getVar('PREFERRED_PROVIDERS', self.configuration.data, 1) or "").split():
491 (providee, provider) = p.split(':')
492 if providee in self.preferred and self.preferred[providee] != provider:
493 bb.error("conflicting preferences for %s: both %s and %s specified" % (providee, provider, self.preferred[providee]))
494 self.preferred[providee] = provider
495
496 # Calculate priorities for each file
497 for p in self.pkgdata.keys():
498 self.status.bbfile_priority[p] = calc_bbfile_priority(p)
499
500 # Build package list for "bitbake world"
501 bb.debug(1, "collating packages for \"world\"")
502 for f in self.status.possible_world:
503 terminal = True
504 pn = self.status.pkg_fn[f]
505
506 for p in pn_provides[pn]:
507 if p.startswith('virtual/'):
508 bb.debug(2, "skipping %s due to %s provider starting with virtual/" % (f, p))
509 terminal = False
510 break
511 for pf in self.status.providers[p]:
512 if self.status.pkg_fn[pf] != pn:
513 bb.debug(2, "skipping %s due to both us and %s providing %s" % (f, pf, p))
514 terminal = False
515 break
516 if terminal:
517 self.status.world_target.add(pn)
518
519 # drop reference count now
520 self.status.possible_world = None
521 self.status.all_depends = None
522
523 def myProgressCallback( self, x, y, f, file_data, from_cache ):
524 # feed the status with new input
525 self.status.handle_bb_data(f, file_data, from_cache)
526
527 if bbdebug > 0:
528 return
529 if os.isatty(sys.stdout.fileno()):
530 sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) )
531 sys.stdout.flush()
532 else:
533 if x == 1:
534 sys.stdout.write("Parsing .bb files, please wait...")
535 sys.stdout.flush()
536 if x == y:
537 sys.stdout.write("done.")
538 sys.stdout.flush()
539
540 def interactiveMode( self ):
541 """Drop off into a shell"""
542 try:
543 from bb import shell
544 except ImportError, details:
545 bb.fatal("Sorry, shell not available (%s)" % details )
546 else:
547 bb.data.update_data( self.configuration.data )
548 shell.start( self )
549 sys.exit( 0 )
550
551 def parseConfigurationFile( self, afile ):
552 try:
553 self.configuration.data = bb.parse.handle( afile, self.configuration.data )
554 except IOError:
555 bb.fatal( "Unable to open %s" % afile )
556 except bb.parse.ParseError, details:
557 bb.fatal( "Unable to parse %s (%s)" % (afile, details) )
558
559 def handleCollections( self, collections ):
560 """Handle collections"""
561 if collections:
562 collection_list = collections.split()
563 for c in collection_list:
564 regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, self.configuration.data, 1)
565 if regex == None:
566 bb.error("BBFILE_PATTERN_%s not defined" % c)
567 continue
568 priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, self.configuration.data, 1)
569 if priority == None:
570 bb.error("BBFILE_PRIORITY_%s not defined" % c)
571 continue
572 try:
573 cre = re.compile(regex)
574 except re.error:
575 bb.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
576 continue
577 try:
578 pri = int(priority)
579 self.status.bbfile_config_priorities.append((cre, pri))
580 except ValueError:
581 bb.error("invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))
582
583
584 def cook( self, configuration, args ):
585 self.configuration = configuration
586
587 if not self.configuration.cmd:
588 self.configuration.cmd = "build"
589
590 if self.configuration.debug:
591 bb.debug_level = self.configuration.debug
592
593 self.configuration.data = bb.data.init()
594
595 for f in self.configuration.file:
596 self.parseConfigurationFile( f )
597
598 self.parseConfigurationFile( os.path.join( "conf", "bitbake.conf" ) )
599
600 if self.configuration.show_environment:
601 self.showEnvironment()
602 sys.exit( 0 )
603
604 # inject custom variables
605 if not bb.data.getVar("BUILDNAME", self.configuration.data):
606 bb.data.setVar("BUILDNAME", os.popen('date +%Y%m%d%H%M').readline().strip(), self.configuration.data)
607 bb.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S',time.gmtime()),self.configuration.data)
608
609 buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
610
611 if self.configuration.interactive:
612 self.interactiveMode()
613
614 if self.configuration.buildfile is not None:
615 bf = os.path.abspath( self.configuration.buildfile )
616 try:
617 bbfile_data = bb.parse.handle(bf, self.configuration.data)
618 except IOError:
619 bb.fatal("Unable to open %s" % bf)
620
621 item = bb.data.getVar('PN', bbfile_data, 1)
622 try:
623 self.tryBuildPackage( bf, item, bbfile_data )
624 except bb.build.EventException:
625 bb.error( "Build of '%s' failed" % item )
626
627 sys.exit( self.stats.show() )
628
629 # initialise the parsing status now we know we will need deps
630 self.status = BBParsingStatus()
631
632 ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
633 self.status.ignored_dependencies = Set( ignore.split() )
634
635 self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )
636
637 pkgs_to_build = None
638 if args:
639 if not pkgs_to_build:
640 pkgs_to_build = []
641 pkgs_to_build.extend(args)
642 if not pkgs_to_build:
643 bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, 1)
644 if bbpkgs:
645 pkgs_to_build = bbpkgs.split()
646 if not pkgs_to_build and not self.configuration.show_versions \
647 and not self.configuration.interactive \
648 and not self.configuration.show_environment:
649 print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'"
650 print "for usage information."
651 sys.exit(0)
652
653 # Import Psyco if available and not disabled
654 if not self.configuration.disable_psyco:
655 try:
656 import psyco
657 except ImportError:
658 if bbdebug == 0:
659 bb.note("Psyco JIT Compiler (http://psyco.sf.net) not available. Install it to increase performance.")
660 else:
661 psyco.bind( self.collect_bbfiles )
662 else:
663 bb.note("You have disabled Psyco. This decreases performance.")
664
665 try:
666 bb.debug(1, "collecting .bb files")
667 self.collect_bbfiles( self.myProgressCallback )
668 bb.debug(1, "parsing complete")
669 if bbdebug == 0:
670 print
671 if self.configuration.parse_only:
672 print "Requested parsing .bb files only. Exiting."
673 return
674
675 bb.data.update_data( self.configuration.data )
676 self.buildDepgraph()
677
678 if self.configuration.show_versions:
679 self.showVersions()
680 sys.exit( 0 )
681 if 'world' in pkgs_to_build:
682 pkgs_to_build.remove('world')
683 for t in self.status.world_target:
684 pkgs_to_build.append(t)
685
686 bb.event.fire(bb.event.BuildStarted(buildname, pkgs_to_build, self.configuration.data))
687
688 for k in pkgs_to_build:
689 failed = False
690 try:
691 if self.buildProvider( k ) == 0:
692 # already diagnosed
693 failed = True
694 except bb.build.EventException:
695 bb.error("Build of " + k + " failed")
696 failed = True
697
698 if failed:
699 if self.configuration.abort:
700 sys.exit(1)
701
702 bb.event.fire(bb.event.BuildCompleted(buildname, pkgs_to_build, self.configuration.data))
703
704 sys.exit( self.stats.show() )
705
706 except KeyboardInterrupt:
707 print "\nNOTE: KeyboardInterrupt - Build not completed."
708 sys.exit(1)
709
710 def get_bbfiles( self, path = os.getcwd() ):
711 """Get list of default .bb files by reading out the current directory"""
712 contents = os.listdir(path)
713 bbfiles = []
714 for f in contents:
715 (root, ext) = os.path.splitext(f)
716 if ext == ".bb":
717 bbfiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
718 return bbfiles
719
720 def find_bbfiles( self, path ):
721 """Find all the .bb files in a directory (uses find)"""
722 findcmd = 'find ' + path + ' -name *.bb | grep -v SCCS/'
723 try:
724 finddata = os.popen(findcmd)
725 except OSError:
726 return []
727 return finddata.readlines()
728
729 def deps_clean(self, d):
730 depstr = data.getVar('__depends', d)
731 if depstr:
732 deps = depstr.split(" ")
733 for dep in deps:
734 (f,old_mtime_s) = dep.split("@")
735 old_mtime = int(old_mtime_s)
736 new_mtime = parse.cached_mtime(f)
737 if (new_mtime > old_mtime):
738 return False
739 return True
740
741 def load_bbfile( self, bbfile ):
742 """Load and parse one .bb build file"""
743
744 if not self.cache in [None, '']:
745 # get the times
746 cache_mtime = data.init_db_mtime(self.cache, bbfile)
747 file_mtime = parse.cached_mtime(bbfile)
748
749 if file_mtime > cache_mtime:
750 #print " : '%s' dirty. reparsing..." % bbfile
751 pass
752 else:
753 #print " : '%s' clean. loading from cache..." % bbfile
754 cache_data = data.init_db( self.cache, bbfile, False )
755 if self.deps_clean(cache_data):
756 return cache_data, True
757
758 topdir = data.getVar('TOPDIR', self.configuration.data)
759 if not topdir:
760 topdir = os.path.abspath(os.getcwd())
761 # set topdir to here
762 data.setVar('TOPDIR', topdir, self.configuration)
763 bbfile = os.path.abspath(bbfile)
764 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
765 # expand tmpdir to include this topdir
766 data.setVar('TMPDIR', data.getVar('TMPDIR', self.configuration.data, 1) or "", self.configuration.data)
767 # set topdir to location of .bb file
768 topdir = bbfile_loc
769 #data.setVar('TOPDIR', topdir, cfg)
770 # go there
771 oldpath = os.path.abspath(os.getcwd())
772 os.chdir(topdir)
773 bb = data.init_db(self.cache,bbfile, True, self.configuration.data)
774 try:
775 parse.handle(bbfile, bb) # read .bb data
776 if not self.cache in [None, '']:
777 bb.commit(parse.cached_mtime(bbfile)) # write cache
778 os.chdir(oldpath)
779 return bb, False
780 finally:
781 os.chdir(oldpath)
782
783 def collect_bbfiles( self, progressCallback ):
784 """Collect all available .bb build files"""
785 self.cb = progressCallback
786 parsed, cached, skipped, masked = 0, 0, 0, 0
787 self.cache = bb.data.getVar( "CACHE", self.configuration.data, 1 )
788 self.pkgdata = data.pkgdata( not self.cache in [None, ''], self.cache, self.configuration.data )
789
790 if not self.cache in [None, '']:
791 if self.cb is not None:
792 print "NOTE: Using cache in '%s'" % self.cache
793 try:
794 os.stat( self.cache )
795 except OSError:
796 bb.mkdirhier( self.cache )
797 else:
798 if self.cb is not None:
799 print "NOTE: Not using a cache. Set CACHE = <directory> to enable."
800 files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split()
801 data.setVar("BBFILES", " ".join(files), self.configuration.data)
802
803 if not len(files):
804 files = self.get_bbfiles()
805
806 if not len(files):
807 bb.error("no files to build.")
808
809 newfiles = []
810 for f in files:
811 if os.path.isdir(f):
812 dirfiles = self.find_bbfiles(f)
813 if dirfiles:
814 newfiles += dirfiles
815 continue
816 newfiles += glob.glob(f) or [ f ]
817
818 bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1) or ""
819 try:
820 bbmask_compiled = re.compile(bbmask)
821 except sre_constants.error:
822 bb.fatal("BBMASK is not a valid regular expression.")
823
824 for i in xrange( len( newfiles ) ):
825 f = newfiles[i]
826 if bbmask and bbmask_compiled.search(f):
827 bb.debug(1, "bbmake: skipping %s" % f)
828 masked += 1
829 continue
830 debug(1, "bbmake: parsing %s" % f)
831
832 # read a file's metadata
833 try:
834 bb_data, fromCache = self.load_bbfile(f)
835 if fromCache: cached += 1
836 else: parsed += 1
837 deps = None
838 if bb_data is not None:
839 # allow metadata files to add items to BBFILES
840 #data.update_data(self.pkgdata[f])
841 addbbfiles = data.getVar('BBFILES', bb_data) or None
842 if addbbfiles:
843 for aof in addbbfiles.split():
844 if not files.count(aof):
845 if not os.path.isabs(aof):
846 aof = os.path.join(os.path.dirname(f),aof)
847 files.append(aof)
848 for var in bb_data.keys():
849 if data.getVarFlag(var, "handler", bb_data) and data.getVar(var, bb_data):
850 event.register(data.getVar(var, bb_data))
851 self.pkgdata[f] = bb_data
852
853 # now inform the caller
854 if self.cb is not None:
855 self.cb( i + 1, len( newfiles ), f, bb_data, fromCache )
856
857 except IOError, e:
858 bb.error("opening %s: %s" % (f, e))
859 pass
860 except bb.parse.SkipPackage:
861 skipped += 1
862 pass
863 except KeyboardInterrupt:
864 raise
865 except Exception, e:
866 bb.error("%s while parsing %s" % (e, f))
867
868 if self.cb is not None:
869 print "\rNOTE: Parsing finished. %d cached, %d parsed, %d skipped, %d masked." % ( cached, parsed, skipped, masked ),
870
871#============================================================================#
872# main
873#============================================================================#
874
875if __name__ == "__main__":
876
877 parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
878 usage = """%prog [options] [package ...]
879
880Executes the specified task (default is 'build') for a given set of BitBake files.
881It expects that BBFILES is defined, which is a space seperated list of files to
882be executed. BBFILES does support wildcards.
883Default BBFILES are the .bb files in the current directory.""" )
884
885 parser.add_option( "-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.",
886 action = "store", dest = "buildfile", default = None )
887
888 parser.add_option( "-k", "--continue", help = "continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.",
889 action = "store_false", dest = "abort", default = True )
890
891 parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
892 action = "store_true", dest = "force", default = False )
893
894 parser.add_option( "-i", "--interactive", help = "drop into the interactive mode.",
895 action = "store_true", dest = "interactive", default = False )
896
897 parser.add_option( "-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing)",
898 action = "store", dest = "cmd", default = "build" )
899
900 parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
901 action = "append", dest = "file", default = [] )
902
903 parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
904 action = "store_true", dest = "verbose", default = False )
905
906 parser.add_option( "-D", "--debug", help = "Increase the debug level",
907 action = "count", dest="debug", default = 0)
908
909 parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
910 action = "store_true", dest = "dry_run", default = False )
911
912 parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
913 action = "store_true", dest = "parse_only", default = False )
914
915 parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
916 action = "store_true", dest = "disable_psyco", default = False )
917
918 parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
919 action = "store_true", dest = "show_versions", default = False )
920
921 parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
922 action = "store_true", dest = "show_environment", default = False )
923
924 options, args = parser.parse_args( sys.argv )
925
926 cooker = BBCooker()
927 cooker.cook( BBConfiguration( options ), args[1:] )
diff --git a/bitbake/bin/bitbakec b/bitbake/bin/bitbakec
new file mode 100644
index 0000000..dc2e0a9
--- /dev/null
+++ b/bitbake/bin/bitbakec
Binary files differ
diff --git a/bitbake/bin/bitdoc b/bitbake/bin/bitdoc
new file mode 100755
index 0000000..64d3294
--- /dev/null
+++ b/bitbake/bin/bitdoc
@@ -0,0 +1,529 @@
1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# Copyright (C) 2005 Holger Hans Peter Freyther
6#
7#
8# Permission is hereby granted, free of charge, to any person obtaining a copy
9# of this software and associated documentation files (the "Software"), to deal
10# in the Software without restriction, including without limitation the rights
11# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12# copies of the Software, and to permit persons to whom the Software is
13# furnished to do so, subject to the following conditions:
14#
15# The above copyright notice and this permission notice shall be included in all
16# copies or substantial portions of the Software.
17#
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
24# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25#
26#
27
28import optparse, os, sys
29
30# bitbake
31sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
32import bb
33from bb import make
34from string import split, join
35
36__version__ = "0.0.2"
37
38class HTMLFormatter:
39 """
40 Simple class to help to generate some sort of HTML files. It is
41 quite inferior solution compared to docbook, gtkdoc, doxygen but it
42 should work for now.
43 We've a global introduction site (index.html) and then one site for
44 the list of keys (alphabetical sorted) and one for the list of groups,
45 one site for each key with links to the relations and groups.
46
47 index.html
48 keys.html
49 groups.html
50 groupNAME.html
51 keyNAME.html
52 """
53
54 def replace(self, text, *pairs):
55 """
56 From pydoc... almost identical at least
57 """
58 while pairs:
59 (a,b) = pairs[0]
60 text = join(split(text, a), b)
61 pairs = pairs[1:]
62 return text
63 def escape(self, text):
64 """
65 Escape string to be conform HTML
66 """
67 return self.replace(text,
68 ('&', '&amp;'),
69 ('<', '&lt;' ),
70 ('>', '&gt;' ) )
71 def createNavigator(self):
72 """
73 Create the navgiator
74 """
75 return """<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
76<tr valign="middle">
77<td><a accesskey="g" href="index.html">Home</a></td>
78<td><a accesskey="n" href="groups.html">Groups</a></td>
79<td><a accesskey="u" href="keys.html">Keys</a></td>
80</tr></table>
81"""
82
83 def relatedKeys(self, item):
84 """
85 Create HTML to link to foreign keys
86 """
87
88 if len(item.related()) == 0:
89 return ""
90
91 txt = "<p><b>See also:</b><br>"
92 for it in item.related():
93 txt += """<a href="key%s.html">%s</a>, """ % (it, it)
94
95 return txt
96
97 def groups(self,item):
98 """
99 Create HTML to link to related groups
100 """
101
102 if len(item.groups()) == 0:
103 return ""
104
105
106 txt = "<p><b>Seel also:</b><br>"
107 for group in item.groups():
108 txt += """<a href="group%s.html">%s</a>, """ % (group,group)
109
110 return txt
111
112
113 def createKeySite(self,item):
114 """
115 Create a site for a key. It contains the header/navigator, a heading,
116 the description, links to related keys and to the groups.
117 """
118
119 return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
120<html><head><title>Key %s</title></head>
121<link rel="stylesheet" href="style.css" type="text/css">
122<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
123%s
124<h2><span class="refentrytitle">%s</span></h2>
125
126<div class="refsynopsisdiv">
127<h2>Synopsis</h2>
128<pre class="synopsis">
129%s
130</pre>
131</div>
132
133<div class="refsynopsisdiv">
134<h2>Related Keys</h2>
135<pre class="synopsis">
136%s
137</pre>
138</div>
139
140<div class="refsynopsisdiv">
141<h2>Groups</h2>
142<pre class="synopsis">
143%s
144</pre>
145</div>
146
147
148</body>
149""" % (item.name(), self.createNavigator(), item.name(),
150 self.escape(item.description()), self.relatedKeys(item), self.groups(item))
151
152 def createGroupsSite(self, doc):
153 """
154 Create the Group Overview site
155 """
156
157 groups = ""
158 sorted_groups = doc.groups()
159 sorted_groups.sort()
160 for group in sorted_groups:
161 groups += """<a href="group%s.html">%s</a><br>""" % (group, group)
162
163 return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
164<html><head><title>Group overview</title></head>
165<link rel="stylesheet" href="style.css" type="text/css">
166<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
167%s
168<h2>Available Groups</h2>
169%s
170</body>
171""" % (self.createNavigator(), groups)
172
173 def createIndex(self):
174 """
175 Create the index file
176 """
177
178 return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
179<html><head><title>Bitbake Documentation</title></head>
180<link rel="stylesheet" href="style.css" type="text/css">
181<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
182%s
183<h2>Documentation Entrance</h2>
184<a href="groups.html">All available groups</a><br>
185<a href="keys.html">All available keys</a><br>
186</body>
187""" % self.createNavigator()
188
189 def createKeysSite(self, doc):
190 """
191 Create Overview of all avilable keys
192 """
193 keys = ""
194 sorted_keys = doc.doc_keys()
195 sorted_keys.sort()
196 for key in sorted_keys:
197 keys += """<a href="key%s.html">%s</a><br>""" % (key, key)
198
199 return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
200<html><head><title>Key overview</title></head>
201<link rel="stylesheet" href="style.css" type="text/css">
202<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
203%s
204<h2>Available Keys</h2>
205%s
206</body>
207""" % (self.createNavigator(), keys)
208
209 def createGroupSite(self,gr, items):
210 """
211 Create a site for a group:
212 Group the name of the group, items contain the name of the keys
213 inside this group
214 """
215 groups = ""
216 for group in items:
217 groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name())
218
219 return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
220<html><head><title>Group %s</title></head>
221<link rel="stylesheet" href="style.css" type="text/css">
222<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
223%s
224<div class="refsynopsisdiv">
225<h2>Keys in Group %s</h2>
226<pre class="synopsis">
227%s
228</pre>
229</div>
230</body>
231""" % (gr, self.createNavigator(), gr, groups)
232
233
234
235 def createCSS(self):
236 """
237 Create the CSS file
238 """
239 return """.synopsis, .classsynopsis
240{
241 background: #eeeeee;
242 border: solid 1px #aaaaaa;
243 padding: 0.5em;
244}
245.programlisting
246{
247 background: #eeeeff;
248 border: solid 1px #aaaaff;
249 padding: 0.5em;
250}
251.variablelist
252{
253 padding: 4px;
254 margin-left: 3em;
255}
256.variablelist td:first-child
257{
258 vertical-align: top;
259}
260table.navigation
261{
262 background: #ffeeee;
263 border: solid 1px #ffaaaa;
264 margin-top: 0.5em;
265 margin-bottom: 0.5em;
266}
267.navigation a
268{
269 color: #770000;
270}
271.navigation a:visited
272{
273 color: #550000;
274}
275.navigation .title
276{
277 font-size: 200%;
278}
279div.refnamediv
280{
281 margin-top: 2em;
282}
283div.gallery-float
284{
285 float: left;
286 padding: 10px;
287}
288div.gallery-float img
289{
290 border-style: none;
291}
292div.gallery-spacer
293{
294 clear: both;
295}
296a
297{
298 text-decoration: none;
299}
300a:hover
301{
302 text-decoration: underline;
303 color: #FF0000;
304}
305"""
306
307
308
309class DocumentationItem:
310 """
311 A class to hold information about a configuration
312 item. It contains the key name, description, a list of related names,
313 and the group this item is contained in.
314 """
315
316 def __init__(self):
317 self._groups = []
318 self._related = []
319 self._name = ""
320 self._desc = ""
321
322 def groups(self):
323 return self._groups
324
325 def name(self):
326 return self._name
327
328 def description(self):
329 return self._desc
330
331 def related(self):
332 return self._related
333
334 def setName(self, name):
335 self._name = name
336
337 def setDescription(self, desc):
338 self._desc = desc
339
340 def addGroup(self, group):
341 self._groups.append(group)
342
343 def addRelation(self,relation):
344 self._related.append(relation)
345
346 def sort(self):
347 self._related.sort()
348 self._groups.sort()
349
350
351class Documentation:
352 """
353 Holds the documentation... with mappings from key to items...
354 """
355
356 def __init__(self):
357 self.__keys = {}
358 self.__groups = {}
359
360 def insert_doc_item(self, item):
361 """
362 Insert the Doc Item into the internal list
363 of representation
364 """
365 item.sort()
366 self.__keys[item.name()] = item
367
368 for group in item.groups():
369 if not group in self.__groups:
370 self.__groups[group] = []
371 self.__groups[group].append(item)
372 self.__groups[group].sort()
373
374
375 def doc_item(self, key):
376 """
377 Return the DocumentationInstance describing the key
378 """
379 try:
380 return self.__keys[key]
381 except KeyError:
382 return None
383
384 def doc_keys(self):
385 """
386 Return the documented KEYS (names)
387 """
388 return self.__keys.keys()
389
390 def groups(self):
391 """
392 Return the names of available groups
393 """
394 return self.__groups.keys()
395
396 def group_content(self,group_name):
397 """
398 Return a list of keys/names that are in a specefic
399 group or the empty list
400 """
401 try:
402 return self.__groups[group_name]
403 except KeyError:
404 return []
405
406
407def parse_cmdline(args):
408 """
409 Parse the CMD line and return the result as a n-tuple
410 """
411
412 parser = optparse.OptionParser( version = "Bitbake Documentation Tool Core version %s, %%prog version %s" % (bb.__version__,__version__))
413 usage = """%prog [options]
414
415Create a set of html pages (documentation) for a bitbake.conf....
416"""
417
418 # Add the needed options
419 parser.add_option( "-c", "--config", help = "Use the specified configuration file as source",
420 action = "store", dest = "config", default = os.path.join("conf", "documentation.conf") )
421
422 parser.add_option( "-o", "--output", help = "Output directory for html files",
423 action = "store", dest = "output", default = "html/" )
424
425 parser.add_option( "-D", "--debug", help = "Increase the debug level",
426 action = "count", dest = "debug", default = 0 )
427
428 parser.add_option( "-v","--verbose", help = "output more chit-char to the terminal",
429 action = "store_true", dest = "verbose", default = False )
430
431 options, args = parser.parse_args( sys.argv )
432
433 if options.debug:
434 bb.debug_level = options.debug
435
436 return options.config, options.output
437
438def main():
439 """
440 The main Method
441 """
442
443 (config_file,output_dir) = parse_cmdline( sys.argv )
444
445 # right to let us load the file now
446 try:
447 documentation = bb.parse.handle( config_file, bb.data.init() )
448 except IOError:
449 bb.fatal( "Unable to open %s" % config_file )
450 except bb.parse.ParseError:
451 bb.fatal( "Unable to parse %s" % config_file )
452
453
454 # Assuming we've the file loaded now, we will initialize the 'tree'
455 doc = Documentation()
456
457 # defined states
458 state_begin = 0
459 state_see = 1
460 state_group = 2
461
462 for key in bb.data.keys(documentation):
463 data = bb.data.getVarFlag(key, "doc", documentation)
464 if not data:
465 continue
466
467 # The Documentation now starts
468 doc_ins = DocumentationItem()
469 doc_ins.setName(key)
470
471
472 tokens = data.split(' ')
473 state = state_begin
474 string= ""
475 for token in tokens:
476 token = token.strip(',')
477
478 if not state == state_see and token == "@see":
479 state = state_see
480 continue
481 elif not state == state_group and token == "@group":
482 state = state_group
483 continue
484
485 if state == state_begin:
486 string += " %s" % token
487 elif state == state_see:
488 doc_ins.addRelation(token)
489 elif state == state_group:
490 doc_ins.addGroup(token)
491
492 # set the description
493 doc_ins.setDescription(string)
494 doc.insert_doc_item(doc_ins)
495
496 # let us create the HTML now
497 bb.mkdirhier(output_dir)
498 os.chdir(output_dir)
499
500 # Let us create the sites now. We do it in the following order
501 # Start with the index.html. It will point to sites explaining all
502 # keys and groups
503 html_slave = HTMLFormatter()
504
505 f = file('style.css', 'w')
506 print >> f, html_slave.createCSS()
507
508 f = file('index.html', 'w')
509 print >> f, html_slave.createIndex()
510
511 f = file('groups.html', 'w')
512 print >> f, html_slave.createGroupsSite(doc)
513
514 f = file('keys.html', 'w')
515 print >> f, html_slave.createKeysSite(doc)
516
517 # now for each group create the site
518 for group in doc.groups():
519 f = file('group%s.html' % group, 'w')
520 print >> f, html_slave.createGroupSite(group, doc.group_content(group))
521
522 # now for the keys
523 for key in doc.doc_keys():
524 f = file('key%s.html' % doc.doc_item(key).name(), 'w')
525 print >> f, html_slave.createKeySite(doc.doc_item(key))
526
527
528if __name__ == "__main__":
529 main()
diff --git a/bitbake/classes/base.bbclass b/bitbake/classes/base.bbclass
new file mode 100644
index 0000000..1d75964
--- /dev/null
+++ b/bitbake/classes/base.bbclass
@@ -0,0 +1,79 @@
1# Copyright (C) 2003 Chris Larson
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the "Software"),
5# to deal in the Software without restriction, including without limitation
6# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7# and/or sell copies of the Software, and to permit persons to whom the
8# Software is furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included
11# in all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19# OTHER DEALINGS IN THE SOFTWARE.
20
21die() {
22 bbfatal "$*"
23}
24
25bbnote() {
26 echo "NOTE:" "$*"
27}
28
29bbwarn() {
30 echo "WARNING:" "$*"
31}
32
33bbfatal() {
34 echo "FATAL:" "$*"
35 exit 1
36}
37
38bbdebug() {
39 test $# -ge 2 || {
40 echo "Usage: bbdebug level \"message\""
41 exit 1
42 }
43
44 test ${@bb.debug_level} -ge $1 && {
45 shift
46 echo "DEBUG:" $*
47 }
48}
49
50addtask showdata
51do_showdata[nostamp] = "1"
52python do_showdata() {
53 import sys
54 # emit variables and shell functions
55 bb.data.emit_env(sys.__stdout__, d, True)
56 # emit the metadata which isnt valid shell
57 for e in bb.data.keys(d):
58 if bb.data.getVarFlag(e, 'python', d):
59 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
60}
61
62addtask listtasks
63do_listtasks[nostamp] = "1"
64python do_listtasks() {
65 import sys
66 for e in bb.data.keys(d):
67 if bb.data.getVarFlag(e, 'task', d):
68 sys.__stdout__.write("%s\n" % e)
69}
70
71addtask build
72do_build[dirs] = "${TOPDIR}"
73do_build[nostamp] = "1"
74python base_do_build () {
75 bb.note("The included, default BB base.bbclass does not define a useful default task.")
76 bb.note("Try running the 'listtasks' task against a .bb to see what tasks are defined.")
77}
78
79EXPORT_FUNCTIONS do_clean do_mrproper do_build
diff --git a/bitbake/conf/bitbake.conf b/bitbake/conf/bitbake.conf
new file mode 100644
index 0000000..fd216a3
--- /dev/null
+++ b/bitbake/conf/bitbake.conf
@@ -0,0 +1,55 @@
1# Copyright (C) 2003 Chris Larson
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the "Software"),
5# to deal in the Software without restriction, including without limitation
6# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7# and/or sell copies of the Software, and to permit persons to whom the
8# Software is furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included
11# in all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19# OTHER DEALINGS IN THE SOFTWARE.
20
21B = "${S}"
22CVSDIR = "${DL_DIR}/cvs"
23DEPENDS = ""
24DEPLOY_DIR = "${TMPDIR}/deploy"
25DEPLOY_DIR_IMAGE = "${DEPLOY_DIR}/images"
26DL_DIR = "${TMPDIR}/downloads"
27FETCHCOMMAND = ""
28FETCHCOMMAND_cvs = "/usr/bin/env cvs -d${CVSROOT} co ${CVSCOOPTS} ${CVSMODULE}"
29FETCHCOMMAND_svn = "/usr/bin/env svn co http://${SVNROOT} ${SVNCOOPTS} ${SVNMODULE}"
30FETCHCOMMAND_wget = "/usr/bin/env wget -t 5 --passive-ftp -P ${DL_DIR} ${URI}"
31FILESDIR = "${@bb.which(bb.data.getVar('FILESPATH', d, 1), '.')}"
32FILESPATH = "${FILE_DIRNAME}/${PF}:${FILE_DIRNAME}/${P}:${FILE_DIRNAME}/${PN}:${FILE_DIRNAME}/files:${FILE_DIRNAME}"
33FILE_DIRNAME = "${@os.path.dirname(bb.data.getVar('FILE', d))}"
34IMAGE_CMD = "_NO_DEFINED_IMAGE_TYPES_"
35IMAGE_ROOTFS = "${TMPDIR}/rootfs"
36MKTEMPCMD = "mktemp -q ${TMPBASE}"
37MKTEMPDIRCMD = "mktemp -d -q ${TMPBASE}"
38OVERRIDES = "local:${MACHINE}:${TARGET_OS}:${TARGET_ARCH}"
39P = "${PN}-${PV}"
40PF = "${PN}-${PV}-${PR}"
41PN = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[0] or 'defaultpkgname'}"
42PR = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or 'r0'}"
43PROVIDES = ""
44PV = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[1] or '1.0'}"
45RESUMECOMMAND = ""
46RESUMECOMMAND_wget = "/usr/bin/env wget -c -t 5 --passive-ftp -P ${DL_DIR} ${URI}"
47S = "${WORKDIR}/${P}"
48SRC_URI = "file://${FILE}"
49STAMP = "${TMPDIR}/stamps/${PF}"
50T = "${WORKDIR}/temp"
51TARGET_ARCH = "${BUILD_ARCH}"
52TMPDIR = "${TOPDIR}/tmp"
53UPDATECOMMAND = ""
54UPDATECOMMAND_cvs = "/usr/bin/env cvs update ${CVSCOOPTS}"
55WORKDIR = "${TMPDIR}/work/${PF}"
diff --git a/bitbake/contrib/README b/bitbake/contrib/README
new file mode 100644
index 0000000..25e5156
--- /dev/null
+++ b/bitbake/contrib/README
@@ -0,0 +1 @@
This directory is for additional contributed files which may be useful.
diff --git a/bitbake/contrib/bbdev.sh b/bitbake/contrib/bbdev.sh
new file mode 100644
index 0000000..33a7853
--- /dev/null
+++ b/bitbake/contrib/bbdev.sh
@@ -0,0 +1,31 @@
1# This is a shell function to be sourced into your shell or placed in your .profile,
2# which makes setting things up for BitBake a bit easier.
3#
4# The author disclaims copyright to the contents of this file and places it in the
5# public domain.
6
7bbdev () {
8 local BBDIR PKGDIR BUILDDIR
9 if test x"$1" = "x--help"; then echo >&2 "syntax: bbdev [bbdir [pkgdir [builddir]]]"; return 1; fi
10 if test x"$1" = x; then BBDIR=`pwd`; else BBDIR=$1; fi
11 if test x"$2" = x; then PKGDIR=`pwd`; else PKGDIR=$2; fi
12 if test x"$3" = x; then BUILDDIR=`pwd`; else BUILDDIR=$3; fi
13
14 BBDIR=`readlink -f $BBDIR`
15 PKGDIR=`readlink -f $PKGDIR`
16 BUILDDIR=`readlink -f $BUILDDIR`
17 if ! (test -d $BBDIR && test -d $PKGDIR && test -d $BUILDDIR); then
18 echo >&2 "syntax: bbdev [bbdir [pkgdir [builddir]]]"
19 return 1
20 fi
21
22 PATH=$BBDIR/bin:$PATH
23 BBPATH=$BBDIR
24 if test x"$BBDIR" != x"$PKGDIR"; then
25 BBPATH=$PKGDIR:$BBPATH
26 fi
27 if test x"$PKGDIR" != x"$BUILDDIR"; then
28 BBPATH=$BUILDDIR:$BBPATH
29 fi
30 export BBPATH
31}
diff --git a/bitbake/doc/COPYING.GPL b/bitbake/doc/COPYING.GPL
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/bitbake/doc/COPYING.GPL
@@ -0,0 +1,340 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Library General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
310
311Also add information on how to contact you by electronic and paper mail.
312
313If the program is interactive, make it output a short notice like this
314when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) year name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321The hypothetical commands `show w' and `show c' should show the appropriate
322parts of the General Public License. Of course, the commands you use may
323be called something other than `show w' and `show c'; they could even be
324mouse-clicks or menu items--whatever suits your program.
325
326You should also get your employer (if you work as a programmer) or your
327school, if any, to sign a "copyright disclaimer" for the program, if
328necessary. Here is a sample; alter the names:
329
330 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333 <signature of Ty Coon>, 1 April 1989
334 Ty Coon, President of Vice
335
336This General Public License does not permit incorporating your program into
337proprietary programs. If your program is a subroutine library, you may
338consider it more useful to permit linking proprietary applications with the
339library. If this is what you want to do, use the GNU Library General
340Public License instead of this License.
diff --git a/bitbake/doc/COPYING.MIT b/bitbake/doc/COPYING.MIT
new file mode 100644
index 0000000..7e7d574
--- /dev/null
+++ b/bitbake/doc/COPYING.MIT
@@ -0,0 +1,17 @@
1Permission is hereby granted, free of charge, to any person obtaining a copy
2of this software and associated documentation files (the "Software"), to deal
3in the Software without restriction, including without limitation the rights
4to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5copies of the Software, and to permit persons to whom the Software is
6furnished to do so, subject to the following conditions:
7
8The above copyright notice and this permission notice shall be included in all
9copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
14SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
17THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/bitbake/doc/manual/Makefile b/bitbake/doc/manual/Makefile
new file mode 100644
index 0000000..a43c025
--- /dev/null
+++ b/bitbake/doc/manual/Makefile
@@ -0,0 +1,56 @@
1topdir = .
2manual = $(topdir)/usermanual.xml
3# types = pdf txt rtf ps xhtml html man tex texi dvi
4# types = pdf txt
5types = $(xmltotypes) $(htmltypes)
6xmltotypes = pdf txt
7htmltypes = html xhtml
8htmlxsl = $(if $(filter $@,$(foreach type,$(htmltypes),$(type)-nochunks)),http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl,http://docbook.sourceforge.net/release/xsl/current/$@/chunk.xsl)
9htmlcssfile = docbook.css
10htmlcss = $(topdir)/html.css
11# htmlcssfile =
12# htmlcss =
13cleanfiles = $(foreach i,$(types),$(topdir)/$(i))
14
15ifdef DEBUG
16define command
17 $(1)
18endef
19else
20define command
21 @echo $(2) $(3) $(4)
22 @$(1) >/dev/null
23endef
24endif
25
26all: $(types)
27
28lint: $(manual) FORCE
29 $(call command,xmllint --xinclude --postvalid --noout $(manual),XMLLINT $(manual))
30
31$(types) $(foreach type,$(htmltypes),$(type)-nochunks): lint FORCE
32
33$(foreach type,$(htmltypes),$(type)-nochunks): $(if $(htmlcss),$(htmlcss)) $(manual)
34 @mkdir -p $@
35ifdef htmlcss
36 $(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
37endif
38 $(call command,xsltproc --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual) > $@/index.$(patsubst %-nochunks,%,$@),XSLTPROC $@ $(manual))
39
40$(htmltypes): $(if $(htmlcss),$(htmlcss)) $(manual)
41 @mkdir -p $@
42ifdef htmlcss
43 $(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
44endif
45 $(call command,xsltproc --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual),XSLTPROC $@ $(manual))
46
47$(xmltotypes): $(manual)
48 $(call command,xmlto --extensions -o $(topdir)/$@ $@ $(manual),XMLTO $@ $(manual))
49
50clean:
51 rm -rf $(cleanfiles)
52
53$(foreach i,$(types) $(foreach type,$(htmltypes),$(type)-nochunks),clean-$(i)):
54 rm -rf $(patsubst clean-%,%,$@)
55
56FORCE:
diff --git a/bitbake/doc/manual/html.css b/bitbake/doc/manual/html.css
new file mode 100644
index 0000000..6eedfd3
--- /dev/null
+++ b/bitbake/doc/manual/html.css
@@ -0,0 +1,281 @@
1/* Feuille de style DocBook du projet Traduc.org */
2/* DocBook CSS stylesheet of the Traduc.org project */
3
4/* (c) Jean-Philippe Guérard - 14 août 2004 */
5/* (c) Jean-Philippe Guérard - 14 August 2004 */
6
7/* Cette feuille de style est libre, vous pouvez la */
8/* redistribuer et la modifier selon les termes de la Licence */
9/* Art Libre. Vous trouverez un exemplaire de cette Licence sur */
10/* http://tigreraye.org/Petit-guide-du-traducteur.html#licence-art-libre */
11
12/* This work of art is free, you can redistribute it and/or */
13/* modify it according to terms of the Free Art license. You */
14/* will find a specimen of this license on the Copyleft */
15/* Attitude web site: http://artlibre.org as well as on other */
16/* sites. */
17/* Please note that the French version of this licence as shown */
18/* on http://tigreraye.org/Petit-guide-du-traducteur.html#licence-art-libre */
19/* is only official licence of this document. The English */
20/* is only provided to help you understand this licence. */
21
22/* La dernière version de cette feuille de style est toujours */
23/* disponible sur : http://tigreraye.org/style.css */
24/* Elle est également disponible sur : */
25/* http://www.traduc.org/docs/HOWTO/lecture/style.css */
26
27/* The latest version of this stylesheet is available from: */
28/* http://tigreraye.org/style.css */
29/* It is also available on: */
30/* http://www.traduc.org/docs/HOWTO/lecture/style.css */
31
32/* N'hésitez pas à envoyer vos commentaires et corrections à */
33/* Jean-Philippe Guérard <jean-philippe.guerard@tigreraye.org> */
34
35/* Please send feedback and bug reports to */
36/* Jean-Philippe Guérard <jean-philippe.guerard@tigreraye.org> */
37
38/* $Id: style.css,v 1.14 2004/09/10 20:12:09 fevrier Exp fevrier $ */
39
40/* Présentation générale du document */
41/* Overall document presentation */
42
43body {
44 /*
45 font-family: Apolline, "URW Palladio L", Garamond, jGaramond,
46 "Bitstream Cyberbit", "Palatino Linotype", serif;
47 */
48 margin: 7%;
49 background-color: white;
50}
51
52/* Taille du texte */
53/* Text size */
54
55* { font-size: 100%; }
56
57/* Gestion des textes mis en relief imbriqués */
58/* Embedded emphasis */
59
60em { font-style: italic; }
61em em { font-style: normal; }
62em em em { font-style: italic; }
63
64/* Titres */
65/* Titles */
66
67h1 { font-size: 200%; font-weight: 900; }
68h2 { font-size: 160%; font-weight: 900; }
69h3 { font-size: 130%; font-weight: bold; }
70h4 { font-size: 115%; font-weight: bold; }
71h5 { font-size: 108%; font-weight: bold; }
72h6 { font-weight: bold; }
73
74/* Nom de famille en petites majuscules (uniquement en français) */
75/* Last names in small caps (for French only) */
76
77*[class~="surname"]:lang(fr) { font-variant: small-caps; }
78
79/* Blocs de citation */
80/* Quotation blocs */
81
82div[class~="blockquote"] {
83 border: solid 2px #AAA;
84 padding: 5px;
85 margin: 5px;
86}
87
88div[class~="blockquote"] > table {
89 border: none;
90}
91
92/* Blocs litéraux : fond gris clair */
93/* Literal blocs: light gray background */
94
95*[class~="literallayout"] {
96 background: #f0f0f0;
97 padding: 5px;
98 margin: 5px;
99}
100
101/* Programmes et captures texte : fond bleu clair */
102/* Listing and text screen snapshots: light blue background */
103
104*[class~="programlisting"], *[class~="screen"] {
105 background: #f0f0ff;
106 padding: 5px;
107 margin: 5px;
108}
109
110/* Les textes à remplacer sont surlignés en vert pâle */
111/* Replaceable text in highlighted in pale green */
112
113*[class~="replaceable"] {
114 background-color: #98fb98;
115 font-style: normal; }
116
117/* Tables : fonds gris clair & bords simples */
118/* Tables: light gray background and solid borders */
119
120*[class~="table"] *[class~="title"] { width:100%; border: 0px; }
121
122table {
123 border: 1px solid #aaa;
124 border-collapse: collapse;
125 padding: 2px;
126 margin: 5px;
127}
128
129/* Listes simples en style table */
130/* Simples lists in table presentation */
131
132table[class~="simplelist"] {
133 background-color: #F0F0F0;
134 margin: 5px;
135 border: solid 1px #AAA;
136}
137
138table[class~="simplelist"] td {
139 border: solid 1px #AAA;
140}
141
142/* Les tables */
143/* Tables */
144
145*[class~="table"] table {
146 background-color: #F0F0F0;
147 border: solid 1px #AAA;
148}
149*[class~="informaltable"] table { background-color: #F0F0F0; }
150
151th,td {
152 vertical-align: baseline;
153 text-align: left;
154 padding: 0.1em 0.3em;
155 empty-cells: show;
156}
157
158/* Alignement des colonnes */
159/* Colunms alignment */
160
161td[align=center] , th[align=center] { text-align: center; }
162td[align=right] , th[align=right] { text-align: right; }
163td[align=left] , th[align=left] { text-align: left; }
164td[align=justify] , th[align=justify] { text-align: justify; }
165
166/* Pas de marge autour des images */
167/* No inside margins for images */
168
169img { border: 0; }
170
171/* Les liens ne sont pas soulignés */
172/* No underlines for links */
173
174:link , :visited , :active { text-decoration: none; }
175
176/* Prudence : cadre jaune et fond jaune clair */
177/* Caution: yellow border and light yellow background */
178
179*[class~="caution"] {
180 border: solid 2px yellow;
181 background-color: #ffffe0;
182 padding: 1em 6px 1em ;
183 margin: 5px;
184}
185
186*[class~="caution"] th {
187 vertical-align: middle
188}
189
190*[class~="caution"] table {
191 background-color: #ffffe0;
192 border: none;
193}
194
195/* Note importante : cadre jaune et fond jaune clair */
196/* Important: yellow border and light yellow background */
197
198*[class~="important"] {
199 border: solid 2px yellow;
200 background-color: #ffffe0;
201 padding: 1em 6px 1em;
202 margin: 5px;
203}
204
205*[class~="important"] th {
206 vertical-align: middle
207}
208
209*[class~="important"] table {
210 background-color: #ffffe0;
211 border: none;
212}
213
214/* Mise en évidence : texte légèrement plus grand */
215/* Highlights: slightly larger texts */
216
217*[class~="highlights"] {
218 font-size: 110%;
219}
220
221/* Note : cadre bleu et fond bleu clair */
222/* Notes: blue border and light blue background */
223
224*[class~="note"] {
225 border: solid 2px #7099C5;
226 background-color: #f0f0ff;
227 padding: 1em 6px 1em ;
228 margin: 5px;
229}
230
231*[class~="note"] th {
232 vertical-align: middle
233}
234
235*[class~="note"] table {
236 background-color: #f0f0ff;
237 border: none;
238}
239
240/* Astuce : cadre vert et fond vert clair */
241/* Tip: green border and light green background */
242
243*[class~="tip"] {
244 border: solid 2px #00ff00;
245 background-color: #f0ffff;
246 padding: 1em 6px 1em ;
247 margin: 5px;
248}
249
250*[class~="tip"] th {
251 vertical-align: middle;
252}
253
254*[class~="tip"] table {
255 background-color: #f0ffff;
256 border: none;
257}
258
259/* Avertissement : cadre rouge et fond rouge clair */
260/* Warning: red border and light red background */
261
262*[class~="warning"] {
263 border: solid 2px #ff0000;
264 background-color: #fff0f0;
265 padding: 1em 6px 1em ;
266 margin: 5px;
267}
268
269*[class~="warning"] th {
270 vertical-align: middle;
271}
272
273
274*[class~="warning"] table {
275 background-color: #fff0f0;
276 border: none;
277}
278
279/* Fin */
280/* The End */
281
diff --git a/bitbake/doc/manual/usermanual.xml b/bitbake/doc/manual/usermanual.xml
new file mode 100644
index 0000000..b96863c
--- /dev/null
+++ b/bitbake/doc/manual/usermanual.xml
@@ -0,0 +1,361 @@
1<?xml version="1.0"?>
2<!--
3 ex:ts=4:sw=4:sts=4:et
4 -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
5-->
6<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
7 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
8<book>
9 <bookinfo>
10 <title>BitBake User Manual</title>
11 <authorgroup>
12 <corpauthor>BitBake Team</corpauthor>
13 </authorgroup>
14 <copyright>
15 <year>2004, 2005</year>
16 <holder>Chris Larson</holder>
17 <holder>Phil Blundell</holder>
18 </copyright>
19 <legalnotice>
20 <para>This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit <ulink url="http://creativecommons.org/licenses/by/2.0/">http://creativecommons.org/licenses/by/2.0/</ulink> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.</para>
21 </legalnotice>
22 </bookinfo>
23 <chapter>
24 <title>Introduction</title>
25 <section>
26 <title>Overview</title>
27 <para>BitBake is, at its simplest, a tool for executing
28tasks and managing metadata. As such, its similarities to GNU make and other
29build tools are readily apparent. It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the <ulink url="http://www.openembedded.org/">OpenEmbedded</ulink> project, which is being used to build and maintain a number of embedded Linux distributions, including OpenZaurus and Familiar.</para>
30 </section>
31 <section>
32 <title>Background and Goals</title>
33 <para>Prior to BitBake, no other build tool adequately met
34the needs of an aspiring embedded Linux distribution. All of the
35buildsystems used by traditional desktop Linux distributions lacked
36important functionality, and none of the ad-hoc
37<emphasis>buildroot</emphasis> systems, prevalent in the
38embedded space, were scalable or maintainable.</para>
39
40 <para>Some important goals for BitBake were:
41 <itemizedlist>
42 <listitem><para>Handle crosscompilation.</para></listitem>
43 <listitem><para>Handle interpackage dependencies (build time on target architecture, build time on native architecture, and runtime).</para></listitem>
44 <listitem><para>Support running any number of tasks within a given package, including, but not limited to, fetching upstream sources, unpacking them, patching them, configuring them, et cetera.</para></listitem>
45 <listitem><para>Must be linux distribution agnostic (both build and target).</para></listitem>
46 <listitem><para>Must be architecture agnostic</para></listitem>
47 <listitem><para>Must support multiple build and target operating systems (including cygwin, the BSDs, etc).</para></listitem>
48 <listitem><para>Must be able to be self contained, rather than tightly integrated into the build machine's root filesystem.</para></listitem>
49 <listitem><para>There must be a way to handle conditional metadata (on target architecture, operating system, distribution, machine).</para></listitem>
50 <listitem><para>It must be easy for the person using the tools to supply their own local metadata and packages to operate against.</para></listitem>
51 <listitem><para>Must make it easy to collaborate
52between multiple projects using BitBake for their
53builds.</para></listitem>
54 <listitem><para>Should provide an inheritance mechanism to
55share common metadata between many packages.</para></listitem>
56 <listitem><para>Et cetera...</para></listitem>
57 </itemizedlist>
58 </para>
59 <para>BitBake satisfies all these and many more. Flexibility and power have always been the priorities. It is highly extensible, supporting embedded Python code and execution of any arbitrary tasks.</para>
60 </section>
61 </chapter>
62 <chapter>
63 <title>Metadata</title>
64 <section>
65 <title>Description</title>
66 <itemizedlist>
67 <para>BitBake metadata can be classified into 3 major areas:</para>
68 <listitem>
69 <para>Configuration Files</para>
70 </listitem>
71 <listitem>
72 <para>.bb Files</para>
73 </listitem>
74 <listitem>
75 <para>Classes</para>
76 </listitem>
77 </itemizedlist>
78 <para>What follows are a large number of examples of BitBake metadata. Any syntax which isn't supported in any of the aforementioned areas will be documented as such.</para>
79 <section>
80 <title>Basic variable setting</title>
81 <para><screen><varname>VARIABLE</varname> = "value"</screen></para>
82 <para>In this example, <varname>VARIABLE</varname> is <literal>value</literal>.</para>
83 </section>
84 <section>
85 <title>Variable expansion</title>
86 <para>BitBake supports variables referencing one another's contents using a syntax which is similar to shell scripting</para>
87 <para><screen><varname>A</varname> = "aval"
88<varname>B</varname> = "pre${A}post"</screen></para>
89 <para>This results in <varname>A</varname> containing <literal>aval</literal> and <varname>B</varname> containing <literal>preavalpost</literal>.</para>
90 </section>
91 <section>
92 <title>Immediate variable expansion (:=)</title>
93 <para>:= results in a variable's contents being expanded immediately, rather than when the variable is actually used.</para>
94 <para><screen><varname>T</varname> = "123"
95<varname>A</varname> := "${B} ${A} test ${T}"
96<varname>T</varname> = "456"
97<varname>B</varname> = "${T} bval"
98
99<varname>C</varname> = "cval"
100<varname>C</varname> := "${C}append"</screen></para>
101 <para>In that example, <varname>A</varname> would contain <literal> test 123</literal>, <varname>B</varname> would contain <literal>456 bval</literal>, and <varname>C</varname> would be <literal>cvalappend</literal>.</para>
102 </section>
103 <section>
104 <title>Appending (+=) and prepending (=+)</title>
105 <para><screen><varname>B</varname> = "bval"
106<varname>B</varname> += "additionaldata"
107<varname>C</varname> = "cval"
108<varname>C</varname> =+ "test"</screen></para>
109 <para>In this example, <varname>B</varname> is now <literal>bval additionaldata</literal> and <varname>C</varname> is <literal>test cval</literal>.</para>
110 </section>
111 <section>
112 <title>Appending (.=) and prepending (=.) without spaces</title>
113 <para><screen><varname>B</varname> = "bval"
114<varname>B</varname> += "additionaldata"
115<varname>C</varname> = "cval"
116<varname>C</varname> =+ "test"</screen></para>
117 <para>In this example, <varname>B</varname> is now <literal>bvaladditionaldata</literal> and <varname>C</varname> is <literal>testcval</literal>. In contrast to the above Appending and Prepending operators no additional space
118will be introduced.</para>
119 </section>
120 <section>
121 <title>Conditional metadata set</title>
122 <para>OVERRIDES is a <quote>:</quote> seperated variable containing each item you want to satisfy conditions. So, if you have a variable which is conditional on <quote>arm</quote>, and <quote>arm</quote> is in OVERRIDES, then the <quote>arm</quote> specific version of the variable is used rather than the non-conditional version. Example:</para>
123 <para><screen><varname>OVERRIDES</varname> = "architecture:os:machine"
124<varname>TEST</varname> = "defaultvalue"
125<varname>TEST_os</varname> = "osspecificvalue"
126<varname>TEST_condnotinoverrides</varname> = "othercondvalue"</screen></para>
127 <para>In this example, <varname>TEST</varname> would be <literal>osspecificvalue</literal>, due to the condition <quote>os</quote> being in <varname>OVERRIDES</varname>.</para>
128 </section>
129 <section>
130 <title>Conditional appending</title>
131 <para>BitBake also supports appending and prepending to variables based on whether something is in OVERRIDES. Example:</para>
132 <para><screen><varname>DEPENDS</varname> = "glibc ncurses"
133<varname>OVERRIDES</varname> = "machine:local"
134<varname>DEPENDS_append_machine</varname> = " libmad"</screen></para>
135 <para>In this example, <varname>DEPENDS</varname> is set to <literal>glibc ncurses libmad</literal>.</para>
136 </section>
137 <section>
138 <title>Inclusion</title>
139 <para>Next, there is the <literal>include</literal> directive, which causes BitBake to parse in whatever file you specify, and insert it at that location, which is not unlike <command>make</command>. However, if the path specified on the <literal>include</literal> line is a relative path, BitBake will locate the first one it can find within <envar>BBPATH</envar>.</para>
140 </section>
141 <section>
142 <title>Python variable expansion</title>
143 <para><screen><varname>DATE</varname> = "${@time.strftime('%Y%m%d',time.gmtime())}"</screen></para>
144 <para>This would result in the <varname>DATE</varname> variable containing today's date.</para>
145 </section>
146 <section>
147 <title>Defining executable metadata</title>
148 <para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
149 <para><screen>do_mytask () {
150 echo "Hello, world!"
151}</screen></para>
152 <para>This is essentially identical to setting a variable, except that this variable happens to be executable shell code.</para>
153 <para><screen>python do_printdate () {
154 import time
155 print time.strftime('%Y%m%d', time.gmtime())
156}</screen></para>
157 <para>This is the similar to the previous, but flags it as python so that BitBake knows it is python code.</para>
158 </section>
159 <section>
160 <title>Defining python functions into the global python namespace</title>
161 <para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
162 <para><screen>def get_depends(bb, d):
163 if bb.data.getVar('SOMECONDITION', d, True):
164 return "dependencywithcond"
165 else:
166 return "dependency"
167
168<varname>SOMECONDITION</varname> = "1"
169<varname>DEPENDS</varname> = "${@get_depends(bb, d)}"</screen></para>
170 <para>This would result in <varname>DEPENDS</varname> containing <literal>dependencywithcond</literal>.</para>
171 </section>
172 <section>
173 <title>Inheritance</title>
174 <para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
175 <para>The <literal>inherit</literal> directive is a means of specifying what classes of functionality your .bb requires. It is a rudamentary form of inheritence. For example, you can easily abstract out the tasks involved in building a package that uses autoconf and automake, and put that into a bbclass for your packages to make use of. A given bbclass is located by searching for classes/filename.oeclass in <envar>BBPATH</envar>, where filename is what you inherited.</para>
176 </section>
177 <section>
178 <title>Tasks</title>
179 <para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
180 <para>In BitBake, each step that needs to be run for a given .bb is known as a task. There is a command <literal>addtask</literal> to add new tasks (must be a defined python executable metadata and must start with <quote>do_</quote>) and describe intertask dependencies.</para>
181 <para><screen>python do_printdate () {
182 import time
183 print time.strftime('%Y%m%d', time.gmtime())
184}
185
186addtask printdate before do_build</screen></para>
187 <para>This defines the necessary python function and adds it as a task which is now a dependency of do_build (the default task). If anyone executes the do_build task, that will result in do_printdate being run first.</para>
188 </section>
189 <section>
190 <title>Events</title>
191 <para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
192 <para>BitBake also implements a means of registering event handlers. Events are triggered at certain points during operation, such as, the beginning of operation against a given .bb, the start of a given task, task failure, task success, et cetera. The intent was to make it easy to do things like email notifications on build failure.</para>
193 <para><screen>addhandler myclass_eventhandler
194python myclass_eventhandler() {
195 from bb.event import NotHandled, getName
196 from bb import data
197
198 print "The name of the Event is %s" % getName(e)
199 print "The file we run for is %s" % data.getVar('FILE', e.data, True)
200
201 return NotHandled
202</screen></para><para>
203This event handler gets called every time an event is triggered. A global variable <varname>e</varname> is defined. <varname>e</varname>.data contains an instance of bb.data. With the getName(<varname>e</varname>)
204method one can get the name of the triggered event.</para><para>The above event handler prints the name
205of the event and the content of the <varname>FILE</varname> variable.</para>
206 </section>
207 </section>
208 <section>
209 <title>Parsing</title>
210 <section>
211 <title>Configuration Files</title>
212 <para>The first of the classifications of metadata in BitBake is configuration metadata. This metadata is global, and therefore affects <emphasis>all</emphasis> packages and tasks which are executed. Currently, BitBake has hardcoded knowledge of a single configuration file. It expects to find 'conf/bitbake.conf' somewhere in the user specified <envar>BBPATH</envar>. That configuration file generally has include directives to pull in any other metadata (generally files specific to architecture, machine, <emphasis>local</emphasis> and so on.</para>
213 <para>Only variable definitions and include directives are allowed in .conf files.</para>
214 </section>
215 <section>
216 <title>Classes</title>
217 <para>BitBake classes are our rudamentary inheritence mechanism. As briefly mentioned in the metadata introduction, they're parsed when an <literal>inherit</literal> directive is encountered, and they are located in classes/ relative to the dirs in <envar>BBPATH</envar>.</para>
218 </section>
219 <section>
220 <title>.bb Files</title>
221 <para>A BitBake (.bb) file is a logical unit of tasks to be executed. Normally this is a package to be built. Inter-.bb dependencies are obeyed. The files themselves are located via the <varname>BBFILES</varname> variable, which is set to a space seperated list of .bb files, and does handle wildcards.</para>
222 </section>
223 </section>
224 </chapter>
225 <chapter>
226 <title>Commands</title>
227 <section>
228 <title>bbread</title>
229 <para>bbread is a command for displaying BitBake metadata. When run with no arguments, it has the core parse 'conf/bitbake.conf', as located in BBPATH, and displays that. If you supply a file on the commandline, such as a .bb, then it parses that afterwards, using the aforementioned configuration metadata.</para>
230 <para><emphasis>NOTE: the stand a lone bbread command was removed. Instead of bbread use bitbake -e.
231 </emphasis></para>
232 </section>
233 <section>
234 <title>bitbake</title>
235 <section>
236 <title>Introduction</title>
237 <para>bitbake is the primary command in the system. It facilitates executing tasks in a single .bb file, or executing a given task on a set of multiple .bb files, accounting for interdependencies amongst them.</para>
238 </section>
239 <section>
240 <title>Usage and Syntax</title>
241 <para>
242 <screen><prompt>$ </prompt>bitbake --help
243usage: bitbake [options] [package ...]
244
245Executes the specified task (default is 'build') for a given set of BitBake files.
246It expects that BBFILES is defined, which is a space seperated list of files to
247be executed. BBFILES does support wildcards.
248Default BBFILES are the .bb files in the current directory.
249
250options:
251 --version show program's version number and exit
252 -h, --help show this help message and exit
253 -b BUILDFILE, --buildfile=BUILDFILE
254 execute the task against this .bb file, rather than a
255 package from BBFILES.
256 -k, --continue continue as much as possible after an error. While the
257 target that failed, and those that depend on it,
258 cannot be remade, the other dependencies of these
259 targets can be processed all the same.
260 -f, --force force run of specified cmd, regardless of stamp status
261 -i, --interactive drop into the interactive mode.
262 -c CMD, --cmd=CMD Specify task to execute. Note that this only executes
263 the specified task for the providee and the packages
264 it depends on, i.e. 'compile' does not implicitly call
265 stage for the dependencies (IOW: use only if you know
266 what you are doing)
267 -r FILE, --read=FILE read the specified file before bitbake.conf
268 -v, --verbose output more chit-chat to the terminal
269 -D, --debug Increase the debug level
270 -n, --dry-run don't execute, just go through the motions
271 -p, --parse-only quit after parsing the BB files (developers only)
272 -d, --disable-psyco disable using the psyco just-in-time compiler (not
273 recommended)
274 -s, --show-versions show current and preferred versions of all packages
275 -e, --environment show the global or per-package environment (this is
276 what used to be bbread)
277
278</screen>
279 </para>
280 <para>
281 <example>
282 <title>Executing a task against a single .bb</title>
283 <para>Executing tasks for a single file is relatively simple. You specify the file in question, and bitbake parses it and executes the specified task (or <quote>build</quote> by default). It obeys intertask dependencies when doing so.</para>
284 <para><quote>clean</quote> task:</para>
285 <para><screen><prompt>$ </prompt>bitbake -b blah_1.0.bb -c clean</screen></para>
286 <para><quote>build</quote> task:</para>
287 <para><screen><prompt>$ </prompt>bitbake -b blah_1.0.bb</screen></para>
288 </example>
289 </para>
290 <para>
291 <example>
292 <title>Executing tasks against a set of .bb files</title>
293 <para>There are a number of additional complexities introduced when one wants to manage multiple .bb files. Clearly there needs to be a way to tell bitbake what files are available, and of those, which we want to execute at this time. There also needs to be a way for each .bb to express its dependencies, both for build time and runtime. There must be a way for the user to express their preferences when multiple .bb's provide the same functionality, or when there are multiple versions of a .bb.</para>
294 <para>The next section, Metadata, outlines how one goes about specifying such things.</para>
295 <para>Note that the bitbake command, when not using --buildfile, accepts a <varname>PROVIDER</varname>, not a filename or anything else. By default, a .bb generally PROVIDES its packagename, packagename-version, and packagename-version-revision.</para>
296 <screen><prompt>$ </prompt>bitbake blah</screen>
297 <screen><prompt>$ </prompt>bitbake blah-1.0</screen>
298 <screen><prompt>$ </prompt>bitbake blah-1.0-r0</screen>
299 <screen><prompt>$ </prompt>bitbake -c clean blah</screen>
300 <screen><prompt>$ </prompt>bitbake virtual/whatever</screen>
301 <screen><prompt>$ </prompt>bitbake -c clean virtual/whatever</screen>
302 </example>
303 </para>
304 </section>
305 <section>
306 <title>Metadata</title>
307 <para>As you may have seen in the usage information, or in the information about .bb files, the BBFILES variable is how the bitbake tool locates its files. This variable is a space seperated list of files that are available, and supports wildcards.
308 <example>
309 <title>Setting BBFILES</title>
310 <programlisting><varname>BBFILES</varname> = "/path/to/bbfiles/*.bb"</programlisting>
311 </example></para>
312 <para>With regard to dependencies, it expects the .bb to define a <varname>DEPENDS</varname> variable, which contains a space seperated list of <quote>package names</quote>, which themselves are the <varname>PN</varname> variable. The <varname>PN</varname> variable is, in general, by default, set to a component of the .bb filename.</para>
313 <example>
314 <title>Depending on another .bb</title>
315 <para>a.bb:
316 <screen>PN = "package-a"
317 DEPENDS += "package-b"</screen>
318 </para>
319 <para>b.bb:
320 <screen>PN = "package-b"</screen>
321 </para>
322 </example>
323 <example>
324 <title>Using PROVIDES</title>
325 <para>This example shows the usage of the PROVIDES variable, which allows a given .bb to specify what functionality it provides.</para>
326 <para>package1.bb:
327 <screen>PROVIDES += "virtual/package"</screen>
328 </para>
329 <para>package2.bb:
330 <screen>DEPENDS += "virtual/package"</screen>
331 </para>
332 <para>package3.bb:
333 <screen>PROVIDES += "virtual/package"</screen>
334 </para>
335 <para>As you can see, here there are two different .bb's that provide the same functionality (virtual/package). Clearly, there needs to be a way for the person running bitbake to control which of those providers gets used. There is, indeed, such a way.</para>
336 <para>The following would go into a .conf file, to select package1:
337 <screen>PREFERRED_PROVIDER_virtual/package = "package1"</screen>
338 </para>
339 </example>
340 <example>
341 <title>Specifying version preference</title>
342 <para>When there are multiple <quote>versions</quote> of a given package, bitbake defaults to selecting the most recent version, unless otherwise specified. If the .bb in question has a <varname>DEFAULT_PREFERENCE</varname> set lower than the other .bb's (default is 0), then it will not be selected. This allows the person or persons maintaining the repository of .bb files to specify their preferences for the default selected version. In addition, the user can specify their preferences with regard to version.</para>
343 <para>If the first .bb is named <filename>a_1.1.bb</filename>, then the <varname>PN</varname> variable will be set to <quote>a</quote>, and the <varname>PV</varname> variable will be set to 1.1.</para>
344 <para>If we then have an <filename>a_1.2.bb</filename>, bitbake will choose 1.2 by default. However, if we define the following variable in a .conf that bitbake parses, we can change that.
345 <screen>PREFERRED_VERSION_a = "1.1"</screen>
346 </para>
347 </example>
348 <example>
349 <title>Using <quote>bbfile collections</quote></title>
350 <para>bbfile collections exist to allow the user to have multiple repositories of bbfiles that contain the same exact package. For example, one could easily use them to make one's own local copy of an upstream repository, but with custom modifications that one does not want upstream. Usage:</para>
351 <screen>BBFILES = "/stuff/openembedded/*/*.bb /stuff/openembedded.modified/*/*.bb"
352BBFILE_COLLECTIONS = "upstream local"
353BBFILE_PATTERN_upstream = "^/stuff/openembedded/"
354BBFILE_PATTERN_local = "^/stuff/openembedded.modified/"
355BBFILE_PRIORITY_upstream = "5"
356BBFILE_PRIORITY_local = "10"</screen>
357 </example>
358 </section>
359 </section>
360 </chapter>
361</book>
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
new file mode 100644
index 0000000..00b0e8b
--- /dev/null
+++ b/bitbake/lib/bb/__init__.py
@@ -0,0 +1,1266 @@
1#!/usr/bin/python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4"""
5BitBake Build System Python Library
6
7Copyright (C) 2003 Holger Schurig
8Copyright (C) 2003, 2004 Chris Larson
9
10Based on Gentoo's portage.py.
11
12This program is free software; you can redistribute it and/or modify it under
13the terms of the GNU General Public License as published by the Free Software
14Foundation; either version 2 of the License, or (at your option) any later
15version.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23Place, Suite 330, Boston, MA 02111-1307 USA.
24"""
25
26__version__ = "1.3.2"
27
28__all__ = [
29
30 "debug",
31 "note",
32 "error",
33 "fatal",
34
35 "mkdirhier",
36 "movefile",
37
38 "tokenize",
39 "evaluate",
40 "flatten",
41 "relparse",
42 "ververify",
43 "isjustname",
44 "isspecific",
45 "pkgsplit",
46 "catpkgsplit",
47 "vercmp",
48 "pkgcmp",
49 "dep_parenreduce",
50 "dep_opconvert",
51 "digraph",
52
53# fetch
54 "decodeurl",
55 "encodeurl",
56
57# modules
58 "parse",
59 "data",
60 "event",
61 "build",
62 "fetch",
63 "manifest"
64 ]
65
66whitespace = '\t\n\x0b\x0c\r '
67lowercase = 'abcdefghijklmnopqrstuvwxyz'
68
69import sys, os, types, re, string
70
71#projectdir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
72projectdir = os.getcwd()
73
74debug_level = 0
75
76if "BBDEBUG" in os.environ:
77 level = int(os.environ["BBDEBUG"])
78 if level:
79 debug_level = level
80 else:
81 debug_level = 0
82
83class VarExpandError(Exception):
84 pass
85
86class MalformedUrl(Exception):
87 """Exception raised when encountering an invalid url"""
88
89
90#######################################################################
91#######################################################################
92#
93# SECTION: Debug
94#
95# PURPOSE: little functions to make yourself known
96#
97#######################################################################
98#######################################################################
99
100debug_prepend = ''
101
102
103def debug(lvl, *args):
104 if debug_level >= lvl:
105 print debug_prepend + 'DEBUG:', ''.join(args)
106
107def note(*args):
108 print debug_prepend + 'NOTE:', ''.join(args)
109
110def error(*args):
111 print debug_prepend + 'ERROR:', ''.join(args)
112
113def fatal(*args):
114 print debug_prepend + 'ERROR:', ''.join(args)
115 sys.exit(1)
116
117
118#######################################################################
119#######################################################################
120#
121# SECTION: File
122#
123# PURPOSE: Basic file and directory tree related functions
124#
125#######################################################################
126#######################################################################
127
128def mkdirhier(dir):
129 """Create a directory like 'mkdir -p', but does not complain if
130 directory already exists like os.makedirs
131 """
132
133 debug(3, "mkdirhier(%s)" % dir)
134 try:
135 os.makedirs(dir)
136 debug(2, "created " + dir)
137 except OSError, e:
138 if e.errno != 17: raise e
139
140
141#######################################################################
142
143import stat
144
145def movefile(src,dest,newmtime=None,sstat=None):
146 """Moves a file from src to dest, preserving all permissions and
147 attributes; mtime will be preserved even when moving across
148 filesystems. Returns true on success and false on failure. Move is
149 atomic.
150 """
151
152 #print "movefile("+src+","+dest+","+str(newmtime)+","+str(sstat)+")"
153 try:
154 if not sstat:
155 sstat=os.lstat(src)
156 except Exception, e:
157 print "!!! Stating source file failed... movefile()"
158 print "!!!",e
159 return None
160
161 destexists=1
162 try:
163 dstat=os.lstat(dest)
164 except:
165 dstat=os.lstat(os.path.dirname(dest))
166 destexists=0
167
168 if destexists:
169 if stat.S_ISLNK(dstat[stat.ST_MODE]):
170 try:
171 os.unlink(dest)
172 destexists=0
173 except Exception, e:
174 pass
175
176 if stat.S_ISLNK(sstat[stat.ST_MODE]):
177 try:
178 target=os.readlink(src)
179 if destexists and not stat.S_ISDIR(dstat[stat.ST_MODE]):
180 os.unlink(dest)
181 os.symlink(target,dest)
182# os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
183 os.unlink(src)
184 return os.lstat(dest)
185 except Exception, e:
186 print "!!! failed to properly create symlink:"
187 print "!!!",dest,"->",target
188 print "!!!",e
189 return None
190
191 renamefailed=1
192 if sstat[stat.ST_DEV]==dstat[stat.ST_DEV]:
193 try:
194 ret=os.rename(src,dest)
195 renamefailed=0
196 except Exception, e:
197 import errno
198 if e[0]!=errno.EXDEV:
199 # Some random error.
200 print "!!! Failed to move",src,"to",dest
201 print "!!!",e
202 return None
203 # Invalid cross-device-link 'bind' mounted or actually Cross-Device
204
205 if renamefailed:
206 didcopy=0
207 if stat.S_ISREG(sstat[stat.ST_MODE]):
208 try: # For safety copy then move it over.
209 shutil.copyfile(src,dest+"#new")
210 os.rename(dest+"#new",dest)
211 didcopy=1
212 except Exception, e:
213 print '!!! copy',src,'->',dest,'failed.'
214 print "!!!",e
215 return None
216 else:
217 #we don't yet handle special, so we need to fall back to /bin/mv
218 a=getstatusoutput("/bin/mv -f "+"'"+src+"' '"+dest+"'")
219 if a[0]!=0:
220 print "!!! Failed to move special file:"
221 print "!!! '"+src+"' to '"+dest+"'"
222 print "!!!",a
223 return None # failure
224 try:
225 if didcopy:
226 missingos.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
227 os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
228 os.unlink(src)
229 except Exception, e:
230 print "!!! Failed to chown/chmod/unlink in movefile()"
231 print "!!!",dest
232 print "!!!",e
233 return None
234
235 if newmtime:
236 os.utime(dest,(newmtime,newmtime))
237 else:
238 os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
239 newmtime=sstat[stat.ST_MTIME]
240 return newmtime
241
242
243
244#######################################################################
245#######################################################################
246#
247# SECTION: Download
248#
249# PURPOSE: Download via HTTP, FTP, CVS, BITKEEPER, handling of MD5-signatures
250# and mirrors
251#
252#######################################################################
253#######################################################################
254
255def decodeurl(url):
256 """Decodes an URL into the tokens (scheme, network location, path,
257 user, password, parameters).
258
259 >>> decodeurl("http://www.google.com/index.html")
260 ('http', 'www.google.com', '/index.html', '', '', {})
261
262 CVS url with username, host and cvsroot. The cvs module to check out is in the
263 parameters:
264
265 >>> decodeurl("cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg")
266 ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'})
267
268 Dito, but this time the username has a password part. And we also request a special tag
269 to check out.
270
271 >>> decodeurl("cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;module=familiar/dist/ipkg;tag=V0-99-81")
272 ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'})
273 """
274
275 m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url)
276 if not m:
277 raise MalformedUrl(url)
278
279 type = m.group('type')
280 location = m.group('location')
281 if not location:
282 raise MalformedUrl(url)
283 user = m.group('user')
284 parm = m.group('parm')
285 m = re.compile('(?P<host>[^/;]+)(?P<path>/[^;]+)').match(location)
286 if m:
287 host = m.group('host')
288 path = m.group('path')
289 else:
290 host = ""
291 path = location
292 if user:
293 m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user)
294 if m:
295 user = m.group('user')
296 pswd = m.group('pswd')
297 else:
298 user = ''
299 pswd = ''
300
301 p = {}
302 if parm:
303 for s in parm.split(';'):
304 s1,s2 = s.split('=')
305 p[s1] = s2
306
307 return (type, host, path, user, pswd, p)
308
309#######################################################################
310
311def encodeurl(decoded):
312 """Encodes a URL from tokens (scheme, network location, path,
313 user, password, parameters).
314
315 >>> encodeurl(['http', 'www.google.com', '/index.html', '', '', {}])
316 'http://www.google.com/index.html'
317
318 CVS with username, host and cvsroot. The cvs module to check out is in the
319 parameters:
320
321 >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}])
322 'cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg'
323
324 Dito, but this time the username has a password part. And we also request a special tag
325 to check out.
326
327 >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}])
328 'cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg'
329 """
330
331 (type, host, path, user, pswd, p) = decoded
332
333 if not type or not path:
334 fatal("invalid or missing parameters for url encoding")
335 url = '%s://' % type
336 if user:
337 url += "%s" % user
338 if pswd:
339 url += ":%s" % pswd
340 url += "@"
341 if host:
342 url += "%s" % host
343 url += "%s" % path
344 if p:
345 for parm in p.keys():
346 url += ";%s=%s" % (parm, p[parm])
347
348 return url
349
350#######################################################################
351
352def which(path, item, direction = 0):
353 """Useful function for locating a file in a PATH"""
354 found = ""
355 for p in (path or "").split(':'):
356 if os.path.exists(os.path.join(p, item)):
357 found = os.path.join(p, item)
358 if direction == 0:
359 break
360 return found
361
362#######################################################################
363
364
365
366
367#######################################################################
368#######################################################################
369#
370# SECTION: Dependency
371#
372# PURPOSE: Compare build & run dependencies
373#
374#######################################################################
375#######################################################################
376
377def tokenize(mystring):
378 """Breaks a string like 'foo? (bar) oni? (blah (blah))' into (possibly embedded) lists:
379
380 >>> tokenize("x")
381 ['x']
382 >>> tokenize("x y")
383 ['x', 'y']
384 >>> tokenize("(x y)")
385 [['x', 'y']]
386 >>> tokenize("(x y) b c")
387 [['x', 'y'], 'b', 'c']
388 >>> tokenize("foo? (bar) oni? (blah (blah))")
389 ['foo?', ['bar'], 'oni?', ['blah', ['blah']]]
390 >>> tokenize("sys-apps/linux-headers nls? (sys-devel/gettext)")
391 ['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']]
392 """
393
394 newtokens = []
395 curlist = newtokens
396 prevlists = []
397 level = 0
398 accum = ""
399 for x in mystring:
400 if x=="(":
401 if accum:
402 curlist.append(accum)
403 accum=""
404 prevlists.append(curlist)
405 curlist=[]
406 level=level+1
407 elif x==")":
408 if accum:
409 curlist.append(accum)
410 accum=""
411 if level==0:
412 print "!!! tokenizer: Unmatched left parenthesis in:\n'"+mystring+"'"
413 return None
414 newlist=curlist
415 curlist=prevlists.pop()
416 curlist.append(newlist)
417 level=level-1
418 elif x in whitespace:
419 if accum:
420 curlist.append(accum)
421 accum=""
422 else:
423 accum=accum+x
424 if accum:
425 curlist.append(accum)
426 if (level!=0):
427 print "!!! tokenizer: Exiting with unterminated parenthesis in:\n'"+mystring+"'"
428 return None
429 return newtokens
430
431
432#######################################################################
433
434def evaluate(tokens,mydefines,allon=0):
435 """Removes tokens based on whether conditional definitions exist or not.
436 Recognizes !
437
438 >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {})
439 ['sys-apps/linux-headers']
440
441 Negate the flag:
442
443 >>> evaluate(['sys-apps/linux-headers', '!nls?', ['sys-devel/gettext']], {})
444 ['sys-apps/linux-headers', ['sys-devel/gettext']]
445
446 Define 'nls':
447
448 >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {"nls":1})
449 ['sys-apps/linux-headers', ['sys-devel/gettext']]
450
451 Turn allon on:
452
453 >>> evaluate(['sys-apps/linux-headers', 'nls?', ['sys-devel/gettext']], {}, True)
454 ['sys-apps/linux-headers', ['sys-devel/gettext']]
455 """
456
457 if tokens == None:
458 return None
459 mytokens = tokens + [] # this copies the list
460 pos = 0
461 while pos < len(mytokens):
462 if type(mytokens[pos]) == types.ListType:
463 evaluate(mytokens[pos], mydefines)
464 if not len(mytokens[pos]):
465 del mytokens[pos]
466 continue
467 elif mytokens[pos][-1] == "?":
468 cur = mytokens[pos][:-1]
469 del mytokens[pos]
470 if allon:
471 if cur[0] == "!":
472 del mytokens[pos]
473 else:
474 if cur[0] == "!":
475 if (cur[1:] in mydefines) and (pos < len(mytokens)):
476 del mytokens[pos]
477 continue
478 elif (cur not in mydefines) and (pos < len(mytokens)):
479 del mytokens[pos]
480 continue
481 pos = pos + 1
482 return mytokens
483
484
485#######################################################################
486
487def flatten(mytokens):
488 """Converts nested arrays into a flat arrays:
489
490 >>> flatten([1,[2,3]])
491 [1, 2, 3]
492 >>> flatten(['sys-apps/linux-headers', ['sys-devel/gettext']])
493 ['sys-apps/linux-headers', 'sys-devel/gettext']
494 """
495
496 newlist=[]
497 for x in mytokens:
498 if type(x)==types.ListType:
499 newlist.extend(flatten(x))
500 else:
501 newlist.append(x)
502 return newlist
503
504
505#######################################################################
506
507_package_weights_ = {"pre":-2,"p":0,"alpha":-4,"beta":-3,"rc":-1} # dicts are unordered
508_package_ends_ = ["pre", "p", "alpha", "beta", "rc", "cvs", "bk", "HEAD" ] # so we need ordered list
509
510def relparse(myver):
511 """Parses the last elements of a version number into a triplet, that can
512 later be compared:
513
514 >>> relparse('1.2_pre3')
515 [1.2, -2, 3.0]
516 >>> relparse('1.2b')
517 [1.2, 98, 0]
518 >>> relparse('1.2')
519 [1.2, 0, 0]
520 """
521
522 number = 0
523 p1 = 0
524 p2 = 0
525 mynewver = myver.split('_')
526 if len(mynewver)==2:
527 # an _package_weights_
528 number = float(mynewver[0])
529 match = 0
530 for x in _package_ends_:
531 elen = len(x)
532 if mynewver[1][:elen] == x:
533 match = 1
534 p1 = _package_weights_[x]
535 try:
536 p2 = float(mynewver[1][elen:])
537 except:
538 p2 = 0
539 break
540 if not match:
541 # normal number or number with letter at end
542 divider = len(myver)-1
543 if myver[divider:] not in "1234567890":
544 # letter at end
545 p1 = ord(myver[divider:])
546 number = float(myver[0:divider])
547 else:
548 number = float(myver)
549 else:
550 # normal number or number with letter at end
551 divider = len(myver)-1
552 if myver[divider:] not in "1234567890":
553 #letter at end
554 p1 = ord(myver[divider:])
555 number = float(myver[0:divider])
556 else:
557 number = float(myver)
558 return [number,p1,p2]
559
560
561#######################################################################
562
563__ververify_cache__ = {}
564
565def ververify(myorigval,silent=1):
566 """Returns 1 if given a valid version string, els 0. Valid versions are in the format
567
568 <v1>.<v2>...<vx>[a-z,_{_package_weights_}[vy]]
569
570 >>> ververify('2.4.20')
571 1
572 >>> ververify('2.4..20') # two dots
573 0
574 >>> ververify('2.x.20') # 'x' is not numeric
575 0
576 >>> ververify('2.4.20a')
577 1
578 >>> ververify('2.4.20cvs') # only one trailing letter
579 0
580 >>> ververify('1a')
581 1
582 >>> ververify('test_a') # no version at all
583 0
584 >>> ververify('2.4.20_beta1')
585 1
586 >>> ververify('2.4.20_beta')
587 1
588 >>> ververify('2.4.20_wrongext') # _wrongext is no valid trailer
589 0
590 """
591
592 # Lookup the cache first
593 try:
594 return __ververify_cache__[myorigval]
595 except KeyError:
596 pass
597
598 if len(myorigval) == 0:
599 if not silent:
600 error("package version is empty")
601 __ververify_cache__[myorigval] = 0
602 return 0
603 myval = myorigval.split('.')
604 if len(myval)==0:
605 if not silent:
606 error("package name has empty version string")
607 __ververify_cache__[myorigval] = 0
608 return 0
609 # all but the last version must be a numeric
610 for x in myval[:-1]:
611 if not len(x):
612 if not silent:
613 error("package version has two points in a row")
614 __ververify_cache__[myorigval] = 0
615 return 0
616 try:
617 foo = int(x)
618 except:
619 if not silent:
620 error("package version contains non-numeric '"+x+"'")
621 __ververify_cache__[myorigval] = 0
622 return 0
623 if not len(myval[-1]):
624 if not silent:
625 error("package version has trailing dot")
626 __ververify_cache__[myorigval] = 0
627 return 0
628 try:
629 foo = int(myval[-1])
630 __ververify_cache__[myorigval] = 1
631 return 1
632 except:
633 pass
634
635 # ok, our last component is not a plain number or blank, let's continue
636 if myval[-1][-1] in lowercase:
637 try:
638 foo = int(myval[-1][:-1])
639 return 1
640 __ververify_cache__[myorigval] = 1
641 # 1a, 2.0b, etc.
642 except:
643 pass
644 # ok, maybe we have a 1_alpha or 1_beta2; let's see
645 ep=string.split(myval[-1],"_")
646 if len(ep)!= 2:
647 if not silent:
648 error("package version has more than one letter at then end")
649 __ververify_cache__[myorigval] = 0
650 return 0
651 try:
652 foo = string.atoi(ep[0])
653 except:
654 # this needs to be numeric, i.e. the "1" in "1_alpha"
655 if not silent:
656 error("package version must have numeric part before the '_'")
657 __ververify_cache__[myorigval] = 0
658 return 0
659
660 for mye in _package_ends_:
661 if ep[1][0:len(mye)] == mye:
662 if len(mye) == len(ep[1]):
663 # no trailing numeric is ok
664 __ververify_cache__[myorigval] = 1
665 return 1
666 else:
667 try:
668 foo = string.atoi(ep[1][len(mye):])
669 __ververify_cache__[myorigval] = 1
670 return 1
671 except:
672 # if no _package_weights_ work, *then* we return 0
673 pass
674 if not silent:
675 error("package version extension after '_' is invalid")
676 __ververify_cache__[myorigval] = 0
677 return 0
678
679
680def isjustname(mypkg):
681 myparts = string.split(mypkg,'-')
682 for x in myparts:
683 if ververify(x):
684 return 0
685 return 1
686
687
688_isspecific_cache_={}
689
690def isspecific(mypkg):
691 "now supports packages with no category"
692 try:
693 return __isspecific_cache__[mypkg]
694 except:
695 pass
696
697 mysplit = string.split(mypkg,"/")
698 if not isjustname(mysplit[-1]):
699 __isspecific_cache__[mypkg] = 1
700 return 1
701 __isspecific_cache__[mypkg] = 0
702 return 0
703
704
705#######################################################################
706
707__pkgsplit_cache__={}
708
709def pkgsplit(mypkg, silent=1):
710
711 """This function can be used as a package verification function. If
712 it is a valid name, pkgsplit will return a list containing:
713 [pkgname, pkgversion(norev), pkgrev ].
714
715 >>> pkgsplit('')
716 >>> pkgsplit('x')
717 >>> pkgsplit('x-')
718 >>> pkgsplit('-1')
719 >>> pkgsplit('glibc-1.2-8.9-r7')
720 >>> pkgsplit('glibc-2.2.5-r7')
721 ['glibc', '2.2.5', 'r7']
722 >>> pkgsplit('foo-1.2-1')
723 >>> pkgsplit('Mesa-3.0')
724 ['Mesa', '3.0', 'r0']
725 """
726
727 try:
728 return __pkgsplit_cache__[mypkg]
729 except KeyError:
730 pass
731
732 myparts = string.split(mypkg,'-')
733 if len(myparts) < 2:
734 if not silent:
735 error("package name without name or version part")
736 __pkgsplit_cache__[mypkg] = None
737 return None
738 for x in myparts:
739 if len(x) == 0:
740 if not silent:
741 error("package name with empty name or version part")
742 __pkgsplit_cache__[mypkg] = None
743 return None
744 # verify rev
745 revok = 0
746 myrev = myparts[-1]
747 ververify(myrev, silent)
748 if len(myrev) and myrev[0] == "r":
749 try:
750 string.atoi(myrev[1:])
751 revok = 1
752 except:
753 pass
754 if revok:
755 if ververify(myparts[-2]):
756 if len(myparts) == 2:
757 __pkgsplit_cache__[mypkg] = None
758 return None
759 else:
760 for x in myparts[:-2]:
761 if ververify(x):
762 __pkgsplit_cache__[mypkg]=None
763 return None
764 # names can't have versiony looking parts
765 myval=[string.join(myparts[:-2],"-"),myparts[-2],myparts[-1]]
766 __pkgsplit_cache__[mypkg]=myval
767 return myval
768 else:
769 __pkgsplit_cache__[mypkg] = None
770 return None
771
772 elif ververify(myparts[-1],silent):
773 if len(myparts)==1:
774 if not silent:
775 print "!!! Name error in",mypkg+": missing name part."
776 __pkgsplit_cache__[mypkg]=None
777 return None
778 else:
779 for x in myparts[:-1]:
780 if ververify(x):
781 if not silent: error("package name has multiple version parts")
782 __pkgsplit_cache__[mypkg] = None
783 return None
784 myval = [string.join(myparts[:-1],"-"), myparts[-1],"r0"]
785 __pkgsplit_cache__[mypkg] = myval
786 return myval
787 else:
788 __pkgsplit_cache__[mypkg] = None
789 return None
790
791
792#######################################################################
793
794__catpkgsplit_cache__ = {}
795
796def catpkgsplit(mydata,silent=1):
797 """returns [cat, pkgname, version, rev ]
798
799 >>> catpkgsplit('sys-libs/glibc-1.2-r7')
800 ['sys-libs', 'glibc', '1.2', 'r7']
801 >>> catpkgsplit('glibc-1.2-r7')
802 [None, 'glibc', '1.2', 'r7']
803 """
804
805 try:
806 return __catpkgsplit_cache__[mydata]
807 except KeyError:
808 pass
809
810 cat = os.path.basename(os.path.dirname(mydata))
811 mydata = os.path.join(cat, os.path.basename(mydata))
812 if mydata[-3:] == '.bb':
813 mydata = mydata[:-3]
814
815 mysplit = mydata.split("/")
816 p_split = None
817 splitlen = len(mysplit)
818 if splitlen == 1:
819 retval = [None]
820 p_split = pkgsplit(mydata,silent)
821 else:
822 retval = [mysplit[splitlen - 2]]
823 p_split = pkgsplit(mysplit[splitlen - 1],silent)
824 if not p_split:
825 __catpkgsplit_cache__[mydata] = None
826 return None
827 retval.extend(p_split)
828 __catpkgsplit_cache__[mydata] = retval
829 return retval
830
831
832#######################################################################
833
834__vercmp_cache__ = {}
835</