diff options
author | Richard Purdie <richard@openedhand.com> | 2007-11-24 14:55:57 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2007-11-24 14:55:57 +0000 |
commit | c0659779483182aff39d8e8a6821a40d1489dc0f (patch) | |
tree | 80c62fdc5c28c4d1820b209374706af7b38bc4b2 /meta/classes/package_deb.bbclass | |
parent | 701aa74aeb2e06368a927b4b61dd02160066101a (diff) | |
download | poky-c0659779483182aff39d8e8a6821a40d1489dc0f.tar.gz |
classes: Use internal bitbake functions and fix packaging unlocking on error paths
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3222 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-rw-r--r-- | meta/classes/package_deb.bbclass | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass index ce4d5c914c..a5b850d8ad 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass | |||
@@ -102,20 +102,11 @@ python do_package_deb () { | |||
102 | bb.debug(1, "No packages; nothing to do") | 102 | bb.debug(1, "No packages; nothing to do") |
103 | return | 103 | return |
104 | 104 | ||
105 | def lockfile(name): | ||
106 | lf = open(name, "a+") | ||
107 | fcntl.flock(lf.fileno(), fcntl.LOCK_EX) | ||
108 | return lf | ||
109 | |||
110 | def unlockfile(lf): | ||
111 | fcntl.flock(lf.fileno(), fcntl.LOCK_UN) | ||
112 | lf.close | ||
113 | |||
114 | for pkg in packages.split(): | 105 | for pkg in packages.split(): |
115 | localdata = bb.data.createCopy(d) | 106 | localdata = bb.data.createCopy(d) |
116 | root = "%s/install/%s" % (workdir, pkg) | 107 | root = "%s/install/%s" % (workdir, pkg) |
117 | 108 | ||
118 | lf = lockfile(root + ".lock") | 109 | lf = bb.utils.lockfile(root + ".lock") |
119 | 110 | ||
120 | bb.data.setVar('ROOT', '', localdata) | 111 | bb.data.setVar('ROOT', '', localdata) |
121 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) | 112 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) |
@@ -147,7 +138,7 @@ python do_package_deb () { | |||
147 | if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": | 138 | if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": |
148 | from bb import note | 139 | from bb import note |
149 | note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) | 140 | note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) |
150 | unlockfile(lf) | 141 | bb.utils.unlockfile(lf) |
151 | continue | 142 | continue |
152 | 143 | ||
153 | controldir = os.path.join(root, 'DEBIAN') | 144 | controldir = os.path.join(root, 'DEBIAN') |
@@ -158,6 +149,7 @@ python do_package_deb () { | |||
158 | # import codecs | 149 | # import codecs |
159 | # ctrlfile = codecs.open("someFile", "w", "utf-8") | 150 | # ctrlfile = codecs.open("someFile", "w", "utf-8") |
160 | except OSError: | 151 | except OSError: |
152 | bb.utils.unlockfile(lf) | ||
161 | raise bb.build.FuncFailed("unable to open control file for writing.") | 153 | raise bb.build.FuncFailed("unable to open control file for writing.") |
162 | 154 | ||
163 | fields = [] | 155 | fields = [] |
@@ -196,6 +188,7 @@ python do_package_deb () { | |||
196 | ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)))) | 188 | ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)))) |
197 | except KeyError: | 189 | except KeyError: |
198 | (type, value, traceback) = sys.exc_info() | 190 | (type, value, traceback) = sys.exc_info() |
191 | bb.utils.unlockfile(lf) | ||
199 | ctrlfile.close() | 192 | ctrlfile.close() |
200 | raise bb.build.FuncFailed("Missing field for deb generation: %s" % value) | 193 | raise bb.build.FuncFailed("Missing field for deb generation: %s" % value) |
201 | # more fields | 194 | # more fields |
@@ -231,6 +224,7 @@ python do_package_deb () { | |||
231 | try: | 224 | try: |
232 | scriptfile = file(os.path.join(controldir, script), 'w') | 225 | scriptfile = file(os.path.join(controldir, script), 'w') |
233 | except OSError: | 226 | except OSError: |
227 | bb.utils.unlockfile(lf) | ||
234 | raise bb.build.FuncFailed("unable to open %s script file for writing." % script) | 228 | raise bb.build.FuncFailed("unable to open %s script file for writing." % script) |
235 | scriptfile.write("#!/bin/sh\n") | 229 | scriptfile.write("#!/bin/sh\n") |
236 | scriptfile.write(scriptvar) | 230 | scriptfile.write(scriptvar) |
@@ -242,6 +236,7 @@ python do_package_deb () { | |||
242 | try: | 236 | try: |
243 | conffiles = file(os.path.join(controldir, 'conffiles'), 'w') | 237 | conffiles = file(os.path.join(controldir, 'conffiles'), 'w') |
244 | except OSError: | 238 | except OSError: |
239 | bb.utils.unlockfile(lf) | ||
245 | raise bb.build.FuncFailed("unable to open conffiles for writing.") | 240 | raise bb.build.FuncFailed("unable to open conffiles for writing.") |
246 | for f in conffiles_str.split(): | 241 | for f in conffiles_str.split(): |
247 | conffiles.write('%s\n' % f) | 242 | conffiles.write('%s\n' % f) |
@@ -250,6 +245,7 @@ python do_package_deb () { | |||
250 | os.chdir(basedir) | 245 | os.chdir(basedir) |
251 | ret = os.system("PATH=\"%s\" fakeroot dpkg-deb -b %s %s" % (bb.data.getVar("PATH", localdata, 1), root, pkgoutdir)) | 246 | ret = os.system("PATH=\"%s\" fakeroot dpkg-deb -b %s %s" % (bb.data.getVar("PATH", localdata, 1), root, pkgoutdir)) |
252 | if ret != 0: | 247 | if ret != 0: |
248 | bb.utils.unlockfile(lf) | ||
253 | raise bb.build.FuncFailed("dpkg-deb execution failed") | 249 | raise bb.build.FuncFailed("dpkg-deb execution failed") |
254 | 250 | ||
255 | for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: | 251 | for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: |
@@ -263,7 +259,7 @@ python do_package_deb () { | |||
263 | except OSError: | 259 | except OSError: |
264 | pass | 260 | pass |
265 | 261 | ||
266 | unlockfile(lf) | 262 | bb.utils.unlockfile(lf) |
267 | } | 263 | } |
268 | 264 | ||
269 | python () { | 265 | python () { |