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_ipk.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_ipk.bbclass')
| -rw-r--r-- | meta/classes/package_ipk.bbclass | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass index be300e04b1..e69745665f 100644 --- a/meta/classes/package_ipk.bbclass +++ b/meta/classes/package_ipk.bbclass | |||
| @@ -33,7 +33,7 @@ python package_ipk_install () { | |||
| 33 | 33 | ||
| 34 | # Generate ipk.conf if it or the stamp doesnt exist | 34 | # Generate ipk.conf if it or the stamp doesnt exist |
| 35 | conffile = os.path.join(stagingdir,"ipkg.conf") | 35 | conffile = os.path.join(stagingdir,"ipkg.conf") |
| 36 | if not os.access(conffile, os.R_OK): | 36 | if not os.access(conffile, os.R_OK): |
| 37 | ipkg_archs = bb.data.getVar('PACKAGE_ARCHS',d) | 37 | ipkg_archs = bb.data.getVar('PACKAGE_ARCHS',d) |
| 38 | if ipkg_archs is None: | 38 | if ipkg_archs is None: |
| 39 | bb.error("PACKAGE_ARCHS missing") | 39 | bb.error("PACKAGE_ARCHS missing") |
| @@ -152,20 +152,11 @@ python do_package_ipk () { | |||
| 152 | bb.debug(1, "No packages; nothing to do") | 152 | bb.debug(1, "No packages; nothing to do") |
| 153 | return | 153 | return |
| 154 | 154 | ||
| 155 | def lockfile(name): | ||
| 156 | lf = open(name, "a+") | ||
| 157 | fcntl.flock(lf.fileno(), fcntl.LOCK_EX) | ||
| 158 | return lf | ||
| 159 | |||
| 160 | def unlockfile(lf): | ||
| 161 | fcntl.flock(lf.fileno(), fcntl.LOCK_UN) | ||
| 162 | lf.close | ||
| 163 | |||
| 164 | for pkg in packages.split(): | 155 | for pkg in packages.split(): |
| 165 | localdata = bb.data.createCopy(d) | 156 | localdata = bb.data.createCopy(d) |
| 166 | root = "%s/install/%s" % (workdir, pkg) | 157 | root = "%s/install/%s" % (workdir, pkg) |
| 167 | 158 | ||
| 168 | lf = lockfile(root + ".lock") | 159 | lf = bb.utils.lockfile(root + ".lock") |
| 169 | 160 | ||
| 170 | bb.data.setVar('ROOT', '', localdata) | 161 | bb.data.setVar('ROOT', '', localdata) |
| 171 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) | 162 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) |
| @@ -195,7 +186,7 @@ python do_package_ipk () { | |||
| 195 | if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": | 186 | if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": |
| 196 | from bb import note | 187 | from bb import note |
| 197 | note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) | 188 | note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) |
| 198 | unlockfile(lf) | 189 | bb.utils.unlockfile(lf) |
| 199 | continue | 190 | continue |
| 200 | 191 | ||
| 201 | controldir = os.path.join(root, 'CONTROL') | 192 | controldir = os.path.join(root, 'CONTROL') |
| @@ -203,6 +194,7 @@ python do_package_ipk () { | |||
| 203 | try: | 194 | try: |
| 204 | ctrlfile = file(os.path.join(controldir, 'control'), 'w') | 195 | ctrlfile = file(os.path.join(controldir, 'control'), 'w') |
| 205 | except OSError: | 196 | except OSError: |
| 197 | bb.utils.unlockfile(lf) | ||
| 206 | raise bb.build.FuncFailed("unable to open control file for writing.") | 198 | raise bb.build.FuncFailed("unable to open control file for writing.") |
| 207 | 199 | ||
| 208 | fields = [] | 200 | fields = [] |
| @@ -236,6 +228,7 @@ python do_package_ipk () { | |||
| 236 | except KeyError: | 228 | except KeyError: |
| 237 | (type, value, traceback) = sys.exc_info() | 229 | (type, value, traceback) = sys.exc_info() |
| 238 | ctrlfile.close() | 230 | ctrlfile.close() |
| 231 | bb.utils.unlockfile(lf) | ||
| 239 | raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value) | 232 | raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value) |
| 240 | # more fields | 233 | # more fields |
| 241 | 234 | ||
| @@ -272,6 +265,7 @@ python do_package_ipk () { | |||
| 272 | try: | 265 | try: |
| 273 | scriptfile = file(os.path.join(controldir, script), 'w') | 266 | scriptfile = file(os.path.join(controldir, script), 'w') |
| 274 | except OSError: | 267 | except OSError: |
| 268 | bb.utils.unlockfile(lf) | ||
| 275 | raise bb.build.FuncFailed("unable to open %s script file for writing." % script) | 269 | raise bb.build.FuncFailed("unable to open %s script file for writing." % script) |
| 276 | scriptfile.write(scriptvar) | 270 | scriptfile.write(scriptvar) |
| 277 | scriptfile.close() | 271 | scriptfile.close() |
| @@ -282,6 +276,7 @@ python do_package_ipk () { | |||
| 282 | try: | 276 | try: |
| 283 | conffiles = file(os.path.join(controldir, 'conffiles'), 'w') | 277 | conffiles = file(os.path.join(controldir, 'conffiles'), 'w') |
| 284 | except OSError: | 278 | except OSError: |
| 279 | bb.utils.unlockfile(lf) | ||
| 285 | raise bb.build.FuncFailed("unable to open conffiles for writing.") | 280 | raise bb.build.FuncFailed("unable to open conffiles for writing.") |
| 286 | for f in conffiles_str.split(): | 281 | for f in conffiles_str.split(): |
| 287 | conffiles.write('%s\n' % f) | 282 | conffiles.write('%s\n' % f) |
| @@ -291,6 +286,7 @@ python do_package_ipk () { | |||
| 291 | ret = os.system("PATH=\"%s\" %s %s %s" % (bb.data.getVar("PATH", localdata, 1), | 286 | ret = os.system("PATH=\"%s\" %s %s %s" % (bb.data.getVar("PATH", localdata, 1), |
| 292 | bb.data.getVar("IPKGBUILDCMD",d,1), pkg, pkgoutdir)) | 287 | bb.data.getVar("IPKGBUILDCMD",d,1), pkg, pkgoutdir)) |
| 293 | if ret != 0: | 288 | if ret != 0: |
| 289 | bb.utils.unlockfile(lf) | ||
| 294 | raise bb.build.FuncFailed("ipkg-build execution failed") | 290 | raise bb.build.FuncFailed("ipkg-build execution failed") |
| 295 | 291 | ||
| 296 | for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: | 292 | for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: |
| @@ -303,7 +299,7 @@ python do_package_ipk () { | |||
| 303 | os.rmdir(controldir) | 299 | os.rmdir(controldir) |
| 304 | except OSError: | 300 | except OSError: |
| 305 | pass | 301 | pass |
| 306 | unlockfile(lf) | 302 | bb.utils.unlockfile(lf) |
| 307 | } | 303 | } |
| 308 | 304 | ||
| 309 | python () { | 305 | python () { |
