Patchwork [2/3] Clean up how we handle unpack/fetch deps from SRC_URI

login
register
mail settings
Submitter Christopher Larson
Date April 5, 2011, 8:39 p.m.
Message ID <f77a7a4b4d9704141c2a66f3a1b48b8366f2c971.1302035800.git.chris_larson@mentor.com>
Download mbox | patch
Permalink /patch/1961/
State New, archived
Headers show

Comments

Christopher Larson - April 5, 2011, 8:39 p.m.
From: Chris Larson <chris_larson@mentor.com>

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

Patch

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