Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: [PATCH] package_deb/package_ipk: Cleanup control file handling/races
Date: Tue, 05 Nov 2013 22:08:56 +0000	[thread overview]
Message-ID: <1383689336.6271.180.camel@ted> (raw)

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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 6a8e080..d18c250 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -202,6 +202,12 @@ python do_package_deb () {
 
     pkgdest = d.getVar('PKGDEST', True)
 
+    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)
@@ -224,13 +230,9 @@ python do_package_deb () {
         bb.utils.mkdirhier(pkgoutdir)
 
         os.chdir(root)
+        cleanupcontrol(root)
         from glob import glob
         g = glob('*')
-        try:
-            del g[g.index('DEBIAN')]
-            del g[g.index('./DEBIAN')]
-        except ValueError:
-            pass
         if not g and localdata.getVar('ALLOW_EMPTY') != "1":
             bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
             bb.utils.unlockfile(lf)
@@ -402,11 +404,10 @@ python do_package_deb () {
         os.chdir(basedir)
         ret = subprocess.call("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH", True), root, pkgoutdir), shell=True)
         if ret != 0:
-            bb.utils.prunedir(controldir)
             bb.utils.unlockfile(lf)
             raise bb.build.FuncFailed("dpkg-deb execution failed")
 
-        bb.utils.prunedir(controldir)
+        cleanupcontrol(root)
         bb.utils.unlockfile(lf)
 }
 
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index a633cfc..d0db945 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -234,6 +234,12 @@ python do_package_ipk () {
     if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
         os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
 
+    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)
@@ -255,13 +261,9 @@ python do_package_ipk () {
         pkgoutdir = "%s/%s" % (outdir, arch)
         bb.utils.mkdirhier(pkgoutdir)
         os.chdir(root)
+        cleanupcontrol(root)
         from glob import glob
         g = glob('*')
-        try:
-            del g[g.index('CONTROL')]
-            del g[g.index('./CONTROL')]
-        except ValueError:
-            pass
         if not g and localdata.getVar('ALLOW_EMPTY') != "1":
             bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
             bb.utils.unlockfile(lf)
@@ -407,7 +409,7 @@ python do_package_ipk () {
             bb.utils.unlockfile(lf)
             raise bb.build.FuncFailed("opkg-build execution failed")
 
-        bb.utils.prunedir(controldir)
+        cleanupcontrol(root)
         bb.utils.unlockfile(lf)
 
 }




                 reply	other threads:[~2013-11-05 22:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383689336.6271.180.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox