diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-31 15:28:07 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-05-12 08:45:36 +0100 |
commit | aee1b575395d09227028c6a999d29f613086287c (patch) | |
tree | 40384643ee93cadcad62ec391b89e5f080b4b62b /meta | |
parent | 086e0db58289fbded898eccb46cf0141444ace97 (diff) | |
download | poky-aee1b575395d09227028c6a999d29f613086287c.tar.gz |
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.
(From OE-Core rev: 9cd7c2631b0840a57b9ed6c201bcb4fc80094f71)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/package_deb.bbclass | 33 | ||||
-rw-r--r-- | 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 636647d6ff..04b91970c7 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass | |||
@@ -69,25 +69,26 @@ python do_package_deb () { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | def deb_write_pkg(pkg, d): | 71 | def deb_write_pkg(pkg, d): |
72 | import re, copy | 72 | import re, copy |
73 | import textwrap | 73 | import textwrap |
74 | import subprocess | 74 | import subprocess |
75 | import collections | 75 | import collections |
76 | import codecs | 76 | import codecs |
77 | 77 | ||
78 | outdir = d.getVar('PKGWRITEDIRDEB') | 78 | outdir = d.getVar('PKGWRITEDIRDEB') |
79 | pkgdest = d.getVar('PKGDEST') | 79 | pkgdest = d.getVar('PKGDEST') |
80 | 80 | ||
81 | def cleanupcontrol(root): | 81 | def cleanupcontrol(root): |
82 | for p in ['CONTROL', 'DEBIAN']: | 82 | for p in ['CONTROL', 'DEBIAN']: |
83 | p = os.path.join(root, p) | 83 | p = os.path.join(root, p) |
84 | if os.path.exists(p): | 84 | if os.path.exists(p): |
85 | bb.utils.prunedir(p) | 85 | bb.utils.prunedir(p) |
86 | 86 | ||
87 | localdata = bb.data.createCopy(d) | 87 | localdata = bb.data.createCopy(d) |
88 | root = "%s/%s" % (pkgdest, pkg) | 88 | root = "%s/%s" % (pkgdest, pkg) |
89 | 89 | ||
90 | lf = bb.utils.lockfile(root + ".lock") | 90 | lf = bb.utils.lockfile(root + ".lock") |
91 | try: | ||
91 | 92 | ||
92 | localdata.setVar('ROOT', '') | 93 | localdata.setVar('ROOT', '') |
93 | localdata.setVar('ROOT_%s' % pkg, root) | 94 | localdata.setVar('ROOT_%s' % pkg, root) |
@@ -109,7 +110,6 @@ def deb_write_pkg(pkg, d): | |||
109 | g = glob('*') | 110 | g = glob('*') |
110 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": | 111 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": |
111 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) | 112 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) |
112 | bb.utils.unlockfile(lf) | ||
113 | return | 113 | return |
114 | 114 | ||
115 | controldir = os.path.join(root, 'DEBIAN') | 115 | controldir = os.path.join(root, 'DEBIAN') |
@@ -283,6 +283,7 @@ def deb_write_pkg(pkg, d): | |||
283 | os.chdir(basedir) | 283 | os.chdir(basedir) |
284 | subprocess.check_output("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH"), root, pkgoutdir), shell=True) | 284 | subprocess.check_output("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH"), root, pkgoutdir), shell=True) |
285 | 285 | ||
286 | finally: | ||
286 | cleanupcontrol(root) | 287 | cleanupcontrol(root) |
287 | bb.utils.unlockfile(lf) | 288 | bb.utils.unlockfile(lf) |
288 | 289 | ||
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass index 16ee761537..5cc7e0a7b2 100644 --- a/meta/classes/package_ipk.bbclass +++ b/meta/classes/package_ipk.bbclass | |||
@@ -44,25 +44,25 @@ python do_package_ipk () { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | def ipk_write_pkg(pkg, d): | 46 | def ipk_write_pkg(pkg, d): |
47 | import re, copy | 47 | import re, copy |
48 | import subprocess | 48 | import subprocess |
49 | import textwrap | 49 | import textwrap |
50 | import collections | 50 | import collections |
51 | 51 | ||
52 | def cleanupcontrol(root): | 52 | def cleanupcontrol(root): |
53 | for p in ['CONTROL', 'DEBIAN']: | 53 | for p in ['CONTROL', 'DEBIAN']: |
54 | p = os.path.join(root, p) | 54 | p = os.path.join(root, p) |
55 | if os.path.exists(p): | 55 | if os.path.exists(p): |
56 | bb.utils.prunedir(p) | 56 | bb.utils.prunedir(p) |
57 | 57 | ||
58 | outdir = d.getVar('PKGWRITEDIRIPK') | 58 | outdir = d.getVar('PKGWRITEDIRIPK') |
59 | pkgdest = d.getVar('PKGDEST') | 59 | pkgdest = d.getVar('PKGDEST') |
60 | |||
61 | localdata = bb.data.createCopy(d) | ||
62 | root = "%s/%s" % (pkgdest, pkg) | ||
63 | 60 | ||
64 | lf = bb.utils.lockfile(root + ".lock") | 61 | localdata = bb.data.createCopy(d) |
62 | root = "%s/%s" % (pkgdest, pkg) | ||
65 | 63 | ||
64 | lf = bb.utils.lockfile(root + ".lock") | ||
65 | try: | ||
66 | localdata.setVar('ROOT', '') | 66 | localdata.setVar('ROOT', '') |
67 | localdata.setVar('ROOT_%s' % pkg, root) | 67 | localdata.setVar('ROOT_%s' % pkg, root) |
68 | pkgname = localdata.getVar('PKG_%s' % pkg) | 68 | pkgname = localdata.getVar('PKG_%s' % pkg) |
@@ -107,7 +107,6 @@ def ipk_write_pkg(pkg, d): | |||
107 | g = glob('*') | 107 | g = glob('*') |
108 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": | 108 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": |
109 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) | 109 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) |
110 | bb.utils.unlockfile(lf) | ||
111 | return | 110 | return |
112 | 111 | ||
113 | controldir = os.path.join(root, 'CONTROL') | 112 | controldir = os.path.join(root, 'CONTROL') |
@@ -245,6 +244,7 @@ def ipk_write_pkg(pkg, d): | |||
245 | ipk_to_sign = "%s/%s_%s_%s.ipk" % (pkgoutdir, pkgname, ipkver, d.getVar('PACKAGE_ARCH')) | 244 | ipk_to_sign = "%s/%s_%s_%s.ipk" % (pkgoutdir, pkgname, ipkver, d.getVar('PACKAGE_ARCH')) |
246 | sign_ipk(d, ipk_to_sign) | 245 | sign_ipk(d, ipk_to_sign) |
247 | 246 | ||
247 | finally: | ||
248 | cleanupcontrol(root) | 248 | cleanupcontrol(root) |
249 | bb.utils.unlockfile(lf) | 249 | bb.utils.unlockfile(lf) |
250 | 250 | ||