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 + "/.patches")
325 os.chdir(patches_dir)
326 cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
328 cmd += " -p %s" % parm["pnum"]
329 # Getting rid of // at the front helps the Cygwin-Users of OE
330 if efile.startswith('//'):
332 cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
335 raise oe.build.FuncFailed("'patcher' execution failed")
339 do_fetch[dirs] = "${DL_DIR}"
340 do_fetch[nostamp] = "1"
341 python base_do_fetch() {
344 localdata = copy.deepcopy(d)
345 oe.data.update_data(localdata)
347 src_uri = oe.data.getVar('SRC_URI', localdata, 1)
352 oe.fetch.init(src_uri.split())
353 except oe.fetch.NoMethodError:
354 (type, value, traceback) = sys.exc_info()
355 raise oe.build.FuncFailed("No method: %s" % value)
358 oe.fetch.go(localdata)
359 except oe.fetch.MissingParameterError:
360 (type, value, traceback) = sys.exc_info()
361 raise oe.build.FuncFailed("Missing parameters: %s" % value)
362 except oe.fetch.FetchError:
363 (type, value, traceback) = sys.exc_info()
364 raise oe.build.FuncFailed("Fetch failed: %s" % value)
367 addtask unpack after do_fetch
368 do_unpack[dirs] = "${WORKDIR}"
369 python base_do_unpack() {
372 localdata = copy.deepcopy(d)
373 oe.data.update_data(localdata)
375 src_uri = oe.data.getVar('SRC_URI', localdata)
378 src_uri = oe.data.expand(src_uri, localdata)
379 for url in src_uri.split():
381 local = oe.data.expand(oe.fetch.localpath(url, localdata), localdata)
382 except oe.MalformedUrl, e:
383 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
384 # dont need any parameters for extraction, strip them off
385 local = re.sub(';.*$', '', local)
386 local = os.path.realpath(local)
387 dots = local.split(".")
388 if dots[-1] in ['gz', 'bz2', 'Z']:
389 efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
393 if local.endswith('.tar'):
394 cmd = 'tar x --no-same-owner -f %s' % local
395 elif local.endswith('.tgz') or local.endswith('.tar.gz'):
396 cmd = 'tar xz --no-same-owner -f %s' % local
397 elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
398 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
399 elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
400 loc = local.rfind('.')
401 cmd = 'gzip -dc %s > %s' % (local, efile)
402 elif local.endswith('.bz2'):
403 loc = local.rfind('.')
404 cmd = 'bzip2 -dc %s > %s' % (local, efile)
405 elif local.endswith('.zip'):
406 loc = local.rfind('.')
407 cmd = 'unzip -q %s' % local
408 elif os.path.isdir(local):
409 filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
411 if local[0:len(filesdir)] == filesdir:
412 destdir = local[len(filesdir):local.rfind('/')]
413 destdir = destdir.strip('/')
416 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
417 os.makedirs("%s/%s" % (os.getcwd(), destdir))
418 cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
420 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
421 if not 'patch' in parm:
422 destdir = oe.decodeurl(url)[1] or "."
423 oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
424 cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
427 cmd = "PATH=\"%s\" %s" % (oe.data.getVar('PATH', d, 1), cmd)
428 oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
431 raise oe.build.FuncFailed("%s execution failed" % cmd)
434 addhandler base_eventhandler
435 python base_eventhandler() {
436 from oe import note, error, data
437 from oe.event import Handled, NotHandled, getName
441 if name in ["PkgSucceeded"]:
442 note("package %s: build completed" % e.pkg)
443 if name in ["PkgStarted"]:
444 note("package %s: build %s" % (e.pkg, name[3:].lower()))
445 elif name in ["PkgFailed"]:
446 error("package %s: build %s" % (e.pkg, name[3:].lower()))
447 elif name in ["TaskStarted"]:
448 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
449 elif name in ["TaskSucceeded"]:
450 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
451 elif name in ["TaskFailed"]:
452 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
453 elif name in ["UnsatisfiedDep"]:
454 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
455 elif name in ["BuildStarted", "BuildCompleted"]:
456 note("build %s %s" % (e.name, name[5:].lower()))
460 addtask configure after do_unpack do_patch
461 do_configure[dirs] = "${S} ${B}"
463 base_do_configure() {
467 addtask compile after do_configure
468 do_compile[dirs] = "${S} ${B}"
470 if [ -e Makefile -o -e makefile ]; then
471 oe_runmake || die "make failed"
473 oenote "nothing to compile"
478 addtask stage after do_compile
483 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
484 ${STAGING_DIR}/${TARGET_SYS}/include \
485 ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
486 ${STAGING_DIR}/${BUILD_SYS}/include \
490 addtask populate_staging after do_compile
492 #python do_populate_staging () {
493 # if not oe.data.getVar('manifest', d):
494 # oe.build.exec_func('do_emit_manifest', d)
495 # if oe.data.getVar('do_stage', d):
496 # oe.build.exec_func('do_stage', d)
498 # oe.build.exec_func('manifest_do_populate_staging', d)
501 python do_populate_staging () {
502 if oe.data.getVar('manifest_do_populate_staging', d):
503 oe.build.exec_func('manifest_do_populate_staging', d)
505 oe.build.exec_func('do_stage', d)
509 addtask install after do_compile
510 do_install[dirs] = "${S} ${B}"
516 #addtask populate_pkgs after do_compile
517 #python do_populate_pkgs () {
518 # if not oe.data.getVar('manifest', d):
519 # oe.build.exec_func('do_emit_manifest', d)
520 # oe.build.exec_func('manifest_do_populate_pkgs', d)
521 # oe.build.exec_func('package_do_shlibs', d)
528 addtask build after do_populate_staging
530 do_build[nostamp] = "1"
533 # Functions that update metadata based on files outputted
534 # during the build process.
537 RDEPENDS_prepend = " ${SHLIBS}"
539 python read_manifest () {
541 mfn = oe.data.getVar("MANIFEST", d, 1)
542 if os.access(mfn, os.R_OK):
543 # we have a manifest, so emit do_stage and do_populate_pkgs,
544 # and stuff some additional bits of data into the metadata store
545 mfile = file(mfn, "r")
546 manifest = oe.manifest.parse(mfile, d)
550 oe.data.setVar('manifest', manifest, d)
553 python parse_manifest () {
554 manifest = oe.data.getVar("manifest", d)
557 for func in ("do_populate_staging", "do_populate_pkgs"):
558 value = oe.manifest.emit(func, manifest, d)
560 oe.data.setVar("manifest_" + func, value, d)
561 oe.data.delVarFlag("manifest_" + func, "python", d)
562 oe.data.delVarFlag("manifest_" + func, "fakeroot", d)
563 oe.data.setVarFlag("manifest_" + func, "func", 1, d)
566 if "pkg" in l and l["pkg"] is not None:
567 packages.append(l["pkg"])
568 oe.data.setVar("PACKAGES", " ".join(packages), d)
583 r[-1] += ' ' + ' '.join(j)
588 python read_shlibdeps () {
589 packages = (oe.data.getVar('PACKAGES', d, 1) or "").split()
591 rdepends = explode_deps(oe.data.getVar('RDEPENDS_' + pkg, d, 0) or oe.data.getVar('RDEPENDS', d, 0) or "")
592 shlibsfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
593 if os.access(shlibsfile, os.R_OK):
594 fd = file(shlibsfile)
595 lines = fd.readlines()
598 rdepends.append(l.rstrip())
599 pcfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d)
600 if os.access(pcfile, os.R_OK):
602 lines = fd.readlines()
605 rdepends.append(l.rstrip())
606 oe.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
609 python read_subpackage_metadata () {
614 c = codecs.getdecoder("string_escape")
617 data_file = oe.data.expand("${WORKDIR}/install/${PN}.package", d)
618 if os.access(data_file, os.R_OK):
619 f = file(data_file, 'r')
620 lines = f.readlines()
622 r = re.compile("([^:]+):\s*(.*)")
626 oe.data.setVar(m.group(1), decode(m.group(2)), d)
629 python __anonymous () {
630 need_host = oe.data.getVar('COMPATIBLE_HOST', d, 1)
633 this_host = oe.data.getVar('HOST_SYS', d, 1)
634 if not re.match(need_host, this_host):
635 raise oe.parse.SkipPackage("incompatible with host %s" % this_host)
637 pn = oe.data.getVar('PN', d, 1)
638 cvsdate = oe.data.getVar('CVSDATE_%s' % pn, d, 1)
640 oe.data.setVar('CVSDATE', cvsdate, d)
643 oe.build.exec_func('read_manifest', d)
644 oe.build.exec_func('parse_manifest', d)
645 oe.build.exec_func('read_shlibdeps', d)
646 oe.build.exec_func('read_subpackage_metadata', d)
648 oe.error("anonymous function: %s" % e)
652 addtask emit_manifest
653 python do_emit_manifest () {
654 # FIXME: emit a manifest here
655 # 1) adjust PATH to hit the wrapper scripts
656 wrappers = oe.which(oe.data.getVar("OEPATH", d, 1), 'build/install', 0)
657 path = (oe.data.getVar('PATH', d, 1) or '').split(':')
658 path.insert(0, os.path.dirname(wrappers))
659 oe.data.setVar('PATH', ':'.join(path), d)
660 # 2) exec_func("do_install", d)
661 oe.build.exec_func('do_install', d)
662 # 3) read in data collected by the wrappers
663 oe.build.exec_func('read_manifest', d)
664 # 4) mangle the manifest we just generated, get paths back into
666 # 5) write it back out
667 # 6) re-parse it to ensure the generated functions are proper
668 oe.build.exec_func('parse_manifest', d)
671 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
675 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
676 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
677 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
678 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
679 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
680 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
681 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
682 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
683 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
684 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
685 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
686 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
687 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
688 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
689 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
690 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
691 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
692 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
693 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
694 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
695 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
696 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
697 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
698 ftp://ftp.kernel.org/pub http://www.kernel.org/pub
699 ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub
700 ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub
701 ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub
702 ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub
703 ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub
704 ftp://.*/.*/ http://treke.net/oe/source/
705 http://.*/.*/ http://treke.net/oe/source/