[oe-commits] org.oe.dev base.bbclass: add checksums.ini generator (from Poky)

hrw commit openembedded-commits at lists.openembedded.org
Wed Oct 17 10:58:11 UTC 2007


base.bbclass: add checksums.ini generator (from Poky)

If file is fetched via HTTP or FTP and we do not have its checksum in
metadata (conf/checksums.ini) then we generate checksums into
TMPDIR/checksums.ini file. Content of that file can be then added into
metadata one.

Author: hrw at openembedded.org
Branch: org.openembedded.dev
Revision: 821ed9384e156b3a4454086cd4a6644020f351ac
ViewMTN: http://monotone.openembedded.org/revision/info/821ed9384e156b3a4454086cd4a6644020f351ac
Files:
1
classes/base.bbclass
Diffs:

#
# mt diff -raa3f03afa328281dc1d2de6ec317bbac1c046acd -r821ed9384e156b3a4454086cd4a6644020f351ac
#
# 
# 
# patch "classes/base.bbclass"
#  from [7a3b6633b42df8f8bc1dfd4e57a66773f8d0cde3]
#    to [c613ae9e914f3d1caac56bfd222330fce26d9a52]
# 
============================================================
--- classes/base.bbclass	7a3b6633b42df8f8bc1dfd4e57a66773f8d0cde3
+++ classes/base.bbclass	c613ae9e914f3d1caac56bfd222330fce26d9a52
@@ -22,6 +22,7 @@ def base_chk_file(parser, pn, pv, src_ur
 
 def base_chk_file(parser, pn, pv, src_uri, localpath, data):
     import os, bb
+    no_checksum = False
     # Try PN-PV-SRC_URI first and then try PN-SRC_URI
     # we rely on the get method to create errors
     pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
@@ -36,8 +37,7 @@ def base_chk_file(parser, pn, pv, src_ur
         md5    = parser.get(src_uri, "md5")
         sha256 = parser.get(src_uri, "sha256")
     else:
-        return False
-        #raise Exception("Can not find a section for '%s' '%s' and '%s'" % (pn,pv,src_uri))
+        no_checksum = True
 
     # md5 and sha256 should be valid now
     if not os.path.exists(localpath):
@@ -60,6 +60,19 @@ def base_chk_file(parser, pn, pv, src_ur
     except OSError:
         raise Exception("Executing shasum failed")
 
+    if no_checksum == True:	# we do not have conf/checksums.ini entry
+        try:
+            file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
+        except:
+            return False
+
+        if not file:
+            raise Exception("Creating checksums.ini failed")
+        
+        file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
+        file.close()
+        return False
+
     if not md5 == md5data:
         bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
         raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
@@ -485,11 +498,9 @@ python base_do_fetch() {
 		(type,host,path,_,_,_) = bb.decodeurl(url)
 		uri = "%s://%s%s" % (type,host,path)
 		try:
-			if not base_chk_file(parser, pn, pv,uri, localpath, d):
-				if type != "file":
+			if type == "http" or type == "https" or type == "ftp" or type == "ftps":
+				if not base_chk_file(parser, pn, pv,uri, localpath, d):
 					bb.note("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
-				else:
-					bb.debug("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
 		except Exception:
 			raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
 }






More information about the Openembedded-commits mailing list