classes: Add support for intertask dependencies to be specified, needed for correct...
authorRichard Purdie <rpurdie@rpsys.net>
Wed, 18 Apr 2007 21:22:03 +0000 (21:22 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Wed, 18 Apr 2007 21:22:03 +0000 (21:22 +0000)
classes/base.bbclass
classes/image.bbclass
classes/package.bbclass
classes/package_deb.bbclass
classes/package_ipk.bbclass
classes/package_tar.bbclass
classes/patch.bbclass
classes/rootfs_deb.bbclass
classes/rootfs_ipk.bbclass

index aa693cd..d78bd3c 100644 (file)
@@ -78,22 +78,9 @@ def base_dep_prepend(d):
        # the case where host == build == target, for now we don't work in
        # that case though.
        #
+       deps = "shasum-native "
        if bb.data.getVar('PN', d, True) == "shasum-native":
                deps = ""
-       else:
-               deps = "shasum-native "
-
-       # INHIBIT_PATCH_TOOL don't apply the patch tool dependency
-       inhibit_patch = (bb.data.getVar("INHIBIT_PATCH_TOOL", d, True) == "1") or False
-
-       # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command.  Whether or  not
-       # we need that built is the responsibility of the patch function / class, not
-       # the application.
-       patchdeps = bb.data.getVar("PATCHTOOL", d, 1)
-        if patchdeps and not inhibit_patch:
-               patchdeps = "%s-native" % patchdeps
-               if not patchdeps in bb.data.getVar("PROVIDES", d, 1):
-                       deps += patchdeps
 
        if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
                if (bb.data.getVar('HOST_SYS', d, 1) !=
@@ -819,11 +806,6 @@ def base_after_parse(d):
 
     pn = bb.data.getVar('PN', d, 1)
 
-    # OBSOLETE in bitbake 1.7.4
-    srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
-    if srcdate != None:
-        bb.data.setVar('SRCDATE', srcdate, d)
-
     use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
     if use_nls != None:
         bb.data.setVar('USE_NLS', use_nls, d)
@@ -850,8 +832,54 @@ def base_after_parse(d):
                 bb.data.setVar('PACKAGE_ARCH', mach_arch, d)
                 return
 
+#
+# Various backwards compatibility stuff to be removed
+# when we switch to bitbake 1.8.2+ as a minimum version
+#
+def base_oldbitbake_workarounds(d):
+    import bb
+    from bb import __version__
+    from distutils.version import LooseVersion
+
+    if (LooseVersion(__version__) > "1.8.0"):
+        return
+
+    pn = bb.data.getVar('PN', d, True)
+    srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, True)
+    if srcdate != None:
+        bb.data.setVar('SRCDATE', srcdate, d)
+    depends = bb.data.getVar('DEPENDS', d, False)
+    patchdeps = bb.data.getVar("PATCHTOOL", d, True)
+    if patchdeps:
+        patchdeps = "%s-native " % patchdeps
+        if not patchdeps in bb.data.getVar("PROVIDES", d, True):
+            depends = patchdeps + depends 
+    if bb.data.inherits_class('rootfs_ipk', d):
+        depends = "ipkg-native ipkg-utils-native fakeroot-native " + depends
+    if bb.data.inherits_class('rootfs_deb', d):
+        depends = "dpkg-native apt-native fakeroot-native " + depends
+    if bb.data.inherits_class('image', d):
+        depends = "makedevs-native " + depends
+        for type in (bb.data.getVar('IMAGE_FSTYPES', d, True) or "").split():
+            deps = bb.data.getVar('IMAGE_DEPENDS_%s' % type, d) or ""
+            if deps:
+                depends = depends + " %s" % deps
+        for dep in (bb.data.getVar('EXTRA_IMAGEDEPENDS', d, True) or "").split():
+            depends =  depends + " %s" % dep
+
+    packages = bb.data.getVar('PACKAGES', d, True)
+    if packages != '':
+        if bb.data.inherits_class('package_ipk', d):
+            depends = "ipkg-utils-native " + depends
+        if bb.data.inherits_class('package_deb', d):
+            depends = "dpkg-native " + depends
+        if bb.data.inherits_class('package', d):
+            depends = "${PACKAGE_DEPENDS} fakeroot-native" + depends
+
+    bb.data.setVar('DEPENDS', depends, d)
 
 python () {
+    base_oldbitbake_workarounds(d)
     base_after_parse(d)
 }
 
index 4f87091..2954dcd 100644 (file)
@@ -13,19 +13,21 @@ USE_DEVFS ?= "0"
 
 PID = "${@os.getpid()}"
 
-DEPENDS += "makedevs-native"
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-def get_image_deps(d):
-       import bb
-       str = ""
-       for type in (bb.data.getVar('IMAGE_FSTYPES', d, 1) or "").split():
-               deps = bb.data.getVar('IMAGE_DEPENDS_%s' % type, d) or ""
-               if deps:
-                       str += " %s" % deps
-       return str
+do_rootfs[depends] += "makedevs-native:do_populate_staging fakeroot-native:do_populate_staging"
 
-DEPENDS += "${@get_image_deps(d)}"
+python () {
+    import bb
+
+    deps = bb.data.getVarFlag('do_rootfs', 'depends', d) or ""
+    for type in (bb.data.getVar('IMAGE_FSTYPES', d, True) or "").split():
+        for dep in ((bb.data.getVar('IMAGE_DEPENDS_%s' % type, d) or "").split() or []):
+            deps += " %s:do_populate_staging" % dep
+    for dep in (bb.data.getVar('EXTRA_IMAGEDEPENDS', d, True) or "").split():
+        deps += " %s:do_populate_staging" % dep
+    bb.data.setVarFlag('do_rootfs', 'depends', deps, d)
+}
 
 #
 # Get a list of files containing device tables to create.
index 3e80b2b..e044395 100644 (file)
@@ -116,8 +116,23 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
 
        bb.data.setVar('PACKAGES', ' '.join(packages), d)
 
-PACKAGE_DEPENDS ?= "file-native fakeroot-native"
-DEPENDS_prepend =+ "${PACKAGE_DEPENDS} "
+PACKAGE_DEPENDS += "file-native"
+
+python () {
+    import bb
+
+    if bb.data.getVar('PACKAGES', d, True) != '':
+        deps = bb.data.getVarFlag('do_package', 'depends', d) or ""
+        for dep in (bb.data.getVar('PACKAGE_DEPENDS', d, True) or "").split():
+            deps += " %s:do_populate_staging" % dep
+        bb.data.setVarFlag('do_package', 'depends', deps, d)
+
+        deps = bb.data.getVarFlag('do_package_write', 'depends', d) or ""
+        for dep in (bb.data.getVar('PACKAGE_EXTRA_DEPENDS', d, True) or "").split():
+            deps += " %s:do_populate_staging" % dep
+        bb.data.setVarFlag('do_package_write', 'depends', deps, d)
+}
+
 # file(1) output to match to consider a file an unstripped executable
 FILE_UNSTRIPPED_MATCH ?= "not stripped"
 #FIXME: this should be "" when any errors are gone!
@@ -126,7 +141,7 @@ IGNORE_STRIP_ERRORS ?= "1"
 runstrip() {
        # Function to strip a single file, called from RUNSTRIP in populate_packages below
        # A working 'file' (one which works on the target architecture)
-       # is necessary for this stuff to work, hence the addition to PACKAGES_DEPENDS
+       # is necessary for this stuff to work, hence the addition to do_package[depends]
 
        local ro st
 
index 0c83e58..d172fb1 100644 (file)
@@ -1,5 +1,7 @@
 inherit package
-DEPENDS_prepend="${@["dpkg-native ", ""][(bb.data.getVar('PACKAGES', d, 1) == '')]}"
+
+PACKAGE_EXTRA_DEPENDS += "dpkg-native fakeroot-native"
+
 BOOTSTRAP_EXTRA_RDEPENDS += "dpkg"
 DISTRO_EXTRA_RDEPENDS += "dpkg"
 PACKAGE_WRITE_FUNCS += "do_package_deb"
index 19c082d..b5cc6af 100644 (file)
@@ -1,5 +1,7 @@
 inherit package
-DEPENDS_prepend="${@["ipkg-utils-native ", ""][(bb.data.getVar('PACKAGES', d, 1) == '')]}"
+
+PACKAGE_EXTRA_DEPENDS += "ipkg-utils-native fakeroot-native"
+
 BOOTSTRAP_EXTRA_RDEPENDS += "ipkg-collateral ipkg"
 PACKAGE_WRITE_FUNCS += "do_package_ipk"
 IMAGE_PKGTYPE ?= "ipk"
index b048b08..e94e763 100644 (file)
@@ -1,5 +1,7 @@
 inherit package
 
+PACKAGE_EXTRA_DEPENDS += "tar-native"
+
 PACKAGE_WRITE_FUNCS += "do_package_tar"
 IMAGE_PKGTYPE ?= "tar"
 
index a28f889..84cca7f 100644 (file)
@@ -417,6 +417,17 @@ def patch_init(d):
 
 addtask patch after do_unpack
 do_patch[dirs] = "${WORKDIR}"
+
+python () {
+    import bb
+    # do_patch tasks require PATCHTOOL-native to have staged
+    patchdeps = bb.data.getVar("PATCHTOOL", d, True)
+    if patchdeps:
+        patchdeps = "%s-native" % patchdeps
+        if not patchdeps in bb.data.getVar("PROVIDES", d, True):
+            bb.data.setVarFlag('do_patch', 'depends', patchdeps + ":do_populate_staging", d)
+}
+
 python patch_do_patch() {
        import re
        import bb.fetch
index 59909d6..f444541 100644 (file)
@@ -1,5 +1,5 @@
-DEPENDS_prepend = "dpkg-native apt-native fakeroot-native "
-DEPENDS_append = " ${EXTRA_IMAGEDEPENDS}"
+
+do_rootfs[depends] += "dpkg-native:do_populate_staging apt-native:do_populate_staging"
 
 fakeroot rootfs_deb_do_rootfs () {
        set +e
index fdd42ee..26eca34 100644 (file)
@@ -5,12 +5,11 @@
 # See image.bbclass for a usage of this.
 #
 
-DEPENDS_prepend="ipkg-native ipkg-utils-native fakeroot-native "
-DEPENDS_append=" ${EXTRA_IMAGEDEPENDS}"
-RDEPENDS += "ipkg ipkg-collateral"
+do_rootfs[depends] += "ipkg-native:do_populate_staging ipkg-utils-native:do_populate_staging"
 
 IPKG_ARGS = "-f ${T}/ipkg.conf -o ${IMAGE_ROOTFS}"
 
+RDEPENDS += "ipkg ipkg-collateral"
 PACKAGE_INSTALL += "ipkg ipkg-collateral"
 
 rootfs_ipk_do_indexes () {