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 def base_path_out(path, d):
43 """ Prepare a path for display to the user. """
44 rel = base_path_relative(d.getVar("TOPDIR", 1), path)
45 if len(rel) > len(path):
50 # for MD5/SHA handling
51 def base_chk_load_parser(config_paths):
52 import ConfigParser, os, bb
53 parser = ConfigParser.ConfigParser()
54 if len(parser.read(config_paths)) < 1:
55 raise ValueError("no ini files could be found")
59 def base_chk_file(parser, pn, pv, src_uri, localpath, data):
62 # Try PN-PV-SRC_URI first and then try PN-SRC_URI
63 # we rely on the get method to create errors
64 pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
65 pn_src = "%s-%s" % (pn,src_uri)
66 if parser.has_section(pn_pv_src):
67 md5 = parser.get(pn_pv_src, "md5")
68 sha256 = parser.get(pn_pv_src, "sha256")
69 elif parser.has_section(pn_src):
70 md5 = parser.get(pn_src, "md5")
71 sha256 = parser.get(pn_src, "sha256")
72 elif parser.has_section(src_uri):
73 md5 = parser.get(src_uri, "md5")
74 sha256 = parser.get(src_uri, "sha256")
78 # md5 and sha256 should be valid now
79 if not os.path.exists(localpath):
80 localpath = base_path_out(localpath, data)
81 bb.note("The localpath does not exist '%s'" % localpath)
82 raise Exception("The path does not exist '%s'" % localpath)
85 # call md5(sum) and shasum
87 md5pipe = os.popen('PATH=%s md5sum %s' % (bb.data.getVar('PATH', data, True), localpath))
88 md5data = (md5pipe.readline().split() or [ "" ])[0]
91 raise Exception("Executing md5sum failed")
94 shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
95 shadata = (shapipe.readline().split() or [ "" ])[0]
98 raise Exception("Executing shasum failed")
100 if no_checksum == True: # we do not have conf/checksums.ini entry
102 file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
107 raise Exception("Creating checksums.ini failed")
109 file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
111 if not bb.data.getVar("OE_STRICT_CHECKSUMS",data, True):
112 bb.note("This package has no entry in checksums.ini, please add one")
113 bb.note("\n[%s]\nmd5=%s\nsha256=%s" % (src_uri, md5data, shadata))
116 bb.note("Missing checksum")
119 if not md5 == md5data:
120 bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
121 raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
123 if not sha256 == shadata:
124 bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
125 raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
130 def base_dep_prepend(d):
133 # Ideally this will check a flag so we will operate properly in
134 # the case where host == build == target, for now we don't work in
137 deps = "shasum-native coreutils-native"
138 if bb.data.getVar('PN', d, True) == "shasum-native" or bb.data.getVar('PN', d, True) == "stagemanager-native":
140 if bb.data.getVar('PN', d, True) == "coreutils-native":
141 deps = "shasum-native"
143 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
144 # we need that built is the responsibility of the patch function / class, not
146 if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
147 if (bb.data.getVar('HOST_SYS', d, 1) !=
148 bb.data.getVar('BUILD_SYS', d, 1)):
149 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
152 def base_read_file(filename):
155 f = file( filename, "r" )
156 except IOError, reason:
157 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
159 return f.read().strip()
162 def base_ifelse(condition, iftrue = True, iffalse = False):
168 def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
170 if bb.data.getVar(variable,d,1) == checkvalue:
175 def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
177 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
182 def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
184 result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
190 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
193 if type(checkvalues).__name__ == "str":
194 checkvalues = [checkvalues]
195 for value in checkvalues:
196 if bb.data.getVar(variable,d,1).find(value) != -1:
197 matches = matches + 1
198 if matches == len(checkvalues):
202 def base_both_contain(variable1, variable2, checkvalue, d):
204 if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
209 DEPENDS_prepend="${@base_dep_prepend(d)} "
211 # Returns PN with various suffixes removed
212 # or PN if no matching suffix was found.
213 def base_package_name(d):
216 pn = bb.data.getVar('PN', d, 1)
217 if pn.endswith("-native"):
219 elif pn.endswith("-cross"):
221 elif pn.endswith("-initial"):
223 elif pn.endswith("-intermediate"):
225 elif pn.endswith("-sdk"):
231 def base_set_filespath(path, d):
233 bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1))
235 # The ":" ensures we have an 'empty' override
236 overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":"
238 for o in overrides.split(":"):
239 filespath.append(os.path.join(p, o))
240 return ":".join(filespath)
242 def oe_filter(f, str, d):
244 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
246 def oe_filter_out(f, str, d):
248 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
269 echo "Usage: oedebug level \"message\""
273 test ${OEDEBUG:-0} -ge $1 && {
280 if [ x"$MAKE" = x ]; then MAKE=make; fi
281 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
282 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
286 # Purpose: Install shared library file and
287 # create the necessary links
292 #oenote installing shared library $1 to $2
294 libname=`basename $1`
295 install -m 755 $1 $2/$libname
296 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
297 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
298 ln -sf $libname $2/$sonamelink
299 ln -sf $libname $2/$solink
303 # Purpose: Install a library, in all its forms
306 # oe_libinstall libltdl ${STAGING_LIBDIR}/
307 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
314 while [ "$#" -gt 0 ]; do
330 oefatal "oe_libinstall: unknown option: $1"
342 if [ -z "$destpath" ]; then
343 oefatal "oe_libinstall: no destination path specified"
345 if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
351 if [ -z "$silent" ]; then
352 echo >&2 "oe_libinstall: $*"
357 if [ -z "$dir" ]; then
363 # Sanity check that the libname.lai is unique
364 number_of_files=`(cd $dir; find . -name "$dotlai") | wc -l`
365 if [ $number_of_files -gt 1 ]; then
366 oefatal "oe_libinstall: $dotlai is not unique in $dir"
370 dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
376 # If such file doesn't exist, try to cut version suffix
377 if [ ! -f "$lafile" ]; then
378 libname1=`echo "$libname" | sed 's/-[0-9.]*$//'`
380 if [ -f "$lafile1" ]; then
386 if [ -f "$lafile" ]; then
388 eval `cat $lafile|grep "^library_names="`
391 library_names="$libname.so* $libname.dll.a"
394 __runcmd install -d $destpath/
396 if [ -f "$dota" -o -n "$require_static" ]; then
397 __runcmd install -m 0644 $dota $destpath/
399 if [ -f "$dotlai" -a -n "$libtool" ]; then
400 if test -n "$staging_install"
402 # stop libtool using the final directory name for libraries
404 __runcmd rm -f $destpath/$libname.la
405 __runcmd sed -e 's/^installed=yes$/installed=no/' \
406 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
407 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
408 $dotlai >$destpath/$libname.la
410 __runcmd install -m 0644 $dotlai $destpath/$libname.la
414 for name in $library_names; do
415 files=`eval echo $name`
417 if [ ! -e "$f" ]; then
418 if [ -n "$libtool" ]; then
419 oefatal "oe_libinstall: $dir/$f not found."
421 elif [ -L "$f" ]; then
422 __runcmd cp -P "$f" $destpath/
423 elif [ ! -L "$f" ]; then
425 __runcmd install -m 0755 $libfile $destpath/
430 if [ -z "$libfile" ]; then
431 if [ -n "$require_shared" ]; then
432 oefatal "oe_libinstall: unable to locate shared library"
434 elif [ -z "$libtool" ]; then
435 # special case hack for non-libtool .so.#.#.# links
436 baselibfile=`basename "$libfile"`
437 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
438 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
439 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
440 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
441 __runcmd ln -sf $baselibfile $destpath/$sonamelink
443 __runcmd ln -sf $baselibfile $destpath/$solink
447 __runcmd cd "$olddir"
450 def package_stagefile(file, d):
453 if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1":
454 destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1))
455 bb.mkdirhier(os.path.dirname(destfile))
456 #print "%s to %s" % (file, destfile)
457 bb.copyfile(file, destfile)
459 package_stagefile_shell() {
460 if [ "$PSTAGING_ACTIVE" = "1" ]; then
462 destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#`
463 destdir=`dirname $destfile`
465 cp -dp $srcfile $destfile
470 # Purpose: Install machine dependent files, if available
471 # If not available, check if there is a default
472 # If no default, just touch the destination
475 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
477 # TODO: Check argument number?
479 filename=`basename $3`
482 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
483 if [ -e $dirname/$o/$filename ]; then
484 oenote $dirname/$o/$filename present, installing to $4
485 install $1 $2 $dirname/$o/$filename $4
489 # oenote overrides specific file NOT present, trying default=$3...
491 oenote $3 present, installing to $4
494 oenote $3 NOT present, touching empty $4
500 do_listtasks[nostamp] = "1"
501 python do_listtasks() {
503 # emit variables and shell functions
504 #bb.data.emit_env(sys.__stdout__, d)
505 # emit the metadata which isnt valid shell
507 if bb.data.getVarFlag(e, 'task', d):
508 sys.__stdout__.write("%s\n" % e)
512 do_clean[dirs] = "${TOPDIR}"
513 do_clean[nostamp] = "1"
514 python base_do_clean() {
515 """clear the build and temp directories"""
516 dir = bb.data.expand("${WORKDIR}", d)
517 if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
518 bb.note("removing " + base_path_out(dir, d))
519 os.system('rm -rf ' + dir)
521 dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
522 bb.note("removing " + base_path_out(dir, d))
523 os.system('rm -f '+ dir)
526 python do_cleanall() {
529 do_cleanall[recrdeptask] = "do_clean"
530 addtask cleanall after do_clean
532 #Uncomment this for bitbake 1.8.12
533 #addtask rebuild after do_${BB_DEFAULT_TASK}
535 do_rebuild[dirs] = "${TOPDIR}"
536 do_rebuild[nostamp] = "1"
537 python base_do_rebuild() {
538 """rebuild a package"""
539 from bb import __version__
541 from distutils.version import LooseVersion
543 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
544 if (LooseVersion(__version__) < LooseVersion('1.8.11')):
545 bb.build.exec_func('do_clean', d)
546 bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d)
550 do_mrproper[dirs] = "${TOPDIR}"
551 do_mrproper[nostamp] = "1"
552 python base_do_mrproper() {
553 """clear downloaded sources, build and temp directories"""
554 dir = bb.data.expand("${DL_DIR}", d)
555 if dir == '/': bb.build.FuncFailed("wrong DATADIR")
556 bb.debug(2, "removing " + dir)
557 os.system('rm -rf ' + dir)
558 bb.build.exec_func('do_clean', d)
562 do_distclean[dirs] = "${TOPDIR}"
563 do_distclean[nostamp] = "1"
564 python base_do_distclean() {
565 """clear downloaded sources, build and temp directories"""
568 bb.build.exec_func('do_clean', d)
570 src_uri = bb.data.getVar('SRC_URI', d, 1)
574 for uri in src_uri.split():
575 if bb.decodeurl(uri)[0] == "file":
579 local = bb.data.expand(bb.fetch.localpath(uri, d), d)
580 except bb.MalformedUrl, e:
581 bb.debug(1, 'Unable to generate local path for malformed uri: %s' % e)
583 bb.note("removing %s" % base_path_out(local, d))
585 if os.path.exists(local + ".md5"):
586 os.remove(local + ".md5")
587 if os.path.exists(local):
590 bb.note("Error in removal: %s" % e)
593 SCENEFUNCS += "base_scenefunction"
595 python base_do_setscene () {
596 for f in (bb.data.getVar('SCENEFUNCS', d, 1) or '').split():
597 bb.build.exec_func(f, d)
598 if not os.path.exists(bb.data.getVar('STAMP', d, 1) + ".do_setscene"):
599 bb.build.make_stamp("do_setscene", d)
601 do_setscene[selfstamp] = "1"
602 addtask setscene before do_fetch
604 python base_scenefunction () {
605 stamp = bb.data.getVar('STAMP', d, 1) + ".needclean"
606 if os.path.exists(stamp):
607 bb.build.exec_func("do_clean", d)
612 do_fetch[dirs] = "${DL_DIR}"
613 do_fetch[depends] = "shasum-native:do_populate_staging"
614 python base_do_fetch() {
617 localdata = bb.data.createCopy(d)
618 bb.data.update_data(localdata)
620 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
625 bb.fetch.init(src_uri.split(),d)
626 except bb.fetch.NoMethodError:
627 (type, value, traceback) = sys.exc_info()
628 raise bb.build.FuncFailed("No method: %s" % value)
629 except bb.MalformedUrl:
630 (type, value, traceback) = sys.exc_info()
631 raise bb.build.FuncFailed("Malformed URL: %s" % value)
634 bb.fetch.go(localdata)
635 except bb.fetch.MissingParameterError:
636 (type, value, traceback) = sys.exc_info()
637 raise bb.build.FuncFailed("Missing parameters: %s" % value)
638 except bb.fetch.FetchError:
639 (type, value, traceback) = sys.exc_info()
640 raise bb.build.FuncFailed("Fetch failed: %s" % value)
641 except bb.fetch.MD5SumError:
642 (type, value, traceback) = sys.exc_info()
643 raise bb.build.FuncFailed("MD5 failed: %s" % value)
645 (type, value, traceback) = sys.exc_info()
646 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
649 # Verify the SHA and MD5 sums we have in OE and check what do
651 checksum_paths = bb.data.getVar('BBPATH', d, True).split(":")
653 # reverse the list to give precedence to directories that
654 # appear first in BBPATH
655 checksum_paths.reverse()
657 checksum_files = ["%s/conf/checksums.ini" % path for path in checksum_paths]
659 parser = base_chk_load_parser(checksum_files)
661 bb.note("No conf/checksums.ini found, not checking checksums")
664 bb.note("Creating the CheckSum parser failed")
667 pv = bb.data.getVar('PV', d, True)
668 pn = bb.data.getVar('PN', d, True)
671 for url in src_uri.split():
672 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
673 (type,host,path,_,_,_) = bb.decodeurl(url)
674 uri = "%s://%s%s" % (type,host,path)
676 if type == "http" or type == "https" or type == "ftp" or type == "ftps":
677 if not base_chk_file(parser, pn, pv,uri, localpath, d):
678 if not bb.data.getVar("OE_ALLOW_INSECURE_DOWNLOADS",d, True):
679 bb.fatal("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
681 bb.note("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
683 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
686 addtask fetchall after do_fetch
687 do_fetchall[recrdeptask] = "do_fetch"
693 do_checkuri[nostamp] = "1"
694 python do_checkuri() {
697 localdata = bb.data.createCopy(d)
698 bb.data.update_data(localdata)
700 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
703 bb.fetch.init(src_uri.split(),d)
704 except bb.fetch.NoMethodError:
705 (type, value, traceback) = sys.exc_info()
706 raise bb.build.FuncFailed("No method: %s" % value)
709 bb.fetch.checkstatus(localdata)
710 except bb.fetch.MissingParameterError:
711 (type, value, traceback) = sys.exc_info()
712 raise bb.build.FuncFailed("Missing parameters: %s" % value)
713 except bb.fetch.FetchError:
714 (type, value, traceback) = sys.exc_info()
715 raise bb.build.FuncFailed("Fetch failed: %s" % value)
716 except bb.fetch.MD5SumError:
717 (type, value, traceback) = sys.exc_info()
718 raise bb.build.FuncFailed("MD5 failed: %s" % value)
720 (type, value, traceback) = sys.exc_info()
721 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
724 addtask checkuriall after do_checkuri
725 do_checkuriall[recrdeptask] = "do_checkuri"
726 do_checkuriall[nostamp] = "1"
727 base_do_checkuriall() {
731 addtask buildall after do_build
732 do_buildall[recrdeptask] = "do_build"
737 def subprocess_setup():
739 # Python installs a SIGPIPE handler by default. This is usually not what
740 # non-Python subprocesses expect.
741 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
743 def oe_unpack_file(file, data, url = None):
744 import bb, os, subprocess
746 url = "file://%s" % file
747 dots = file.split(".")
748 if dots[-1] in ['gz', 'bz2', 'Z']:
749 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
753 if file.endswith('.tar'):
754 cmd = 'tar x --no-same-owner -f %s' % file
755 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
756 cmd = 'tar xz --no-same-owner -f %s' % file
757 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
758 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
759 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
760 cmd = 'gzip -dc %s > %s' % (file, efile)
761 elif file.endswith('.bz2'):
762 cmd = 'bzip2 -dc %s > %s' % (file, efile)
763 elif file.endswith('.zip') or file.endswith('.jar'):
765 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
768 cmd = '%s %s' % (cmd, file)
769 elif os.path.isdir(file):
771 filespath = bb.data.getVar("FILESPATH", data, 1).split(":")
773 if file[0:len(fp)] == fp:
774 destdir = file[len(fp):file.rfind('/')]
775 destdir = destdir.strip('/')
778 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
779 os.makedirs("%s/%s" % (os.getcwd(), destdir))
782 cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
784 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
785 if not 'patch' in parm:
786 # The "destdir" handling was specifically done for FILESPATH
787 # items. So, only do so for file:// entries.
789 destdir = bb.decodeurl(url)[1] or "."
792 bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
793 cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
798 dest = os.path.join(os.getcwd(), os.path.basename(file))
799 if os.path.exists(dest):
800 if os.path.samefile(file, dest):
803 # Change to subdir before executing command
804 save_cwd = os.getcwd();
805 parm = bb.decodeurl(url)[5]
807 newdir = ("%s/%s" % (os.getcwd(), parm['subdir']))
811 cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
812 bb.note("Unpacking %s to %s/" % (base_path_out(file, data), base_path_out(os.getcwd(), data)))
813 ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True)
819 addtask unpack after do_fetch
820 do_unpack[dirs] = "${WORKDIR}"
821 python base_do_unpack() {
824 localdata = bb.data.createCopy(d)
825 bb.data.update_data(localdata)
827 src_uri = bb.data.getVar('SRC_URI', localdata)
830 src_uri = bb.data.expand(src_uri, localdata)
831 for url in src_uri.split():
833 local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
834 except bb.MalformedUrl, e:
835 raise bb.build.FuncFailed('Unable to generate local path for malformed uri: %s' % e)
837 raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
838 local = os.path.realpath(local)
839 ret = oe_unpack_file(local, localdata, url)
841 raise bb.build.FuncFailed()
844 METADATA_SCM = "${@base_get_scm(d)}"
845 METADATA_REVISION = "${@base_get_scm_revision(d)}"
846 METADATA_BRANCH = "${@base_get_scm_branch(d)}"
851 baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass")))
852 for (scm, scmpath) in {"svn": ".svn",
854 "monotone": "_MTN"}.iteritems():
855 if os.path.exists(os.path.join(baserepo, scmpath)):
856 return "%s %s" % (scm, baserepo)
857 return "<unknown> %s" % baserepo
859 def base_get_scm_revision(d):
860 (scm, path) = d.getVar("METADATA_SCM", 1).split()
862 if scm != "<unknown>":
863 return globals()["base_get_metadata_%s_revision" % scm](path, d)
869 def base_get_scm_branch(d):
870 (scm, path) = d.getVar("METADATA_SCM", 1).split()
872 if scm != "<unknown>":
873 return globals()["base_get_metadata_%s_branch" % scm](path, d)
879 def base_get_metadata_monotone_branch(path, d):
880 monotone_branch = "<unknown>"
882 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
883 if monotone_branch.startswith( "database" ):
884 monotone_branch_words = monotone_branch.split()
885 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
888 return monotone_branch
890 def base_get_metadata_monotone_revision(path, d):
891 monotone_revision = "<unknown>"
893 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
894 if monotone_revision.startswith( "format_version" ):
895 monotone_revision_words = monotone_revision.split()
896 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
899 return monotone_revision
901 def base_get_metadata_svn_revision(path, d):
902 revision = "<unknown>"
904 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
909 def base_get_metadata_git_branch(path, d):
911 branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip()
914 return branch.replace("refs/heads/", "")
917 def base_get_metadata_git_revision(path, d):
919 rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip()
925 addhandler base_eventhandler
926 python base_eventhandler() {
927 from bb import note, error, data
928 from bb.event import Handled, NotHandled, getName
932 if name == "TaskCompleted":
933 msg = "package %s: task %s is complete." % (data.getVar("PF", e.data, 1), e.task)
934 elif name == "UnsatisfiedDep":
935 msg = "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower())
939 # Only need to output when using 1.8 or lower, the UI code handles it
941 if (int(bb.__version__.split(".")[0]) <= 1 and int(bb.__version__.split(".")[1]) <= 8):
945 if name.startswith("BuildStarted"):
946 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
947 statusvars = bb.data.getVar("BUILDCFG_VARS", e.data, 1).split()
948 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
949 statusmsg = "\n%s\n%s\n" % (bb.data.getVar("BUILDCFG_HEADER", e.data, 1), "\n".join(statuslines))
952 needed_vars = bb.data.getVar("BUILDCFG_NEEDEDVARS", e.data, 1).split()
954 for v in needed_vars:
955 val = bb.data.getVar(v, e.data, 1)
956 if not val or val == 'INVALID':
959 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))
962 # Handle removing stamps for 'rebuild' task
964 if name.startswith("StampUpdate"):
965 for (fn, task) in e.targets:
966 #print "%s %s" % (task, fn)
967 if task == "do_rebuild":
968 dir = "%s.*" % e.stampPrefix[fn]
969 bb.note("Removing stamps: " + dir)
970 os.system('rm -f '+ dir)
971 os.system('touch ' + e.stampPrefix[fn] + '.needclean')
973 if not data in e.__dict__:
976 log = data.getVar("EVENTLOG", e.data, 1)
978 logfile = file(log, "a")
979 logfile.write("%s\n" % msg)
985 addtask configure after do_unpack do_patch
986 do_configure[dirs] = "${S} ${B}"
987 do_configure[deptask] = "do_populate_staging"
988 base_do_configure() {
992 addtask compile after do_configure
993 do_compile[dirs] = "${S} ${B}"
995 if [ -e Makefile -o -e makefile ]; then
996 oe_runmake || die "make failed"
998 oenote "nothing to compile"
1006 do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${layout_bindir} ${STAGING_DIR_TARGET}/${layout_libdir} \
1007 ${STAGING_DIR_TARGET}/${layout_includedir} \
1008 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
1009 ${STAGING_INCDIR_NATIVE} \
1010 ${STAGING_DATADIR} \
1013 # Could be compile but populate_staging and do_install shouldn't run at the same time
1014 addtask populate_staging after do_install
1016 python do_populate_staging () {
1017 bb.build.exec_func('do_stage', d)
1020 addtask install after do_compile
1021 do_install[dirs] = "${D} ${S} ${B}"
1022 # Remove and re-create ${D} so that is it guaranteed to be empty
1023 do_install[cleandirs] = "${D}"
1033 addtask build after do_populate_staging
1035 do_build[func] = "1"
1037 # Functions that update metadata based on files outputted
1038 # during the build process.
1040 def explode_deps(s):
1052 r[-1] += ' ' + ' '.join(j)
1057 def packaged(pkg, d):
1059 return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
1061 def read_pkgdatafile(fn):
1066 c = codecs.getdecoder("string_escape")
1070 if os.access(fn, os.R_OK):
1073 lines = f.readlines()
1075 r = re.compile("([^:]+):\s*(.*)")
1079 pkgdata[m.group(1)] = decode(m.group(2))
1083 def get_subpkgedata_fn(pkg, d):
1085 archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
1087 pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
1088 targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
1090 fn = pkgdata + arch + targetdir + pkg
1091 if os.path.exists(fn):
1093 return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
1095 def has_subpkgdata(pkg, d):
1097 return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
1099 def read_subpkgdata(pkg, d):
1101 return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1103 def has_pkgdata(pn, d):
1105 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1106 return os.access(fn, os.R_OK)
1108 def read_pkgdata(pn, d):
1110 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1111 return read_pkgdatafile(fn)
1113 python read_subpackage_metadata () {
1115 data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
1117 for key in data.keys():
1118 bb.data.setVar(key, data[key], d)
1120 for pkg in bb.data.getVar('PACKAGES', d, 1).split():
1121 sdata = read_subpkgdata(pkg, d)
1122 for key in sdata.keys():
1123 bb.data.setVar(key, sdata[key], d)
1128 # Collapse FOO_pkg variables into FOO
1130 def read_subpkgdata_dict(pkg, d):
1133 subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1135 newvar = var.replace("_" + pkg, "")
1136 ret[newvar] = subd[var]
1139 # Make sure MACHINE isn't exported
1140 # (breaks binutils at least)
1141 MACHINE[unexport] = "1"
1143 # Make sure TARGET_ARCH isn't exported
1144 # (breaks Makefiles using implicit rules, e.g. quilt, as GNU make has this
1145 # in them, undocumented)
1146 TARGET_ARCH[unexport] = "1"
1148 # Make sure DISTRO isn't exported
1149 # (breaks sysvinit at least)
1150 DISTRO[unexport] = "1"
1153 def base_after_parse(d):
1154 import bb, os, exceptions
1156 source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
1157 if not source_mirror_fetch:
1158 need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
1161 this_host = bb.data.getVar('HOST_SYS', d, 1)
1162 if not re.match(need_host, this_host):
1163 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
1165 need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
1168 this_machine = bb.data.getVar('MACHINE', d, 1)
1169 if this_machine and not re.match(need_machine, this_machine):
1170 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
1172 pn = bb.data.getVar('PN', d, 1)
1174 # OBSOLETE in bitbake 1.7.4
1175 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
1177 bb.data.setVar('SRCDATE', srcdate, d)
1179 use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
1181 bb.data.setVar('USE_NLS', use_nls, d)
1183 # Git packages should DEPEND on git-native
1184 srcuri = bb.data.getVar('SRC_URI', d, 1)
1185 if "git://" in srcuri:
1186 depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
1187 depends = depends + " git-native:do_populate_staging"
1188 bb.data.setVarFlag('do_fetch', 'depends', depends, d)
1190 # 'multimachine' handling
1191 mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
1192 pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
1194 if (pkg_arch == mach_arch):
1195 # Already machine specific - nothing further to do
1199 # We always try to scan SRC_URI for urls with machine overrides
1200 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
1202 override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
1205 for p in [ "${PF}", "${P}", "${PN}", "files", "" ]:
1206 path = bb.data.expand(os.path.join("${FILE_DIRNAME}", p, "${MACHINE}"), d)
1207 if os.path.isdir(path):
1210 for s in srcuri.split():
1211 if not s.startswith("file://"):
1213 local = bb.data.expand(bb.fetch.localpath(s, d), d)
1215 if local.startswith(mp):
1216 #bb.note("overriding PACKAGE_ARCH from %s to %s" % (pkg_arch, mach_arch))
1217 bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
1218 bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
1221 multiarch = pkg_arch
1223 packages = bb.data.getVar('PACKAGES', d, 1).split()
1224 for pkg in packages:
1225 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
1227 # We could look for != PACKAGE_ARCH here but how to choose
1228 # if multiple differences are present?
1229 # Look through PACKAGE_ARCHS for the priority order?
1230 if pkgarch and pkgarch == mach_arch:
1231 multiarch = mach_arch
1234 bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
1238 from bb import __version__
1241 # Remove this for bitbake 1.8.12
1243 from distutils.version import LooseVersion
1245 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
1246 if (LooseVersion(__version__) >= LooseVersion('1.8.11')):
1247 deps = bb.data.getVarFlag('do_rebuild', 'deps', d) or []
1248 deps.append('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1))
1249 bb.data.setVarFlag('do_rebuild', 'deps', deps, d)
1252 def check_app_exists(app, d):
1253 from bb import which, data
1255 app = data.expand(app, d)
1256 path = data.getVar('PATH', d, 1)
1257 return len(which(path, app)) != 0
1259 def check_gcc3(data):
1260 # Primarly used by qemu to make sure we have a workable gcc-3.4.x.
1261 # Start by checking for the program name as we build it, was not
1262 # all host-provided gcc-3.4's will work.
1264 gcc3_versions = 'gcc-3.4.6 gcc-3.4.4 gcc34 gcc-3.4 gcc-3.4.7 gcc-3.3 gcc33 gcc-3.3.6 gcc-3.2 gcc32'
1266 for gcc3 in gcc3_versions.split():
1267 if check_app_exists(gcc3, data):
1275 # Configuration data from site files
1276 # Move to autotools.bbclass?
1279 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
1283 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
1284 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
1285 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
1286 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
1287 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
1288 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
1289 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
1290 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
1291 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
1292 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
1293 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
1294 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
1295 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
1296 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
1297 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
1298 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
1299 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
1300 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
1301 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
1302 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
1303 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
1304 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
1305 ${KERNELORG_MIRROR} http://www.kernel.org/pub
1306 ${KERNELORG_MIRROR} ftp://ftp.us.kernel.org/pub
1307 ${KERNELORG_MIRROR} ftp://ftp.uk.kernel.org/pub
1308 ${KERNELORG_MIRROR} ftp://ftp.hk.kernel.org/pub
1309 ${KERNELORG_MIRROR} ftp://ftp.au.kernel.org/pub
1310 ${KERNELORG_MIRROR} ftp://ftp.jp.kernel.org/pub
1311 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
1312 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/
1313 ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/
1314 ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
1315 ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
1316 ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
1317 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
1318 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
1319 ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
1320 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
1321 ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
1322 http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
1323 http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
1324 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
1325 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tau.ac.il/pub/unix/admin/
1326 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
1327 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
1328 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.kaizo.org/pub/lsof/
1329 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
1330 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
1331 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
1332 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
1333 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://the.wiretapped.net/pub/security/host-security/lsof/
1334 http://www.apache.org/dist http://archive.apache.org/dist
1335 ftp://.*/.* http://mirrors.openembedded.org/
1336 https?$://.*/.* http://mirrors.openembedded.org/
1337 ftp://.*/.* http://sources.openembedded.org/
1338 https?$://.*/.* http://sources.openembedded.org/