diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-11-05 18:44:24 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-11-09 10:21:19 +0000 |
commit | 593f14b2e3d1474d0c21d8d872dc7685163ffad2 (patch) | |
tree | f5435b3cad009f953faa0fadf1fcd93380ca6be3 /meta/classes | |
parent | d01b8d556e6956f677dd1e07cb0f4d54507e7cdc (diff) | |
download | poky-593f14b2e3d1474d0c21d8d872dc7685163ffad2.tar.gz |
package/prserv: Merge two similar functions into one
Having these two separate functions handling PR values seems pointless,
and worse, there are impossible code branches mixed within them.
Merge them into one function and tweak comments so at least you
don't have to read both functions to figure out what is going on.
This does restructure the conditionals to try and aid readability.
(From OE-Core rev: 865d001de168915a5796e5c760f96bdd04cebd61)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/package.bbclass | 52 | ||||
-rw-r--r-- | meta/classes/prserv.bbclass | 31 |
2 files changed, 38 insertions, 45 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 2aec3e6bd9..510617c3de 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -392,28 +392,52 @@ def runtime_mapping_rename (varname, pkg, d): | |||
392 | # | 392 | # |
393 | 393 | ||
394 | python package_get_auto_pr() { | 394 | python package_get_auto_pr() { |
395 | # per recipe PRSERV_HOST | 395 | import oe.prservice |
396 | import re | ||
397 | |||
398 | # Support per recipe PRSERV_HOST | ||
396 | pn = d.getVar('PN', True) | 399 | pn = d.getVar('PN', True) |
397 | host = d.getVar("PRSERV_HOST_" + pn, True) | 400 | host = d.getVar("PRSERV_HOST_" + pn, True) |
398 | if not (host is None): | 401 | if not (host is None): |
399 | d.setVar("PRSERV_HOST", host) | 402 | d.setVar("PRSERV_HOST", host) |
400 | 403 | ||
401 | if d.getVar('PRSERV_HOST', True): | 404 | # PR Server not active, handle AUTOINC |
402 | try: | 405 | if not d.getVar('PRSERV_HOST', True): |
403 | auto_pr=prserv_get_pr_auto(d) | ||
404 | except Exception as e: | ||
405 | bb.fatal("Can NOT get PRAUTO, exception %s" % str(e)) | ||
406 | if auto_pr is None: | ||
407 | if d.getVar('PRSERV_LOCKDOWN', True): | ||
408 | bb.fatal("Can NOT get PRAUTO from lockdown exported file") | ||
409 | else: | ||
410 | bb.fatal("Can NOT get PRAUTO from remote PR service") | ||
411 | return | ||
412 | d.setVar('PRAUTO',str(auto_pr)) | ||
413 | else: | ||
414 | pkgv = d.getVar("PKGV", True) | 406 | pkgv = d.getVar("PKGV", True) |
415 | if 'AUTOINC' in pkgv: | 407 | if 'AUTOINC' in pkgv: |
416 | d.setVar("PKGV", pkgv.replace("AUTOINC", "0")) | 408 | d.setVar("PKGV", pkgv.replace("AUTOINC", "0")) |
409 | return | ||
410 | |||
411 | auto_pr = None | ||
412 | pv = d.getVar("PV", True) | ||
413 | version = d.getVar("PRAUTOINX", True) | ||
414 | pkgarch = d.getVar("PACKAGE_ARCH", True) | ||
415 | checksum = d.getVar("BB_TASKHASH", True) | ||
416 | |||
417 | if d.getVar('PRSERV_LOCKDOWN', True): | ||
418 | auto_pr = d.getVar('PRAUTO_' + version + '_' + pkgarch, True) or d.getVar('PRAUTO_' + version, True) or None | ||
419 | if auto_pr is None: | ||
420 | bb.fatal("Can NOT get PRAUTO from lockdown exported file") | ||
421 | d.setVar('PRAUTO',str(auto_pr)) | ||
422 | return | ||
423 | |||
424 | try: | ||
425 | conn = d.getVar("__PRSERV_CONN", True) | ||
426 | if conn is None: | ||
427 | conn = oe.prservice.prserv_make_conn(d) | ||
428 | if conn is not None: | ||
429 | if "AUTOINC" in pv: | ||
430 | srcpv = bb.fetch2.get_srcrev(d) | ||
431 | base_ver = "AUTOINC-%s" % version[:version.find(srcpv)] | ||
432 | value = conn.getPR(base_ver, pkgarch, srcpv) | ||
433 | d.setVar("PKGV", pv.replace("AUTOINC", str(value))) | ||
434 | |||
435 | auto_pr = conn.getPR(version, pkgarch, checksum) | ||
436 | except Exception as e: | ||
437 | bb.fatal("Can NOT get PRAUTO, exception %s" % str(e)) | ||
438 | if auto_pr is None: | ||
439 | bb.fatal("Can NOT get PRAUTO from remote PR service") | ||
440 | d.setVar('PRAUTO',str(auto_pr)) | ||
417 | } | 441 | } |
418 | 442 | ||
419 | LOCALEBASEPN ??= "${PN}" | 443 | LOCALEBASEPN ??= "${PN}" |
diff --git a/meta/classes/prserv.bbclass b/meta/classes/prserv.bbclass index b440d863ef..139597f9cb 100644 --- a/meta/classes/prserv.bbclass +++ b/meta/classes/prserv.bbclass | |||
@@ -1,33 +1,2 @@ | |||
1 | def prserv_get_pr_auto(d): | ||
2 | import oe.prservice | ||
3 | import re | ||
4 | 1 | ||
5 | pv = d.getVar("PV", True) | ||
6 | if not d.getVar('PRSERV_HOST', True): | ||
7 | if 'AUTOINC' in pv: | ||
8 | d.setVar("PKGV", pv.replace("AUTOINC", "0")) | ||
9 | bb.warn("Not using network based PR service") | ||
10 | return None | ||
11 | 2 | ||
12 | version = d.getVar("PRAUTOINX", True) | ||
13 | pkgarch = d.getVar("PACKAGE_ARCH", True) | ||
14 | checksum = d.getVar("BB_TASKHASH", True) | ||
15 | |||
16 | conn = d.getVar("__PRSERV_CONN", True) | ||
17 | if conn is None: | ||
18 | conn = oe.prservice.prserv_make_conn(d) | ||
19 | if conn is None: | ||
20 | return None | ||
21 | |||
22 | if "AUTOINC" in pv: | ||
23 | srcpv = bb.fetch2.get_srcrev(d) | ||
24 | base_ver = "AUTOINC-%s" % version[:version.find(srcpv)] | ||
25 | value = conn.getPR(base_ver, pkgarch, srcpv) | ||
26 | d.setVar("PKGV", pv.replace("AUTOINC", str(value))) | ||
27 | |||
28 | if d.getVar('PRSERV_LOCKDOWN', True): | ||
29 | auto_rev = d.getVar('PRAUTO_' + version + '_' + pkgarch, True) or d.getVar('PRAUTO_' + version, True) or None | ||
30 | else: | ||
31 | auto_rev = conn.getPR(version, pkgarch, checksum) | ||
32 | |||
33 | return auto_rev | ||