3 def base_dep_prepend(d):
6 # Ideally this will check a flag so we will operate properly in
7 # the case where host == build == target, for now we don't work in
11 if not oe.data.getVar('INHIBIT_DEFAULT_DEPS', d):
12 deps += "patcher-native"
13 if (oe.data.getVar('HOST_SYS', d, 1) !=
14 oe.data.getVar('BUILD_SYS', d, 1)):
15 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
18 def base_read_file(filename):
20 f = file( filename, "r" )
21 except IOError, reason:
22 return "<unknown>:%s" % reason
24 return f.read().strip()
27 DEPENDS_prepend="${@base_dep_prepend(d)} "
29 def base_set_filespath(d):
32 for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
33 overrides = oe.data.getVar("OVERRIDES", d, 1) or ""
34 overrides = overrides + ":"
35 for o in overrides.split(":"):
36 filespath.append(os.path.join(p, o))
37 oe.data.setVar("FILESPATH", ":".join(filespath), d)
39 FILESPATH = "${@base_set_filespath(d)}"
60 echo "Usage: oedebug level \"message\""
64 test ${OEDEBUG:-0} -ge $1 && {
71 if [ x"$MAKE" = x ]; then MAKE=make; fi
72 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
73 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oemake failed"
77 # Purpose: Install shared library file and
78 # create the necessary links
83 #oenote installing shared library $1 to $2
86 install -m 755 $1 $2/$libname
87 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
88 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
89 ln -sf $libname $2/$sonamelink
90 ln -sf $libname $2/$solink
94 # Purpose: Install a library, in all its forms
97 # oe_libinstall libltdl ${STAGING_LIBDIR}/
98 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
101 while [ "$#" -gt 0 ]; do
117 oefatal "oe_libinstall: unknown option: $1"
129 if [ -z "$destpath" ]; then
130 oefatal "oe_libinstall: no destination path specified"
134 if [ -z "$silent" ]; then
135 echo >&2 "oe_libinstall: $*"
140 if [ -z "$dir" ]; then
143 if [ -d "$dir/.libs" ]; then
150 if [ -f "$lafile" ]; then
152 eval `cat $lafile|grep "^library_names="`
155 library_names="$libname.so* $libname.dll.a"
158 __runcmd install -d $destpath/
160 if [ -f "$dota" -o -n "$require_static" ]; then
161 __runcmd install -m 0644 $dota $destpath/
164 if [ -f "$dotlai" -o -n "$libtool" ]; then
165 __runcmd install -m 0644 $dotlai $destpath/$libname.la
168 for name in $library_names; do
169 files=`eval echo $name`
171 if [ ! -e "$f" ]; then
172 if [ -n "$libtool" ]; then
173 oefatal "oe_libinstall: $dir/$f not found."
175 elif [ -L "$f" ]; then
176 __runcmd cp -P "$f" $destpath/
177 elif [ ! -L "$f" ]; then
179 __runcmd install -m 0755 $libfile $destpath/
184 if [ -z "$libfile" ]; then
185 if [ -n "$require_shared" ]; then
186 oefatal "oe_libinstall: unable to locate shared library"
188 elif [ -z "$libtool" ]; then
189 # special case hack for non-libtool .so.#.#.# links
190 baselibfile=`basename "$libfile"`
191 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
192 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
193 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
194 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
195 __runcmd ln -sf $baselibfile $destpath/$sonamelink
197 __runcmd ln -sf $baselibfile $destpath/$solink
201 __runcmd cd "$olddir"
205 # Purpose: Install machine dependent files, if available
206 # If not available, check if there is a default
207 # If no default, just touch the destination
210 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
212 # TODO: Check argument number?
214 filename=`basename $3`
217 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
218 if [ -e $dirname/$o/$filename ]; then
219 oenote $dirname/$o/$filename present, installing to $4
220 install $1 $2 $dirname/$o/$filename $4
224 # oenote overrides specific file NOT present, trying default=$3...
226 oenote $3 present, installing to $4
229 oenote $3 NOT present, touching empty $4
235 do_showdata[nostamp] = "1"
236 python do_showdata() {
238 # emit variables and shell functions
239 oe.data.emit_env(sys.__stdout__, d, True)
240 # emit the metadata which isnt valid shell
242 if oe.data.getVarFlag(e, 'python', d):
243 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
244 elif oe.data.getVarFlag(e, 'func', d):
245 sys.__stdout__.write("\n%s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
247 sys.__stdout__.write("%s=%s\n" % (e, oe.data.getVar(e, d, 1)))
251 do_listtasks[nostamp] = "1"
252 python do_listtasks() {
254 # emit variables and shell functions
255 #oe.data.emit_env(sys.__stdout__, d)
256 # emit the metadata which isnt valid shell
258 if oe.data.getVarFlag(e, 'task', d):
259 sys.__stdout__.write("%s\n" % e)
263 do_clean[dirs] = "${TOPDIR}"
264 do_clean[nostamp] = "1"
265 python base_do_clean() {
266 """clear the build and temp directories"""
267 dir = oe.data.expand("${WORKDIR}", d)
268 if dir == '//': raise oe.build.FuncFailed("wrong DATADIR")
269 oe.note("removing " + dir)
270 os.system('rm -rf ' + dir)
272 dir = "%s.*" % oe.data.expand(oe.data.getVar('STAMP', d), d)
273 oe.note("removing " + dir)
274 os.system('rm -f '+ dir)
278 do_mrproper[dirs] = "${TOPDIR}"
279 do_mrproper[nostamp] = "1"
280 python base_do_mrproper() {
281 """clear downloaded sources, build and temp directories"""
282 dir = oe.data.expand("${DL_DIR}", d)
283 if dir == '/': oe.build.FuncFailed("wrong DATADIR")
284 oe.debug(2, "removing " + dir)
285 os.system('rm -rf ' + dir)
286 oe.build.exec_task('do_clean', d)
289 addtask patch after do_unpack
290 do_patch[dirs] = "${WORKDIR}"
291 python base_do_patch() {
294 src_uri = oe.data.getVar('SRC_URI', d)
297 src_uri = oe.data.expand(src_uri, d)
298 for url in src_uri.split():
299 # oe.note('url is %s' % url)
300 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
301 if not "patch" in parm:
303 from oe.fetch import init, localpath
305 url = oe.encodeurl((type, host, path, user, pswd, []))
306 local = '/' + localpath(url, d)
308 dots = local.split(".")
309 if dots[-1] in ['gz', 'bz2', 'Z']:
310 efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
313 efile = oe.data.expand(efile, d)
314 patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
315 oe.mkdirhier(patches_dir)
316 os.chdir(patches_dir)
317 cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
319 cmd += " -p %s" % parm["pnum"]
320 cmd += " -n \"%s\" -i %s" % (os.path.basename(efile), efile)
323 raise oe.build.FuncFailed("'patcher' execution failed")
327 do_fetch[dirs] = "${DL_DIR}"
328 do_fetch[nostamp] = "1"
329 python base_do_fetch() {
332 localdata = copy.deepcopy(d)
333 oe.data.update_data(localdata)
335 src_uri = oe.data.getVar('SRC_URI', localdata, 1)
340 oe.fetch.init(src_uri.split())
341 except oe.fetch.NoMethodError:
342 (type, value, traceback) = sys.exc_info()
343 raise oe.build.FuncFailed("No method: %s" % value)
346 oe.fetch.go(localdata)
347 except oe.fetch.MissingParameterError:
348 (type, value, traceback) = sys.exc_info()
349 raise oe.build.FuncFailed("Missing parameters: %s" % value)
350 except oe.fetch.FetchError:
351 (type, value, traceback) = sys.exc_info()
352 raise oe.build.FuncFailed("Fetch failed: %s" % value)
355 addtask unpack after do_fetch
356 do_unpack[dirs] = "${WORKDIR}"
357 python base_do_unpack() {
360 localdata = copy.deepcopy(d)
361 oe.data.update_data(localdata)
363 src_uri = oe.data.getVar('SRC_URI', localdata)
366 src_uri = oe.data.expand(src_uri, localdata)
367 for url in src_uri.split():
369 local = oe.data.expand(oe.fetch.localpath(url, localdata), localdata)
370 except oe.MalformedUrl, e:
371 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
372 # dont need any parameters for extraction, strip them off
373 local = re.sub(';.*$', '', local)
374 local = os.path.realpath(local)
375 dots = local.split(".")
376 if dots[-1] in ['gz', 'bz2', 'Z']:
377 efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
381 if local.endswith('.tar'):
382 cmd = 'tar x --no-same-owner -f %s' % local
383 elif local.endswith('.tgz') or local.endswith('.tar.gz'):
384 cmd = 'tar xz --no-same-owner -f %s' % local
385 elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
386 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
387 elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
388 loc = local.rfind('.')
389 cmd = 'gzip -dc %s > %s' % (local, efile)
390 elif local.endswith('.bz2'):
391 loc = local.rfind('.')
392 cmd = 'bzip2 -dc %s > %s' % (local, efile)
393 elif local.endswith('.zip'):
394 loc = local.rfind('.')
395 cmd = 'unzip %s' % local
396 elif os.path.isdir(local):
397 filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
399 if local[0:len(filesdir)] == filesdir:
400 destdir = local[len(filesdir):local.rfind('/')]
401 destdir = destdir.strip('/')
404 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
405 os.makedirs("%s/%s" % (os.getcwd(), destdir))
406 cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
408 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
409 if not 'patch' in parm:
410 destdir = oe.decodeurl(url)[1] or "."
411 oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
412 cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
415 oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
418 raise oe.build.FuncFailed("%s execution failed" % cmd)
421 addhandler base_eventhandler
422 python base_eventhandler() {
423 from oe import note, error, data
424 from oe.event import Handled, NotHandled, getName
428 if name in ["PkgSucceeded"]:
429 note("package %s: build completed" % e.pkg)
430 if name in ["PkgStarted"]:
431 note("package %s: build %s" % (e.pkg, name[3:].lower()))
432 elif name in ["PkgFailed"]:
433 error("package %s: build %s" % (e.pkg, name[3:].lower()))
434 elif name in ["TaskStarted"]:
435 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
436 elif name in ["TaskSucceeded"]:
437 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
438 elif name in ["TaskFailed"]:
439 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
440 elif name in ["UnsatisfiedDep"]:
441 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
442 elif name in ["BuildStarted", "BuildCompleted"]:
443 note("build %s %s" % (e.name, name[5:].lower()))
447 addtask configure after do_unpack do_patch
448 do_configure[dirs] = "${S} ${B}"
450 base_do_configure() {
454 addtask compile after do_configure
455 do_compile[dirs] = "${S} ${B}"
457 if [ -e Makefile -o -e makefile ]; then
458 oe_runmake || die "make failed"
460 oenote "nothing to compile"
465 addtask stage after do_compile
470 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
471 ${STAGING_DIR}/${TARGET_SYS}/include \
472 ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
473 ${STAGING_DIR}/${BUILD_SYS}/include \
477 addtask populate_staging after do_compile
479 #python do_populate_staging () {
480 # if not oe.data.getVar('manifest', d):
481 # oe.build.exec_func('do_emit_manifest', d)
482 # if oe.data.getVar('do_stage', d):
483 # oe.build.exec_func('do_stage', d)
485 # oe.build.exec_func('manifest_do_populate_staging', d)
488 python do_populate_staging () {
489 if oe.data.getVar('manifest_do_populate_staging', d):
490 oe.build.exec_func('manifest_do_populate_staging', d)
492 oe.build.exec_func('do_stage', d)
496 addtask install after do_compile
497 do_install[dirs] = "${S} ${B}"
503 #addtask populate_pkgs after do_compile
504 #python do_populate_pkgs () {
505 # if not oe.data.getVar('manifest', d):
506 # oe.build.exec_func('do_emit_manifest', d)
507 # oe.build.exec_func('manifest_do_populate_pkgs', d)
508 # oe.build.exec_func('package_do_shlibs', d)
515 addtask build after do_populate_staging
517 do_build[nostamp] = "1"
520 # Functions that update metadata based on files outputted
521 # during the build process.
524 RDEPENDS_prepend = " ${SHLIBS}"
526 python read_manifest () {
528 mfn = oe.data.getVar("MANIFEST", d, 1)
529 if os.access(mfn, os.R_OK):
530 # we have a manifest, so emit do_stage and do_populate_pkgs,
531 # and stuff some additional bits of data into the metadata store
532 mfile = file(mfn, "r")
533 manifest = oe.manifest.parse(mfile, d)
537 oe.data.setVar('manifest', manifest, d)
540 python parse_manifest () {
541 manifest = oe.data.getVar("manifest", d)
544 for func in ("do_populate_staging", "do_populate_pkgs"):
545 value = oe.manifest.emit(func, manifest, d)
547 oe.data.setVar("manifest_" + func, value, d)
548 oe.data.delVarFlag("manifest_" + func, "python", d)
549 oe.data.delVarFlag("manifest_" + func, "fakeroot", d)
550 oe.data.setVarFlag("manifest_" + func, "func", 1, d)
553 if "pkg" in l and l["pkg"] is not None:
554 packages.append(l["pkg"])
555 oe.data.setVar("PACKAGES", " ".join(packages), d)
570 r[-1] += ' ' + ' '.join(j)
575 python read_shlibdeps () {
576 packages = (oe.data.getVar('PACKAGES', d, 1) or "").split()
578 shlibsfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
579 if os.access(shlibsfile, os.R_OK):
580 fd = file(shlibsfile)
581 lines = fd.readlines()
583 rdepends = explode_deps(oe.data.getVar('RDEPENDS_' + pkg, d, 1) or oe.data.getVar('RDEPENDS', d, 1) or "")
585 rdepends.append(l.rstrip())
586 oe.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
589 python read_subpackage_metadata () {
592 data_file = oe.data.expand("${WORKDIR}/install/${PN}.package", d)
593 if os.access(data_file, os.R_OK):
594 f = file(data_file, 'r')
595 lines = f.readlines()
597 r = re.compile("([^:]+):\s*(.*)")
601 oe.data.setVar(m.group(1), m.group(2), d)
604 python __anonymous () {
605 need_host = oe.data.getVar('COMPATIBLE_HOST', d, 1)
608 this_host = oe.data.getVar('HOST_SYS', d, 1)
609 if not re.match(need_host, this_host):
610 raise oe.parse.SkipPackage("incompatible with host %s" % this_host)
612 pn = oe.data.getVar('PN', d, 1)
613 cvsdate = oe.data.getVar('CVSDATE_%s' % pn, d, 1)
615 oe.data.setVar('CVSDATE', cvsdate, d)
618 oe.build.exec_func('read_manifest', d)
619 oe.build.exec_func('parse_manifest', d)
620 oe.build.exec_func('read_shlibdeps', d)
621 oe.build.exec_func('read_subpackage_metadata', d)
623 oe.error("anonymous function: %s" % e)
627 addtask emit_manifest
628 python do_emit_manifest () {
629 # FIXME: emit a manifest here
630 # 1) adjust PATH to hit the wrapper scripts
631 wrappers = oe.which(oe.data.getVar("OEPATH", d, 1), 'build/install', 0)
632 path = (oe.data.getVar('PATH', d, 1) or '').split(':')
633 path.insert(0, os.path.dirname(wrappers))
634 oe.data.setVar('PATH', ':'.join(path), d)
635 # 2) exec_func("do_install", d)
636 oe.build.exec_func('do_install', d)
637 # 3) read in data collected by the wrappers
638 oe.build.exec_func('read_manifest', d)
639 # 4) mangle the manifest we just generated, get paths back into
641 # 5) write it back out
642 # 6) re-parse it to ensure the generated functions are proper
643 oe.build.exec_func('parse_manifest', d)
646 EXPORT_FUNCTIONS do_clean do_mrproper do_fetch do_unpack do_configure do_compile do_install do_package do_patch do_populate_pkgs do_stage
650 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
651 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
652 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
653 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
654 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
655 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
656 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
657 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
658 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
659 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
660 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
661 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
662 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
663 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
664 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
665 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
666 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
667 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
668 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
669 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
670 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
671 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
672 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
673 ftp://ftp.kernel.org/pub http://www.kernel.org/pub
674 ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub
675 ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub
676 ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub
677 ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub
678 ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub
679 ftp://.*/.*/ http://treke.net/oe/source/
680 http://.*/.*/ http://treke.net/oe/source/