summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-06-01 16:45:25 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-03 16:38:45 +0100
commit8c6bd8a84338c528d409301b4377ad2809338cdf (patch)
tree10d2df8d80d89a41c5375d6e07fbfa5a039035bb /meta/lib/oe
parent7cd3c6028c0a868ddefa02aa73393f4b16a72b5c (diff)
downloadpoky-8c6bd8a84338c528d409301b4377ad2809338cdf.tar.gz
recipeutils: Add get_recipe_upstream_version and get_recipe_pv_without_srcpv functions
The get_recipe_upstream_version functions tries to get the current version of recipe in upstream it uses bb.fetch2 latest_versionstring method also latest_revision when is SCM. The get_recipe_pv_without_srcpv discards the SRCPV in SCM's recipe like git it returns a tuple with the version, prefix and suffix of a PV. (From OE-Core rev: d1683b5bb584e2b09bda76bf8523b12636d91d73) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/recipeutils.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index f05b6c06ba..37efefb093 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -626,3 +626,99 @@ def replace_dir_vars(path, d):
626 path = path.replace(dirpath, '${%s}' % dirvars[dirpath]) 626 path = path.replace(dirpath, '${%s}' % dirvars[dirpath])
627 return path 627 return path
628 628
629def get_recipe_pv_without_srcpv(rd, uri_type):
630 """
631 Get PV without SRCPV common in SCM's for now only
632 support git.
633
634 Returns tuple with pv, prefix and suffix.
635 """
636 pv = ''
637 pfx = ''
638 sfx = ''
639
640 if uri_type == 'git':
641 rd_tmp = rd.createCopy()
642
643 rd_tmp.setVar('SRCPV', '')
644 pv = rd_tmp.getVar('PV', True)
645
646 git_regex = re.compile("(?P<pfx>(v|))(?P<ver>((\d+[\.\-_]*)+))(?P<sfx>(\+|)(git|)(r|)(AUTOINC|)(\+|))(?P<rev>.*)")
647 m = git_regex.match(pv)
648
649 if m:
650 pv = m.group('ver')
651 pfx = m.group('pfx')
652 sfx = m.group('sfx')
653 else:
654 pv = rd.getVar('PV', True)
655
656 return (pv, pfx, sfx)
657
658def get_recipe_upstream_version(rd):
659 """
660 Get upstream version of recipe using bb.fetch2 methods with support for
661 http, https, ftp and git.
662
663 bb.fetch2 exceptions can be raised,
664 FetchError when don't have network access or upstream site don't response.
665 NoMethodError when uri latest_versionstring method isn't implemented.
666
667 Returns a dictonary with version, type and datetime.
668 Type can be A for Automatic, M for Manual and U for Unknown.
669 """
670 from bb.fetch2 import decodeurl
671 from datetime import datetime
672
673 ru = {}
674 ru['version'] = ''
675 ru['type'] = 'U'
676 ru['datetime'] = ''
677
678 # XXX: we suppose that the first entry points to the upstream sources
679 src_uri = rd.getVar('SRC_URI', True).split()[0]
680 uri_type, _, _, _, _, _ = decodeurl(src_uri)
681
682 pv = rd.getVar('PV', True)
683
684 manual_upstream_version = rd.getVar("RECIPE_UPSTREAM_VERSION", True)
685 if manual_upstream_version:
686 # manual tracking of upstream version.
687 ru['version'] = manual_upstream_version
688 ru['type'] = 'M'
689
690 manual_upstream_date = rd.getVar("CHECK_DATE", True)
691 if manual_upstream_date:
692 date = datetime.strptime(manual_upstream_date, "%b %d, %Y")
693 else:
694 date = datetime.now()
695 ru['datetime'] = date
696
697 elif uri_type == "file":
698 # files are always up-to-date
699 ru['version'] = pv
700 ru['type'] = 'A'
701 ru['datetime'] = datetime.now()
702 else:
703 ud = bb.fetch2.FetchData(src_uri, rd)
704 pupver = ud.method.latest_versionstring(ud, rd)
705
706 if uri_type == 'git':
707 (pv, pfx, sfx) = get_recipe_pv_without_srcpv(rd, uri_type)
708
709 latest_revision = ud.method.latest_revision(ud, rd, ud.names[0])
710
711 # if contains revision but not pupver use current pv
712 if pupver == '' and latest_revision:
713 pupver = pv
714
715 if pupver != '':
716 pupver = pfx + pupver + sfx + latest_revision[:10]
717
718 if pupver != '':
719 ru['version'] = pupver
720 ru['type'] = 'A'
721
722 ru['datetime'] = datetime.now()
723
724 return ru