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 # for MD5/SHA handling
14 def base_chk_load_parser(config_path):
15 import ConfigParser, os, bb
16 parser = ConfigParser.ConfigParser()
17 if not len(parser.read(config_path)) == 1:
18 bb.note("Can not open the '%s' ini file" % config_path)
19 raise Exception("Can not open the '%s'" % config_path)
23 def base_chk_file(parser, pn, pv, src_uri, localpath, data):
26 # Try PN-PV-SRC_URI first and then try PN-SRC_URI
27 # we rely on the get method to create errors
28 pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
29 pn_src = "%s-%s" % (pn,src_uri)
30 if parser.has_section(pn_pv_src):
31 md5 = parser.get(pn_pv_src, "md5")
32 sha256 = parser.get(pn_pv_src, "sha256")
33 elif parser.has_section(pn_src):
34 md5 = parser.get(pn_src, "md5")
35 sha256 = parser.get(pn_src, "sha256")
36 elif parser.has_section(src_uri):
37 md5 = parser.get(src_uri, "md5")
38 sha256 = parser.get(src_uri, "sha256")
42 # md5 and sha256 should be valid now
43 if not os.path.exists(localpath):
44 bb.note("The localpath does not exist '%s'" % localpath)
45 raise Exception("The path does not exist '%s'" % localpath)
48 # call md5(sum) and shasum
50 md5pipe = os.popen('md5sum ' + localpath)
51 md5data = (md5pipe.readline().split() or [ "" ])[0]
54 raise Exception("Executing md5sum failed")
57 shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
58 shadata = (shapipe.readline().split() or [ "" ])[0]
61 raise Exception("Executing shasum failed")
63 if no_checksum == True: # we do not have conf/checksums.ini entry
65 file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
70 raise Exception("Creating checksums.ini failed")
72 file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
74 if not bb.data.getVar("OE_STRICT_CHECKSUMS",data, True):
75 bb.note("This package has no entry in checksums.ini, please add one")
76 bb.note("\n[%s]\nmd5=%s\nsha256=%s" % (src_uri, md5data, shadata))
79 bb.note("Missing checksum")
82 if not md5 == md5data:
83 bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
84 raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
86 if not sha256 == shadata:
87 bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
88 raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
93 def base_dep_prepend(d):
96 # Ideally this will check a flag so we will operate properly in
97 # the case where host == build == target, for now we don't work in
100 deps = "shasum-native "
101 if bb.data.getVar('PN', d, True) == "shasum-native":
104 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
105 # we need that built is the responsibility of the patch function / class, not
107 if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
108 if (bb.data.getVar('HOST_SYS', d, 1) !=
109 bb.data.getVar('BUILD_SYS', d, 1)):
110 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
113 def base_read_file(filename):
116 f = file( filename, "r" )
117 except IOError, reason:
118 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
120 return f.read().strip()
123 def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
125 if bb.data.getVar(variable,d,1) == checkvalue:
130 def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
132 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
137 def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
139 result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
145 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
148 if type(checkvalues).__name__ == "str":
149 checkvalues = [checkvalues]
150 for value in checkvalues:
151 if bb.data.getVar(variable,d,1).find(value) != -1:
152 matches = matches + 1
153 if matches == len(checkvalues):
157 def base_both_contain(variable1, variable2, checkvalue, d):
159 if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
164 DEPENDS_prepend="${@base_dep_prepend(d)} "
166 # Returns PN with various suffixes removed
167 # or PN if no matching suffix was found.
168 def base_package_name(d):
171 pn = bb.data.getVar('PN', d, 1)
172 if pn.endswith("-native"):
174 elif pn.endswith("-cross"):
176 elif pn.endswith("-initial"):
178 elif pn.endswith("-intermediate"):
183 def base_set_filespath(path, d):
186 # The ":" ensures we have an 'empty' override
187 overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":"
189 for o in overrides.split(":"):
190 filespath.append(os.path.join(p, o))
191 return ":".join(filespath)
193 FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}"
195 def oe_filter(f, str, d):
197 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
199 def oe_filter_out(f, str, d):
201 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
222 echo "Usage: oedebug level \"message\""
226 test ${OEDEBUG:-0} -ge $1 && {
233 if [ x"$MAKE" = x ]; then MAKE=make; fi
234 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
235 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
239 # Purpose: Install shared library file and
240 # create the necessary links
245 #oenote installing shared library $1 to $2
247 libname=`basename $1`
248 install -m 755 $1 $2/$libname
249 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
250 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
251 ln -sf $libname $2/$sonamelink
252 ln -sf $libname $2/$solink
256 # Purpose: Install a library, in all its forms
259 # oe_libinstall libltdl ${STAGING_LIBDIR}/
260 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
267 while [ "$#" -gt 0 ]; do
283 oefatal "oe_libinstall: unknown option: $1"
295 if [ -z "$destpath" ]; then
296 oefatal "oe_libinstall: no destination path specified"
298 if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
304 if [ -z "$silent" ]; then
305 echo >&2 "oe_libinstall: $*"
310 if [ -z "$dir" ]; then
316 # Sanity check that the libname.lai is unique
317 number_of_files=`(cd $dir; find . -name "$dotlai") | wc -l`
318 if [ $number_of_files -gt 1 ]; then
319 oefatal "oe_libinstall: $dotlai is not unique in $dir"
323 dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
329 # If such file doesn't exist, try to cut version suffix
330 if [ ! -f "$lafile" ]; then
331 libname1=`echo "$libname" | sed 's/-[0-9.]*$//'`
333 if [ -f "$lafile1" ]; then
339 if [ -f "$lafile" ]; then
341 eval `cat $lafile|grep "^library_names="`
344 library_names="$libname.so* $libname.dll.a"
347 __runcmd install -d $destpath/
349 if [ -f "$dota" -o -n "$require_static" ]; then
350 __runcmd install -m 0644 $dota $destpath/
352 if [ -f "$dotlai" -a -n "$libtool" ]; then
353 if test -n "$staging_install"
355 # stop libtool using the final directory name for libraries
357 __runcmd rm -f $destpath/$libname.la
358 __runcmd sed -e 's/^installed=yes$/installed=no/' \
359 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
360 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
361 $dotlai >$destpath/$libname.la
363 __runcmd install -m 0644 $dotlai $destpath/$libname.la
367 for name in $library_names; do
368 files=`eval echo $name`
370 if [ ! -e "$f" ]; then
371 if [ -n "$libtool" ]; then
372 oefatal "oe_libinstall: $dir/$f not found."
374 elif [ -L "$f" ]; then
375 __runcmd cp -P "$f" $destpath/
376 elif [ ! -L "$f" ]; then
378 __runcmd install -m 0755 $libfile $destpath/
383 if [ -z "$libfile" ]; then
384 if [ -n "$require_shared" ]; then
385 oefatal "oe_libinstall: unable to locate shared library"
387 elif [ -z "$libtool" ]; then
388 # special case hack for non-libtool .so.#.#.# links
389 baselibfile=`basename "$libfile"`
390 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
391 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
392 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
393 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
394 __runcmd ln -sf $baselibfile $destpath/$sonamelink
396 __runcmd ln -sf $baselibfile $destpath/$solink
400 __runcmd cd "$olddir"
403 def package_stagefile(file, d):
406 if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1":
407 destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1))
408 bb.mkdirhier(os.path.dirname(destfile))
409 #print "%s to %s" % (file, destfile)
410 bb.copyfile(file, destfile)
412 package_stagefile_shell() {
413 if [ "$PSTAGING_ACTIVE" = "1" ]; then
415 destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#`
416 destdir=`dirname $destfile`
418 cp -dp $srcfile $destfile
423 # Purpose: Install machine dependent files, if available
424 # If not available, check if there is a default
425 # If no default, just touch the destination
428 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
430 # TODO: Check argument number?
432 filename=`basename $3`
435 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
436 if [ -e $dirname/$o/$filename ]; then
437 oenote $dirname/$o/$filename present, installing to $4
438 install $1 $2 $dirname/$o/$filename $4
442 # oenote overrides specific file NOT present, trying default=$3...
444 oenote $3 present, installing to $4
447 oenote $3 NOT present, touching empty $4
453 do_listtasks[nostamp] = "1"
454 python do_listtasks() {
456 # emit variables and shell functions
457 #bb.data.emit_env(sys.__stdout__, d)
458 # emit the metadata which isnt valid shell
460 if bb.data.getVarFlag(e, 'task', d):
461 sys.__stdout__.write("%s\n" % e)
465 do_clean[dirs] = "${TOPDIR}"
466 do_clean[nostamp] = "1"
467 python base_do_clean() {
468 """clear the build and temp directories"""
469 dir = bb.data.expand("${WORKDIR}", d)
470 if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
471 bb.note("removing " + dir)
472 os.system('rm -rf ' + dir)
474 dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
475 bb.note("removing " + dir)
476 os.system('rm -f '+ dir)
479 #Uncomment this for bitbake 1.8.12
480 #addtask rebuild after do_${BB_DEFAULT_TASK}
482 do_rebuild[dirs] = "${TOPDIR}"
483 do_rebuild[nostamp] = "1"
484 python base_do_rebuild() {
485 """rebuild a package"""
486 from bb import __version__
488 from distutils.version import LooseVersion
490 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
491 if (LooseVersion(__version__) < LooseVersion('1.8.11')):
492 bb.build.exec_func('do_clean', d)
493 bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d)
497 do_mrproper[dirs] = "${TOPDIR}"
498 do_mrproper[nostamp] = "1"
499 python base_do_mrproper() {
500 """clear downloaded sources, build and temp directories"""
501 dir = bb.data.expand("${DL_DIR}", d)
502 if dir == '/': bb.build.FuncFailed("wrong DATADIR")
503 bb.debug(2, "removing " + dir)
504 os.system('rm -rf ' + dir)
505 bb.build.exec_func('do_clean', d)
509 do_distclean[dirs] = "${TOPDIR}"
510 do_distclean[nostamp] = "1"
511 python base_do_distclean() {
512 """clear downloaded sources, build and temp directories"""
515 bb.build.exec_func('do_clean', d)
517 src_uri = bb.data.getVar('SRC_URI', d, 1)
521 for uri in src_uri.split():
522 if bb.decodeurl(uri)[0] == "file":
526 local = bb.data.expand(bb.fetch.localpath(uri, d), d)
527 except bb.MalformedUrl, e:
528 bb.debug(1, 'Unable to generate local path for malformed uri: %s' % e)
530 bb.note("removing %s" % local)
532 if os.path.exists(local + ".md5"):
533 os.remove(local + ".md5")
534 if os.path.exists(local):
537 bb.note("Error in removal: %s" % e)
540 SCENEFUNCS += "base_scenefunction"
542 python base_do_setscene () {
543 for f in (bb.data.getVar('SCENEFUNCS', d, 1) or '').split():
544 bb.build.exec_func(f, d)
545 if not os.path.exists(bb.data.getVar('STAMP', d, 1) + ".do_setscene"):
546 bb.build.make_stamp("do_setscene", d)
548 do_setscene[selfstamp] = "1"
549 addtask setscene before do_fetch
551 python base_scenefunction () {
552 stamp = bb.data.getVar('STAMP', d, 1) + ".needclean"
553 if os.path.exists(stamp):
554 bb.build.exec_func("do_clean", d)
559 do_fetch[dirs] = "${DL_DIR}"
560 do_fetch[depends] = "shasum-native:do_populate_staging"
561 python base_do_fetch() {
564 localdata = bb.data.createCopy(d)
565 bb.data.update_data(localdata)
567 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
572 bb.fetch.init(src_uri.split(),d)
573 except bb.fetch.NoMethodError:
574 (type, value, traceback) = sys.exc_info()
575 raise bb.build.FuncFailed("No method: %s" % value)
578 bb.fetch.go(localdata)
579 except bb.fetch.MissingParameterError:
580 (type, value, traceback) = sys.exc_info()
581 raise bb.build.FuncFailed("Missing parameters: %s" % value)
582 except bb.fetch.FetchError:
583 (type, value, traceback) = sys.exc_info()
584 raise bb.build.FuncFailed("Fetch failed: %s" % value)
585 except bb.fetch.MD5SumError:
586 (type, value, traceback) = sys.exc_info()
587 raise bb.build.FuncFailed("MD5 failed: %s" % value)
589 (type, value, traceback) = sys.exc_info()
590 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
593 # Verify the SHA and MD5 sums we have in OE and check what do
595 check_sum = bb.which(bb.data.getVar('BBPATH', d, True), "conf/checksums.ini")
597 bb.note("No conf/checksums.ini found, not checking checksums")
601 parser = base_chk_load_parser(check_sum)
603 bb.note("Creating the CheckSum parser failed")
606 pv = bb.data.getVar('PV', d, True)
607 pn = bb.data.getVar('PN', d, True)
610 for url in src_uri.split():
611 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
612 (type,host,path,_,_,_) = bb.decodeurl(url)
613 uri = "%s://%s%s" % (type,host,path)
615 if type == "http" or type == "https" or type == "ftp" or type == "ftps":
616 if not base_chk_file(parser, pn, pv,uri, localpath, d):
617 if not bb.data.getVar("OE_ALLOW_INSECURE_DOWNLOADS",d, True):
618 bb.fatal("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
620 bb.note("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
622 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
625 addtask fetchall after do_fetch
626 do_fetchall[recrdeptask] = "do_fetch"
632 do_checkuri[nostamp] = "1"
633 python do_checkuri() {
636 localdata = bb.data.createCopy(d)
637 bb.data.update_data(localdata)
639 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
642 bb.fetch.init(src_uri.split(),d)
643 except bb.fetch.NoMethodError:
644 (type, value, traceback) = sys.exc_info()
645 raise bb.build.FuncFailed("No method: %s" % value)
648 bb.fetch.checkstatus(localdata)
649 except bb.fetch.MissingParameterError:
650 (type, value, traceback) = sys.exc_info()
651 raise bb.build.FuncFailed("Missing parameters: %s" % value)
652 except bb.fetch.FetchError:
653 (type, value, traceback) = sys.exc_info()
654 raise bb.build.FuncFailed("Fetch failed: %s" % value)
655 except bb.fetch.MD5SumError:
656 (type, value, traceback) = sys.exc_info()
657 raise bb.build.FuncFailed("MD5 failed: %s" % value)
659 (type, value, traceback) = sys.exc_info()
660 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
663 addtask checkuriall after do_checkuri
664 do_checkuriall[recrdeptask] = "do_checkuri"
665 do_checkuriall[nostamp] = "1"
666 base_do_checkuriall() {
670 addtask buildall after do_build
671 do_buildall[recrdeptask] = "do_build"
677 def oe_unpack_file(file, data, url = None):
680 url = "file://%s" % file
681 dots = file.split(".")
682 if dots[-1] in ['gz', 'bz2', 'Z']:
683 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
687 if file.endswith('.tar'):
688 cmd = 'tar x --no-same-owner -f %s' % file
689 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
690 cmd = 'tar xz --no-same-owner -f %s' % file
691 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
692 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
693 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
694 cmd = 'gzip -dc %s > %s' % (file, efile)
695 elif file.endswith('.bz2'):
696 cmd = 'bzip2 -dc %s > %s' % (file, efile)
697 elif file.endswith('.zip') or file.endswith('.jar'):
699 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
702 cmd = '%s %s' % (cmd, file)
703 elif os.path.isdir(file):
704 filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, 1))
706 if file[0:len(filesdir)] == filesdir:
707 destdir = file[len(filesdir):file.rfind('/')]
708 destdir = destdir.strip('/')
711 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
712 os.makedirs("%s/%s" % (os.getcwd(), destdir))
713 cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
715 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
716 if not 'patch' in parm:
717 # The "destdir" handling was specifically done for FILESPATH
718 # items. So, only do so for file:// entries.
720 destdir = bb.decodeurl(url)[1] or "."
723 bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
724 cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
729 dest = os.path.join(os.getcwd(), os.path.basename(file))
730 if os.path.exists(dest):
731 if os.path.samefile(file, dest):
734 # Change to subdir before executing command
735 save_cwd = os.getcwd();
736 parm = bb.decodeurl(url)[5]
738 newdir = ("%s/%s" % (os.getcwd(), parm['subdir']))
742 cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
743 bb.note("Unpacking %s to %s/" % (file, os.getcwd()))
750 addtask unpack after do_fetch
751 do_unpack[dirs] = "${WORKDIR}"
752 python base_do_unpack() {
755 localdata = bb.data.createCopy(d)
756 bb.data.update_data(localdata)
758 src_uri = bb.data.getVar('SRC_URI', localdata)
761 src_uri = bb.data.expand(src_uri, localdata)
762 for url in src_uri.split():
764 local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
765 except bb.MalformedUrl, e:
766 raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
767 local = os.path.realpath(local)
768 ret = oe_unpack_file(local, localdata, url)
770 raise bb.build.FuncFailed()
773 def base_get_scmbasepath(d):
775 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
776 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
778 def base_get_metadata_monotone_branch(d):
779 monotone_branch = "<unknown>"
781 monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip()
782 if monotone_branch.startswith( "database" ):
783 monotone_branch_words = monotone_branch.split()
784 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
787 return monotone_branch
789 def base_get_metadata_monotone_revision(d):
790 monotone_revision = "<unknown>"
792 monotone_revision = file( "%s/_MTN/revision" % base_get_scmbasepath(d) ).read().strip()
793 if monotone_revision.startswith( "format_version" ):
794 monotone_revision_words = monotone_revision.split()
795 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
798 return monotone_revision
800 def base_get_metadata_svn_revision(d):
801 revision = "<unknown>"
803 revision = file( "%s/.svn/entries" % base_get_scmbasepath(d) ).readlines()[3].strip()
808 def base_get_metadata_git_branch(d):
810 branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read()
816 def base_get_metadata_git_revision(d):
818 rev = os.popen("cd %s; git log -n 1 --pretty=oneline --" % base_get_scmbasepath(d)).read().split(" ")[0]
823 def base_detect_revision(d):
824 scms = [base_get_metadata_monotone_revision, \
825 base_get_metadata_svn_revision, \
826 base_get_metadata_git_revision]
830 if rev <> "<unknown>":
835 def base_detect_branch(d):
836 scms = [base_get_metadata_monotone_branch, \
837 base_get_metadata_git_branch]
841 if rev <> "<unknown>":
848 METADATA_BRANCH ?= "${@base_detect_branch(d)}"
849 METADATA_REVISION ?= "${@base_detect_revision(d)}"
851 addhandler base_eventhandler
852 python base_eventhandler() {
853 from bb import note, error, data
854 from bb.event import Handled, NotHandled, getName
858 messages["Completed"] = "completed"
859 messages["Succeeded"] = "completed"
860 messages["Started"] = "started"
861 messages["Failed"] = "failed"
865 if name.startswith("Pkg"):
866 msg += "package %s: " % data.getVar("P", e.data, 1)
867 msg += messages.get(name[3:]) or name[3:]
868 elif name.startswith("Task"):
869 msg += "package %s: task %s: " % (data.getVar("PF", e.data, 1), e.task)
870 msg += messages.get(name[4:]) or name[4:]
871 elif name.startswith("Build"):
872 msg += "build %s: " % e.name
873 msg += messages.get(name[5:]) or name[5:]
874 elif name == "UnsatisfiedDep":
875 msg += "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower())
877 # Only need to output when using 1.8 or lower, the UI code handles it
879 if (int(bb.__version__.split(".")[0]) <= 1 and int(bb.__version__.split(".")[1]) <= 8):
883 if name.startswith("BuildStarted"):
884 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
885 statusvars = ['BB_VERSION', 'METADATA_BRANCH', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
886 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
887 statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
890 needed_vars = [ "TARGET_ARCH", "TARGET_OS" ]
892 for v in needed_vars:
893 val = bb.data.getVar(v, e.data, 1)
894 if not val or val == 'INVALID':
897 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))
900 # Handle removing stamps for 'rebuild' task
902 if name.startswith("StampUpdate"):
903 for (fn, task) in e.targets:
904 #print "%s %s" % (task, fn)
905 if task == "do_rebuild":
906 dir = "%s.*" % e.stampPrefix[fn]
907 bb.note("Removing stamps: " + dir)
908 os.system('rm -f '+ dir)
909 os.system('touch ' + e.stampPrefix[fn] + '.needclean')
911 if not data in e.__dict__:
914 log = data.getVar("EVENTLOG", e.data, 1)
916 logfile = file(log, "a")
917 logfile.write("%s\n" % msg)
923 addtask configure after do_unpack do_patch
924 do_configure[dirs] = "${S} ${B}"
925 do_configure[deptask] = "do_populate_staging"
926 base_do_configure() {
930 addtask compile after do_configure
931 do_compile[dirs] = "${S} ${B}"
933 if [ -e Makefile -o -e makefile ]; then
934 oe_runmake || die "make failed"
936 oenote "nothing to compile"
944 do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${layout_bindir} ${STAGING_DIR_TARGET}/${layout_libdir} \
945 ${STAGING_DIR_TARGET}/${layout_includedir} \
946 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
947 ${STAGING_INCDIR_NATIVE} \
951 # Could be compile but populate_staging and do_install shouldn't run at the same time
952 addtask populate_staging after do_install
954 python do_populate_staging () {
955 bb.build.exec_func('do_stage', d)
958 addtask install after do_compile
959 do_install[dirs] = "${D} ${S} ${B}"
960 # Remove and re-create ${D} so that is it guaranteed to be empty
961 do_install[cleandirs] = "${D}"
971 addtask build after do_populate_staging
975 # Functions that update metadata based on files outputted
976 # during the build process.
990 r[-1] += ' ' + ' '.join(j)
995 def packaged(pkg, d):
997 return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
999 def read_pkgdatafile(fn):
1004 c = codecs.getdecoder("string_escape")
1008 if os.access(fn, os.R_OK):
1011 lines = f.readlines()
1013 r = re.compile("([^:]+):\s*(.*)")
1017 pkgdata[m.group(1)] = decode(m.group(2))
1021 def get_subpkgedata_fn(pkg, d):
1023 archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
1025 pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
1026 targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
1028 fn = pkgdata + arch + targetdir + pkg
1029 if os.path.exists(fn):
1031 return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
1033 def has_subpkgdata(pkg, d):
1035 return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
1037 def read_subpkgdata(pkg, d):
1039 return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1041 def has_pkgdata(pn, d):
1043 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1044 return os.access(fn, os.R_OK)
1046 def read_pkgdata(pn, d):
1048 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1049 return read_pkgdatafile(fn)
1051 python read_subpackage_metadata () {
1053 data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
1055 for key in data.keys():
1056 bb.data.setVar(key, data[key], d)
1058 for pkg in bb.data.getVar('PACKAGES', d, 1).split():
1059 sdata = read_subpkgdata(pkg, d)
1060 for key in sdata.keys():
1061 bb.data.setVar(key, sdata[key], d)
1064 # Make sure MACHINE isn't exported
1065 # (breaks binutils at least)
1066 MACHINE[unexport] = "1"
1068 # Make sure TARGET_ARCH isn't exported
1069 # (breaks Makefiles using implicit rules, e.g. quilt, as GNU make has this
1070 # in them, undocumented)
1071 TARGET_ARCH[unexport] = "1"
1073 # Make sure DISTRO isn't exported
1074 # (breaks sysvinit at least)
1075 DISTRO[unexport] = "1"
1078 def base_after_parse(d):
1079 import bb, os, exceptions
1081 source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
1082 if not source_mirror_fetch:
1083 need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
1086 this_host = bb.data.getVar('HOST_SYS', d, 1)
1087 if not re.match(need_host, this_host):
1088 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
1090 need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
1093 this_machine = bb.data.getVar('MACHINE', d, 1)
1094 if this_machine and not re.match(need_machine, this_machine):
1095 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
1097 pn = bb.data.getVar('PN', d, 1)
1099 # OBSOLETE in bitbake 1.7.4
1100 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
1102 bb.data.setVar('SRCDATE', srcdate, d)
1104 use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
1106 bb.data.setVar('USE_NLS', use_nls, d)
1108 # Git packages should DEPEND on git-native
1109 srcuri = bb.data.getVar('SRC_URI', d, 1)
1110 if "git://" in srcuri:
1111 depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
1112 depends = depends + " git-native:do_populate_staging"
1113 bb.data.setVarFlag('do_fetch', 'depends', depends, d)
1115 # 'multimachine' handling
1116 mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
1117 pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
1119 if (pkg_arch == mach_arch):
1120 # Already machine specific - nothing further to do
1124 # We always try to scan SRC_URI for urls with machine overrides
1125 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
1127 override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
1130 for p in [ "${PF}", "${P}", "${PN}", "files", "" ]:
1131 path = bb.data.expand(os.path.join("${FILE_DIRNAME}", p, "${MACHINE}"), d)
1132 if os.path.isdir(path):
1135 for s in srcuri.split():
1136 if not s.startswith("file://"):
1138 local = bb.data.expand(bb.fetch.localpath(s, d), d)
1140 if local.startswith(mp):
1141 #bb.note("overriding PACKAGE_ARCH from %s to %s" % (pkg_arch, mach_arch))
1142 bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
1143 bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
1146 multiarch = pkg_arch
1148 packages = bb.data.getVar('PACKAGES', d, 1).split()
1149 for pkg in packages:
1150 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
1152 # We could look for != PACKAGE_ARCH here but how to choose
1153 # if multiple differences are present?
1154 # Look through PACKAGE_ARCHS for the priority order?
1155 if pkgarch and pkgarch == mach_arch:
1156 multiarch = mach_arch
1159 bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
1163 from bb import __version__
1166 # Remove this for bitbake 1.8.12
1168 from distutils.version import LooseVersion
1170 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
1171 if (LooseVersion(__version__) >= LooseVersion('1.8.11')):
1172 deps = bb.data.getVarFlag('do_rebuild', 'deps', d) or []
1173 deps.append('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1))
1174 bb.data.setVarFlag('do_rebuild', 'deps', deps, d)
1177 def check_app_exists(app, d):
1178 from bb import which, data
1180 app = data.expand(app, d)
1181 path = data.getVar('PATH', d, 1)
1182 return len(which(path, app)) != 0
1184 def check_gcc3(data):
1186 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'
1188 for gcc3 in gcc3_versions.split():
1189 if check_app_exists(gcc3, data):
1197 # Configuration data from site files
1198 # Move to autotools.bbclass?
1201 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
1205 ${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
1206 ${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
1207 ${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
1208 ${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
1209 ${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
1210 ${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
1211 ${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
1212 ${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
1213 ${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
1214 ${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
1215 ${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
1216 ${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
1217 ${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
1218 ${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
1219 ${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
1220 ${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
1221 ${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
1222 ${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
1223 ${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
1224 ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
1225 ${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
1226 ${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
1227 ${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
1228 ${KERNELORG_MIRROR} http://www.kernel.org/pub
1229 ${KERNELORG_MIRROR} ftp://ftp.us.kernel.org/pub
1230 ${KERNELORG_MIRROR} ftp://ftp.uk.kernel.org/pub
1231 ${KERNELORG_MIRROR} ftp://ftp.hk.kernel.org/pub
1232 ${KERNELORG_MIRROR} ftp://ftp.au.kernel.org/pub
1233 ${KERNELORG_MIRROR} ftp://ftp.jp.kernel.org/pub
1234 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
1235 ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/
1236 ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/
1237 ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
1238 ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
1239 ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
1240 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
1241 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
1242 ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
1243 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
1244 ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
1245 http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
1246 http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
1247 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
1248 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tau.ac.il/pub/unix/admin/
1249 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
1250 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
1251 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.kaizo.org/pub/lsof/
1252 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
1253 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
1254 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
1255 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
1256 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://the.wiretapped.net/pub/security/host-security/lsof/
1257 http://www.apache.org/dist http://archive.apache.org/dist