summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-11-05 22:08:56 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-11-06 11:02:27 +0000
commit0331fc280525bf96707927379accfba7b5e8651b (patch)
treea1dc8807065c4a72286150264b7777006d9b9600 /meta
parent1eefcf0ba8c5c74312c78fbcf5f27c3840a6578a (diff)
downloadpoky-0331fc280525bf96707927379accfba7b5e8651b.tar.gz
package_deb/package_ipk: Cleanup control file handling/races
If you Ctrl+C ppackage_write_{deb/ipk} control files can get left lying around and make it into another packaging format. This ensures we cleanup all known control files before starting packaging. We can simplify some of the globbing as a result. (From OE-Core rev: 7f8c728c82a17621461be2114c1afab3713a808e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package_deb.bbclass15
-rw-r--r--meta/classes/package_ipk.bbclass14
2 files changed, 16 insertions, 13 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 6a8e080138..d18c250ecc 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -202,6 +202,12 @@ python do_package_deb () {
202 202
203 pkgdest = d.getVar('PKGDEST', True) 203 pkgdest = d.getVar('PKGDEST', True)
204 204
205 def cleanupcontrol(root):
206 for p in ['CONTROL', 'DEBIAN']:
207 p = os.path.join(root, p)
208 if os.path.exists(p):
209 bb.utils.prunedir(p)
210
205 for pkg in packages.split(): 211 for pkg in packages.split():
206 localdata = bb.data.createCopy(d) 212 localdata = bb.data.createCopy(d)
207 root = "%s/%s" % (pkgdest, pkg) 213 root = "%s/%s" % (pkgdest, pkg)
@@ -224,13 +230,9 @@ python do_package_deb () {
224 bb.utils.mkdirhier(pkgoutdir) 230 bb.utils.mkdirhier(pkgoutdir)
225 231
226 os.chdir(root) 232 os.chdir(root)
233 cleanupcontrol(root)
227 from glob import glob 234 from glob import glob
228 g = glob('*') 235 g = glob('*')
229 try:
230 del g[g.index('DEBIAN')]
231 del g[g.index('./DEBIAN')]
232 except ValueError:
233 pass
234 if not g and localdata.getVar('ALLOW_EMPTY') != "1": 236 if not g and localdata.getVar('ALLOW_EMPTY') != "1":
235 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True))) 237 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
236 bb.utils.unlockfile(lf) 238 bb.utils.unlockfile(lf)
@@ -402,11 +404,10 @@ python do_package_deb () {
402 os.chdir(basedir) 404 os.chdir(basedir)
403 ret = subprocess.call("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH", True), root, pkgoutdir), shell=True) 405 ret = subprocess.call("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH", True), root, pkgoutdir), shell=True)
404 if ret != 0: 406 if ret != 0:
405 bb.utils.prunedir(controldir)
406 bb.utils.unlockfile(lf) 407 bb.utils.unlockfile(lf)
407 raise bb.build.FuncFailed("dpkg-deb execution failed") 408 raise bb.build.FuncFailed("dpkg-deb execution failed")
408 409
409 bb.utils.prunedir(controldir) 410 cleanupcontrol(root)
410 bb.utils.unlockfile(lf) 411 bb.utils.unlockfile(lf)
411} 412}
412 413
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index a633cfcc76..d0db9454d1 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -234,6 +234,12 @@ python do_package_ipk () {
234 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): 234 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
235 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) 235 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
236 236
237 def cleanupcontrol(root):
238 for p in ['CONTROL', 'DEBIAN']:
239 p = os.path.join(root, p)
240 if os.path.exists(p):
241 bb.utils.prunedir(p)
242
237 for pkg in packages.split(): 243 for pkg in packages.split():
238 localdata = bb.data.createCopy(d) 244 localdata = bb.data.createCopy(d)
239 root = "%s/%s" % (pkgdest, pkg) 245 root = "%s/%s" % (pkgdest, pkg)
@@ -255,13 +261,9 @@ python do_package_ipk () {
255 pkgoutdir = "%s/%s" % (outdir, arch) 261 pkgoutdir = "%s/%s" % (outdir, arch)
256 bb.utils.mkdirhier(pkgoutdir) 262 bb.utils.mkdirhier(pkgoutdir)
257 os.chdir(root) 263 os.chdir(root)
264 cleanupcontrol(root)
258 from glob import glob 265 from glob import glob
259 g = glob('*') 266 g = glob('*')
260 try:
261 del g[g.index('CONTROL')]
262 del g[g.index('./CONTROL')]
263 except ValueError:
264 pass
265 if not g and localdata.getVar('ALLOW_EMPTY') != "1": 267 if not g and localdata.getVar('ALLOW_EMPTY') != "1":
266 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True))) 268 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
267 bb.utils.unlockfile(lf) 269 bb.utils.unlockfile(lf)
@@ -407,7 +409,7 @@ python do_package_ipk () {
407 bb.utils.unlockfile(lf) 409 bb.utils.unlockfile(lf)
408 raise bb.build.FuncFailed("opkg-build execution failed") 410 raise bb.build.FuncFailed("opkg-build execution failed")
409 411
410 bb.utils.prunedir(controldir) 412 cleanupcontrol(root)
411 bb.utils.unlockfile(lf) 413 bb.utils.unlockfile(lf)
412 414
413} 415}