[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5817/8267] package_deb: Split do_package_write_deb into two functions



commit 086e0db58289fbded898eccb46cf0141444ace97
Author: Richard Purdie <richard purdie linuxfoundation org>
Date:   Fri Mar 31 13:34:24 2017 +0100

    package_deb: Split do_package_write_deb into two functions
    
    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.
    
    (From OE-Core rev: 5054f66f8fbaaa422f74a4b5d0e61e68de6ffe91)
    
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 meta/classes/package_deb.bbclass |   57 ++++++++++++++++----------------------
 1 files changed, 24 insertions(+), 33 deletions(-)
---
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index eacabcd..636647d 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -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}"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]