summaryrefslogtreecommitdiffstats
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-03-19 23:12:06 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-19 23:12:06 +0000
commit9c5386c1fd74d832cf6e2acad3c69b1cc90de6b2 (patch)
treeaa2db23da10e883f0f8627f5993cd2cfade2e705 /meta/classes/base.bbclass
parent185cb38f1319856b4bdaaf4d9a73b5056be53d54 (diff)
downloadpoky-9c5386c1fd74d832cf6e2acad3c69b1cc90de6b2.tar.gz
base.bbclass: Split up as per the patch in OE.dev by Chris Larson making code more readable and modularised
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass729
1 files changed, 7 insertions, 722 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 256f89954c..51a514570b 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -1,87 +1,6 @@
1BB_DEFAULT_TASK ?= "build" 1BB_DEFAULT_TASK ?= "build"
2 2
3# like os.path.join but doesn't treat absolute RHS specially 3inherit utils
4def base_path_join(a, *p):
5 path = a
6 for b in p:
7 if path == '' or path.endswith('/'):
8 path += b
9 else:
10 path += '/' + b
11 return path
12
13# for MD5/SHA handling
14def base_chk_load_parser(config_path):
15 import ConfigParser
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)
20
21 return parser
22
23def base_chk_file(parser, pn, pv, src_uri, localpath, data):
24 no_checksum = False
25 # Try PN-PV-SRC_URI first and then try PN-SRC_URI
26 # we rely on the get method to create errors
27 pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
28 pn_src = "%s-%s" % (pn,src_uri)
29 if parser.has_section(pn_pv_src):
30 md5 = parser.get(pn_pv_src, "md5")
31 sha256 = parser.get(pn_pv_src, "sha256")
32 elif parser.has_section(pn_src):
33 md5 = parser.get(pn_src, "md5")
34 sha256 = parser.get(pn_src, "sha256")
35 elif parser.has_section(src_uri):
36 md5 = parser.get(src_uri, "md5")
37 sha256 = parser.get(src_uri, "sha256")
38 else:
39 no_checksum = True
40
41 # md5 and sha256 should be valid now
42 if not os.path.exists(localpath):
43 bb.note("The localpath does not exist '%s'" % localpath)
44 raise Exception("The path does not exist '%s'" % localpath)
45
46
47 # Calculate the MD5 and 256-bit SHA checksums
48 md5data = bb.utils.md5_file(localpath)
49 shadata = bb.utils.sha256_file(localpath)
50
51 # sha256_file() can return None if we are running on Python 2.4 (hashlib is
52 # 2.5 onwards, sha in 2.4 is 160-bit only), so check for this and call the
53 # standalone shasum binary if required.
54 if shadata is None:
55 try:
56 shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
57 shadata = (shapipe.readline().split() or [ "" ])[0]
58 shapipe.close()
59 except OSError:
60 raise Exception("Executing shasum failed, please build shasum-native")
61
62 if no_checksum == True: # we do not have conf/checksums.ini entry
63 try:
64 file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
65 except:
66 return False
67
68 if not file:
69 raise Exception("Creating checksums.ini failed")
70
71 file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
72 file.close()
73 return False
74
75 if not md5 == md5data:
76 bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
77 raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
78
79 if not sha256 == shadata:
80 bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
81 raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
82
83 return True
84
85 4
86def base_dep_prepend(d): 5def base_dep_prepend(d):
87 # 6 #
@@ -112,62 +31,11 @@ def base_dep_prepend(d):
112 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc " 31 deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
113 return deps 32 return deps
114 33
115def base_read_file(filename):
116 try:
117 f = file( filename, "r" )
118 except IOError, reason:
119 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
120 else:
121 return f.read().strip()
122 return None
123
124def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
125 if bb.data.getVar(variable,d,1) == checkvalue:
126 return truevalue
127 else:
128 return falsevalue
129
130def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
131 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
132 return truevalue
133 else:
134 return falsevalue
135
136def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
137 result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
138 if result <= 0:
139 return truevalue
140 else:
141 return falsevalue
142
143def base_contains(variable, checkvalues, truevalue, falsevalue, d):
144 matches = 0
145 if type(checkvalues).__name__ == "str":
146 checkvalues = [checkvalues]
147 for value in checkvalues:
148 if bb.data.getVar(variable,d,1).find(value) != -1:
149 matches = matches + 1
150 if matches == len(checkvalues):
151 return truevalue
152 return falsevalue
153
154def base_both_contain(variable1, variable2, checkvalue, d):
155 if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
156 return checkvalue
157 else:
158 return ""
159 34
160DEPENDS_prepend="${@base_dep_prepend(d)} " 35DEPENDS_prepend="${@base_dep_prepend(d)} "
161DEPENDS_virtclass-native_prepend="${@base_dep_prepend(d)} " 36DEPENDS_virtclass-native_prepend="${@base_dep_prepend(d)} "
162DEPENDS_virtclass-nativesdk_prepend="${@base_dep_prepend(d)} " 37DEPENDS_virtclass-nativesdk_prepend="${@base_dep_prepend(d)} "
163 38
164def base_prune_suffix(var, suffixes, d):
165 # See if var ends with any of the suffixes listed and
166 # remove it if found
167 for suffix in suffixes:
168 if var.endswith(suffix):
169 return var.replace(suffix, "")
170 return var
171 39
172def base_set_filespath(path, d): 40def base_set_filespath(path, d):
173 filespath = [] 41 filespath = []
@@ -180,13 +48,6 @@ def base_set_filespath(path, d):
180 48
181FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}" 49FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}"
182 50
183def oe_filter(f, str, d):
184 from re import match
185 return " ".join(filter(lambda x: match(f, x, 0), str.split()))
186
187def oe_filter_out(f, str, d):
188 from re import match
189 return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
190 51
191die() { 52die() {
192 oefatal "$*" 53 oefatal "$*"
@@ -223,173 +84,6 @@ oe_runmake() {
223 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed" 84 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
224} 85}
225 86
226oe_soinstall() {
227 # Purpose: Install shared library file and
228 # create the necessary links
229 # Example:
230 #
231 # oe_
232 #
233 #oenote installing shared library $1 to $2
234 #
235 libname=`basename $1`
236 install -m 755 $1 $2/$libname
237 sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
238 solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
239 ln -sf $libname $2/$sonamelink
240 ln -sf $libname $2/$solink
241}
242
243oe_libinstall() {
244 # Purpose: Install a library, in all its forms
245 # Example
246 #
247 # oe_libinstall libltdl ${STAGING_LIBDIR}/
248 # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
249 dir=""
250 libtool=""
251 silent=""
252 require_static=""
253 require_shared=""
254 staging_install=""
255 while [ "$#" -gt 0 ]; do
256 case "$1" in
257 -C)
258 shift
259 dir="$1"
260 ;;
261 -s)
262 silent=1
263 ;;
264 -a)
265 require_static=1
266 ;;
267 -so)
268 require_shared=1
269 ;;
270 -*)
271 oefatal "oe_libinstall: unknown option: $1"
272 ;;
273 *)
274 break;
275 ;;
276 esac
277 shift
278 done
279
280 libname="$1"
281 shift
282 destpath="$1"
283 if [ -z "$destpath" ]; then
284 oefatal "oe_libinstall: no destination path specified"
285 fi
286 if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
287 then
288 staging_install=1
289 fi
290
291 __runcmd () {
292 if [ -z "$silent" ]; then
293 echo >&2 "oe_libinstall: $*"
294 fi
295 $*
296 }
297
298 if [ -z "$dir" ]; then
299 dir=`pwd`
300 fi
301
302 dotlai=$libname.lai
303
304 # Sanity check that the libname.lai is unique
305 number_of_files=`(cd $dir; find . -name "$dotlai") | wc -l`
306 if [ $number_of_files -gt 1 ]; then
307 oefatal "oe_libinstall: $dotlai is not unique in $dir"
308 fi
309
310
311 dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
312 olddir=`pwd`
313 __runcmd cd $dir
314
315 lafile=$libname.la
316
317 # If such file doesn't exist, try to cut version suffix
318 if [ ! -f "$lafile" ]; then
319 libname1=`echo "$libname" | sed 's/-[0-9.]*$//'`
320 lafile1=$libname.la
321 if [ -f "$lafile1" ]; then
322 libname=$libname1
323 lafile=$lafile1
324 fi
325 fi
326
327 if [ -f "$lafile" ]; then
328 # libtool archive
329 eval `cat $lafile|grep "^library_names="`
330 libtool=1
331 else
332 library_names="$libname.so* $libname.dll.a"
333 fi
334
335 __runcmd install -d $destpath/
336 dota=$libname.a
337 if [ -f "$dota" -o -n "$require_static" ]; then
338 rm -f $destpath/$dota
339 __runcmd install -m 0644 $dota $destpath/
340 fi
341 if [ -f "$dotlai" -a -n "$libtool" ]; then
342 if test -n "$staging_install"
343 then
344 # stop libtool using the final directory name for libraries
345 # in staging:
346 __runcmd rm -f $destpath/$libname.la
347 __runcmd sed -e 's/^installed=yes$/installed=no/' \
348 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
349 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
350 $dotlai >$destpath/$libname.la
351 else
352 rm -f $destpath/$libname.la
353 __runcmd install -m 0644 $dotlai $destpath/$libname.la
354 fi
355 fi
356
357 for name in $library_names; do
358 files=`eval echo $name`
359 for f in $files; do
360 if [ ! -e "$f" ]; then
361 if [ -n "$libtool" ]; then
362 oefatal "oe_libinstall: $dir/$f not found."
363 fi
364 elif [ -L "$f" ]; then
365 __runcmd cp -P "$f" $destpath/
366 elif [ ! -L "$f" ]; then
367 libfile="$f"
368 rm -f $destpath/$libfile
369 __runcmd install -m 0755 $libfile $destpath/
370 fi
371 done
372 done
373
374 if [ -z "$libfile" ]; then
375 if [ -n "$require_shared" ]; then
376 oefatal "oe_libinstall: unable to locate shared library"
377 fi
378 elif [ -z "$libtool" ]; then
379 # special case hack for non-libtool .so.#.#.# links
380 baselibfile=`basename "$libfile"`
381 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
382 sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
383 solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
384 if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
385 __runcmd ln -sf $baselibfile $destpath/$sonamelink
386 fi
387 __runcmd ln -sf $baselibfile $destpath/$solink
388 fi
389 fi
390
391 __runcmd cd "$olddir"
392}
393 87
394def package_stagefile(file, d): 88def package_stagefile(file, d):
395 89
@@ -409,81 +103,7 @@ package_stagefile_shell() {
409 fi 103 fi
410} 104}
411 105
412oe_machinstall() { 106inherit utility-tasks
413 # Purpose: Install machine dependent files, if available
414 # If not available, check if there is a default
415 # If no default, just touch the destination
416 # Example:
417 # $1 $2 $3 $4
418 # oe_machinstall -m 0644 fstab ${D}/etc/fstab
419 #
420 # TODO: Check argument number?
421 #
422 filename=`basename $3`
423 dirname=`dirname $3`
424
425 for o in `echo ${OVERRIDES} | tr ':' ' '`; do
426 if [ -e $dirname/$o/$filename ]; then
427 oenote $dirname/$o/$filename present, installing to $4
428 install $1 $2 $dirname/$o/$filename $4
429 return
430 fi
431 done
432# oenote overrides specific file NOT present, trying default=$3...
433 if [ -e $3 ]; then
434 oenote $3 present, installing to $4
435 install $1 $2 $3 $4
436 else
437 oenote $3 NOT present, touching empty $4
438 touch $4
439 fi
440}
441
442addtask listtasks
443do_listtasks[nostamp] = "1"
444python do_listtasks() {
445 import sys
446 # emit variables and shell functions
447 #bb.data.emit_env(sys.__stdout__, d)
448 # emit the metadata which isnt valid shell
449 for e in d.keys():
450 if bb.data.getVarFlag(e, 'task', d):
451 sys.__stdout__.write("%s\n" % e)
452}
453
454addtask clean
455do_clean[dirs] = "${TOPDIR}"
456do_clean[nostamp] = "1"
457python base_do_clean() {
458 """clear the build and temp directories"""
459 dir = bb.data.expand("${WORKDIR}", d)
460 if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
461 bb.note("removing " + dir)
462 os.system('rm -rf ' + dir)
463
464 dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
465 bb.note("removing " + dir)
466 os.system('rm -f '+ dir)
467}
468
469addtask rebuild after do_${BB_DEFAULT_TASK}
470do_rebuild[dirs] = "${TOPDIR}"
471do_rebuild[nostamp] = "1"
472python base_do_rebuild() {
473 """rebuild a package"""
474}
475
476#addtask mrproper
477#do_mrproper[dirs] = "${TOPDIR}"
478#do_mrproper[nostamp] = "1"
479#python base_do_mrproper() {
480# """clear downloaded sources, build and temp directories"""
481# dir = bb.data.expand("${DL_DIR}", d)
482# if dir == '/': bb.build.FuncFailed("wrong DATADIR")
483# bb.debug(2, "removing " + dir)
484# os.system('rm -rf ' + dir)
485# bb.build.exec_func('do_clean', d)
486#}
487 107
488SCENEFUNCS += "base_scenefunction" 108SCENEFUNCS += "base_scenefunction"
489 109
@@ -566,57 +186,6 @@ python base_do_fetch() {
566 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri) 186 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
567} 187}
568 188
569addtask fetchall after do_fetch
570do_fetchall[recrdeptask] = "do_fetch"
571base_do_fetchall() {
572 :
573}
574
575addtask checkuri
576do_checkuri[nostamp] = "1"
577python do_checkuri() {
578 import sys
579
580 localdata = bb.data.createCopy(d)
581 bb.data.update_data(localdata)
582
583 src_uri = bb.data.getVar('SRC_URI', localdata, 1)
584
585 try:
586 bb.fetch.init(src_uri.split(),d)
587 except bb.fetch.NoMethodError:
588 (type, value, traceback) = sys.exc_info()
589 raise bb.build.FuncFailed("No method: %s" % value)
590
591 try:
592 bb.fetch.checkstatus(localdata)
593 except bb.fetch.MissingParameterError:
594 (type, value, traceback) = sys.exc_info()
595 raise bb.build.FuncFailed("Missing parameters: %s" % value)
596 except bb.fetch.FetchError:
597 (type, value, traceback) = sys.exc_info()
598 raise bb.build.FuncFailed("Fetch failed: %s" % value)
599 except bb.fetch.MD5SumError:
600 (type, value, traceback) = sys.exc_info()
601 raise bb.build.FuncFailed("MD5 failed: %s" % value)
602 except:
603 (type, value, traceback) = sys.exc_info()
604 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
605}
606
607addtask checkuriall after do_checkuri
608do_checkuriall[recrdeptask] = "do_checkuri"
609do_checkuriall[nostamp] = "1"
610base_do_checkuriall() {
611 :
612}
613
614addtask buildall after do_build
615do_buildall[recrdeptask] = "do_build"
616base_do_buildall() {
617 :
618}
619
620def subprocess_setup(): 189def subprocess_setup():
621 import signal 190 import signal
622 # Python installs a SIGPIPE handler by default. This is usually not what 191 # Python installs a SIGPIPE handler by default. This is usually not what
@@ -720,82 +289,7 @@ python base_do_unpack() {
720 raise bb.build.FuncFailed() 289 raise bb.build.FuncFailed()
721} 290}
722 291
723METADATA_BRANCH ?= "${@base_detect_branch(d)}" 292inherit metadata_scm
724METADATA_REVISION ?= "${@base_detect_revision(d)}"
725
726def base_detect_revision(d):
727 path = base_get_scmbasepath(d)
728
729 scms = [base_get_metadata_git_revision, \
730 base_get_metadata_svn_revision]
731
732 for scm in scms:
733 rev = scm(path, d)
734 if rev <> "<unknown>":
735 return rev
736
737 return "<unknown>"
738
739def base_detect_branch(d):
740 path = base_get_scmbasepath(d)
741
742 scms = [base_get_metadata_git_branch]
743
744 for scm in scms:
745 rev = scm(path, d)
746 if rev <> "<unknown>":
747 return rev.strip()
748
749 return "<unknown>"
750
751
752
753def base_get_scmbasepath(d):
754 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
755 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
756
757def base_get_metadata_monotone_branch(path, d):
758 monotone_branch = "<unknown>"
759 try:
760 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
761 if monotone_branch.startswith( "database" ):
762 monotone_branch_words = monotone_branch.split()
763 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
764 except:
765 pass
766 return monotone_branch
767
768def base_get_metadata_monotone_revision(path, d):
769 monotone_revision = "<unknown>"
770 try:
771 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
772 if monotone_revision.startswith( "format_version" ):
773 monotone_revision_words = monotone_revision.split()
774 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
775 except IOError:
776 pass
777 return monotone_revision
778
779def base_get_metadata_svn_revision(path, d):
780 revision = "<unknown>"
781 try:
782 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
783 except IOError:
784 pass
785 return revision
786
787def base_get_metadata_git_branch(path, d):
788 branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % path).read()
789
790 if len(branch) != 0:
791 return branch
792 return "<unknown>"
793
794def base_get_metadata_git_revision(path, d):
795 rev = os.popen("cd %s; git log -n 1 --pretty=oneline --" % path).read().split(" ")[0]
796 if len(rev) != 0:
797 return rev
798 return "<unknown>"
799 293
800GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" 294GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig"
801 295
@@ -909,145 +403,7 @@ base_do_compile() {
909 fi 403 fi
910} 404}
911 405
912 406inherit staging
913sysroot_stage_dir() {
914 src="$1"
915 dest="$2"
916 # This will remove empty directories so we can ignore them
917 rmdir "$src" 2> /dev/null || true
918 if [ -d "$src" ]; then
919 mkdir -p "$dest"
920 cp -fpPR "$src"/* "$dest"
921 fi
922}
923
924sysroot_stage_libdir() {
925 src="$1"
926 dest="$2"
927
928 olddir=`pwd`
929 cd $src
930 las=$(find . -name \*.la -type f)
931 cd $olddir
932 echo "Found la files: $las"
933 for i in $las
934 do
935 sed -e 's/^installed=yes$/installed=no/' \
936 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
937 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
938 -i $src/$i
939 done
940 sysroot_stage_dir $src $dest
941}
942
943sysroot_stage_dirs() {
944 from="$1"
945 to="$2"
946
947 sysroot_stage_dir $from${includedir} $to${STAGING_INCDIR}
948 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
949 sysroot_stage_dir $from${bindir} $to${STAGING_DIR_HOST}${bindir}
950 sysroot_stage_dir $from${sbindir} $to${STAGING_DIR_HOST}${sbindir}
951 sysroot_stage_dir $from${base_bindir} $to${STAGING_DIR_HOST}${base_bindir}
952 sysroot_stage_dir $from${base_sbindir} $to${STAGING_DIR_HOST}${base_sbindir}
953 sysroot_stage_dir $from${libexecdir} $to${STAGING_DIR_HOST}${libexecdir}
954 sysroot_stage_dir $from${sysconfdir} $to${STAGING_DIR_HOST}${sysconfdir}
955 fi
956 if [ -d $from${libdir} ]
957 then
958 sysroot_stage_libdir $from/${libdir} $to${STAGING_LIBDIR}
959 fi
960 if [ -d $from${base_libdir} ]
961 then
962 sysroot_stage_libdir $from${base_libdir} $to${STAGING_DIR_HOST}${base_libdir}
963 fi
964 sysroot_stage_dir $from${datadir} $to${STAGING_DATADIR}
965}
966
967sysroot_stage_all() {
968 sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR}
969}
970
971def is_legacy_staging(d):
972 stagefunc = bb.data.getVar('do_stage', d, True)
973 legacy = True
974 if stagefunc is None:
975 legacy = False
976 elif stagefunc.strip() == "use_do_install_for_stage":
977 legacy = False
978 elif stagefunc.strip() == "autotools_stage_all":
979 legacy = False
980 elif stagefunc.strip() == "do_stage_native" and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1":
981 legacy = False
982 elif bb.data.getVar('NATIVE_INSTALL_WORKS', d, 1) == "1":
983 legacy = False
984 return legacy
985
986do_populate_sysroot[dirs] = "${STAGING_DIR_TARGET}/${bindir} ${STAGING_DIR_TARGET}/${libdir} \
987 ${STAGING_DIR_TARGET}/${includedir} \
988 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
989 ${STAGING_INCDIR_NATIVE} \
990 ${STAGING_DATADIR} \
991 ${S} ${B}"
992
993# Could be compile but populate_sysroot and do_install shouldn't run at the same time
994addtask populate_sysroot after do_install
995
996PSTAGING_ACTIVE = "0"
997SYSROOT_PREPROCESS_FUNCS ?= ""
998SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir/"
999SYSROOT_LOCK = "${STAGING_DIR}/staging.lock"
1000
1001python populate_sysroot_prehook () {
1002 return
1003}
1004
1005python populate_sysroot_posthook () {
1006 return
1007}
1008
1009packagedstaging_fastpath () {
1010 :
1011}
1012
1013python do_populate_sysroot () {
1014 #
1015 # if do_stage exists, we're legacy. In that case run the do_stage,
1016 # modify the SYSROOT_DESTDIR variable and then run the staging preprocess
1017 # functions against staging directly.
1018 #
1019 # Otherwise setup a destdir, copy the results from do_install
1020 # and run the staging preprocess against that
1021 #
1022 pstageactive = (bb.data.getVar("PSTAGING_ACTIVE", d, True) == "1")
1023 lockfile = bb.data.getVar("SYSROOT_LOCK", d, True)
1024 stagefunc = bb.data.getVar('do_stage', d, True)
1025 legacy = is_legacy_staging(d)
1026 if legacy:
1027 bb.data.setVar("SYSROOT_DESTDIR", "", d)
1028 bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
1029 lock = bb.utils.lockfile(lockfile)
1030 bb.build.exec_func('populate_sysroot_prehook', d)
1031 bb.build.exec_func('do_stage', d)
1032 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
1033 bb.build.exec_func(f, d)
1034 bb.build.exec_func('populate_sysroot_posthook', d)
1035 bb.utils.unlockfile(lock)
1036 else:
1037 dest = bb.data.getVar('D', d, True)
1038 sysrootdest = bb.data.expand('${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}', d)
1039 bb.mkdirhier(sysrootdest)
1040
1041 bb.build.exec_func("sysroot_stage_all", d)
1042 #os.system('cp -pPR %s/* %s/' % (dest, sysrootdest))
1043 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
1044 bb.build.exec_func(f, d)
1045 bb.build.exec_func("packagedstaging_fastpath", d)
1046
1047 lock = bb.utils.lockfile(lockfile)
1048 os.system(bb.data.expand('cp -pPR ${SYSROOT_DESTDIR}${TMPDIR}/* ${TMPDIR}/', d))
1049 bb.utils.unlockfile(lock)
1050}
1051 407
1052addtask install after do_compile 408addtask install after do_compile
1053do_install[dirs] = "${D} ${S} ${B}" 409do_install[dirs] = "${D} ${S} ${B}"
@@ -1066,19 +422,6 @@ addtask build after do_populate_sysroot
1066do_build = "" 422do_build = ""
1067do_build[func] = "1" 423do_build[func] = "1"
1068 424
1069# Make sure MACHINE isn't exported
1070# (breaks binutils at least)
1071MACHINE[unexport] = "1"
1072
1073# Make sure TARGET_ARCH isn't exported
1074# (breaks Makefiles using implicit rules, e.g. quilt, as GNU make has this
1075# in them, undocumented)
1076TARGET_ARCH[unexport] = "1"
1077
1078# Make sure DISTRO isn't exported
1079# (breaks sysvinit at least)
1080DISTRO[unexport] = "1"
1081
1082 425
1083def base_after_parse(d): 426def base_after_parse(d):
1084 import exceptions 427 import exceptions
@@ -1176,7 +519,7 @@ def base_after_parse(d):
1176 for pkg in packages: 519 for pkg in packages:
1177 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1) 520 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
1178 521
1179 # We could look for != PACKAGE_ARCH here but how to choose 522 # We could look for != PACKAGE_ARCH here but how to choose
1180 # if multiple differences are present? 523 # if multiple differences are present?
1181 # Look through PACKAGE_ARCHS for the priority order? 524 # Look through PACKAGE_ARCHS for the priority order?
1182 if pkgarch and pkgarch == mach_arch: 525 if pkgarch and pkgarch == mach_arch:
@@ -1187,8 +530,6 @@ def base_after_parse(d):
1187 530
1188python () { 531python () {
1189 base_after_parse(d) 532 base_after_parse(d)
1190 if is_legacy_staging(d):
1191 bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
1192} 533}
1193 534
1194def check_app_exists(app, d): 535def check_app_exists(app, d):
@@ -1211,63 +552,7 @@ def check_gcc3(data):
1211# Patch handling 552# Patch handling
1212inherit patch 553inherit patch
1213 554
1214EXPORT_FUNCTIONS do_setscene do_clean do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_rebuild do_fetchall 555EXPORT_FUNCTIONS do_setscene do_fetch do_unpack do_configure do_compile do_install do_package
1215
1216MIRRORS[func] = "0"
1217MIRRORS () {
1218${DEBIAN_MIRROR}/main http://snapshot.debian.net/archive/pool
1219${DEBIAN_MIRROR} ftp://ftp.de.debian.org/debian/pool
1220${DEBIAN_MIRROR} ftp://ftp.au.debian.org/debian/pool
1221${DEBIAN_MIRROR} ftp://ftp.cl.debian.org/debian/pool
1222${DEBIAN_MIRROR} ftp://ftp.hr.debian.org/debian/pool
1223${DEBIAN_MIRROR} ftp://ftp.fi.debian.org/debian/pool
1224${DEBIAN_MIRROR} ftp://ftp.hk.debian.org/debian/pool
1225${DEBIAN_MIRROR} ftp://ftp.hu.debian.org/debian/pool
1226${DEBIAN_MIRROR} ftp://ftp.ie.debian.org/debian/pool
1227${DEBIAN_MIRROR} ftp://ftp.it.debian.org/debian/pool
1228${DEBIAN_MIRROR} ftp://ftp.jp.debian.org/debian/pool
1229${DEBIAN_MIRROR} ftp://ftp.no.debian.org/debian/pool
1230${DEBIAN_MIRROR} ftp://ftp.pl.debian.org/debian/pool
1231${DEBIAN_MIRROR} ftp://ftp.ro.debian.org/debian/pool
1232${DEBIAN_MIRROR} ftp://ftp.si.debian.org/debian/pool
1233${DEBIAN_MIRROR} ftp://ftp.es.debian.org/debian/pool
1234${DEBIAN_MIRROR} ftp://ftp.se.debian.org/debian/pool
1235${DEBIAN_MIRROR} ftp://ftp.tr.debian.org/debian/pool
1236${GNU_MIRROR} ftp://mirrors.kernel.org/gnu
1237${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
1238${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
1239${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
1240${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
1241${KERNELORG_MIRROR} http://www.kernel.org/pub
1242${KERNELORG_MIRROR} ftp://ftp.us.kernel.org/pub
1243${KERNELORG_MIRROR} ftp://ftp.uk.kernel.org/pub
1244${KERNELORG_MIRROR} ftp://ftp.hk.kernel.org/pub
1245${KERNELORG_MIRROR} ftp://ftp.au.kernel.org/pub
1246${KERNELORG_MIRROR} ftp://ftp.jp.kernel.org/pub
1247ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
1248ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/
1249ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/
1250ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
1251ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
1252ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
1253ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
1254ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
1255ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
1256ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
1257ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
1258http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
1259http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
1260ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
1261ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tau.ac.il/pub/unix/admin/
1262ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
1263ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
1264ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.kaizo.org/pub/lsof/
1265ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
1266ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
1267ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
1268ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
1269ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://the.wiretapped.net/pub/security/host-security/lsof/
1270http://www.apache.org/dist http://archive.apache.org/dist
1271 556
1272} 557inherit mirrors
1273 558