diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-10-29 23:41:24 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-11-13 12:15:22 +0000 |
commit | 4f4a3da8432e31e6d5cec376155999fcc5f3e2bc (patch) | |
tree | ed4e744e8f829ad645d8c4cd2199800895aee694 /meta/classes/package.bbclass | |
parent | 764f73a033b6686a50dff71881e2491f9e990c87 (diff) | |
download | poky-4f4a3da8432e31e6d5cec376155999fcc5f3e2bc.tar.gz |
package.bbclass: Move variable checks to one place making the code more readable
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r-- | meta/classes/package.bbclass | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 523d7aeaee..ca23cc6472 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -31,9 +31,6 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst | |||
31 | import os, os.path, bb | 31 | import os, os.path, bb |
32 | 32 | ||
33 | dvar = bb.data.getVar('D', d, True) | 33 | dvar = bb.data.getVar('D', d, True) |
34 | if not dvar: | ||
35 | bb.error("D not defined") | ||
36 | return | ||
37 | 34 | ||
38 | packages = bb.data.getVar('PACKAGES', d, True).split() | 35 | packages = bb.data.getVar('PACKAGES', d, True).split() |
39 | 36 | ||
@@ -242,14 +239,7 @@ python package_do_split_locales() { | |||
242 | return | 239 | return |
243 | 240 | ||
244 | dvar = bb.data.getVar('D', d, True) | 241 | dvar = bb.data.getVar('D', d, True) |
245 | if not dvar: | ||
246 | bb.error("D not defined") | ||
247 | return | ||
248 | |||
249 | pn = bb.data.getVar('PN', d, True) | 242 | pn = bb.data.getVar('PN', d, True) |
250 | if not pn: | ||
251 | bb.error("PN not defined") | ||
252 | return | ||
253 | 243 | ||
254 | if pn + '-locale' in packages: | 244 | if pn + '-locale' in packages: |
255 | packages.remove(pn + '-locale') | 245 | packages.remove(pn + '-locale') |
@@ -293,32 +283,17 @@ python package_do_split_locales() { | |||
293 | } | 283 | } |
294 | 284 | ||
295 | python populate_packages () { | 285 | python populate_packages () { |
296 | import glob, stat, errno, re | 286 | import os, glob, stat, errno, re |
297 | 287 | ||
298 | workdir = bb.data.getVar('WORKDIR', d, True) | 288 | workdir = bb.data.getVar('WORKDIR', d, True) |
299 | if not workdir: | ||
300 | bb.error("WORKDIR not defined, unable to package") | ||
301 | return | ||
302 | |||
303 | import os # path manipulations | ||
304 | outdir = bb.data.getVar('DEPLOY_DIR', d, True) | 289 | outdir = bb.data.getVar('DEPLOY_DIR', d, True) |
305 | if not outdir: | ||
306 | bb.error("DEPLOY_DIR not defined, unable to package") | ||
307 | return | ||
308 | bb.mkdirhier(outdir) | ||
309 | |||
310 | dvar = bb.data.getVar('D', d, True) | 290 | dvar = bb.data.getVar('D', d, True) |
311 | if not dvar: | ||
312 | bb.error("D not defined, unable to package") | ||
313 | return | ||
314 | bb.mkdirhier(dvar) | ||
315 | |||
316 | packages = bb.data.getVar('PACKAGES', d, True) | 291 | packages = bb.data.getVar('PACKAGES', d, True) |
317 | |||
318 | pn = bb.data.getVar('PN', d, True) | 292 | pn = bb.data.getVar('PN', d, True) |
319 | if not pn: | 293 | |
320 | bb.error("PN not defined") | 294 | bb.mkdirhier(outdir) |
321 | return | 295 | bb.mkdirhier(dvar) |
296 | |||
322 | 297 | ||
323 | os.chdir(dvar) | 298 | os.chdir(dvar) |
324 | 299 | ||
@@ -557,9 +532,6 @@ python package_do_shlibs() { | |||
557 | targetos = bb.data.getVar('TARGET_OS', d, True) | 532 | targetos = bb.data.getVar('TARGET_OS', d, True) |
558 | 533 | ||
559 | workdir = bb.data.getVar('WORKDIR', d, True) | 534 | workdir = bb.data.getVar('WORKDIR', d, True) |
560 | if not workdir: | ||
561 | bb.error("WORKDIR not defined") | ||
562 | return | ||
563 | 535 | ||
564 | ver = bb.data.getVar('PV', d, True) | 536 | ver = bb.data.getVar('PV', d, True) |
565 | if not ver: | 537 | if not ver: |
@@ -765,12 +737,7 @@ python package_do_pkgconfig () { | |||
765 | import re, os | 737 | import re, os |
766 | 738 | ||
767 | packages = bb.data.getVar('PACKAGES', d, True) | 739 | packages = bb.data.getVar('PACKAGES', d, True) |
768 | |||
769 | workdir = bb.data.getVar('WORKDIR', d, True) | 740 | workdir = bb.data.getVar('WORKDIR', d, True) |
770 | if not workdir: | ||
771 | bb.error("WORKDIR not defined") | ||
772 | return | ||
773 | |||
774 | pkgdest = bb.data.getVar('PKGDEST', d, True) | 741 | pkgdest = bb.data.getVar('PKGDEST', d, True) |
775 | 742 | ||
776 | shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True) | 743 | shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True) |
@@ -1009,6 +976,15 @@ python package_do_package () { | |||
1009 | bb.debug(1, "No packages to build, skipping do_package") | 976 | bb.debug(1, "No packages to build, skipping do_package") |
1010 | return | 977 | return |
1011 | 978 | ||
979 | workdir = bb.data.getVar('WORKDIR', d, True) | ||
980 | outdir = bb.data.getVar('DEPLOY_DIR', d, True) | ||
981 | dvar = bb.data.getVar('D', d, True) | ||
982 | pn = bb.data.getVar('PN', d, True) | ||
983 | |||
984 | if not workdir or not outdir or not dvar or not pn or not packages: | ||
985 | bb.error("WORKDIR, DEPLOY_DIR, D, and PN all must be defined, unable to package") | ||
986 | return | ||
987 | |||
1012 | for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split(): | 988 | for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split(): |
1013 | bb.build.exec_func(f, d) | 989 | bb.build.exec_func(f, d) |
1014 | } | 990 | } |