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(path, d):
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([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}"
42 def oe_filter(f, str, d):
44 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
46 def oe_filter_out(f, str, d):
48 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
69 echo "Usage: oedebug level \"message\""
73 test ${OEDEBUG:-0} -ge $1 && {
80 if [ x"$MAKE" = x ]; then MAKE=make; fi
81 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
82 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oemake failed"
86 # Purpose: Install shared library file and
87 # create the necessary links
92 #oenote installing shared library $1 to $2
95 install -m 755 $1 $2/$libname
96 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
97 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
98 ln -sf $libname $2/$sonamelink
99 ln -sf $libname $2/$solink
103 # Purpose: Install a library, in all its forms
106 # oe_libinstall libltdl ${STAGING_LIBDIR}/
107 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
110 while [ "$#" -gt 0 ]; do
126 oefatal "oe_libinstall: unknown option: $1"
138 if [ -z "$destpath" ]; then
139 oefatal "oe_libinstall: no destination path specified"
143 if [ -z "$silent" ]; then
144 echo >&2 "oe_libinstall: $*"
149 if [ -z "$dir" ]; then
152 if [ -d "$dir/.libs" ]; then
159 if [ -f "$lafile" ]; then
161 eval `cat $lafile|grep "^library_names="`
164 library_names="$libname.so* $libname.dll.a"
167 __runcmd install -d $destpath/
169 if [ -f "$dota" -o -n "$require_static" ]; then
170 __runcmd install -m 0644 $dota $destpath/
173 if [ -f "$dotlai" -o -n "$libtool" ]; then
174 __runcmd install -m 0644 $dotlai $destpath/$libname.la
177 for name in $library_names; do
178 files=`eval echo $name`
180 if [ ! -e "$f" ]; then
181 if [ -n "$libtool" ]; then
182 oefatal "oe_libinstall: $dir/$f not found."
184 elif [ -L "$f" ]; then
185 __runcmd cp -P "$f" $destpath/
186 elif [ ! -L "$f" ]; then
188 __runcmd install -m 0755 $libfile $destpath/
193 if [ -z "$libfile" ]; then
194 if [ -n "$require_shared" ]; then
195 oefatal "oe_libinstall: unable to locate shared library"
197 elif [ -z "$libtool" ]; then
198 # special case hack for non-libtool .so.#.#.# links
199 baselibfile=`basename "$libfile"`
200 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
201 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
202 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
203 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
204 __runcmd ln -sf $baselibfile $destpath/$sonamelink
206 __runcmd ln -sf $baselibfile $destpath/$solink
210 __runcmd cd "$olddir"
214 # Purpose: Install machine dependent files, if available
215 # If not available, check if there is a default
216 # If no default, just touch the destination
219 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
221 # TODO: Check argument number?
223 filename=`basename $3`
226 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
227 if [ -e $dirname/$o/$filename ]; then
228 oenote $dirname/$o/$filename present, installing to $4
229 install $1 $2 $dirname/$o/$filename $4
233 # oenote overrides specific file NOT present, trying default=$3...
235 oenote $3 present, installing to $4
238 oenote $3 NOT present, touching empty $4
244 do_showdata[nostamp] = "1"
245 python do_showdata() {
247 # emit variables and shell functions
248 oe.data.emit_env(sys.__stdout__, d, True)
249 # emit the metadata which isnt valid shell
251 if oe.data.getVarFlag(e, 'python', d):
252 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
253 elif oe.data.getVarFlag(e, 'func', d):
254 sys.__stdout__.write("\n%s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
256 sys.__stdout__.write("%s=%s\n" % (e, oe.data.getVar(e, d, 1)))
260 do_listtasks[nostamp] = "1"
261 python do_listtasks() {
263 # emit variables and shell functions
264 #oe.data.emit_env(sys.__stdout__, d)
265 # emit the metadata which isnt valid shell
267 if oe.data.getVarFlag(e, 'task', d):
268 sys.__stdout__.write("%s\n" % e)
272 do_clean[dirs] = "${TOPDIR}"
273 do_clean[nostamp] = "1"
274 python base_do_clean() {
275 """clear the build and temp directories"""
276 dir = oe.data.expand("${WORKDIR}", d)
277 if dir == '//': raise oe.build.FuncFailed("wrong DATADIR")
278 oe.note("removing " + dir)
279 os.system('rm -rf ' + dir)
281 dir = "%s.*" % oe.data.expand(oe.data.getVar('STAMP', d), d)
282 oe.note("removing " + dir)
283 os.system('rm -f '+ dir)
287 do_mrproper[dirs] = "${TOPDIR}"
288 do_mrproper[nostamp] = "1"
289 python base_do_mrproper() {
290 """clear downloaded sources, build and temp directories"""
291 dir = oe.data.expand("${DL_DIR}", d)
292 if dir == '/': oe.build.FuncFailed("wrong DATADIR")
293 oe.debug(2, "removing " + dir)
294 os.system('rm -rf ' + dir)
295 oe.build.exec_task('do_clean', d)
298 addtask patch after do_unpack
299 do_patch[dirs] = "${WORKDIR}"
300 python base_do_patch() {
303 src_uri = oe.data.getVar('SRC_URI', d)
306 src_uri = oe.data.expand(src_uri, d)
307 for url in src_uri.split():
308 # oe.note('url is %s' % url)
309 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
310 if not "patch" in parm:
312 from oe.fetch import init, localpath
314 url = oe.encodeurl((type, host, path, user, pswd, []))
315 local = '/' + localpath(url, d)
317 dots = local.split(".")
318 if dots[-1] in ['gz', 'bz2', 'Z']:
319 efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
322 efile = oe.data.expand(efile, d)
323 patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
324 oe.mkdirhier(patches_dir)
325 os.chdir(patches_dir)
326 cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
328 cmd += " -p %s" % parm["pnum"]
329 cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
332 raise oe.build.FuncFailed("'patcher' execution failed")
336 do_fetch[dirs] = "${DL_DIR}"
337 do_fetch[nostamp] = "1"
338 python base_do_fetch() {
341 localdata = copy.deepcopy(d)
342 oe.data.update_data(localdata)
344 src_uri = oe.data.getVar('SRC_URI', localdata, 1)
349 oe.fetch.init(src_uri.split())
350 except oe.fetch.NoMethodError:
351 (type, value, traceback) = sys.exc_info()
352 raise oe.build.FuncFailed("No method: %s" % value)
355 oe.fetch.go(localdata)
356 except oe.fetch.MissingParameterError:
357 (type, value, traceback) = sys.exc_info()
358 raise oe.build.FuncFailed("Missing parameters: %s" % value)
359 except oe.fetch.FetchError:
360 (type, value, traceback) = sys.exc_info()
361 raise oe.build.FuncFailed("Fetch failed: %s" % value)
364 addtask unpack after do_fetch
365 do_unpack[dirs] = "${WORKDIR}"
366 python base_do_unpack() {
369 localdata = copy.deepcopy(d)
370 oe.data.update_data(localdata)
372 src_uri = oe.data.getVar('SRC_URI', localdata)
375 src_uri = oe.data.expand(src_uri, localdata)
376 for url in src_uri.split():
378 local = oe.data.expand(oe.fetch.localpath(url, localdata), localdata)
379 except oe.MalformedUrl, e:
380 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
381 # dont need any parameters for extraction, strip them off
382 local = re.sub(';.*$', '', local)
383 local = os.path.realpath(local)
384 dots = local.split(".")
385 if dots[-1] in ['gz', 'bz2', 'Z']:
386 efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
390 if local.endswith('.tar'):
391 cmd = 'tar x --no-same-owner -f %s' % local
392 elif local.endswith('.tgz') or local.endswith('.tar.gz'):
393 cmd = 'tar xz --no-same-owner -f %s' % local
394 elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
395 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
396 elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
397 loc = local.rfind('.')
398 cmd = 'gzip -dc %s > %s' % (local, efile)
399 elif local.endswith('.bz2'):
400 loc = local.rfind('.')
401 cmd = 'bzip2 -dc %s > %s' % (local, efile)
402 elif local.endswith('.zip'):
403 loc = local.rfind('.')
404 cmd = 'unzip -q %s' % local
405 elif os.path.isdir(local):
406 filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
408 if local[0:len(filesdir)] == filesdir:
409 destdir = local[len(filesdir):local.rfind('/')]
410 destdir = destdir.strip('/')
413 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
414 os.makedirs("%s/%s" % (os.getcwd(), destdir))
415 cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
417 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
418 if not 'patch' in parm:
419 destdir = oe.decodeurl(url)[1] or "."
420 oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
421 cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
424 oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
427 raise oe.build.FuncFailed("%s execution failed" % cmd)
430 addhandler base_eventhandler
431 python base_eventhandler() {
432 from oe import note, error, data
433 from oe.event import Handled, NotHandled, getName
437 if name in ["PkgSucceeded"]:
438 note("package %s: build completed" % e.pkg)
439 if name in ["PkgStarted"]:
440 note("package %s: build %s" % (e.pkg, name[3:].lower()))
441 elif name in ["PkgFailed"]:
442 error("package %s: build %s" % (e.pkg, name[3:].lower()))
443 elif name in ["TaskStarted"]:
444 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
445 elif name in ["TaskSucceeded"]:
446 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
447 elif name in ["TaskFailed"]:
448 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
449 elif name in ["UnsatisfiedDep"]:
450 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
451 elif name in ["BuildStarted", "BuildCompleted"]:
452 note("build %s %s" % (e.name, name[5:].lower()))
456 addtask configure after do_unpack do_patch
457 do_configure[dirs] = "${S} ${B}"
459 base_do_configure() {
463 addtask compile after do_configure
464 do_compile[dirs] = "${S} ${B}"
466 if [ -e Makefile -o -e makefile ]; then
467 oe_runmake || die "make failed"
469 oenote "nothing to compile"
474 addtask stage after do_compile
479 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
480 ${STAGING_DIR}/${TARGET_SYS}/include \
481 ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
482 ${STAGING_DIR}/${BUILD_SYS}/include \
486 addtask populate_staging after do_compile
488 #python do_populate_staging () {
489 # if not oe.data.getVar('manifest', d):
490 # oe.build.exec_func('do_emit_manifest', d)
491 # if oe.data.getVar('do_stage', d):
492 # oe.build.exec_func('do_stage', d)
494 # oe.build.exec_func('manifest_do_populate_staging', d)
497 python do_populate_staging () {
498 if oe.data.getVar('manifest_do_populate_staging', d):
499 oe.build.exec_func('manifest_do_populate_staging', d)
501 oe.build.exec_func('do_stage', d)
505 addtask install after do_compile
506 do_install[dirs] = "${S} ${B}"
512 #addtask populate_pkgs after do_compile
513 #python do_populate_pkgs () {
514 # if not oe.data.getVar('manifest', d):
515 # oe.build.exec_func('do_emit_manifest', d)
516 # oe.build.exec_func('manifest_do_populate_pkgs', d)
517 # oe.build.exec_func('package_do_shlibs', d)
524 addtask build after do_populate_staging
526 do_build[nostamp] = "1"
529 # Functions that update metadata based on files outputted
530 # during the build process.
533 RDEPENDS_prepend = " ${SHLIBS}"
535 python read_manifest () {
537 mfn = oe.data.getVar("MANIFEST", d, 1)
538 if os.access(mfn, os.R_OK):
539 # we have a manifest, so emit do_stage and do_populate_pkgs,
540 # and stuff some additional bits of data into the metadata store
541 mfile = file(mfn, "r")
542 manifest = oe.manifest.parse(mfile, d)
546 oe.data.setVar('manifest', manifest, d)
549 python parse_manifest () {
550 manifest = oe.data.getVar("manifest", d)
553 for func in ("do_populate_staging", "do_populate_pkgs"):
554 value = oe.manifest.emit(func, manifest, d)
556 oe.data.setVar("manifest_" + func, value, d)
557 oe.data.delVarFlag("manifest_" + func, "python", d)
558 oe.data.delVarFlag("manifest_" + func, "fakeroot", d)
559 oe.data.setVarFlag("manifest_" + func, "func", 1, d)
562 if "pkg" in l and l["pkg"] is not None:
563 packages.append(l["pkg"])
564 oe.data.setVar("PACKAGES", " ".join(packages), d)
579 r[-1] += ' ' + ' '.join(j)
584 python read_shlibdeps () {
585 packages = (oe.data.getVar('PACKAGES', d, 1) or "").split()
587 rdepends = explode_deps(oe.data.getVar('RDEPENDS_' + pkg, d, 0) or oe.data.getVar('RDEPENDS', d, 0) or "")
588 shlibsfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
589 if os.access(shlibsfile, os.R_OK):
590 fd = file(shlibsfile)
591 lines = fd.readlines()
594 rdepends.append(l.rstrip())
595 pcfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d)
596 if os.access(pcfile, os.R_OK):
598 lines = fd.readlines()
601 rdepends.append(l.rstrip())
602 oe.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
605 python read_subpackage_metadata () {
610 c = codecs.getdecoder("string_escape")
613 data_file = oe.data.expand("${WORKDIR}/install/${PN}.package", d)
614 if os.access(data_file, os.R_OK):
615 f = file(data_file, 'r')
616 lines = f.readlines()
618 r = re.compile("([^:]+):\s*(.*)")
622 oe.data.setVar(m.group(1), decode(m.group(2)), d)
625 python __anonymous () {
626 need_host = oe.data.getVar('COMPATIBLE_HOST', d, 1)
629 this_host = oe.data.getVar('HOST_SYS', d, 1)
630 if not re.match(need_host, this_host):
631 raise oe.parse.SkipPackage("incompatible with host %s" % this_host)
633 pn = oe.data.getVar('PN', d, 1)
634 cvsdate = oe.data.getVar('CVSDATE_%s' % pn, d, 1)
636 oe.data.setVar('CVSDATE', cvsdate, d)
639 oe.build.exec_func('read_manifest', d)
640 oe.build.exec_func('parse_manifest', d)
641 oe.build.exec_func('read_shlibdeps', d)
642 oe.build.exec_func('read_subpackage_metadata', d)
644 oe.error("anonymous function: %s" % e)
648 addtask emit_manifest
649 python do_emit_manifest () {
650 # FIXME: emit a manifest here
651 # 1) adjust PATH to hit the wrapper scripts
652 wrappers = oe.which(oe.data.getVar("OEPATH", d, 1), 'build/install', 0)
653 path = (oe.data.getVar('PATH', d, 1) or '').split(':')
654 path.insert(0, os.path.dirname(wrappers))
655 oe.data.setVar('PATH', ':'.join(path), d)
656 # 2) exec_func("do_install", d)
657 oe.build.exec_func('do_install', d)
658 # 3) read in data collected by the wrappers
659 oe.build.exec_func('read_manifest', d)
660 # 4) mangle the manifest we just generated, get paths back into
662 # 5) write it back out
663 # 6) re-parse it to ensure the generated functions are proper
664 oe.build.exec_func('parse_manifest', d)
667 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
671 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
672 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
673 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
674 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
675 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
676 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
677 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
678 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
679 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
680 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
681 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
682 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
683 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
684 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
685 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
686 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
687 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
688 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
689 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
690 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
691 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
692 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
693 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
694 ftp://ftp.kernel.org/pub http://www.kernel.org/pub
695 ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub
696 ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub
697 ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub
698 ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub
699 ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub
700 ftp://.*/.*/ http://treke.net/oe/source/
701 http://.*/.*/ http://treke.net/oe/source/