[poky] [RFC PATCH 2/2] [RFC] Automatically patch recipes to add the SRC_URI checksum

Yu Ke ke.yu at intel.com
Thu Dec 2 00:18:51 PST 2010


Initially, most recpies don't have SRC_URI[] checksum, so we
need one mechanism to add SRC_URI[] checksum for all recpies.

This patch add the mechanism, the usage is:

1. add the following variable to conf/local.conf:
OE_CHECKSUMS_PATCH = "1"

2. # bitbake -f -c fetch <recipe-name>

it will automatically patch the recipe file to append checksum, like
SRC_URI[md5sum] = "6e497f861c77bbba2f7da4e10270995b"
SRC_URI[sha256sum] = "f3f6ce41b8e0f327abd05c95990f113ddafbae131e10f79a99728ed46458494b"

Note: this patch is only for one time usage, so not sure if we need to checked into upstream

Signed-off-by: Yu Ke <ke.yu at intel.com>
---
 meta/classes/utils.bbclass |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index 766cfc5..2729fe4 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -146,6 +146,8 @@ def base_chk_src_uri_checksum(localpath, params, data):
         bb.warn("Missing SRC_URI checksum for %s, recommend to add\n" \
                 "SRC_URI[%s] = \"%s\"\nSRC_URI[%s] = \"%s\"" \
 				% (localpath, md5flag, md5data, sha256flag, sha256data))
+        base_patch_src_uri_checksum(expected_md5sum, expected_sha256sum, \
+                md5data, sha256data, md5flag, sha256flag, data)
         return not strict_checking
 
     if (expected_md5sum != md5data or expected_sha256sum != sha256data):
@@ -208,6 +210,27 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data):
 
     return True
 
+def base_patch_src_uri_checksum(expected_md5sum, expected_sha256sum, md5data, sha256data, md5flag, sha256flag, data):
+    #
+    # Purpose: patch the recpies file to append SRC_URI[] checksum automatically
+    #          this behavor is only enabled when OE_CHECKSUMS_PATCH = "1"
+    #
+    if (bb.data.getVar("OE_CHECKSUMS_PATCH", data, True) != "1"):
+        return
+
+    buf = []
+    if (expected_md5sum == None):
+        buf.append('SRC_URI[%s] = \"%s\"' % (md5flag, md5data))
+    if (expected_sha256sum == None):
+        buf.append('SRC_URI[%s] = \"%s\"' % (sha256flag, sha256data))
+    if ( len(buf) > 0):
+        bbfile = bb.data.getVar("FILE", data, True)
+        bb.note("bbfile=%s" % bbfile)
+        f = open(bbfile, 'a')
+        f.write('\n'.join(buf))
+        f.close()
+        bb.note("Add SRC_URI checksum for %s succeeded" % bbfile)
+
 oe_soinstall() {
 	# Purpose: Install shared library file and
 	#          create the necessary links
-- 
1.7.0.4




More information about the poky mailing list