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):
21 f = file( filename, "r" )
22 except IOError, reason:
23 raise oe.build.FuncFailed("can't read from file '%s' (%s)", (filename,reason))
25 return f.read().strip()
28 DEPENDS_prepend="${@base_dep_prepend(d)} "
30 def base_set_filespath(d):
33 for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
34 overrides = oe.data.getVar("OVERRIDES", d, 1) or ""
35 overrides = overrides + ":"
36 for o in overrides.split(":"):
37 filespath.append(os.path.join(p, o))
38 oe.data.setVar("FILESPATH", ":".join(filespath), d)
40 FILESPATH = "${@base_set_filespath(d)}"
61 echo "Usage: oedebug level \"message\""
65 test ${OEDEBUG:-0} -ge $1 && {
72 if [ x"$MAKE" = x ]; then MAKE=make; fi
73 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
74 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oemake failed"
78 # Purpose: Install shared library file and
79 # create the necessary links
84 #oenote installing shared library $1 to $2
87 install -m 755 $1 $2/$libname
88 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
89 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
90 ln -sf $libname $2/$sonamelink
91 ln -sf $libname $2/$solink
95 # Purpose: Install a library, in all its forms
98 # oe_libinstall libltdl ${STAGING_LIBDIR}/
99 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
102 while [ "$#" -gt 0 ]; do
118 oefatal "oe_libinstall: unknown option: $1"
130 if [ -z "$destpath" ]; then
131 oefatal "oe_libinstall: no destination path specified"
135 if [ -z "$silent" ]; then
136 echo >&2 "oe_libinstall: $*"
141 if [ -z "$dir" ]; then
144 if [ -d "$dir/.libs" ]; then
151 if [ -f "$lafile" ]; then
153 eval `cat $lafile|grep "^library_names="`
156 library_names="$libname.so* $libname.dll.a"
159 __runcmd install -d $destpath/
161 if [ -f "$dota" -o -n "$require_static" ]; then
162 __runcmd install -m 0644 $dota $destpath/
165 if [ -f "$dotlai" -o -n "$libtool" ]; then
166 __runcmd install -m 0644 $dotlai $destpath/$libname.la
169 for name in $library_names; do
170 files=`eval echo $name`
172 if [ ! -e "$f" ]; then
173 if [ -n "$libtool" ]; then
174 oefatal "oe_libinstall: $dir/$f not found."
176 elif [ -L "$f" ]; then
177 __runcmd cp -P "$f" $destpath/
178 elif [ ! -L "$f" ]; then
180 __runcmd install -m 0755 $libfile $destpath/
185 if [ -z "$libfile" ]; then
186 if [ -n "$require_shared" ]; then
187 oefatal "oe_libinstall: unable to locate shared library"
189 elif [ -z "$libtool" ]; then
190 # special case hack for non-libtool .so.#.#.# links
191 baselibfile=`basename "$libfile"`
192 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
193 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
194 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
195 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
196 __runcmd ln -sf $baselibfile $destpath/$sonamelink
198 __runcmd ln -sf $baselibfile $destpath/$solink
202 __runcmd cd "$olddir"
206 # Purpose: Install machine dependent files, if available
207 # If not available, check if there is a default
208 # If no default, just touch the destination
211 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
213 # TODO: Check argument number?
215 filename=`basename $3`
218 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
219 if [ -e $dirname/$o/$filename ]; then
220 oenote $dirname/$o/$filename present, installing to $4
221 install $1 $2 $dirname/$o/$filename $4
225 # oenote overrides specific file NOT present, trying default=$3...
227 oenote $3 present, installing to $4
230 oenote $3 NOT present, touching empty $4
236 do_showdata[nostamp] = "1"
237 python do_showdata() {
239 # emit variables and shell functions
240 oe.data.emit_env(sys.__stdout__, d, True)
241 # emit the metadata which isnt valid shell
243 if oe.data.getVarFlag(e, 'python', d):
244 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
245 elif oe.data.getVarFlag(e, 'func', d):
246 sys.__stdout__.write("\n%s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
248 sys.__stdout__.write("%s=%s\n" % (e, oe.data.getVar(e, d, 1)))
252 do_listtasks[nostamp] = "1"
253 python do_listtasks() {
255 # emit variables and shell functions
256 #oe.data.emit_env(sys.__stdout__, d)
257 # emit the metadata which isnt valid shell
259 if oe.data.getVarFlag(e, 'task', d):
260 sys.__stdout__.write("%s\n" % e)
264 do_clean[dirs] = "${TOPDIR}"
265 do_clean[nostamp] = "1"
266 python base_do_clean() {
267 """clear the build and temp directories"""
268 dir = oe.data.expand("${WORKDIR}", d)
269 if dir == '//': raise oe.build.FuncFailed("wrong DATADIR")
270 oe.note("removing " + dir)
271 os.system('rm -rf ' + dir)
273 dir = "%s.*" % oe.data.expand(oe.data.getVar('STAMP', d), d)
274 oe.note("removing " + dir)
275 os.system('rm -f '+ dir)
279 do_mrproper[dirs] = "${TOPDIR}"
280 do_mrproper[nostamp] = "1"
281 python base_do_mrproper() {
282 """clear downloaded sources, build and temp directories"""
283 dir = oe.data.expand("${DL_DIR}", d)
284 if dir == '/': oe.build.FuncFailed("wrong DATADIR")
285 oe.debug(2, "removing " + dir)
286 os.system('rm -rf ' + dir)
287 oe.build.exec_task('do_clean', d)
290 addtask patch after do_unpack
291 do_patch[dirs] = "${WORKDIR}"
292 python base_do_patch() {
295 src_uri = oe.data.getVar('SRC_URI', d)
298 src_uri = oe.data.expand(src_uri, d)
299 for url in src_uri.split():
300 # oe.note('url is %s' % url)
301 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
302 if not "patch" in parm:
304 from oe.fetch import init, localpath
306 url = oe.encodeurl((type, host, path, user, pswd, []))
307 local = '/' + localpath(url, d)
309 dots = local.split(".")
310 if dots[-1] in ['gz', 'bz2', 'Z']:
311 efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
314 efile = oe.data.expand(efile, d)
315 patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
316 oe.mkdirhier(patches_dir)
317 os.chdir(patches_dir)
318 cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
320 cmd += " -p %s" % parm["pnum"]
321 cmd += " -n \"%s\" -i %s" % (os.path.basename(efile), efile)
324 raise oe.build.FuncFailed("'patcher' execution failed")
328 do_fetch[dirs] = "${DL_DIR}"
329 do_fetch[nostamp] = "1"
330 python base_do_fetch() {
333 localdata = copy.deepcopy(d)
334 oe.data.update_data(localdata)
336 src_uri = oe.data.getVar('SRC_URI', localdata, 1)
341 oe.fetch.init(src_uri.split())
342 except oe.fetch.NoMethodError:
343 (type, value, traceback) = sys.exc_info()
344 raise oe.build.FuncFailed("No method: %s" % value)
347 oe.fetch.go(localdata)
348 except oe.fetch.MissingParameterError:
349 (type, value, traceback) = sys.exc_info()
350 raise oe.build.FuncFailed("Missing parameters: %s" % value)
351 except oe.fetch.FetchError:
352 (type, value, traceback) = sys.exc_info()
353 raise oe.build.FuncFailed("Fetch failed: %s" % value)
356 addtask unpack after do_fetch
357 do_unpack[dirs] = "${WORKDIR}"
358 python base_do_unpack() {
361 localdata = copy.deepcopy(d)
362 oe.data.update_data(localdata)
364 src_uri = oe.data.getVar('SRC_URI', localdata)
367 src_uri = oe.data.expand(src_uri, localdata)
368 for url in src_uri.split():
370 local = oe.data.expand(oe.fetch.localpath(url, localdata), localdata)
371 except oe.MalformedUrl, e:
372 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
373 # dont need any parameters for extraction, strip them off
374 local = re.sub(';.*$', '', local)
375 local = os.path.realpath(local)
376 dots = local.split(".")
377 if dots[-1] in ['gz', 'bz2', 'Z']:
378 efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
382 if local.endswith('.tar'):
383 cmd = 'tar x --no-same-owner -f %s' % local
384 elif local.endswith('.tgz') or local.endswith('.tar.gz'):
385 cmd = 'tar xz --no-same-owner -f %s' % local
386 elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
387 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
388 elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
389 loc = local.rfind('.')
390 cmd = 'gzip -dc %s > %s' % (local, efile)
391 elif local.endswith('.bz2'):
392 loc = local.rfind('.')
393 cmd = 'bzip2 -dc %s > %s' % (local, efile)
394 elif local.endswith('.zip'):
395 loc = local.rfind('.')
396 cmd = 'unzip %s' % local
397 elif os.path.isdir(local):
398 filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
400 if local[0:len(filesdir)] == filesdir:
401 destdir = local[len(filesdir):local.rfind('/')]
402 destdir = destdir.strip('/')
405 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
406 os.makedirs("%s/%s" % (os.getcwd(), destdir))
407 cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
409 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
410 if not 'patch' in parm:
411 destdir = oe.decodeurl(url)[1] or "."
412 oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
413 cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
416 oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
419 raise oe.build.FuncFailed("%s execution failed" % cmd)
422 addhandler base_eventhandler
423 python base_eventhandler() {
424 from oe import note, error, data
425 from oe.event import Handled, NotHandled, getName
429 if name in ["PkgSucceeded"]:
430 note("package %s: build completed" % e.pkg)
431 if name in ["PkgStarted"]:
432 note("package %s: build %s" % (e.pkg, name[3:].lower()))
433 elif name in ["PkgFailed"]:
434 error("package %s: build %s" % (e.pkg, name[3:].lower()))
435 elif name in ["TaskStarted"]:
436 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
437 elif name in ["TaskSucceeded"]:
438 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
439 elif name in ["TaskFailed"]:
440 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
441 elif name in ["UnsatisfiedDep"]:
442 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
443 elif name in ["BuildStarted", "BuildCompleted"]:
444 note("build %s %s" % (e.name, name[5:].lower()))
448 addtask configure after do_unpack do_patch
449 do_configure[dirs] = "${S} ${B}"
451 base_do_configure() {
455 addtask compile after do_configure
456 do_compile[dirs] = "${S} ${B}"
458 if [ -e Makefile -o -e makefile ]; then
459 oe_runmake || die "make failed"
461 oenote "nothing to compile"
466 addtask stage after do_compile
471 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
472 ${STAGING_DIR}/${TARGET_SYS}/include \
473 ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
474 ${STAGING_DIR}/${BUILD_SYS}/include \
478 addtask populate_staging after do_compile
480 #python do_populate_staging () {
481 # if not oe.data.getVar('manifest', d):
482 # oe.build.exec_func('do_emit_manifest', d)
483 # if oe.data.getVar('do_stage', d):
484 # oe.build.exec_func('do_stage', d)
486 # oe.build.exec_func('manifest_do_populate_staging', d)
489 python do_populate_staging () {
490 if oe.data.getVar('manifest_do_populate_staging', d):
491 oe.build.exec_func('manifest_do_populate_staging', d)
493 oe.build.exec_func('do_stage', d)
497 addtask install after do_compile
498 do_install[dirs] = "${S} ${B}"
504 #addtask populate_pkgs after do_compile
505 #python do_populate_pkgs () {
506 # if not oe.data.getVar('manifest', d):
507 # oe.build.exec_func('do_emit_manifest', d)
508 # oe.build.exec_func('manifest_do_populate_pkgs', d)
509 # oe.build.exec_func('package_do_shlibs', d)
516 addtask build after do_populate_staging
518 do_build[nostamp] = "1"
521 # Functions that update metadata based on files outputted
522 # during the build process.
525 RDEPENDS_prepend = " ${SHLIBS}"
527 python read_manifest () {
529 mfn = oe.data.getVar("MANIFEST", d, 1)
530 if os.access(mfn, os.R_OK):
531 # we have a manifest, so emit do_stage and do_populate_pkgs,
532 # and stuff some additional bits of data into the metadata store
533 mfile = file(mfn, "r")
534 manifest = oe.manifest.parse(mfile, d)
538 oe.data.setVar('manifest', manifest, d)
541 python parse_manifest () {
542 manifest = oe.data.getVar("manifest", d)
545 for func in ("do_populate_staging", "do_populate_pkgs"):
546 value = oe.manifest.emit(func, manifest, d)
548 oe.data.setVar("manifest_" + func, value, d)
549 oe.data.delVarFlag("manifest_" + func, "python", d)
550 oe.data.delVarFlag("manifest_" + func, "fakeroot", d)
551 oe.data.setVarFlag("manifest_" + func, "func", 1, d)
554 if "pkg" in l and l["pkg"] is not None:
555 packages.append(l["pkg"])
556 oe.data.setVar("PACKAGES", " ".join(packages), d)
571 r[-1] += ' ' + ' '.join(j)
576 python read_shlibdeps () {
577 packages = (oe.data.getVar('PACKAGES', d, 1) or "").split()
579 rdepends = explode_deps(oe.data.getVar('RDEPENDS_' + pkg, d, 0) or oe.data.getVar('RDEPENDS', d, 0) or "")
580 shlibsfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
581 if os.access(shlibsfile, os.R_OK):
582 fd = file(shlibsfile)
583 lines = fd.readlines()
586 rdepends.append(l.rstrip())
587 pcfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d)
588 if os.access(pcfile, os.R_OK):
590 lines = fd.readlines()
593 rdepends.append(l.rstrip())
594 oe.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
597 python read_subpackage_metadata () {
602 c = codecs.getdecoder("string_escape")
605 data_file = oe.data.expand("${WORKDIR}/install/${PN}.package", d)
606 if os.access(data_file, os.R_OK):
607 f = file(data_file, 'r')
608 lines = f.readlines()
610 r = re.compile("([^:]+):\s*(.*)")
614 oe.data.setVar(m.group(1), decode(m.group(2)), d)
617 python __anonymous () {
618 need_host = oe.data.getVar('COMPATIBLE_HOST', d, 1)
621 this_host = oe.data.getVar('HOST_SYS', d, 1)
622 if not re.match(need_host, this_host):
623 raise oe.parse.SkipPackage("incompatible with host %s" % this_host)
625 pn = oe.data.getVar('PN', d, 1)
626 cvsdate = oe.data.getVar('CVSDATE_%s' % pn, d, 1)
628 oe.data.setVar('CVSDATE', cvsdate, d)
631 oe.build.exec_func('read_manifest', d)
632 oe.build.exec_func('parse_manifest', d)
633 oe.build.exec_func('read_shlibdeps', d)
634 oe.build.exec_func('read_subpackage_metadata', d)
636 oe.error("anonymous function: %s" % e)
640 addtask emit_manifest
641 python do_emit_manifest () {
642 # FIXME: emit a manifest here
643 # 1) adjust PATH to hit the wrapper scripts
644 wrappers = oe.which(oe.data.getVar("OEPATH", d, 1), 'build/install', 0)
645 path = (oe.data.getVar('PATH', d, 1) or '').split(':')
646 path.insert(0, os.path.dirname(wrappers))
647 oe.data.setVar('PATH', ':'.join(path), d)
648 # 2) exec_func("do_install", d)
649 oe.build.exec_func('do_install', d)
650 # 3) read in data collected by the wrappers
651 oe.build.exec_func('read_manifest', d)
652 # 4) mangle the manifest we just generated, get paths back into
654 # 5) write it back out
655 # 6) re-parse it to ensure the generated functions are proper
656 oe.build.exec_func('parse_manifest', d)
659 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
663 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
664 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
665 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
666 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
667 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
668 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
669 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
670 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
671 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
672 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
673 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
674 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
675 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
676 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
677 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
678 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
679 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
680 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
681 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
682 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
683 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
684 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
685 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
686 ftp://ftp.kernel.org/pub http://www.kernel.org/pub
687 ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub
688 ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub
689 ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub
690 ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub
691 ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub
692 ftp://.*/.*/ http://treke.net/oe/source/
693 http://.*/.*/ http://treke.net/oe/source/