summaryrefslogtreecommitdiff
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2011-05-16 11:18:38 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-17 14:38:52 +0100
commit9aeaae7b786a42d213ad4224743dfd49e2324077 (patch)
treeece72afa13d2ac601e70296705edf3e98ffaf74a /meta/classes/base.bbclass
parentb41148cda9f0cc292b662a8473f26bc1ee0148f3 (diff)
downloadopenembedded-core-9aeaae7b786a42d213ad4224743dfd49e2324077.tar.gz
openembedded-core-9aeaae7b786a42d213ad4224743dfd49e2324077.tar.bz2
openembedded-core-9aeaae7b786a42d213ad4224743dfd49e2324077.zip
base.bbclass: Fix PR increment bug when PR number is a single digit
PRINC which should add to base PR value has a problem when the PR is single digit e.g. r0 - r9. Current algorithm needed atleasts 2 digits to successfully populate end and begin markers. We reimplement the incrementing algorithm using regular expressions which addressed the above mentioned problem and simplifies the logic a bit and gets rid of loops and conditionals Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass19
1 files changed, 6 insertions, 13 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index d9ed15fee4..23095eca3b 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -233,25 +233,18 @@ do_build () {
}
python () {
- import exceptions, string
+ import exceptions, string, re
# If PRINC is set, try and increase the PR value by the amount specified
princ = bb.data.getVar('PRINC', d, True)
if princ:
pr = bb.data.getVar('PR', d, True)
- start = -1
- end = -1
- for i in range(len(pr)):
- if pr[i] in string.digits:
- if start == -1:
- start = i
- else:
- end = i
- if start == -1 or end == -1:
+ pr_prefix = re.search("\D+",pr)
+ prval = re.search("\d+",pr)
+ if pr_prefix is None or prval is None:
bb.error("Unable to analyse format of PR variable: %s" % pr)
- prval = pr[start:end+1]
- prval = int(prval) + int(princ)
- pr = pr[0:start] + str(prval) + pr[end:len(pr)-1]
+ nval = int(prval.group(0)) + int(princ)
+ pr = pr_prefix.group(0) + str(nval) + pr[prval.end():]
bb.data.setVar('PR', pr, d)
pn = bb.data.getVar('PN', d, 1)