[OE-core] [PATCH 2/3] Clean up how we handle unpack/fetch deps from SRC_URI

Chris Larson kergoth at gmail.com
Tue Apr 5 20:39:56 UTC 2011


From: Chris Larson <chris_larson at mentor.com>

Signed-off-by: Chris Larson <chris_larson at mentor.com>
---
 meta/classes/base.bbclass |   56 +++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 9c9fc7c..0a1aebf 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -254,9 +254,37 @@ do_build () {
 	:
 }
 
+
+def set_uri_depends(d):
+    import oe.fetch
+
+    unpack_depends = set()
+    fetch_depends = set()
+    for uri in oe.fetch.src_uri(d):
+	if uri.scheme == 'git':
+	    fetch_depends.add('git-native')
+	elif uri.scheme == 'hg':
+	    fetch_depends.add('mercurial-native')
+	elif uri.scheme == 'osc':
+	    fetch_depends.add('osc-native')
+
+	root, ext = os.path.splitext(uri.path)
+	if ext == '.xz':
+	    unpack_depends.add('xz-native')
+
+    fdepends = d.getVarFlag('do_fetch', 'depends') or ''
+    fdepends += ' '.join('%s:do_populate_sysroot' % f for f in fetch_depends)
+    d.setVarFlag('do_fetch', 'depends', fdepends)
+
+    udepends = d.getVarFlag('do_unpack', 'depends') or ''
+    udepends += ' '.join('%s:do_populate_sysroot' % u for u in unpack_depends)
+    d.setVarFlag('do_unpack', 'depends', udepends)
+
 python () {
     import exceptions, string
 
+    set_uri_depends(d)
+
     # If PRINC is set, try and increase the PR value by the amount specified
     princ = bb.data.getVar('PRINC', d, True)
     if princ:
@@ -341,25 +369,6 @@ python () {
     if use_nls != None:
         bb.data.setVar('USE_NLS', use_nls, d)
 
-    # Git packages should DEPEND on git-native
-    srcuri = bb.data.getVar('SRC_URI', d, 1)
-    if "git://" in srcuri:
-        depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
-        depends = depends + " git-native:do_populate_sysroot"
-        bb.data.setVarFlag('do_fetch', 'depends', depends, d)
-
-    # Mercurial packages should DEPEND on mercurial-native
-    elif "hg://" in srcuri:
-        depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
-        depends = depends + " mercurial-native:do_populate_sysroot"
-        bb.data.setVarFlag('do_fetch', 'depends', depends, d)
-
-    # OSC packages should DEPEND on osc-native
-    elif "osc://" in srcuri:
-        depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
-        depends = depends + " osc-native:do_populate_sysroot"
-        bb.data.setVarFlag('do_fetch', 'depends', depends, d)
-
     # bb.utils.sha256_file() will fail if hashlib isn't present, so we fallback
     # on shasum-native.  We need to ensure that it is staged before we fetch.
     if bb.data.getVar('PN', d, True) != "shasum-native":
@@ -370,13 +379,6 @@ python () {
             depends = depends + " shasum-native:do_populate_sysroot"
             bb.data.setVarFlag('do_fetch', 'depends', depends, d)
 
-    # *.xz should depends on xz-native for unpacking
-    # Not endswith because of "*.patch.xz;patch=1". Need bb.decodeurl in future
-    if '.xz' in srcuri:
-        depends = bb.data.getVarFlag('do_unpack', 'depends', d) or ""
-        depends = depends + " xz-native:do_populate_sysroot"
-        bb.data.setVarFlag('do_unpack', 'depends', depends, d)
-
     # 'multimachine' handling
     mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
     pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
@@ -432,7 +434,7 @@ def check_gcc3(data):
 	for gcc3 in gcc3_versions.split():
 		if check_app_exists(gcc3, data):
 			return gcc3
-	
+
 	return False
 
 addtask cleanall after do_clean
-- 
1.7.4.1





More information about the Openembedded-core mailing list