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 filter(f, str, d):
50 def filter_out(f, str, d):
54 if not match(f, w, 0):
77 echo "Usage: oedebug level \"message\""
81 test ${OEDEBUG:-0} -ge $1 && {
88 if [ x"$MAKE" = x ]; then MAKE=make; fi
89 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
90 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oemake failed"
94 # Purpose: Install shared library file and
95 # create the necessary links
100 #oenote installing shared library $1 to $2
102 libname=`basename $1`
103 install -m 755 $1 $2/$libname
104 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
105 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
106 ln -sf $libname $2/$sonamelink
107 ln -sf $libname $2/$solink
111 # Purpose: Install a library, in all its forms
114 # oe_libinstall libltdl ${STAGING_LIBDIR}/
115 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
118 while [ "$#" -gt 0 ]; do
134 oefatal "oe_libinstall: unknown option: $1"
146 if [ -z "$destpath" ]; then
147 oefatal "oe_libinstall: no destination path specified"
151 if [ -z "$silent" ]; then
152 echo >&2 "oe_libinstall: $*"
157 if [ -z "$dir" ]; then
160 if [ -d "$dir/.libs" ]; then
167 if [ -f "$lafile" ]; then
169 eval `cat $lafile|grep "^library_names="`
172 library_names="$libname.so* $libname.dll.a"
175 __runcmd install -d $destpath/
177 if [ -f "$dota" -o -n "$require_static" ]; then
178 __runcmd install -m 0644 $dota $destpath/
181 if [ -f "$dotlai" -o -n "$libtool" ]; then
182 __runcmd install -m 0644 $dotlai $destpath/$libname.la
185 for name in $library_names; do
186 files=`eval echo $name`
188 if [ ! -e "$f" ]; then
189 if [ -n "$libtool" ]; then
190 oefatal "oe_libinstall: $dir/$f not found."
192 elif [ -L "$f" ]; then
193 __runcmd cp -P "$f" $destpath/
194 elif [ ! -L "$f" ]; then
196 __runcmd install -m 0755 $libfile $destpath/
201 if [ -z "$libfile" ]; then
202 if [ -n "$require_shared" ]; then
203 oefatal "oe_libinstall: unable to locate shared library"
205 elif [ -z "$libtool" ]; then
206 # special case hack for non-libtool .so.#.#.# links
207 baselibfile=`basename "$libfile"`
208 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
209 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
210 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
211 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
212 __runcmd ln -sf $baselibfile $destpath/$sonamelink
214 __runcmd ln -sf $baselibfile $destpath/$solink
218 __runcmd cd "$olddir"
222 # Purpose: Install machine dependent files, if available
223 # If not available, check if there is a default
224 # If no default, just touch the destination
227 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
229 # TODO: Check argument number?
231 filename=`basename $3`
234 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
235 if [ -e $dirname/$o/$filename ]; then
236 oenote $dirname/$o/$filename present, installing to $4
237 install $1 $2 $dirname/$o/$filename $4
241 # oenote overrides specific file NOT present, trying default=$3...
243 oenote $3 present, installing to $4
246 oenote $3 NOT present, touching empty $4
252 do_showdata[nostamp] = "1"
253 python do_showdata() {
255 # emit variables and shell functions
256 oe.data.emit_env(sys.__stdout__, d, True)
257 # emit the metadata which isnt valid shell
259 if oe.data.getVarFlag(e, 'python', d):
260 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
261 elif oe.data.getVarFlag(e, 'func', d):
262 sys.__stdout__.write("\n%s () {\n%s}\n" % (e, oe.data.getVar(e, d, 1)))
264 sys.__stdout__.write("%s=%s\n" % (e, oe.data.getVar(e, d, 1)))
268 do_listtasks[nostamp] = "1"
269 python do_listtasks() {
271 # emit variables and shell functions
272 #oe.data.emit_env(sys.__stdout__, d)
273 # emit the metadata which isnt valid shell
275 if oe.data.getVarFlag(e, 'task', d):
276 sys.__stdout__.write("%s\n" % e)
280 do_clean[dirs] = "${TOPDIR}"
281 do_clean[nostamp] = "1"
282 python base_do_clean() {
283 """clear the build and temp directories"""
284 dir = oe.data.expand("${WORKDIR}", d)
285 if dir == '//': raise oe.build.FuncFailed("wrong DATADIR")
286 oe.note("removing " + dir)
287 os.system('rm -rf ' + dir)
289 dir = "%s.*" % oe.data.expand(oe.data.getVar('STAMP', d), d)
290 oe.note("removing " + dir)
291 os.system('rm -f '+ dir)
295 do_mrproper[dirs] = "${TOPDIR}"
296 do_mrproper[nostamp] = "1"
297 python base_do_mrproper() {
298 """clear downloaded sources, build and temp directories"""
299 dir = oe.data.expand("${DL_DIR}", d)
300 if dir == '/': oe.build.FuncFailed("wrong DATADIR")
301 oe.debug(2, "removing " + dir)
302 os.system('rm -rf ' + dir)
303 oe.build.exec_task('do_clean', d)
306 addtask patch after do_unpack
307 do_patch[dirs] = "${WORKDIR}"
308 python base_do_patch() {
311 src_uri = oe.data.getVar('SRC_URI', d)
314 src_uri = oe.data.expand(src_uri, d)
315 for url in src_uri.split():
316 # oe.note('url is %s' % url)
317 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
318 if not "patch" in parm:
320 from oe.fetch import init, localpath
322 url = oe.encodeurl((type, host, path, user, pswd, []))
323 local = '/' + localpath(url, d)
325 dots = local.split(".")
326 if dots[-1] in ['gz', 'bz2', 'Z']:
327 efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
330 efile = oe.data.expand(efile, d)
331 patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
332 oe.mkdirhier(patches_dir)
333 os.chdir(patches_dir)
334 cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
336 cmd += " -p %s" % parm["pnum"]
337 cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
340 raise oe.build.FuncFailed("'patcher' execution failed")
344 do_fetch[dirs] = "${DL_DIR}"
345 do_fetch[nostamp] = "1"
346 python base_do_fetch() {
349 localdata = copy.deepcopy(d)
350 oe.data.update_data(localdata)
352 src_uri = oe.data.getVar('SRC_URI', localdata, 1)
357 oe.fetch.init(src_uri.split())
358 except oe.fetch.NoMethodError:
359 (type, value, traceback) = sys.exc_info()
360 raise oe.build.FuncFailed("No method: %s" % value)
363 oe.fetch.go(localdata)
364 except oe.fetch.MissingParameterError:
365 (type, value, traceback) = sys.exc_info()
366 raise oe.build.FuncFailed("Missing parameters: %s" % value)
367 except oe.fetch.FetchError:
368 (type, value, traceback) = sys.exc_info()
369 raise oe.build.FuncFailed("Fetch failed: %s" % value)
372 addtask unpack after do_fetch
373 do_unpack[dirs] = "${WORKDIR}"
374 python base_do_unpack() {
377 localdata = copy.deepcopy(d)
378 oe.data.update_data(localdata)
380 src_uri = oe.data.getVar('SRC_URI', localdata)
383 src_uri = oe.data.expand(src_uri, localdata)
384 for url in src_uri.split():
386 local = oe.data.expand(oe.fetch.localpath(url, localdata), localdata)
387 except oe.MalformedUrl, e:
388 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
389 # dont need any parameters for extraction, strip them off
390 local = re.sub(';.*$', '', local)
391 local = os.path.realpath(local)
392 dots = local.split(".")
393 if dots[-1] in ['gz', 'bz2', 'Z']:
394 efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
398 if local.endswith('.tar'):
399 cmd = 'tar x --no-same-owner -f %s' % local
400 elif local.endswith('.tgz') or local.endswith('.tar.gz'):
401 cmd = 'tar xz --no-same-owner -f %s' % local
402 elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
403 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
404 elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
405 loc = local.rfind('.')
406 cmd = 'gzip -dc %s > %s' % (local, efile)
407 elif local.endswith('.bz2'):
408 loc = local.rfind('.')
409 cmd = 'bzip2 -dc %s > %s' % (local, efile)
410 elif local.endswith('.zip'):
411 loc = local.rfind('.')
412 cmd = 'unzip -q %s' % local
413 elif os.path.isdir(local):
414 filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
416 if local[0:len(filesdir)] == filesdir:
417 destdir = local[len(filesdir):local.rfind('/')]
418 destdir = destdir.strip('/')
421 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
422 os.makedirs("%s/%s" % (os.getcwd(), destdir))
423 cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
425 (type, host, path, user, pswd, parm) = oe.decodeurl(url)
426 if not 'patch' in parm:
427 destdir = oe.decodeurl(url)[1] or "."
428 oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
429 cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
432 oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
435 raise oe.build.FuncFailed("%s execution failed" % cmd)
438 addhandler base_eventhandler
439 python base_eventhandler() {
440 from oe import note, error, data
441 from oe.event import Handled, NotHandled, getName
445 if name in ["PkgSucceeded"]:
446 note("package %s: build completed" % e.pkg)
447 if name in ["PkgStarted"]:
448 note("package %s: build %s" % (e.pkg, name[3:].lower()))
449 elif name in ["PkgFailed"]:
450 error("package %s: build %s" % (e.pkg, name[3:].lower()))
451 elif name in ["TaskStarted"]:
452 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
453 elif name in ["TaskSucceeded"]:
454 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
455 elif name in ["TaskFailed"]:
456 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
457 elif name in ["UnsatisfiedDep"]:
458 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
459 elif name in ["BuildStarted", "BuildCompleted"]:
460 note("build %s %s" % (e.name, name[5:].lower()))
464 addtask configure after do_unpack do_patch
465 do_configure[dirs] = "${S} ${B}"
467 base_do_configure() {
471 addtask compile after do_configure
472 do_compile[dirs] = "${S} ${B}"
474 if [ -e Makefile -o -e makefile ]; then
475 oe_runmake || die "make failed"
477 oenote "nothing to compile"
482 addtask stage after do_compile
487 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
488 ${STAGING_DIR}/${TARGET_SYS}/include \
489 ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
490 ${STAGING_DIR}/${BUILD_SYS}/include \
494 addtask populate_staging after do_compile
496 #python do_populate_staging () {
497 # if not oe.data.getVar('manifest', d):
498 # oe.build.exec_func('do_emit_manifest', d)
499 # if oe.data.getVar('do_stage', d):
500 # oe.build.exec_func('do_stage', d)
502 # oe.build.exec_func('manifest_do_populate_staging', d)
505 python do_populate_staging () {
506 if oe.data.getVar('manifest_do_populate_staging', d):
507 oe.build.exec_func('manifest_do_populate_staging', d)
509 oe.build.exec_func('do_stage', d)
513 addtask install after do_compile
514 do_install[dirs] = "${S} ${B}"
520 #addtask populate_pkgs after do_compile
521 #python do_populate_pkgs () {
522 # if not oe.data.getVar('manifest', d):
523 # oe.build.exec_func('do_emit_manifest', d)
524 # oe.build.exec_func('manifest_do_populate_pkgs', d)
525 # oe.build.exec_func('package_do_shlibs', d)
532 addtask build after do_populate_staging
534 do_build[nostamp] = "1"
537 # Functions that update metadata based on files outputted
538 # during the build process.
541 RDEPENDS_prepend = " ${SHLIBS}"
543 python read_manifest () {
545 mfn = oe.data.getVar("MANIFEST", d, 1)
546 if os.access(mfn, os.R_OK):
547 # we have a manifest, so emit do_stage and do_populate_pkgs,
548 # and stuff some additional bits of data into the metadata store
549 mfile = file(mfn, "r")
550 manifest = oe.manifest.parse(mfile, d)
554 oe.data.setVar('manifest', manifest, d)
557 python parse_manifest () {
558 manifest = oe.data.getVar("manifest", d)
561 for func in ("do_populate_staging", "do_populate_pkgs"):
562 value = oe.manifest.emit(func, manifest, d)
564 oe.data.setVar("manifest_" + func, value, d)
565 oe.data.delVarFlag("manifest_" + func, "python", d)
566 oe.data.delVarFlag("manifest_" + func, "fakeroot", d)
567 oe.data.setVarFlag("manifest_" + func, "func", 1, d)
570 if "pkg" in l and l["pkg"] is not None:
571 packages.append(l["pkg"])
572 oe.data.setVar("PACKAGES", " ".join(packages), d)
587 r[-1] += ' ' + ' '.join(j)
592 python read_shlibdeps () {
593 packages = (oe.data.getVar('PACKAGES', d, 1) or "").split()
595 rdepends = explode_deps(oe.data.getVar('RDEPENDS_' + pkg, d, 0) or oe.data.getVar('RDEPENDS', d, 0) or "")
596 shlibsfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
597 if os.access(shlibsfile, os.R_OK):
598 fd = file(shlibsfile)
599 lines = fd.readlines()
602 rdepends.append(l.rstrip())
603 pcfile = oe.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d)
604 if os.access(pcfile, os.R_OK):
606 lines = fd.readlines()
609 rdepends.append(l.rstrip())
610 oe.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
613 python read_subpackage_metadata () {
618 c = codecs.getdecoder("string_escape")
621 data_file = oe.data.expand("${WORKDIR}/install/${PN}.package", d)
622 if os.access(data_file, os.R_OK):
623 f = file(data_file, 'r')
624 lines = f.readlines()
626 r = re.compile("([^:]+):\s*(.*)")
630 oe.data.setVar(m.group(1), decode(m.group(2)), d)
633 python __anonymous () {
634 need_host = oe.data.getVar('COMPATIBLE_HOST', d, 1)
637 this_host = oe.data.getVar('HOST_SYS', d, 1)
638 if not re.match(need_host, this_host):
639 raise oe.parse.SkipPackage("incompatible with host %s" % this_host)
641 pn = oe.data.getVar('PN', d, 1)
642 cvsdate = oe.data.getVar('CVSDATE_%s' % pn, d, 1)
644 oe.data.setVar('CVSDATE', cvsdate, d)
647 oe.build.exec_func('read_manifest', d)
648 oe.build.exec_func('parse_manifest', d)
649 oe.build.exec_func('read_shlibdeps', d)
650 oe.build.exec_func('read_subpackage_metadata', d)
652 oe.error("anonymous function: %s" % e)
656 addtask emit_manifest
657 python do_emit_manifest () {
658 # FIXME: emit a manifest here
659 # 1) adjust PATH to hit the wrapper scripts
660 wrappers = oe.which(oe.data.getVar("OEPATH", d, 1), 'build/install', 0)
661 path = (oe.data.getVar('PATH', d, 1) or '').split(':')
662 path.insert(0, os.path.dirname(wrappers))
663 oe.data.setVar('PATH', ':'.join(path), d)
664 # 2) exec_func("do_install", d)
665 oe.build.exec_func('do_install', d)
666 # 3) read in data collected by the wrappers
667 oe.build.exec_func('read_manifest', d)
668 # 4) mangle the manifest we just generated, get paths back into
670 # 5) write it back out
671 # 6) re-parse it to ensure the generated functions are proper
672 oe.build.exec_func('parse_manifest', d)
675 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
679 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
680 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
681 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
682 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
683 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
684 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
685 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
686 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
687 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
688 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
689 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
690 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
691 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
692 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
693 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
694 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
695 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
696 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
697 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
698 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
699 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
700 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
701 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
702 ftp://ftp.kernel.org/pub http://www.kernel.org/pub
703 ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub
704 ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub
705 ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub
706 ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub
707 ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub
708 ftp://.*/.*/ http://treke.net/oe/source/
709 http://.*/.*/ http://treke.net/oe/source/