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>
This commit is contained in:
Richard Purdie
2017-03-31 15:28:07 +01:00
parent 086e0db582
commit aee1b57539
2 changed files with 33 additions and 32 deletions

View File

@@ -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)

View File

@@ -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')
outdir = d.getVar('PKGWRITEDIRIPK')
pkgdest = d.getVar('PKGDEST')
localdata = bb.data.createCopy(d)
root = "%s/%s" % (pkgdest, pkg)
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)