e94e331fb4d589f7b69693a06aa56971ed230f01
[vuplus_openembedded] / classes / base.bbclass
1 PATCHES_DIR="${S}"
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         if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
12                 deps += "patcher-native"
13                 if (bb.data.getVar('HOST_SYS', d, 1) !=
14                     bb.data.getVar('BUILD_SYS', d, 1)):
15                         deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
16         return deps
17
18 def base_read_file(filename):
19         import bb
20         try:
21                 f = file( filename, "r" )
22         except IOError, reason:
23                 raise bb.build.FuncFailed("can't read from file '%s' (%s)", (filename,reason))
24         else:
25                 return f.read().strip()
26         return None
27
28 DEPENDS_prepend="${@base_dep_prepend(d)} "
29
30 def base_set_filespath(path, d):
31         import os, bb
32         filespath = []
33         for p in path:
34                 overrides = bb.data.getVar("OVERRIDES", d, 1) or ""
35                 overrides = overrides + ":"
36                 for o in overrides.split(":"):
37                         filespath.append(os.path.join(p, o))
38         bb.data.setVar("FILESPATH", ":".join(filespath), d)
39
40 FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}"
41
42 def oe_filter(f, str, d):
43         from re import match
44         return " ".join(filter(lambda x: match(f, x, 0), str.split()))
45
46 def oe_filter_out(f, str, d):
47         from re import match
48         return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
49
50 die() {
51         oefatal "$*"
52 }
53
54 oenote() {
55         echo "NOTE:" "$*"
56 }
57
58 oewarn() {
59         echo "WARNING:" "$*"
60 }
61
62 oefatal() {
63         echo "FATAL:" "$*"
64         exit 1
65 }
66
67 oedebug() {
68         test $# -ge 2 || {
69                 echo "Usage: oedebug level \"message\""
70                 exit 1
71         }
72
73         test ${OEDEBUG:-0} -ge $1 && {
74                 shift
75                 echo "DEBUG:" $*
76         }
77 }
78
79 oe_runmake() {
80         if [ x"$MAKE" = x ]; then MAKE=make; fi
81         oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
82         ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
83 }
84
85 oe_soinstall() {
86         # Purpose: Install shared library file and
87         #          create the necessary links
88         # Example:
89         #
90         # oe_
91         #
92         #oenote installing shared library $1 to $2
93         #
94         libname=`basename $1`
95         install -m 755 $1 $2/$libname
96         sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
97         solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
98         ln -sf $libname $2/$sonamelink
99         ln -sf $libname $2/$solink
100 }
101
102 oe_libinstall() {
103         # Purpose: Install a library, in all its forms
104         # Example
105         #
106         # oe_libinstall libltdl ${STAGING_LIBDIR}/
107         # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
108         dir=""
109         libtool=""
110         silent=""
111         require_static=""
112         require_shared=""
113         while [ "$#" -gt 0 ]; do
114                 case "$1" in
115                 -C)
116                         shift
117                         dir="$1"
118                         ;;
119                 -s)
120                         silent=1
121                         ;;
122                 -a)
123                         require_static=1
124                         ;;
125                 -so)
126                         require_shared=1
127                         ;;
128                 -*)
129                         oefatal "oe_libinstall: unknown option: $1"
130                         ;;
131                 *)
132                         break;
133                         ;;
134                 esac
135                 shift
136         done
137
138         libname="$1"
139         shift
140         destpath="$1"
141         if [ -z "$destpath" ]; then
142                 oefatal "oe_libinstall: no destination path specified"
143         fi
144
145         __runcmd () {
146                 if [ -z "$silent" ]; then
147                         echo >&2 "oe_libinstall: $*"
148                 fi
149                 $*
150         }
151
152         if [ -z "$dir" ]; then
153                 dir=`pwd`
154         fi
155         if [ -d "$dir/.libs" ]; then
156                 dir=$dir/.libs
157         fi
158         olddir=`pwd`
159         __runcmd cd $dir
160
161         lafile=$libname.la
162         if [ -f "$lafile" ]; then
163                 # libtool archive
164                 eval `cat $lafile|grep "^library_names="`
165                 libtool=1
166         else
167                 library_names="$libname.so* $libname.dll.a"
168         fi
169
170         __runcmd install -d $destpath/
171         dota=$libname.a
172         if [ -f "$dota" -o -n "$require_static" ]; then
173                 __runcmd install -m 0644 $dota $destpath/
174         fi
175         dotlai=$libname.lai
176         if [ -f "$dotlai" -o -n "$libtool" ]; then
177                 __runcmd install -m 0644 $dotlai $destpath/$libname.la
178         fi
179
180         for name in $library_names; do
181                 files=`eval echo $name`
182                 for f in $files; do
183                         if [ ! -e "$f" ]; then
184                                 if [ -n "$libtool" ]; then
185                                         oefatal "oe_libinstall: $dir/$f not found."
186                                 fi
187                         elif [ -L "$f" ]; then
188                                 __runcmd cp -P "$f" $destpath/
189                         elif [ ! -L "$f" ]; then
190                                 libfile="$f"
191                                 __runcmd install -m 0755 $libfile $destpath/
192                         fi
193                 done
194         done
195
196         if [ -z "$libfile" ]; then
197                 if  [ -n "$require_shared" ]; then
198                         oefatal "oe_libinstall: unable to locate shared library"
199                 fi
200         elif [ -z "$libtool" ]; then
201                 # special case hack for non-libtool .so.#.#.# links
202                 baselibfile=`basename "$libfile"`
203                 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
204                         sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
205                         solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
206                         if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
207                                 __runcmd ln -sf $baselibfile $destpath/$sonamelink
208                         fi
209                         __runcmd ln -sf $baselibfile $destpath/$solink
210                 fi
211         fi
212
213         __runcmd cd "$olddir"
214 }
215
216 oe_machinstall() {
217         # Purpose: Install machine dependent files, if available
218         #          If not available, check if there is a default
219         #          If no default, just touch the destination
220         # Example:
221         #                $1  $2   $3         $4
222         # oe_machinstall -m 0644 fstab ${D}/etc/fstab
223         #
224         # TODO: Check argument number?
225         #
226         filename=`basename $3`
227         dirname=`dirname $3`
228
229         for o in `echo ${OVERRIDES} | tr ':' ' '`; do
230                 if [ -e $dirname/$o/$filename ]; then
231                         oenote $dirname/$o/$filename present, installing to $4
232                         install $1 $2 $dirname/$o/$filename $4
233                         return
234                 fi
235         done
236 #       oenote overrides specific file NOT present, trying default=$3...
237         if [ -e $3 ]; then
238                 oenote $3 present, installing to $4
239                 install $1 $2 $3 $4
240         else
241                 oenote $3 NOT present, touching empty $4
242                 touch $4
243         fi
244 }
245
246 addtask showdata
247 do_showdata[nostamp] = "1"
248 python do_showdata() {
249         import sys
250         # emit variables and shell functions
251         bb.data.emit_env(sys.__stdout__, d, True)
252         # emit the metadata which isnt valid shell
253         for e in d.keys():
254             if bb.data.getVarFlag(e, 'python', d):
255                 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
256 }
257
258 addtask listtasks
259 do_listtasks[nostamp] = "1"
260 python do_listtasks() {
261         import sys
262         # emit variables and shell functions
263         #bb.data.emit_env(sys.__stdout__, d)
264         # emit the metadata which isnt valid shell
265         for e in d.keys():
266                 if bb.data.getVarFlag(e, 'task', d):
267                         sys.__stdout__.write("%s\n" % e)
268 }
269
270 addtask clean
271 do_clean[dirs] = "${TOPDIR}"
272 do_clean[nostamp] = "1"
273 do_clean[bbdepcmd] = ""
274 python base_do_clean() {
275         """clear the build and temp directories"""
276         dir = bb.data.expand("${WORKDIR}", d)
277         if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
278         bb.note("removing " + dir)
279         os.system('rm -rf ' + dir)
280
281         dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
282         bb.note("removing " + dir)
283         os.system('rm -f '+ dir)
284 }
285
286 addtask mrproper
287 do_mrproper[dirs] = "${TOPDIR}"
288 do_mrproper[nostamp] = "1"
289 do_mrproper[bbdepcmd] = ""
290 python base_do_mrproper() {
291         """clear downloaded sources, build and temp directories"""
292         dir = bb.data.expand("${DL_DIR}", d)
293         if dir == '/': bb.build.FuncFailed("wrong DATADIR")
294         bb.debug(2, "removing " + dir)
295         os.system('rm -rf ' + dir)
296         bb.build.exec_task('do_clean', d)
297 }
298
299 addtask fetch
300 do_fetch[dirs] = "${DL_DIR}"
301 do_fetch[nostamp] = "1"
302 python base_do_fetch() {
303         import sys, copy
304
305         localdata = copy.deepcopy(d)
306         bb.data.update_data(localdata)
307
308         src_uri = bb.data.getVar('SRC_URI', localdata, 1)
309         if not src_uri:
310                 return 1
311
312         try:
313                 bb.fetch.init(src_uri.split())
314         except bb.fetch.NoMethodError:
315                 (type, value, traceback) = sys.exc_info()
316                 raise bb.build.FuncFailed("No method: %s" % value)
317
318         try:
319                 bb.fetch.go(localdata)
320         except bb.fetch.MissingParameterError:
321                 (type, value, traceback) = sys.exc_info()
322                 raise bb.build.FuncFailed("Missing parameters: %s" % value)
323         except bb.fetch.FetchError:
324                 (type, value, traceback) = sys.exc_info()
325                 raise bb.build.FuncFailed("Fetch failed: %s" % value)
326 }
327
328 def oe_unpack_file(file, data, url = None):
329         import bb, os
330         if not url:
331                 url = "file://%s" % file
332         dots = file.split(".")
333         if dots[-1] in ['gz', 'bz2', 'Z']:
334                 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
335         else:
336                 efile = file
337         cmd = None
338         if file.endswith('.tar'):
339                 cmd = 'tar x --no-same-owner -f %s' % file
340         elif file.endswith('.tgz') or file.endswith('.tar.gz'):
341                 cmd = 'tar xz --no-same-owner -f %s' % file
342         elif file.endswith('.tbz') or file.endswith('.tar.bz2'):
343                 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
344         elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
345                 cmd = 'gzip -dc %s > %s' % (file, efile)
346         elif file.endswith('.bz2'):
347                 cmd = 'bzip2 -dc %s > %s' % (file, efile)
348         elif file.endswith('.zip'):
349                 cmd = 'unzip -q %s' % file
350         elif os.path.isdir(file):
351                 filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, 1))
352                 destdir = "."
353                 if file[0:len(filesdir)] == filesdir:
354                         destdir = file[len(filesdir):file.rfind('/')]
355                         destdir = destdir.strip('/')
356                         if len(destdir) < 1:
357                                 destdir = "."
358                         elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
359                                 os.makedirs("%s/%s" % (os.getcwd(), destdir))
360                 cmd = 'cp -a %s %s/%s/' % (file, os.getcwd(), destdir)
361         else:
362                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
363                 if not 'patch' in parm:
364                         destdir = bb.decodeurl(url)[1] or "."
365                         bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
366                         cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
367         if not cmd:
368                 return True
369         cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
370         bb.note("Unpacking %s to %s/" % (file, os.getcwd()))
371         ret = os.system(cmd)
372         return ret == 0
373
374 addtask unpack after do_fetch
375 do_unpack[dirs] = "${WORKDIR}"
376 python base_do_unpack() {
377         import re, copy, os
378
379         localdata = copy.deepcopy(d)
380         bb.data.update_data(localdata)
381
382         src_uri = bb.data.getVar('SRC_URI', localdata)
383         if not src_uri:
384                 return
385         src_uri = bb.data.expand(src_uri, localdata)
386         for url in src_uri.split():
387                 try:
388                         local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
389                 except bb.MalformedUrl, e:
390                         raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
391                 # dont need any parameters for extraction, strip them off
392                 local = re.sub(';.*$', '', local)
393                 local = os.path.realpath(local)
394                 ret = oe_unpack_file(local, localdata, url)
395                 if not ret:
396                         raise bb.build.FuncFailed()
397 }
398
399 addtask patch after do_unpack
400 do_patch[dirs] = "${WORKDIR}"
401 python base_do_patch() {
402         import re
403
404         src_uri = bb.data.getVar('SRC_URI', d)
405         if not src_uri:
406                 return
407         src_uri = bb.data.expand(src_uri, d)
408         for url in src_uri.split():
409 #               bb.note('url is %s' % url)
410                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
411                 if not "patch" in parm:
412                         continue
413                 from bb.fetch import init, localpath
414                 init([url])
415                 url = bb.encodeurl((type, host, path, user, pswd, []))
416                 local = '/' + localpath(url, d)
417                 # patch!
418                 dots = local.split(".")
419                 if dots[-1] in ['gz', 'bz2', 'Z']:
420                         efile = os.path.join(bb.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
421                 else:
422                         efile = local
423                 efile = bb.data.expand(efile, d)
424                 patches_dir = bb.data.expand(bb.data.getVar('PATCHES_DIR', d), d)
425                 bb.mkdirhier(patches_dir + "/.patches")
426                 os.chdir(patches_dir)
427                 cmd = "PATH=\"%s\" patcher" % bb.data.getVar("PATH", d, 1)
428                 if "pnum" in parm:
429                         cmd += " -p %s" % parm["pnum"]
430                 # Getting rid of // at the front helps the Cygwin-Users of OE
431                 if efile.startswith('//'):
432                         efile = efile[1:]
433                 cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
434                 ret = os.system(cmd)
435                 if ret != 0:
436                         raise bb.build.FuncFailed("'patcher' execution failed")
437 }
438
439
440 addhandler base_eventhandler
441 python base_eventhandler() {
442         from bb import note, error, data
443         from bb.event import Handled, NotHandled, getName
444         import os
445
446         name = getName(e)
447         if name in ["PkgSucceeded"]:
448                 note("package %s: build completed" % e.pkg)
449         if name in ["PkgStarted"]:
450                 note("package %s: build %s" % (e.pkg, name[3:].lower()))
451         elif name in ["PkgFailed"]:
452                 error("package %s: build %s" % (e.pkg, name[3:].lower()))
453         elif name in ["TaskStarted"]:
454                 note("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
455         elif name in ["TaskSucceeded"]:
456                 note("package %s: task %s completed" % (data.expand(data.getVar("PF", e.data), e.data), e.task))
457         elif name in ["TaskFailed"]:
458                 error("package %s: task %s %s" % (data.expand(data.getVar("PF", e.data), e.data), e.task, name[4:].lower()))
459         elif name in ["UnsatisfiedDep"]:
460                 note("package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()))
461         elif name in ["BuildStarted", "BuildCompleted"]:
462                 note("build %s %s" % (e.name, name[5:].lower()))
463         return NotHandled
464 }
465
466 addtask configure after do_unpack do_patch
467 do_configure[dirs] = "${S} ${B}"
468 do_configure[bbdepcmd] = "do_populate_staging"
469 base_do_configure() {
470         :
471 }
472
473 addtask compile after do_configure
474 do_compile[dirs] = "${S} ${B}"
475 do_compile[bbdepcmd] = "do_populate_staging"
476 base_do_compile() {
477         if [ -e Makefile -o -e makefile ]; then
478                 oe_runmake || die "make failed"
479         else
480                 oenote "nothing to compile"
481         fi
482 }
483
484
485 addtask stage after do_compile
486 base_do_stage () {
487         :
488 }
489
490 do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${TARGET_SYS}/lib \
491                              ${STAGING_DIR}/${TARGET_SYS}/include \
492                              ${STAGING_DIR}/${BUILD_SYS}/bin ${STAGING_DIR}/${BUILD_SYS}/lib \
493                              ${STAGING_DIR}/${BUILD_SYS}/include \
494                              ${STAGING_DATADIR} \
495                              ${S} ${B}"
496
497 addtask populate_staging after do_compile
498
499 #python do_populate_staging () {
500 #       if not bb.data.getVar('manifest', d):
501 #               bb.build.exec_func('do_emit_manifest', d)
502 #       if bb.data.getVar('do_stage', d):
503 #               bb.build.exec_func('do_stage', d)
504 #       else:
505 #               bb.build.exec_func('manifest_do_populate_staging', d)
506 #}
507
508 python do_populate_staging () {
509         if bb.data.getVar('manifest_do_populate_staging', d):
510                 bb.build.exec_func('manifest_do_populate_staging', d)
511         else:
512                 bb.build.exec_func('do_stage', d)
513 }
514
515 #addtask install
516 addtask install after do_compile
517 do_install[dirs] = "${S} ${B}"
518
519 base_do_install() {
520         :
521 }
522
523 #addtask populate_pkgs after do_compile
524 #python do_populate_pkgs () {
525 #       if not bb.data.getVar('manifest', d):
526 #               bb.build.exec_func('do_emit_manifest', d)
527 #       bb.build.exec_func('manifest_do_populate_pkgs', d)
528 #       bb.build.exec_func('package_do_shlibs', d)
529 #}
530
531 base_do_package() {
532         :
533 }
534
535 addtask build after do_populate_staging
536 do_build = ""
537 do_build[nostamp] = "1"
538 do_build[func] = "1"
539
540 # Functions that update metadata based on files outputted
541 # during the build process.
542
543 SHLIBS = ""
544 RDEPENDS_prepend = " ${SHLIBS}"
545
546 python read_manifest () {
547         import sys
548         mfn = bb.data.getVar("MANIFEST", d, 1)
549         if os.access(mfn, os.R_OK):
550                 # we have a manifest, so emit do_stage and do_populate_pkgs,
551                 # and stuff some additional bits of data into the metadata store
552                 mfile = file(mfn, "r")
553                 manifest = bb.manifest.parse(mfile, d)
554                 if not manifest:
555                         return
556
557                 bb.data.setVar('manifest', manifest, d)
558 }
559
560 python parse_manifest () {
561                 manifest = bb.data.getVar("manifest", d)
562                 if not manifest:
563                         return
564                 for func in ("do_populate_staging", "do_populate_pkgs"):
565                         value = bb.manifest.emit(func, manifest, d)
566                         if value:
567                                 bb.data.setVar("manifest_" + func, value, d)
568                                 bb.data.delVarFlag("manifest_" + func, "python", d)
569                                 bb.data.delVarFlag("manifest_" + func, "fakeroot", d)
570                                 bb.data.setVarFlag("manifest_" + func, "func", 1, d)
571                 packages = []
572                 for l in manifest:
573                         if "pkg" in l and l["pkg"] is not None:
574                                 packages.append(l["pkg"])
575                 bb.data.setVar("PACKAGES", " ".join(packages), d)
576 }
577
578 def explode_deps(s):
579         r = []
580         l = s.split()
581         flag = False
582         for i in l:
583                 if i[0] == '(':
584                         flag = True
585                         j = []
586                 if flag:
587                         j.append(i)
588                         if i.endswith(')'):
589                                 flag = False
590                                 r[-1] += ' ' + ' '.join(j)
591                 else:
592                         r.append(i)
593         return r
594
595 python read_shlibdeps () {
596         packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
597         for pkg in packages:
598                 rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
599                 shlibsfile = bb.data.expand("${WORKDIR}/install/" + pkg + ".shlibdeps", d)
600                 if os.access(shlibsfile, os.R_OK):
601                         fd = file(shlibsfile)
602                         lines = fd.readlines()
603                         fd.close()
604                         for l in lines:
605                                 rdepends.append(l.rstrip())
606                 pcfile = bb.data.expand("${WORKDIR}/install/" + pkg + ".pcdeps", d)
607                 if os.access(pcfile, os.R_OK):
608                         fd = file(pcfile)
609                         lines = fd.readlines()
610                         fd.close()
611                         for l in lines:
612                                 rdepends.append(l.rstrip())
613                 bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
614 }
615
616 python read_subpackage_metadata () {
617         import re
618
619         def decode(str):
620                 import codecs
621                 c = codecs.getdecoder("string_escape")
622                 return c(str)[0]
623
624         data_file = bb.data.expand("${WORKDIR}/install/${PN}.package", d)
625         if os.access(data_file, os.R_OK):
626                 f = file(data_file, 'r')
627                 lines = f.readlines()
628                 f.close()
629                 r = re.compile("([^:]+):\s*(.*)")
630                 for l in lines:
631                         m = r.match(l)
632                         if m:
633                                 bb.data.setVar(m.group(1), decode(m.group(2)), d)
634 }
635
636 python __anonymous () {
637         import exceptions
638         need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
639         if need_host:
640                 import re
641                 this_host = bb.data.getVar('HOST_SYS', d, 1)
642                 if not re.match(need_host, this_host):
643                         raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
644         
645         pn = bb.data.getVar('PN', d, 1)
646         cvsdate = bb.data.getVar('CVSDATE_%s' % pn, d, 1)
647         if cvsdate != None:
648                 bb.data.setVar('CVSDATE', cvsdate, d)
649
650         try:
651                 bb.build.exec_func('read_manifest', d)
652                 bb.build.exec_func('parse_manifest', d)
653                 bb.build.exec_func('read_shlibdeps', d)
654                 bb.build.exec_func('read_subpackage_metadata', d)
655         except exceptions.KeyboardInterrupt:
656                 raise
657         except Exception, e:
658                 bb.error("anonymous function: %s" % e)
659                 pass
660 }
661
662 python () {
663         import bb, os
664         mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
665         old_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
666         if (old_arch == mach_arch):
667                 # Nothing to do
668                 return
669         paths = []
670         for p in [ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ]:
671                 paths.append(bb.data.expand(os.path.join(p, mach_arch), d))
672         for s in bb.data.getVar('SRC_URI', d, 1).split():
673                 local = bb.data.expand(bb.fetch.localpath(s, d), d)
674                 for mp in paths:
675                         if local.startswith(mp):
676 #                               bb.note("overriding PACKAGE_ARCH from %s to %s" % (old_arch, mach_arch))
677                                 bb.data.setVar('PACKAGE_ARCH', mach_arch, d)
678                                 return
679 }
680
681
682 addtask emit_manifest
683 python do_emit_manifest () {
684 #       FIXME: emit a manifest here
685 #       1) adjust PATH to hit the wrapper scripts
686         wrappers = bb.which(bb.data.getVar("BBPATH", d, 1), 'build/install', 0)
687         path = (bb.data.getVar('PATH', d, 1) or '').split(':')
688         path.insert(0, os.path.dirname(wrappers))
689         bb.data.setVar('PATH', ':'.join(path), d)
690 #       2) exec_func("do_install", d)
691         bb.build.exec_func('do_install', d)
692 #       3) read in data collected by the wrappers
693         bb.build.exec_func('read_manifest', d)
694 #       4) mangle the manifest we just generated, get paths back into
695 #          our variable form
696 #       5) write it back out
697 #       6) re-parse it to ensure the generated functions are proper
698         bb.build.exec_func('parse_manifest', d)
699 }
700
701 EXPORT_FUNCTIONS do_clean do_mrproper do_fetch do_unpack do_configure do_compile do_install do_package do_patch do_populate_pkgs do_stage
702
703 MIRRORS[func] = "0"
704 MIRRORS () {
705 ${DEBIAN_MIRROR}/main   http://snapshot.debian.net/archive/pool
706 ${DEBIAN_MIRROR}        ftp://ftp.de.debian.org/debian/pool
707 ${DEBIAN_MIRROR}        ftp://ftp.au.debian.org/debian/pool
708 ${DEBIAN_MIRROR}        ftp://ftp.cl.debian.org/debian/pool
709 ${DEBIAN_MIRROR}        ftp://ftp.hr.debian.org/debian/pool
710 ${DEBIAN_MIRROR}        ftp://ftp.fi.debian.org/debian/pool
711 ${DEBIAN_MIRROR}        ftp://ftp.hk.debian.org/debian/pool
712 ${DEBIAN_MIRROR}        ftp://ftp.hu.debian.org/debian/pool
713 ${DEBIAN_MIRROR}        ftp://ftp.ie.debian.org/debian/pool
714 ${DEBIAN_MIRROR}        ftp://ftp.it.debian.org/debian/pool
715 ${DEBIAN_MIRROR}        ftp://ftp.jp.debian.org/debian/pool
716 ${DEBIAN_MIRROR}        ftp://ftp.no.debian.org/debian/pool
717 ${DEBIAN_MIRROR}        ftp://ftp.pl.debian.org/debian/pool
718 ${DEBIAN_MIRROR}        ftp://ftp.ro.debian.org/debian/pool
719 ${DEBIAN_MIRROR}        ftp://ftp.si.debian.org/debian/pool
720 ${DEBIAN_MIRROR}        ftp://ftp.es.debian.org/debian/pool
721 ${DEBIAN_MIRROR}        ftp://ftp.se.debian.org/debian/pool
722 ${DEBIAN_MIRROR}        ftp://ftp.tr.debian.org/debian/pool
723 ${GNU_MIRROR}   ftp://mirrors.kernel.org/gnu
724 ${GNU_MIRROR}   ftp://ftp.matrix.com.br/pub/gnu
725 ${GNU_MIRROR}   ftp://ftp.cs.ubc.ca/mirror2/gnu
726 ${GNU_MIRROR}   ftp://sunsite.ust.hk/pub/gnu
727 ${GNU_MIRROR}   ftp://ftp.ayamura.org/pub/gnu
728 ftp://ftp.kernel.org/pub        http://www.kernel.org/pub
729 ftp://ftp.kernel.org/pub        ftp://ftp.us.kernel.org/pub
730 ftp://ftp.kernel.org/pub        ftp://ftp.uk.kernel.org/pub
731 ftp://ftp.kernel.org/pub        ftp://ftp.hk.kernel.org/pub
732 ftp://ftp.kernel.org/pub        ftp://ftp.au.kernel.org/pub
733 ftp://ftp.kernel.org/pub        ftp://ftp.jp.kernel.org/pub
734 ftp://.*/.*/    http://treke.net/oe/source/
735 http://.*/.*/   http://treke.net/oe/source/
736 }
737