conf/distro/jlime-donkey.conf : Added parted & Dialog to distro_rdepends
[vuplus_openembedded] / classes / base.bbclass
1 BB_DEFAULT_TASK = "build"
2
3 def base_dep_prepend(d):
4         import bb;
5         #
6         # Ideally this will check a flag so we will operate properly in
7         # the case where host == build == target, for now we don't work in
8         # that case though.
9         #
10         deps = ""
11
12         # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command.  Whether or  not
13         # we need that built is the responsibility of the patch function / class, not
14         # the application.
15         patchdeps = bb.data.getVar("PATCHTOOL", d, 1)
16         if patchdeps:
17                 patchdeps = "%s-native" % patchdeps
18                 if not patchdeps in bb.data.getVar("PROVIDES", d, 1):
19                         deps = patchdeps
20
21         if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
22                 if (bb.data.getVar('HOST_SYS', d, 1) !=
23                     bb.data.getVar('BUILD_SYS', d, 1)):
24                         deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
25         return deps
26
27 def base_read_file(filename):
28         import bb
29         try:
30                 f = file( filename, "r" )
31         except IOError, reason:
32                 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
33         else:
34                 return f.read().strip()
35         return None
36
37 def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
38         import bb
39         if bb.data.getVar(variable,d,1) == checkvalue:
40                 return truevalue
41         else:
42                 return falsevalue
43
44 def base_contains(variable, checkvalue, truevalue, falsevalue, d):
45        import bb
46        if bb.data.getVar(variable,d,1).find(checkvalue) != -1:
47                return truevalue
48        else:
49                return falsevalue
50
51 def base_both_contain(variable1, variable2, checkvalue, d):
52        import bb
53        if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
54                return checkvalue
55        else:
56                return ""
57
58 DEPENDS_prepend="${@base_dep_prepend(d)} "
59
60 def base_set_filespath(path, d):
61         import os, bb
62         filespath = []
63         for p in path:
64                 overrides = bb.data.getVar("OVERRIDES", d, 1) or ""
65                 overrides = overrides + ":"
66                 for o in overrides.split(":"):
67                         filespath.append(os.path.join(p, o))
68         return ":".join(filespath)
69
70 FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}"
71
72 def oe_filter(f, str, d):
73         from re import match
74         return " ".join(filter(lambda x: match(f, x, 0), str.split()))
75
76 def oe_filter_out(f, str, d):
77         from re import match
78         return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
79
80 die() {
81         oefatal "$*"
82 }
83
84 oenote() {
85         echo "NOTE:" "$*"
86 }
87
88 oewarn() {
89         echo "WARNING:" "$*"
90 }
91
92 oefatal() {
93         echo "FATAL:" "$*"
94         exit 1
95 }
96
97 oedebug() {
98         test $# -ge 2 || {
99                 echo "Usage: oedebug level \"message\""
100                 exit 1
101         }
102
103         test ${OEDEBUG:-0} -ge $1 && {
104                 shift
105                 echo "DEBUG:" $*
106         }
107 }
108
109 oe_runmake() {
110         if [ x"$MAKE" = x ]; then MAKE=make; fi
111         oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
112         ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
113 }
114
115 oe_soinstall() {
116         # Purpose: Install shared library file and
117         #          create the necessary links
118         # Example:
119         #
120         # oe_
121         #
122         #oenote installing shared library $1 to $2
123         #
124         libname=`basename $1`
125         install -m 755 $1 $2/$libname
126         sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
127         solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
128         ln -sf $libname $2/$sonamelink
129         ln -sf $libname $2/$solink
130 }
131
132 oe_libinstall() {
133         # Purpose: Install a library, in all its forms
134         # Example
135         #
136         # oe_libinstall libltdl ${STAGING_LIBDIR}/
137         # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
138         dir=""
139         libtool=""
140         silent=""
141         require_static=""
142         require_shared=""
143         staging_install=""
144         while [ "$#" -gt 0 ]; do
145                 case "$1" in
146                 -C)
147                         shift
148                         dir="$1"
149                         ;;
150                 -s)
151                         silent=1
152                         ;;
153                 -a)
154                         require_static=1
155                         ;;
156                 -so)
157                         require_shared=1
158                         ;;
159                 -*)
160                         oefatal "oe_libinstall: unknown option: $1"
161                         ;;
162                 *)
163                         break;
164                         ;;
165                 esac
166                 shift
167         done
168
169         libname="$1"
170         shift
171         destpath="$1"
172         if [ -z "$destpath" ]; then
173                 oefatal "oe_libinstall: no destination path specified"
174         fi
175         if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
176         then
177                 staging_install=1
178         fi
179
180         __runcmd () {
181                 if [ -z "$silent" ]; then
182                         echo >&2 "oe_libinstall: $*"
183                 fi
184                 $*
185         }
186
187         if [ -z "$dir" ]; then
188                 dir=`pwd`
189         fi
190         dotlai=$libname.lai
191         dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
192         olddir=`pwd`
193         __runcmd cd $dir
194
195         lafile=$libname.la
196
197         # If such file doesn't exist, try to cut version suffix
198         if [ ! -f "$lafile" ]; then
199                 libname=`echo "$libname" | sed 's/-[0-9.]*$//'`
200                 lafile=$libname.la
201         fi
202
203         if [ -f "$lafile" ]; then
204                 # libtool archive
205                 eval `cat $lafile|grep "^library_names="`
206                 libtool=1
207         else
208                 library_names="$libname.so* $libname.dll.a"
209         fi
210
211         __runcmd install -d $destpath/
212         dota=$libname.a
213         if [ -f "$dota" -o -n "$require_static" ]; then
214                 __runcmd install -m 0644 $dota $destpath/
215         fi
216         if [ -f "$dotlai" -a -n "$libtool" ]; then
217                 if test -n "$staging_install"
218                 then
219                         # stop libtool using the final directory name for libraries
220                         # in staging:
221                         __runcmd rm -f $destpath/$libname.la
222                         __runcmd sed -e 's/^installed=yes$/installed=no/' -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' $dotlai >$destpath/$libname.la
223                 else
224                         __runcmd install -m 0644 $dotlai $destpath/$libname.la
225                 fi
226         fi
227
228         for name in $library_names; do
229                 files=`eval echo $name`
230                 for f in $files; do
231                         if [ ! -e "$f" ]; then
232                                 if [ -n "$libtool" ]; then
233                                         oefatal "oe_libinstall: $dir/$f not found."
234                                 fi
235                         elif [ -L "$f" ]; then
236                                 __runcmd cp -P "$f" $destpath/
237                         elif [ ! -L "$f" ]; then
238                                 libfile="$f"
239                                 __runcmd install -m 0755 $libfile $destpath/
240                         fi
241                 done
242         done
243
244         if [ -z "$libfile" ]; then
245                 if  [ -n "$require_shared" ]; then
246                         oefatal "oe_libinstall: unable to locate shared library"
247                 fi
248         elif [ -z "$libtool" ]; then
249                 # special case hack for non-libtool .so.#.#.# links
250                 baselibfile=`basename "$libfile"`
251                 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
252                         sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
253                         solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
254                         if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
255                                 __runcmd ln -sf $baselibfile $destpath/$sonamelink
256                         fi
257                         __runcmd ln -sf $baselibfile $destpath/$solink
258                 fi
259         fi
260
261         __runcmd cd "$olddir"
262 }
263
264 oe_machinstall() {
265         # Purpose: Install machine dependent files, if available
266         #          If not available, check if there is a default
267         #          If no default, just touch the destination
268         # Example:
269         #                $1  $2   $3         $4
270         # oe_machinstall -m 0644 fstab ${D}/etc/fstab
271         #
272         # TODO: Check argument number?
273         #
274         filename=`basename $3`
275         dirname=`dirname $3`
276
277         for o in `echo ${OVERRIDES} | tr ':' ' '`; do
278                 if [ -e $dirname/$o/$filename ]; then
279                         oenote $dirname/$o/$filename present, installing to $4
280                         install $1 $2 $dirname/$o/$filename $4
281                         return
282                 fi
283         done
284 #       oenote overrides specific file NOT present, trying default=$3...
285         if [ -e $3 ]; then
286                 oenote $3 present, installing to $4
287                 install $1 $2 $3 $4
288         else
289                 oenote $3 NOT present, touching empty $4
290                 touch $4
291         fi
292 }
293
294 addtask showdata
295 do_showdata[nostamp] = "1"
296 python do_showdata() {
297         import sys
298         # emit variables and shell functions
299         bb.data.emit_env(sys.__stdout__, d, True)
300         # emit the metadata which isnt valid shell
301         for e in d.keys():
302             if bb.data.getVarFlag(e, 'python', d):
303                 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
304 }
305
306 addtask listtasks
307 do_listtasks[nostamp] = "1"
308 python do_listtasks() {
309         import sys
310         # emit variables and shell functions
311         #bb.data.emit_env(sys.__stdout__, d)
312         # emit the metadata which isnt valid shell
313         for e in d.keys():
314                 if bb.data.getVarFlag(e, 'task', d):
315                         sys.__stdout__.write("%s\n" % e)
316 }
317
318 addtask clean
319 do_clean[dirs] = "${TOPDIR}"
320 do_clean[nostamp] = "1"
321 do_clean[bbdepcmd] = ""
322 python base_do_clean() {
323         """clear the build and temp directories"""
324         dir = bb.data.expand("${WORKDIR}", d)
325         if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
326         bb.note("removing " + dir)
327         os.system('rm -rf ' + dir)
328
329         dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
330         bb.note("removing " + dir)
331         os.system('rm -f '+ dir)
332 }
333
334 addtask rebuild
335 do_rebuild[dirs] = "${TOPDIR}"
336 do_rebuild[nostamp] = "1"
337 do_rebuild[bbdepcmd] = ""
338 python base_do_rebuild() {
339         """rebuild a package"""
340         bb.build.exec_task('do_clean', d)
341         bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d)
342 }
343
344 addtask mrproper
345 do_mrproper[dirs] = "${TOPDIR}"
346 do_mrproper[nostamp] = "1"
347 do_mrproper[bbdepcmd] = ""
348 python base_do_mrproper() {
349         """clear downloaded sources, build and temp directories"""
350         dir = bb.data.expand("${DL_DIR}", d)
351         if dir == '/': bb.build.FuncFailed("wrong DATADIR")
352         bb.debug(2, "removing " + dir)
353         os.system('rm -rf ' + dir)
354         bb.build.exec_task('do_clean', d)
355 }
356
357 addtask fetch
358 do_fetch[dirs] = "${DL_DIR}"
359 python base_do_fetch() {
360         import sys
361
362         localdata = bb.data.createCopy(d)
363         bb.data.update_data(localdata)
364
365         src_uri = bb.data.getVar('SRC_URI', localdata, 1)
366         if not src_uri:
367                 return 1
368
369         try:
370                 bb.fetch.init(src_uri.split(),d)
371         except bb.fetch.NoMethodError:
372                 (type, value, traceback) = sys.exc_info()
373                 raise bb.build.FuncFailed("No method: %s" % value)
374
375         try:
376                 bb.fetch.go(localdata)
377         except bb.fetch.MissingParameterError:
378                 (type, value, traceback) = sys.exc_info()
379                 raise bb.build.FuncFailed("Missing parameters: %s" % value)
380         except bb.fetch.FetchError:
381                 (type, value, traceback) = sys.exc_info()
382                 raise bb.build.FuncFailed("Fetch failed: %s" % value)
383 }
384
385 addtask fetchall after do_fetch
386 do_fetchall[recrdeptask] = "do_fetch"
387 base_do_fetchall() {
388         :
389 }
390
391 def oe_unpack_file(file, data, url = None):
392         import bb, os
393         if not url:
394                 url = "file://%s" % file
395         dots = file.split(".")
396         if dots[-1] in ['gz', 'bz2', 'Z']:
397                 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
398         else:
399                 efile = file
400         cmd = None
401         if file.endswith('.tar'):
402                 cmd = 'tar x --no-same-owner -f %s' % file
403         elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
404                 cmd = 'tar xz --no-same-owner -f %s' % file
405         elif file.endswith('.tbz') or file.endswith('.tar.bz2'):
406                 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
407         elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
408                 cmd = 'gzip -dc %s > %s' % (file, efile)
409         elif file.endswith('.bz2'):
410                 cmd = 'bzip2 -dc %s > %s' % (file, efile)
411         elif file.endswith('.zip'):
412                 cmd = 'unzip -q'
413                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
414                 if 'dos' in parm:
415                         cmd = '%s -a' % cmd
416                 cmd = '%s %s' % (cmd, file)
417         elif os.path.isdir(file):
418                 filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, 1))
419                 destdir = "."
420                 if file[0:len(filesdir)] == filesdir:
421                         destdir = file[len(filesdir):file.rfind('/')]
422                         destdir = destdir.strip('/')
423                         if len(destdir) < 1:
424                                 destdir = "."
425                         elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
426                                 os.makedirs("%s/%s" % (os.getcwd(), destdir))
427                 cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
428         else:
429                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
430                 if not 'patch' in parm:
431                         # The "destdir" handling was specifically done for FILESPATH
432                         # items.  So, only do so for file:// entries.
433                         if type == "file":
434                                 destdir = bb.decodeurl(url)[1] or "."
435                         else:
436                                 destdir = "."
437                         bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
438                         cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
439
440         if not cmd:
441                 return True
442
443         dest = os.path.join(os.getcwd(), os.path.basename(file))
444         if os.path.exists(dest):
445                 if os.path.samefile(file, dest):
446                         return True
447
448         cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
449         bb.note("Unpacking %s to %s/" % (file, os.getcwd()))
450         ret = os.system(cmd)
451         return ret == 0
452
453 addtask unpack after do_fetch
454 do_unpack[dirs] = "${WORKDIR}"
455 python base_do_unpack() {
456         import re, os
457
458         localdata = bb.data.createCopy(d)
459         bb.data.update_data(localdata)
460
461         src_uri = bb.data.getVar('SRC_URI', localdata)
462         if not src_uri:
463                 return
464         src_uri = bb.data.expand(src_uri, localdata)
465         for url in src_uri.split():
466                 try:
467                         local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
468                 except bb.MalformedUrl, e:
469                         raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
470                 # dont need any parameters for extraction, strip them off
471                 local = re.sub(';.*$', '', local)
472                 local = os.path.realpath(local)
473                 ret = oe_unpack_file(local, localdata, url)
474                 if not ret:
475                         raise bb.build.FuncFailed()
476 }
477
478
479 addhandler base_eventhandler
480 python base_eventhandler() {
481         from bb import note, error, data
482         from bb.event import Handled, NotHandled, getName
483         import os
484
485         messages = {}
486         messages["Completed"] = "completed"
487         messages["Succeeded"] = "completed"
488         messages["Started"] = "started"
489         messages["Failed"] = "failed"
490
491         name = getName(e)
492         msg = ""
493         if name.startswith("Pkg"):
494                 msg += "package %s: " % data.getVar("P", e.data, 1)
495                 msg += messages.get(name[3:]) or name[3:]
496         elif name.startswith("Task"):
497                 msg += "package %s: task %s: " % (data.getVar("PF", e.data, 1), e.task)
498                 msg += messages.get(name[4:]) or name[4:]
499         elif name.startswith("Build"):
500                 msg += "build %s: " % e.name
501                 msg += messages.get(name[5:]) or name[5:]
502         elif name == "UnsatisfiedDep":
503                 msg += "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower())
504         if msg:
505                 note(msg)
506
507         if name.startswith("BuildStarted"):
508                 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
509                 path_to_bbfiles = bb.data.getVar( 'BBFILES', e.data, 1 )
510                 path_to_packages = path_to_bbfiles[:path_to_bbfiles.rindex( "packages" )]
511                 monotone_revision = "<unknown>"
512                 try:
513                         monotone_revision = file( "%s/_MTN/revision" % path_to_packages ).read().strip()
514                         if monotone_revision.startswith( "format_version" ):
515                                 monotone_revision_words = monotone_revision.split()
516                                 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
517                 except IOError:
518                         pass
519                 bb.data.setVar( 'OE_REVISION', monotone_revision, e.data )
520                 statusvars = ['BB_VERSION', 'OE_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
521                 statuslines = ["%-14s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
522                 statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
523                 print statusmsg
524
525                 needed_vars = [ "TARGET_ARCH", "TARGET_OS" ]
526                 pesteruser = []
527                 for v in needed_vars:
528                         val = bb.data.getVar(v, e.data, 1)
529                         if not val or val == 'INVALID':
530                                 pesteruser.append(v)
531                 if pesteruser:
532                         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))
533
534         if not data in e.__dict__:
535                 return NotHandled
536
537         log = data.getVar("EVENTLOG", e.data, 1)
538         if log:
539                 logfile = file(log, "a")
540                 logfile.write("%s\n" % msg)
541                 logfile.close()
542
543         return NotHandled
544 }
545
546 addtask configure after do_unpack do_patch
547 do_configure[dirs] = "${S} ${B}"
548 do_configure[bbdepcmd] = "do_populate_staging"
549 do_configure[deptask] = "do_populate_staging"
550 base_do_configure() {
551         :
552 }
553
554 addtask compile after do_configure
555 do_compile[dirs] = "${S} ${B}"
556 do_compile[bbdepcmd] = "do_populate_staging"
557 base_do_compile() {
558         if [ -e Makefile -o -e makefile ]; then
559                 oe_runmake || die "make failed"
560         else
561                 oenote "nothing to compile"
562         fi
563 }
564
565 base_do_stage () {
566         :
567 }
568
569 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
570                              ${STAGING_DIR}/${TARGET_SYS}/include \
571                              ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
572                              ${STAGING_DIR}/${BUILD_SYS}/include \
573                              ${STAGING_DATADIR} \
574                              ${S} ${B}"
575
576 addtask populate_staging after do_package_write
577
578 python do_populate_staging () {
579         bb.build.exec_func('do_stage', d)
580 }
581
582 addtask install after do_compile
583 do_install[dirs] = "${D} ${S} ${B}"
584
585 base_do_install() {
586         :
587 }
588
589 base_do_package() {
590         :
591 }
592
593 addtask build after do_populate_staging
594 do_build = ""
595 do_build[func] = "1"
596
597 # Functions that update metadata based on files outputted
598 # during the build process.
599
600 def explode_deps(s):
601         r = []
602         l = s.split()
603         flag = False
604         for i in l:
605                 if i[0] == '(':
606                         flag = True
607                         j = []
608                 if flag:
609                         j.append(i)
610                         if i.endswith(')'):
611                                 flag = False
612                                 r[-1] += ' ' + ' '.join(j)
613                 else:
614                         r.append(i)
615         return r
616
617 def packaged(pkg, d):
618         import os, bb
619         return os.access(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), os.R_OK)
620
621 def read_pkgdatafile(fn):
622         pkgdata = {}
623
624         def decode(str):
625                 import codecs
626                 c = codecs.getdecoder("string_escape")
627                 return c(str)[0]
628
629         import os
630         if os.access(fn, os.R_OK):
631                 import re
632                 f = file(fn, 'r')
633                 lines = f.readlines()
634                 f.close()
635                 r = re.compile("([^:]+):\s*(.*)")
636                 for l in lines:
637                         m = r.match(l)
638                         if m:
639                                 pkgdata[m.group(1)] = decode(m.group(2))
640
641         return pkgdata
642
643 def has_subpkgdata(pkg, d):
644         import bb, os
645         fn = bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s' % pkg, d)
646         return os.access(fn, os.R_OK)
647
648 def read_subpkgdata(pkg, d):
649         import bb, os
650         fn = bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s' % pkg, d)
651         return read_pkgdatafile(fn)
652
653
654 def has_pkgdata(pn, d):
655         import bb, os
656         fn = bb.data.expand('${STAGING_DIR}/pkgdata/%s' % pn, d)
657         return os.access(fn, os.R_OK)
658
659 def read_pkgdata(pn, d):
660         import bb, os
661         fn = bb.data.expand('${STAGING_DIR}/pkgdata/%s' % pn, d)
662         return read_pkgdatafile(fn)
663
664 python read_subpackage_metadata () {
665         import bb
666         data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
667
668         for key in data.keys():
669                 bb.data.setVar(key, data[key], d)
670
671         for pkg in bb.data.getVar('PACKAGES', d, 1).split():
672                 sdata = read_subpkgdata(pkg, d)
673                 for key in sdata.keys():
674                         bb.data.setVar(key, sdata[key], d)
675 }
676
677 def base_after_parse_two(d):
678     import bb
679     import exceptions
680     source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
681     if not source_mirror_fetch:
682         need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
683         if need_host:
684             import re
685             this_host = bb.data.getVar('HOST_SYS', d, 1)
686             if not re.match(need_host, this_host):
687                 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
688
689         need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
690         if need_machine:
691             import re
692             this_machine = bb.data.getVar('MACHINE', d, 1)
693             if this_machine and not re.match(need_machine, this_machine):
694                 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
695
696     pn = bb.data.getVar('PN', d, 1)
697
698     # OBSOLETE in bitbake 1.7.4
699     srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
700     if srcdate != None:
701         bb.data.setVar('SRCDATE', srcdate, d)
702
703     use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
704     if use_nls != None:
705         bb.data.setVar('USE_NLS', use_nls, d)
706
707 def base_after_parse(d):
708     import bb, os
709     mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
710     old_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
711     if (old_arch == mach_arch):
712         # Nothing to do
713         return
714     if (bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1) == '0'):
715         return
716     paths = []
717     for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
718         paths.append(bb.data.expand(os.path.join(p, mach_arch), d))
719     for s in bb.data.getVar('SRC_URI', d, 1).split():
720         local = bb.data.expand(bb.fetch.localpath(s, d), d)
721         for mp in paths:
722             if local.startswith(mp):
723                 #bb.note("overriding PACKAGE_ARCH from %s to %s" % (old_arch, mach_arch))
724                 bb.data.setVar('PACKAGE_ARCH', mach_arch, d)
725                 return
726
727
728 python () {
729     base_after_parse_two(d)
730     base_after_parse(d)
731 }
732
733
734 # Patch handling
735 inherit patch
736
737 # Configuration data from site files
738 # Move to autotools.bbclass?
739 inherit siteinfo
740
741 EXPORT_FUNCTIONS do_clean do_mrproper do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_stage do_rebuild do_fetchall
742
743 MIRRORS[func] = "0"
744 MIRRORS () {
745 ${DEBIAN_MIRROR}/main   http://snapshot.debian.net/archive/pool
746 ${DEBIAN_MIRROR}        ftp://ftp.de.debian.org/debian/pool
747 ${DEBIAN_MIRROR}        ftp://ftp.au.debian.org/debian/pool
748 ${DEBIAN_MIRROR}        ftp://ftp.cl.debian.org/debian/pool
749 ${DEBIAN_MIRROR}        ftp://ftp.hr.debian.org/debian/pool
750 ${DEBIAN_MIRROR}        ftp://ftp.fi.debian.org/debian/pool
751 ${DEBIAN_MIRROR}        ftp://ftp.hk.debian.org/debian/pool
752 ${DEBIAN_MIRROR}        ftp://ftp.hu.debian.org/debian/pool
753 ${DEBIAN_MIRROR}        ftp://ftp.ie.debian.org/debian/pool
754 ${DEBIAN_MIRROR}        ftp://ftp.it.debian.org/debian/pool
755 ${DEBIAN_MIRROR}        ftp://ftp.jp.debian.org/debian/pool
756 ${DEBIAN_MIRROR}        ftp://ftp.no.debian.org/debian/pool
757 ${DEBIAN_MIRROR}        ftp://ftp.pl.debian.org/debian/pool
758 ${DEBIAN_MIRROR}        ftp://ftp.ro.debian.org/debian/pool
759 ${DEBIAN_MIRROR}        ftp://ftp.si.debian.org/debian/pool
760 ${DEBIAN_MIRROR}        ftp://ftp.es.debian.org/debian/pool
761 ${DEBIAN_MIRROR}        ftp://ftp.se.debian.org/debian/pool
762 ${DEBIAN_MIRROR}        ftp://ftp.tr.debian.org/debian/pool
763 ${GNU_MIRROR}   ftp://mirrors.kernel.org/gnu
764 ${GNU_MIRROR}   ftp://ftp.matrix.com.br/pub/gnu
765 ${GNU_MIRROR}   ftp://ftp.cs.ubc.ca/mirror2/gnu
766 ${GNU_MIRROR}   ftp://sunsite.ust.hk/pub/gnu
767 ${GNU_MIRROR}   ftp://ftp.ayamura.org/pub/gnu
768 ftp://ftp.kernel.org/pub        http://www.kernel.org/pub
769 ftp://ftp.kernel.org/pub        ftp://ftp.us.kernel.org/pub
770 ftp://ftp.kernel.org/pub        ftp://ftp.uk.kernel.org/pub
771 ftp://ftp.kernel.org/pub        ftp://ftp.hk.kernel.org/pub
772 ftp://ftp.kernel.org/pub        ftp://ftp.au.kernel.org/pub
773 ftp://ftp.kernel.org/pub        ftp://ftp.jp.kernel.org/pub
774 ftp://ftp.gnupg.org/gcrypt/     ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
775 ftp://ftp.gnupg.org/gcrypt/     ftp://ftp.surfnet.nl/pub/security/gnupg/
776 ftp://ftp.gnupg.org/gcrypt/     http://gulus.USherbrooke.ca/pub/appl/GnuPG/
777 ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
778 ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
779 ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
780 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
781 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
782 ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
783 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
784 ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
785 http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
786 http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
787 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
788 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tau.ac.il/pub/unix/admin/
789 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
790 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
791 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.kaizo.org/pub/lsof/
792 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
793 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
794 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
795 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
796 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://the.wiretapped.net/pub/security/host-security/lsof/
797
798 }
799