summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2007-08-08 21:04:28 +0000
committerRichard Purdie <richard@openedhand.com>2007-08-08 21:04:28 +0000
commit9c900768c48f5eac3d8e8171392b5d3dee91b422 (patch)
tree24c24e4537ff9d162a72aa57494bf96734699d62 /meta/classes
parent9d3073bb2d6996628dbf1df89529a14e87a3b5d0 (diff)
downloadpoky-9c900768c48f5eac3d8e8171392b5d3dee91b422.tar.gz
base.bbclass: Sync with OE.dev (mainly download checksumming code)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2411 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/base.bbclass148
1 files changed, 134 insertions, 14 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index b29010c9d5..5d26c2b7ed 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -1,5 +1,76 @@
1BB_DEFAULT_TASK = "build" 1BB_DEFAULT_TASK = "build"
2 2
3# like os.path.join but doesn't treat absolute RHS specially
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, 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)
20
21 return parser
22
23def base_chk_file(parser, pn, pv, src_uri, localpath, data):
24 import os, bb
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 return False
40 #raise Exception("Can not find a section for '%s' '%s' and '%s'" % (pn,pv,src_uri))
41
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)
46
47
48 # call md5(sum) and shasum
49 try:
50 md5pipe = os.popen('md5sum ' + localpath)
51 md5data = (md5pipe.readline().split() or [ "" ])[0]
52 md5pipe.close()
53 except OSError:
54 raise Exception("Executing md5sum failed")
55
56 try:
57 shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
58 shadata = (shapipe.readline().split() or [ "" ])[0]
59 shapipe.close()
60 except OSError:
61 raise Exception("Executing shasum failed")
62
63 if not md5 == md5data:
64 bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
65 raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
66
67 if not sha256 == shadata:
68 bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
69 raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
70
71 return True
72
73
3def base_dep_prepend(d): 74def base_dep_prepend(d):
4 import bb; 75 import bb;
5 # 76 #
@@ -7,7 +78,9 @@ def base_dep_prepend(d):
7 # the case where host == build == target, for now we don't work in 78 # the case where host == build == target, for now we don't work in
8 # that case though. 79 # that case though.
9 # 80 #
10 deps = "" 81 deps = "shasum-native "
82 if bb.data.getVar('PN', d, True) == "shasum-native":
83 deps = ""
11 84
12 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not 85 # 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 86 # we need that built is the responsibility of the patch function / class, not
@@ -35,6 +108,13 @@ def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
35 else: 108 else:
36 return falsevalue 109 return falsevalue
37 110
111def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
112 import bb
113 if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
114 return truevalue
115 else:
116 return falsevalue
117
38def base_contains(variable, checkvalues, truevalue, falsevalue, d): 118def base_contains(variable, checkvalues, truevalue, falsevalue, d):
39 import bb 119 import bb
40 matches = 0 120 matches = 0
@@ -359,6 +439,7 @@ python base_do_mrproper() {
359 439
360addtask fetch 440addtask fetch
361do_fetch[dirs] = "${DL_DIR}" 441do_fetch[dirs] = "${DL_DIR}"
442do_fetch[depends] = "shasum-native:do_populate_staging"
362python base_do_fetch() { 443python base_do_fetch() {
363 import sys 444 import sys
364 445
@@ -383,6 +464,40 @@ python base_do_fetch() {
383 except bb.fetch.FetchError: 464 except bb.fetch.FetchError:
384 (type, value, traceback) = sys.exc_info() 465 (type, value, traceback) = sys.exc_info()
385 raise bb.build.FuncFailed("Fetch failed: %s" % value) 466 raise bb.build.FuncFailed("Fetch failed: %s" % value)
467 except bb.fetch.MD5SumError:
468 (type, value, traceback) = sys.exc_info()
469 raise bb.build.FuncFailed("MD5 failed: %s" % value)
470 except:
471 (type, value, traceback) = sys.exc_info()
472 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
473
474
475 # Verify the SHA and MD5 sums we have in OE and check what do
476 # in
477 check_sum = bb.which(bb.data.getVar('BBPATH', d, True), "conf/checksums.ini")
478 if not check_sum:
479 bb.note("No conf/checksums.ini found, not checking checksums")
480 return
481
482 try:
483 parser = base_chk_load_parser(check_sum)
484 except:
485 bb.note("Creating the CheckSum parser failed")
486 return
487
488 pv = bb.data.getVar('PV', d, True)
489 pn = bb.data.getVar('PN', d, True)
490
491 # Check each URI
492 for url in src_uri.split():
493 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
494 (type,host,path,_,_,_) = bb.decodeurl(url)
495 uri = "%s://%s%s" % (type,host,path)
496 try:
497 if not base_chk_file(parser, pn, pv,uri, localpath, d):
498 bb.note("%s-%s-%s has no section, not checking URI" % (pn,pv,uri))
499 except Exception:
500 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
386} 501}
387 502
388addtask fetchall after do_fetch 503addtask fetchall after do_fetch
@@ -752,13 +867,6 @@ python () {
752 base_after_parse(d) 867 base_after_parse(d)
753} 868}
754 869
755def base_get_srcrev(d):
756 import bb
757
758 if hasattr(bb.fetch, "get_srcrev"):
759 return bb.fetch.get_srcrev(d)
760 return "NOT IMPLEMENTED"
761
762# Patch handling 870# Patch handling
763inherit patch 871inherit patch
764 872
@@ -793,12 +901,12 @@ ${GNU_MIRROR} ftp://ftp.matrix.com.br/pub/gnu
793${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu 901${GNU_MIRROR} ftp://ftp.cs.ubc.ca/mirror2/gnu
794${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu 902${GNU_MIRROR} ftp://sunsite.ust.hk/pub/gnu
795${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu 903${GNU_MIRROR} ftp://ftp.ayamura.org/pub/gnu
796ftp://ftp.kernel.org/pub http://www.kernel.org/pub 904${KERNELORG_MIRROR} http://www.kernel.org/pub
797ftp://ftp.kernel.org/pub ftp://ftp.us.kernel.org/pub 905${KERNELORG_MIRROR} ftp://ftp.us.kernel.org/pub
798ftp://ftp.kernel.org/pub ftp://ftp.uk.kernel.org/pub 906${KERNELORG_MIRROR} ftp://ftp.uk.kernel.org/pub
799ftp://ftp.kernel.org/pub ftp://ftp.hk.kernel.org/pub 907${KERNELORG_MIRROR} ftp://ftp.hk.kernel.org/pub
800ftp://ftp.kernel.org/pub ftp://ftp.au.kernel.org/pub 908${KERNELORG_MIRROR} ftp://ftp.au.kernel.org/pub
801ftp://ftp.kernel.org/pub ftp://ftp.jp.kernel.org/pub 909${KERNELORG_MIRROR} ftp://ftp.jp.kernel.org/pub
802ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/ 910ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
803ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/ 911ftp://ftp.gnupg.org/gcrypt/ ftp://ftp.surfnet.nl/pub/security/gnupg/
804ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/ 912ftp://ftp.gnupg.org/gcrypt/ http://gulus.USherbrooke.ca/pub/appl/GnuPG/
@@ -812,5 +920,17 @@ ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/ne
812ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/ 920ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
813http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/ 921http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
814http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/ 922http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
923ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
924ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tau.ac.il/pub/unix/admin/
925ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
926ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
927ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.kaizo.org/pub/lsof/
928ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
929ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
930ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
931ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
932ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ ftp://the.wiretapped.net/pub/security/host-security/lsof/
933http://www.apache.org/dist http://archive.apache.org/dist
934
815} 935}
816 936