summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-05 18:44:24 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-11 17:40:09 +0000
commit51d5204084a3c3d8417af7bf28658bc5cae1b7ca (patch)
tree216820a39b7c895b0e8c04f6ab64e2ee0adb0858
parent909a80fe34da981a0e20689812cdb2d70525f8e9 (diff)
downloadpoky-51d5204084a3c3d8417af7bf28658bc5cae1b7ca.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) (From OE-Core rev: 508f7dfb301db30964bf77d370a9e48cb7f354f8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/package.bbclass52
-rw-r--r--meta/classes/prserv.bbclass31
2 files changed, 38 insertions, 45 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4685cd2bc0..320ec0ee01 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -394,28 +394,52 @@ def runtime_mapping_rename (varname, pkg, d):
394# 394#
395 395
396python package_get_auto_pr() { 396python package_get_auto_pr() {
397 # per recipe PRSERV_HOST 397 import oe.prservice
398 import re
399
400 # Support per recipe PRSERV_HOST
398 pn = d.getVar('PN', True) 401 pn = d.getVar('PN', True)
399 host = d.getVar("PRSERV_HOST_" + pn, True) 402 host = d.getVar("PRSERV_HOST_" + pn, True)
400 if not (host is None): 403 if not (host is None):
401 d.setVar("PRSERV_HOST", host) 404 d.setVar("PRSERV_HOST", host)
402 405
403 if d.getVar('PRSERV_HOST', True): 406 # PR Server not active, handle AUTOINC
404 try: 407 if not d.getVar('PRSERV_HOST', True):
405 auto_pr=prserv_get_pr_auto(d)
406 except Exception as e:
407 bb.fatal("Can NOT get PRAUTO, exception %s" % str(e))
408 if auto_pr is None:
409 if d.getVar('PRSERV_LOCKDOWN', True):
410 bb.fatal("Can NOT get PRAUTO from lockdown exported file")
411 else:
412 bb.fatal("Can NOT get PRAUTO from remote PR service")
413 return
414 d.setVar('PRAUTO',str(auto_pr))
415 else:
416 pkgv = d.getVar("PKGV", True) 408 pkgv = d.getVar("PKGV", True)
417 if 'AUTOINC' in pkgv: 409 if 'AUTOINC' in pkgv:
418 d.setVar("PKGV", pkgv.replace("AUTOINC", "0")) 410 d.setVar("PKGV", pkgv.replace("AUTOINC", "0"))
411 return
412
413 auto_pr = None
414 pv = d.getVar("PV", True)
415 version = d.getVar("PRAUTOINX", True)
416 pkgarch = d.getVar("PACKAGE_ARCH", True)
417 checksum = d.getVar("BB_TASKHASH", True)
418
419 if d.getVar('PRSERV_LOCKDOWN', True):
420 auto_pr = d.getVar('PRAUTO_' + version + '_' + pkgarch, True) or d.getVar('PRAUTO_' + version, True) or None
421 if auto_pr is None:
422 bb.fatal("Can NOT get PRAUTO from lockdown exported file")
423 d.setVar('PRAUTO',str(auto_pr))
424 return
425
426 try:
427 conn = d.getVar("__PRSERV_CONN", True)
428 if conn is None:
429 conn = oe.prservice.prserv_make_conn(d)
430 if conn is not None:
431 if "AUTOINC" in pv:
432 srcpv = bb.fetch2.get_srcrev(d)
433 base_ver = "AUTOINC-%s" % version[:version.find(srcpv)]
434 value = conn.getPR(base_ver, pkgarch, srcpv)
435 d.setVar("PKGV", pv.replace("AUTOINC", str(value)))
436
437 auto_pr = conn.getPR(version, pkgarch, checksum)
438 except Exception as e:
439 bb.fatal("Can NOT get PRAUTO, exception %s" % str(e))
440 if auto_pr is None:
441 bb.fatal("Can NOT get PRAUTO from remote PR service")
442 d.setVar('PRAUTO',str(auto_pr))
419} 443}
420 444
421LOCALEBASEPN ??= "${PN}" 445LOCALEBASEPN ??= "${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 @@
1def 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