[oe-commits] [openembedded-core] 03/03: package_ipk/deb: Tweak functions for better cleanup and layout

git at git.openembedded.org git at git.openembedded.org
Thu May 11 23:08:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 9cd7c2631b0840a57b9ed6c201bcb4fc80094f71
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Fri Mar 31 15:28:07 2017 +0100

    package_ipk/deb: Tweak functions for better cleanup and layout
    
    This uses more modern formatting to handle the lockfiles and control
    file cleanup with try/finally, taking advantage of the previous
    extra indentation.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/package_deb.bbclass | 33 +++++++++++++++++----------------
 meta/classes/package_ipk.bbclass | 32 ++++++++++++++++----------------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 636647d..04b9197 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -69,25 +69,26 @@ python do_package_deb () {
 }
 
 def deb_write_pkg(pkg, d):
-        import re, copy
-        import textwrap
-        import subprocess
-        import collections
-        import codecs
+    import re, copy
+    import textwrap
+    import subprocess
+    import collections
+    import codecs
 
-        outdir = d.getVar('PKGWRITEDIRDEB')
-        pkgdest = d.getVar('PKGDEST')
+    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)
+    def cleanupcontrol(root):
+        for p in ['CONTROL', 'DEBIAN']:
+            p = os.path.join(root, p)
+            if os.path.exists(p):
+                bb.utils.prunedir(p)
 
-        localdata = bb.data.createCopy(d)
-        root = "%s/%s" % (pkgdest, pkg)
+    localdata = bb.data.createCopy(d)
+    root = "%s/%s" % (pkgdest, pkg)
 
-        lf = bb.utils.lockfile(root + ".lock")
+    lf = bb.utils.lockfile(root + ".lock")
+    try:
 
         localdata.setVar('ROOT', '')
         localdata.setVar('ROOT_%s' % pkg, root)
@@ -109,7 +110,6 @@ def deb_write_pkg(pkg, d):
         g = glob('*')
         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)
             return
 
         controldir = os.path.join(root, 'DEBIAN')
@@ -283,6 +283,7 @@ def deb_write_pkg(pkg, d):
         os.chdir(basedir)
         subprocess.check_output("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH"), root, pkgoutdir), shell=True)
 
+    finally:
         cleanupcontrol(root)
         bb.utils.unlockfile(lf)
 
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 16ee761..5cc7e0a 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -44,25 +44,25 @@ python do_package_ipk () {
 }
 
 def ipk_write_pkg(pkg, d):
-        import re, copy
-        import subprocess
-        import textwrap
-        import collections
+    import re, copy
+    import subprocess
+    import textwrap
+    import collections
 
-        def cleanupcontrol(root):
-            for p in ['CONTROL', 'DEBIAN']:
-                p = os.path.join(root, p)
-                if os.path.exists(p):
-                    bb.utils.prunedir(p)
+    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('PKGWRITEDIRIPK')
-        pkgdest = d.getVar('PKGDEST')
-
-        localdata = bb.data.createCopy(d)
-        root = "%s/%s" % (pkgdest, pkg)
+    outdir = d.getVar('PKGWRITEDIRIPK')
+    pkgdest = d.getVar('PKGDEST')
 
-        lf = bb.utils.lockfile(root + ".lock")
+    localdata = bb.data.createCopy(d)
+    root = "%s/%s" % (pkgdest, pkg)
 
+    lf = bb.utils.lockfile(root + ".lock")
+    try:
         localdata.setVar('ROOT', '')
         localdata.setVar('ROOT_%s' % pkg, root)
         pkgname = localdata.getVar('PKG_%s' % pkg)
@@ -107,7 +107,6 @@ def ipk_write_pkg(pkg, d):
         g = glob('*')
         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)
             return
 
         controldir = os.path.join(root, 'CONTROL')
@@ -245,6 +244,7 @@ def ipk_write_pkg(pkg, d):
             ipk_to_sign = "%s/%s_%s_%s.ipk" % (pkgoutdir, pkgname, ipkver, d.getVar('PACKAGE_ARCH'))
             sign_ipk(d, ipk_to_sign)
 
+    finally:
         cleanupcontrol(root)
         bb.utils.unlockfile(lf)
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list