diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-20 14:37:16 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-20 15:21:36 +0000 |
commit | 8a2f86ad907d3e3eed365b34586dbd99f743c89a (patch) | |
tree | 169135066d2813ea2762dbb50235369304541d0f /bitbake | |
parent | d8b3caa085bad90f021e5102d43deaf653e04c1d (diff) | |
download | poky-8a2f86ad907d3e3eed365b34586dbd99f743c89a.tar.gz |
utils: Add split_version function for splitting a version into its components
(Bitbake rev: b7b7c768761d205bc5a60922ff709c9c184d4158)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index d7cefb245f..21d3a812d3 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -60,6 +60,20 @@ def explode_version(s): | |||
60 | s = s[1:] | 60 | s = s[1:] |
61 | return r | 61 | return r |
62 | 62 | ||
63 | def split_version(s): | ||
64 | """Split a version string into its constituent parts (PE, PV, PR)""" | ||
65 | s = s.strip(" <>=") | ||
66 | e = 0 | ||
67 | if s.count(':'): | ||
68 | e = int(s.split(":")[0]) | ||
69 | s = s.split(":")[1] | ||
70 | r = "" | ||
71 | if s.count('-'): | ||
72 | r = s.rsplit("-", 1)[1] | ||
73 | s = s.rsplit("-", 1)[0] | ||
74 | v = s | ||
75 | return (e, v, r) | ||
76 | |||
63 | def vercmp_part(a, b): | 77 | def vercmp_part(a, b): |
64 | va = explode_version(a) | 78 | va = explode_version(a) |
65 | vb = explode_version(b) | 79 | vb = explode_version(b) |