1 BB_DEFAULT_TASK ?= "build"
3 # like os.path.join but doesn't treat absolute RHS specially
4 def base_path_join(a, *p):
7 if path == '' or path.endswith('/'):
13 def base_path_relative(src, dest):
14 """ Return a relative path from src to dest.
16 >>> base_path_relative("/usr/bin", "/tmp/foo/bar")
19 >>> base_path_relative("/usr/bin", "/usr/lib")
22 >>> base_path_relative("/tmp", "/tmp/foo/bar")
25 from os.path import sep, pardir, normpath, commonprefix
27 destlist = normpath(dest).split(sep)
28 srclist = normpath(src).split(sep)
30 # Find common section of the path
31 common = commonprefix([destlist, srclist])
32 commonlen = len(common)
34 # Climb back to the point where they differentiate
35 relpath = [ pardir ] * (len(srclist) - commonlen)
36 if commonlen < len(destlist):
37 # Add remaining portion
38 relpath += destlist[commonlen:]
40 return sep.join(relpath)
42 # for MD5/SHA handling
43 def base_chk_load_parser(config_paths):
44 import ConfigParser, os, bb
45 parser = ConfigParser.ConfigParser()
46 if len(parser.read(config_paths)) < 1:
47 raise ValueError("no ini files could be found")
51 def base_chk_file(parser, pn, pv, src_uri, localpath, data):
54 # Try PN-PV-SRC_URI first and then try PN-SRC_URI
55 # we rely on the get method to create errors
56 pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
57 pn_src = "%s-%s" % (pn,src_uri)
58 if parser.has_section(pn_pv_src):
59 md5 = parser.get(pn_pv_src, "md5")
60 sha256 = parser.get(pn_pv_src, "sha256")
61 elif parser.has_section(pn_src):
62 md5 = parser.get(pn_src, "md5")
63 sha256 = parser.get(pn_src, "sha256")
64 elif parser.has_section(src_uri):
65 md5 = parser.get(src_uri, "md5")
66 sha256 = parser.get(src_uri, "sha256")
70 # md5 and sha256 should be valid now
71 if not os.path.exists(localpath):
72 bb.note("The localpath does not exist '%s'" % localpath)
73 raise Exception("The path does not exist '%s'" % localpath)
76 # call md5(sum) and shasum
78 md5pipe = os.popen('md5sum ' + localpath)
79 md5data = (md5pipe.readline().split() or [ "" ])[0]
82 raise Exception("Executing md5sum failed")
85 shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
86 shadata = (shapipe.readline().split() or [ "" ])[0]
89 raise Exception("Executing shasum failed")
91 if no_checksum == True: # we do not have conf/checksums.ini entry
93 file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
98 raise Exception("Creating checksums.ini failed")
100 file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
102 if not bb.data.getVar("OE_STRICT_CHECKSUMS",data, True):
103 bb.note("This package has no entry in checksums.ini, please add one")
104 bb.note("\n[%s]\nmd5=%s\nsha256=%s" % (src_uri, md5data, shadata))
107 bb.note("Missing checksum")
110 if not md5 == md5data:
111 bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
112 raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
114 if not sha256 == shadata:
115 bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
116 raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
121 def base_dep_prepend(d):
124 # Ideally this will check a flag so we will operate properly in
125 # the case where host == build == target, for now we don't work in
128 deps = "shasum-native "
129 if bb.data.getVar('PN', d, True) == "shasum-native":
132 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
133 # we need that built is the responsibility of the patch function / class, not
135 if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
136 if (bb.data.getVar('HOST_SYS', d, 1) !=
137 bb.data.getVar('BUILD_SYS', d, 1)):
138 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
141 def base_read_file(filename):
144 f = file( filename, "r" )
145 except IOError, reason:
146 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
148 return f.read().strip()
151 def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
153 if bb.data.getVar(variable,d,1) == checkvalue:
158 def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
160 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
165 def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
167 result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
173 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
176 if type(checkvalues).__name__ == "str":
177 checkvalues = [checkvalues]
178 for value in checkvalues:
179 if bb.data.getVar(variable,d,1).find(value) != -1:
180 matches = matches + 1
181 if matches == len(checkvalues):
185 def base_both_contain(variable1, variable2, checkvalue, d):
187 if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
192 DEPENDS_prepend="${@base_dep_prepend(d)} "
194 # Returns PN with various suffixes removed
195 # or PN if no matching suffix was found.
196 def base_package_name(d):
199 pn = bb.data.getVar('PN', d, 1)
200 if pn.endswith("-native"):
202 elif pn.endswith("-cross"):
204 elif pn.endswith("-initial"):
206 elif pn.endswith("-intermediate"):
211 def base_set_filespath(path, d):
213 bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1))
215 # The ":" ensures we have an 'empty' override
216 overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":"
218 for o in overrides.split(":"):
219 filespath.append(os.path.join(p, o))
220 return ":".join(filespath)
222 def oe_filter(f, str, d):
224 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
226 def oe_filter_out(f, str, d):
228 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
249 echo "Usage: oedebug level \"message\""
253 test ${OEDEBUG:-0} -ge $1 && {
260 if [ x"$MAKE" = x ]; then MAKE=make; fi
261 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
262 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
266 # Purpose: Install shared library file and
267 # create the necessary links
272 #oenote installing shared library $1 to $2
274 libname=`basename $1`
275 install -m 755 $1 $2/$libname
276 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
277 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
278 ln -sf $libname $2/$sonamelink
279 ln -sf $libname $2/$solink
283 # Purpose: Install a library, in all its forms
286 # oe_libinstall libltdl ${STAGING_LIBDIR}/
287 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
294 while [ "$#" -gt 0 ]; do
310 oefatal "oe_libinstall: unknown option: $1"
322 if [ -z "$destpath" ]; then
323 oefatal "oe_libinstall: no destination path specified"
325 if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
331 if [ -z "$silent" ]; then
332 echo >&2 "oe_libinstall: $*"
337 if [ -z "$dir" ]; then
343 # Sanity check that the libname.lai is unique
344 number_of_files=`(cd $dir; find . -name "$dotlai") | wc -l`
345 if [ $number_of_files -gt 1 ]; then
346 oefatal "oe_libinstall: $dotlai is not unique in $dir"
350 dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
356 # If such file doesn't exist, try to cut version suffix
357 if [ ! -f "$lafile" ]; then
358 libname1=`echo "$libname" | sed 's/-[0-9.]*$//'`
360 if [ -f "$lafile1" ]; then
366 if [ -f "$lafile" ]; then
368 eval `cat $lafile|grep "^library_names="`
371 library_names="$libname.so* $libname.dll.a"
374 __runcmd install -d $destpath/
376 if [ -f "$dota" -o -n "$require_static" ]; then
377 __runcmd install -m 0644 $dota $destpath/
379 if [ -f "$dotlai" -a -n "$libtool" ]; then
380 if test -n "$staging_install"
382 # stop libtool using the final directory name for libraries
384 __runcmd rm -f $destpath/$libname.la
385 __runcmd sed -e 's/^installed=yes$/installed=no/' \
386 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
387 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
388 $dotlai >$destpath/$libname.la
390 __runcmd install -m 0644 $dotlai $destpath/$libname.la
394 for name in $library_names; do
395 files=`eval echo $name`
397 if [ ! -e "$f" ]; then
398 if [ -n "$libtool" ]; then
399 oefatal "oe_libinstall: $dir/$f not found."
401 elif [ -L "$f" ]; then
402 __runcmd cp -P "$f" $destpath/
403 elif [ ! -L "$f" ]; then
405 __runcmd install -m 0755 $libfile $destpath/
410 if [ -z "$libfile" ]; then
411 if [ -n "$require_shared" ]; then
412 oefatal "oe_libinstall: unable to locate shared library"
414 elif [ -z "$libtool" ]; then
415 # special case hack for non-libtool .so.#.#.# links
416 baselibfile=`basename "$libfile"`
417 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
418 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
419 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
420 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
421 __runcmd ln -sf $baselibfile $destpath/$sonamelink
423 __runcmd ln -sf $baselibfile $destpath/$solink
427 __runcmd cd "$olddir"
430 def package_stagefile(file, d):
433 if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1":
434 destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1))
435 bb.mkdirhier(os.path.dirname(destfile))
436 #print "%s to %s" % (file, destfile)
437 bb.copyfile(file, destfile)
439 package_stagefile_shell() {
440 if [ "$PSTAGING_ACTIVE" = "1" ]; then
442 destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#`
443 destdir=`dirname $destfile`
445 cp -dp $srcfile $destfile
450 # Purpose: Install machine dependent files, if available
451 # If not available, check if there is a default
452 # If no default, just touch the destination
455 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
457 # TODO: Check argument number?
459 filename=`basename $3`
462 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
463 if [ -e $dirname/$o/$filename ]; then
464 oenote $dirname/$o/$filename present, installing to $4
465 install $1 $2 $dirname/$o/$filename $4
469 # oenote overrides specific file NOT present, trying default=$3...
471 oenote $3 present, installing to $4
474 oenote $3 NOT present, touching empty $4
480 do_listtasks[nostamp] = "1"
481 python do_listtasks() {
483 # emit variables and shell functions
484 #bb.data.emit_env(sys.__stdout__, d)
485 # emit the metadata which isnt valid shell
487 if bb.data.getVarFlag(e, 'task', d):
488 sys.__stdout__.write("%s\n" % e)
492 do_clean[dirs] = "${TOPDIR}"
493 do_clean[nostamp] = "1"
494 python base_do_clean() {
495 """clear the build and temp directories"""
496 dir = bb.data.expand("${WORKDIR}", d)
497 if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
498 bb.note("removing " + dir)
499 os.system('rm -rf ' + dir)
501 dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
502 bb.note("removing " + dir)
503 os.system('rm -f '+ dir)
506 #Uncomment this for bitbake 1.8.12
507 #addtask rebuild after do_${BB_DEFAULT_TASK}
509 do_rebuild[dirs] = "${TOPDIR}"
510 do_rebuild[nostamp] = "1"
511 python base_do_rebuild() {
512 """rebuild a package"""
513 from bb import __version__
515 from distutils.version import LooseVersion
517 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
518 if (LooseVersion(__version__) < LooseVersion('1.8.11')):
519 bb.build.exec_func('do_clean', d)
520 bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d)
524 do_mrproper[dirs] = "${TOPDIR}"
525 do_mrproper[nostamp] = "1"
526 python base_do_mrproper() {
527 """clear downloaded sources, build and temp directories"""
528 dir = bb.data.expand("${DL_DIR}", d)
529 if dir == '/': bb.build.FuncFailed("wrong DATADIR")
530 bb.debug(2, "removing " + dir)
531 os.system('rm -rf ' + dir)
532 bb.build.exec_func('do_clean', d)
536 do_distclean[dirs] = "${TOPDIR}"
537 do_distclean[nostamp] = "1"
538 python base_do_distclean() {
539 """clear downloaded sources, build and temp directories"""
542 bb.build.exec_func('do_clean', d)
544 src_uri = bb.data.getVar('SRC_URI', d, 1)
548 for uri in src_uri.split():
549 if bb.decodeurl(uri)[0] == "file":
553 local = bb.data.expand(bb.fetch.localpath(uri, d), d)
554 except bb.MalformedUrl, e:
555 bb.debug(1, 'Unable to generate local path for malformed uri: %s' % e)
557 bb.note("removing %s" % local)
559 if os.path.exists(local + ".md5"):
560 os.remove(local + ".md5")
561 if os.path.exists(local):
564 bb.note("Error in removal: %s" % e)
567 SCENEFUNCS += "base_scenefunction"
569 python base_do_setscene () {
570 for f in (bb.data.getVar('SCENEFUNCS', d, 1) or '').split():
571 bb.build.exec_func(f, d)
572 if not os.path.exists(bb.data.getVar('STAMP', d, 1) + ".do_setscene"):
573 bb.build.make_stamp("do_setscene", d)
575 do_setscene[selfstamp] = "1"
576 addtask setscene before do_fetch
578 python base_scenefunction () {
579 stamp = bb.data.getVar('STAMP', d, 1) + ".needclean"
580 if os.path.exists(stamp):
581 bb.build.exec_func("do_clean", d)
586 do_fetch[dirs] = "${DL_DIR}"
587 do_fetch[depends] = "shasum-native:do_populate_staging"
588 python base_do_fetch() {
591 localdata = bb.data.createCopy(d)
592 bb.data.update_data(localdata)
594 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
599 bb.fetch.init(src_uri.split(),d)
600 except bb.fetch.NoMethodError:
601 (type, value, traceback) = sys.exc_info()
602 raise bb.build.FuncFailed("No method: %s" % value)
605 bb.fetch.go(localdata)
606 except bb.fetch.MissingParameterError:
607 (type, value, traceback) = sys.exc_info()
608 raise bb.build.FuncFailed("Missing parameters: %s" % value)
609 except bb.fetch.FetchError:
610 (type, value, traceback) = sys.exc_info()
611 raise bb.build.FuncFailed("Fetch failed: %s" % value)
612 except bb.fetch.MD5SumError:
613 (type, value, traceback) = sys.exc_info()
614 raise bb.build.FuncFailed("MD5 failed: %s" % value)
616 (type, value, traceback) = sys.exc_info()
617 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
620 # Verify the SHA and MD5 sums we have in OE and check what do
622 checksum_paths = bb.data.getVar('BBPATH', d, True).split(":")
624 # reverse the list to give precedence to directories that
625 # appear first in BBPATH
626 checksum_paths.reverse()
628 checksum_files = ["%s/conf/checksums.ini" % path for path in checksum_paths]
630 parser = base_chk_load_parser(checksum_files)
632 bb.note("No conf/checksums.ini found, not checking checksums")
635 bb.note("Creating the CheckSum parser failed")
638 pv = bb.data.getVar('PV', d, True)
639 pn = bb.data.getVar('PN', d, True)
642 for url in src_uri.split():
643 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
644 (type,host,path,_,_,_) = bb.decodeurl(url)
645 uri = "%s://%s%s" % (type,host,path)
647 if type == "http" or type == "https" or type == "ftp" or type == "ftps":
648 if not base_chk_file(parser, pn, pv,uri, localpath, d):
649 if not bb.data.getVar("OE_ALLOW_INSECURE_DOWNLOADS",d, True):
650 bb.fatal("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
652 bb.note("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
654 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
657 addtask fetchall after do_fetch
658 do_fetchall[recrdeptask] = "do_fetch"
664 do_checkuri[nostamp] = "1"
665 python do_checkuri() {
668 localdata = bb.data.createCopy(d)
669 bb.data.update_data(localdata)
671 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
674 bb.fetch.init(src_uri.split(),d)
675 except bb.fetch.NoMethodError:
676 (type, value, traceback) = sys.exc_info()
677 raise bb.build.FuncFailed("No method: %s" % value)
680 bb.fetch.checkstatus(localdata)
681 except bb.fetch.MissingParameterError:
682 (type, value, traceback) = sys.exc_info()
683 raise bb.build.FuncFailed("Missing parameters: %s" % value)
684 except bb.fetch.FetchError:
685 (type, value, traceback) = sys.exc_info()
686 raise bb.build.FuncFailed("Fetch failed: %s" % value)
687 except bb.fetch.MD5SumError:
688 (type, value, traceback) = sys.exc_info()
689 raise bb.build.FuncFailed("MD5 failed: %s" % value)
691 (type, value, traceback) = sys.exc_info()
692 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
695 addtask checkuriall after do_checkuri
696 do_checkuriall[recrdeptask] = "do_checkuri"
697 do_checkuriall[nostamp] = "1"
698 base_do_checkuriall() {
702 addtask buildall after do_build
703 do_buildall[recrdeptask] = "do_build"
709 def oe_unpack_file(file, data, url = None):
712 url = "file://%s" % file
713 dots = file.split(".")
714 if dots[-1] in ['gz', 'bz2', 'Z']:
715 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
719 if file.endswith('.tar'):
720 cmd = 'tar x --no-same-owner -f %s' % file
721 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
722 cmd = 'tar xz --no-same-owner -f %s' % file
723 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
724 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
725 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
726 cmd = 'gzip -dc %s > %s' % (file, efile)
727 elif file.endswith('.bz2'):
728 cmd = 'bzip2 -dc %s > %s' % (file, efile)
729 elif file.endswith('.zip') or file.endswith('.jar'):
731 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
734 cmd = '%s %s' % (cmd, file)
735 elif os.path.isdir(file):
737 filespath = bb.data.getVar("FILESPATH", data, 1).split(":")
739 if file[0:len(fp)] == fp:
740 destdir = file[len(fp):file.rfind('/')]
741 destdir = destdir.strip('/')
744 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
745 os.makedirs("%s/%s" % (os.getcwd(), destdir))
748 cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
750 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
751 if not 'patch' in parm:
752 # The "destdir" handling was specifically done for FILESPATH
753 # items. So, only do so for file:// entries.
755 destdir = bb.decodeurl(url)[1] or "."
758 bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
759 cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
764 dest = os.path.join(os.getcwd(), os.path.basename(file))
765 if os.path.exists(dest):
766 if os.path.samefile(file, dest):
769 # Change to subdir before executing command
770 save_cwd = os.getcwd();
771 parm = bb.decodeurl(url)[5]
773 newdir = ("%s/%s" % (os.getcwd(), parm['subdir']))
777 cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
778 bb.note("Unpacking %s to %s/" % (file, os.getcwd()))
785 addtask unpack after do_fetch
786 do_unpack[dirs] = "${WORKDIR}"
787 python base_do_unpack() {
790 localdata = bb.data.createCopy(d)
791 bb.data.update_data(localdata)
793 src_uri = bb.data.getVar('SRC_URI', localdata)
796 src_uri = bb.data.expand(src_uri, localdata)
797 for url in src_uri.split():
799 local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
800 except bb.MalformedUrl, e:
801 raise bb.build.FuncFailed('Unable to generate local path for malformed uri: %s' % e)
803 raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
804 local = os.path.realpath(local)
805 ret = oe_unpack_file(local, localdata, url)
807 raise bb.build.FuncFailed()
810 METADATA_SCM = "${@base_get_scm(d)}"
811 METADATA_REVISION = "${@base_get_scm_revision(d)}"
812 METADATA_BRANCH = "${@base_get_scm_branch(d)}"
817 baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass")))
818 for (scm, scmpath) in {"svn": ".svn",
820 "monotone": "_MTN"}.iteritems():
821 if os.path.exists(os.path.join(baserepo, scmpath)):
822 return "%s %s" % (scm, baserepo)
823 return "<unknown> %s" % baserepo
825 def base_get_scm_revision(d):
826 (scm, path) = d.getVar("METADATA_SCM", 1).split()
828 if scm != "<unknown>":
829 return globals()["base_get_metadata_%s_revision" % scm](path, d)
835 def base_get_scm_branch(d):
836 (scm, path) = d.getVar("METADATA_SCM", 1).split()
838 if scm != "<unknown>":
839 return globals()["base_get_metadata_%s_branch" % scm](path, d)
845 def base_get_metadata_monotone_branch(path, d):
846 monotone_branch = "<unknown>"
848 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
849 if monotone_branch.startswith( "database" ):
850 monotone_branch_words = monotone_branch.split()
851 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
854 return monotone_branch
856 def base_get_metadata_monotone_revision(path, d):
857 monotone_revision = "<unknown>"
859 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
860 if monotone_revision.startswith( "format_version" ):
861 monotone_revision_words = monotone_revision.split()
862 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
865 return monotone_revision
867 def base_get_metadata_svn_revision(path, d):
868 revision = "<unknown>"
870 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
875 def base_get_metadata_git_branch(path, d):
877 branch = os.popen('cd %s; git symbolic-ref HEAD' % path).read().rstrip()
880 return branch.replace("refs/heads/", "")
883 def base_get_metadata_git_revision(path, d):
885 rev = os.popen("cd %s; git show-ref HEAD" % path).read().split(" ")[0].rstrip()
891 addhandler base_eventhandler
892 python base_eventhandler() {
893 from bb import note, error, data
894 from bb.event import Handled, NotHandled, getName
898 messages["Completed"] = "completed"
899 messages["Succeeded"] = "completed"
900 messages["Started"] = "started"
901 messages["Failed"] = "failed"
905 if name.startswith("Task"):
906 msg += "package %s: task %s: " % (data.getVar("PF", e.data, 1), e.task)
907 msg += messages.get(name[4:]) or name[4:]
908 elif name.startswith("Build"):
909 msg += "build %s: " % e.name
910 msg += messages.get(name[5:]) or name[5:]
911 elif name == "UnsatisfiedDep":
912 msg += "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower())
916 # Only need to output when using 1.8 or lower, the UI code handles it
918 if (int(bb.__version__.split(".")[0]) <= 1 and int(bb.__version__.split(".")[1]) <= 8):
922 if name.startswith("BuildStarted"):
923 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
924 statusvars = bb.data.getVar("BUILDCFG_VARS", e.data, 1).split()
925 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
926 statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
929 needed_vars = bb.data.getVar("BUILDCFG_NEEDEDVARS", e.data, 1).split()
931 for v in needed_vars:
932 val = bb.data.getVar(v, e.data, 1)
933 if not val or val == 'INVALID':
936 bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser))
939 # Handle removing stamps for 'rebuild' task
941 if name.startswith("StampUpdate"):
942 for (fn, task) in e.targets:
943 #print "%s %s" % (task, fn)
944 if task == "do_rebuild":
945 dir = "%s.*" % e.stampPrefix[fn]
946 bb.note("Removing stamps: " + dir)
947 os.system('rm -f '+ dir)
948 os.system('touch ' + e.stampPrefix[fn] + '.needclean')
950 if not data in e.__dict__:
953 log = data.getVar("EVENTLOG", e.data, 1)
955 logfile = file(log, "a")
956 logfile.write("%s\n" % msg)
962 addtask configure after do_unpack do_patch
963 do_configure[dirs] = "${S} ${B}"
964 do_configure[deptask] = "do_populate_staging"
965 base_do_configure() {
969 addtask compile after do_configure
970 do_compile[dirs] = "${S} ${B}"
972 if [ -e Makefile -o -e makefile ]; then
973 oe_runmake || die "make failed"
975 oenote "nothing to compile"
983 do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${layout_bindir} ${STAGING_DIR_TARGET}/${layout_libdir} \
984 ${STAGING_DIR_TARGET}/${layout_includedir} \
985 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
986 ${STAGING_INCDIR_NATIVE} \
990 # Could be compile but populate_staging and do_install shouldn't run at the same time
991 addtask populate_staging after do_install
993 python do_populate_staging () {
994 bb.build.exec_func('do_stage', d)
997 addtask install after do_compile
998 do_install[dirs] = "${D} ${S} ${B}"
999 # Remove and re-create ${D} so that is it guaranteed to be empty
1000 do_install[cleandirs] = "${D}"
1010 addtask build after do_populate_staging
1012 do_build[func] = "1"
1014 # Functions that update metadata based on files outputted
1015 # during the build process.
1017 def explode_deps(s):
1029 r[-1] += ' ' + ' '.join(j)
1034 def packaged(pkg, d):
1036 return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
1038 def read_pkgdatafile(fn):
1043 c = codecs.getdecoder("string_escape")
1047 if os.access(fn, os.R_OK):
1050 lines = f.readlines()
1052 r = re.compile("([^:]+):\s*(.*)")
1056 pkgdata[m.group(1)] = decode(m.group(2))
1060 def get_subpkgedata_fn(pkg, d):
1062 archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
1064 pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
1065 targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
1067 fn = pkgdata + arch + targetdir + pkg
1068 if os.path.exists(fn):
1070 return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
1072 def has_subpkgdata(pkg, d):
1074 return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
1076 def read_subpkgdata(pkg, d):
1078 return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1080 def has_pkgdata(pn, d):
1082 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1083 return os.access(fn, os.R_OK)
1085 def read_pkgdata(pn, d):
1087 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1088 return read_pkgdatafile(fn)
1090 python read_subpackage_metadata () {
1092 data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
1094 for key in data.keys():
1095 bb.data.setVar(key, data[key], d)
1097 for pkg in bb.data.getVar('PACKAGES', d, 1).split():
1098 sdata = read_subpkgdata(pkg, d)
1099 for key in sdata.keys():
1100 bb.data.setVar(key, sdata[key], d)
1105 # Collapse FOO_pkg variables into FOO
1107 def read_subpkgdata_dict(pkg, d):
1110 subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1112 newvar = var.replace("_" + pkg, "")
1113 ret[newvar] = subd[var]
1116 # Make sure MACHINE isn't exported
1117 # (breaks binutils at least)
1118 MACHINE[unexport] = "1"
1120 # Make sure TARGET_ARCH isn't exported
1121 # (breaks Makefiles using implicit rules, e.g. quilt, as GNU make has this
1122 # in them, undocumented)
1123 TARGET_ARCH[unexport] = "1"
1125 # Make sure DISTRO isn't exported
1126 # (breaks sysvinit at least)
1127 DISTRO[unexport] = "1"
1130 def base_after_parse(d):
1131 import bb, os, exceptions
1133 source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
1134 if not source_mirror_fetch:
1135 need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
1138 this_host = bb.data.getVar('HOST_SYS', d, 1)
1139 if not re.match(need_host, this_host):
1140 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
1142 need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
1145 this_machine = bb.data.getVar('MACHINE', d, 1)
1146 if this_machine and not re.match(need_machine, this_machine):
1147 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
1149 pn = bb.data.getVar('PN', d, 1)
1151 # OBSOLETE in bitbake 1.7.4
1152 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
1154 bb.data.setVar('SRCDATE', srcdate, d)
1156 use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
1158 bb.data.setVar('USE_NLS', use_nls, d)
1160 # Git packages should DEPEND on git-native
1161 srcuri = bb.data.getVar('SRC_URI', d, 1)
1162 if "git://" in srcuri:
1163 depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
1164 depends = depends + " git-native:do_populate_staging"
1165 bb.data.setVarFlag('do_fetch', 'depends', depends, d)
1167 # 'multimachine' handling
1168 mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
1169 pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
1171 if (pkg_arch == mach_arch):
1172 # Already machine specific - nothing further to do
1176 # We always try to scan SRC_URI for urls with machine overrides
1177 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
1179 override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
1182 for p in [ "${PF}", "${P}", "${PN}", "files", "" ]:
1183 path = bb.data.expand(os.path.join("${FILE_DIRNAME}", p, "${MACHINE}"), d)
1184 if os.path.isdir(path):
1187 for s in srcuri.split():
1188 if not s.startswith("file://"):
1190 local = bb.data.expand(bb.fetch.localpath(s, d), d)
1192 if local.startswith(mp):
1193 #bb.note("overriding PACKAGE_ARCH from %s to %s" % (pkg_arch, mach_arch))
1194 bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
1195 bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
1198 multiarch = pkg_arch
1200 packages = bb.data.getVar('PACKAGES', d, 1).split()
1201 for pkg in packages:
1202 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
1204 # We could look for != PACKAGE_ARCH here but how to choose
1205 # if multiple differences are present?
1206 # Look through PACKAGE_ARCHS for the priority order?
1207 if pkgarch and pkgarch == mach_arch:
1208 multiarch = mach_arch
1211 bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
1215 from bb import __version__
1218 # Remove this for bitbake 1.8.12
1220 from distutils.version import LooseVersion
1222 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
1223 if (LooseVersion(__version__) >= LooseVersion('1.8.11')):
1224 deps = bb.data.getVarFlag('do_rebuild', 'deps', d) or []
1225 deps.append('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1))
1226 bb.data.setVarFlag('do_rebuild', 'deps', deps, d)
1229 def check_app_exists(app, d):
1230 from bb import which, data
1232 app = data.expand(app, d)
1233 path = data.getVar('PATH', d, 1)
1234 return len(which(path, app)) != 0
1236 def check_gcc3(data):
1238 gcc3_versions = 'gcc-3.4 gcc34 gcc-3.4.4 gcc-3.4.6 gcc-3.4.7 gcc-3.3 gcc33 gcc-3.3.6 gcc-3.2 gcc32'
1240 for gcc3 in gcc3_versions.split():
1241 if check_app_exists(gcc3, data):
1249 # Configuration data from site files
1250 # Move to autotools.bbclass?
1253 EXPORT_FUNCTIONS do_setscene do_clean do_mrproper do_distclean do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_stage do_rebuild do_fetchall
1257 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
1258 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
1259 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
1260 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
1261 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
1262 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
1263 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
1264 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
1265 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
1266 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
1267 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
1268 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
1269 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
1270 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
1271 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
1272 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
1273 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
1274 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
1275 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
1276 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
1277 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
1278 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
1279 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
1280 ${KERNELORG_MIRROR} http://www.kernel.org/pub
1281 ${KERNELORG_MIRROR} ftp://ftp.us.kernel.org/pub
1282 ${KERNELORG_MIRROR} ftp://ftp.uk.kernel.org/pub
1283 ${KERNELORG_MIRROR} ftp://ftp.hk.kernel.org/pub
1284 ${KERNELORG_MIRROR} ftp://ftp.au.kernel.org/pub
1285 ${KERNELORG_MIRROR} ftp://ftp.jp.kernel.org/pub
1286 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
1287 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/
1288 ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/
1289 ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
1290 ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
1291 ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
1292 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
1293 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
1294 ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
1295 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
1296 ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
1297 http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
1298 http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
1299 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
1300 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tau.ac.il/pub/unix/admin/
1301 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
1302 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
1303 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.kaizo.org/pub/lsof/
1304 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
1305 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
1306 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
1307 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
1308 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://the.wiretapped.net/pub/security/host-security/lsof/
1309 http://www.apache.org/dist http://archive.apache.org/dist