]> code.ossystems Code Review - openembedded-core.git/commitdiff
package_deb: Split do_package_write_deb into two functions
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 31 Mar 2017 12:34:24 +0000 (13:34 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 11 May 2017 16:41:05 +0000 (17:41 +0100)
This prepares the way to parallelise deb generation and splits the iteration
over packages and the package generation into separate functions. Whitespace
indentation is unchanged deliberately and is fixed in a followup patch. There
should be no functional change.

Some checks on variables are removed as they were pointless when you looked
at the code.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/package_deb.bbclass

index eacabcdb61a0054957a08ae6691a6b0b5b917326..636647d6ffae94dd366474e0eb5010f648f6e6c0 100644 (file)
@@ -51,47 +51,39 @@ def debian_arch_map(arch, tune):
 # INSTALL_TASK_DEB - task name
 
 python do_package_deb () {
-    import re, copy
-    import textwrap
-    import subprocess
-    import collections
-    import codecs
-
     oldcwd = os.getcwd()
 
-    workdir = d.getVar('WORKDIR')
-    if not workdir:
-        bb.error("WORKDIR not defined, unable to package")
-        return
-
-    outdir = d.getVar('PKGWRITEDIRDEB')
-    if not outdir:
-        bb.error("PKGWRITEDIRDEB not defined, unable to package")
-        return
-
     packages = d.getVar('PACKAGES')
     if not packages:
         bb.debug(1, "PACKAGES not defined, nothing to package")
         return
 
     tmpdir = d.getVar('TMPDIR')
-
     if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK):
         os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"))
 
-    if packages == []:
-        bb.debug(1, "No packages; nothing to do")
-        return
+    for pkg in packages.split():
+        deb_write_pkg(pkg, d)
+
+    os.chdir(oldcwd)
+}
 
-    pkgdest = d.getVar('PKGDEST')
+def deb_write_pkg(pkg, d):
+        import re, copy
+        import textwrap
+        import subprocess
+        import collections
+        import codecs
 
-    def cleanupcontrol(root):
-        for p in ['CONTROL', 'DEBIAN']:
-            p = os.path.join(root, p)
-            if os.path.exists(p):
-                bb.utils.prunedir(p)
+        outdir = d.getVar('PKGWRITEDIRDEB')
+        pkgdest = d.getVar('PKGDEST')
+
+        def cleanupcontrol(root):
+            for p in ['CONTROL', 'DEBIAN']:
+                p = os.path.join(root, p)
+                if os.path.exists(p):
+                    bb.utils.prunedir(p)
 
-    for pkg in packages.split():
         localdata = bb.data.createCopy(d)
         root = "%s/%s" % (pkgdest, pkg)
 
@@ -118,7 +110,7 @@ python do_package_deb () {
         if not g and localdata.getVar('ALLOW_EMPTY', False) != "1":
             bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR')))
             bb.utils.unlockfile(lf)
-            continue
+            return
 
         controldir = os.path.join(root, 'DEBIAN')
         bb.utils.mkdirhier(controldir)
@@ -293,13 +285,12 @@ python do_package_deb () {
 
         cleanupcontrol(root)
         bb.utils.unlockfile(lf)
-    os.chdir(oldcwd)
-}
-# Indirect references to these vars
-do_package_write_deb[vardeps] += "PKGV PKGR PKGV DESCRIPTION SECTION PRIORITY MAINTAINER DPKG_ARCH PN HOMEPAGE"
+
 # Otherwise allarch packages may change depending on override configuration
-do_package_deb[vardepsexclude] = "OVERRIDES"
+deb_write_pkg[vardepsexclude] = "OVERRIDES"
 
+# Indirect references to these vars
+do_package_write_deb[vardeps] += "PKGV PKGR PKGV DESCRIPTION SECTION PRIORITY MAINTAINER DPKG_ARCH PN HOMEPAGE"
 
 SSTATETASKS += "do_package_write_deb"
 do_package_write_deb[sstate-inputdirs] = "${PKGWRITEDIRDEB}"