From 2a44ac1add0338cd7ff012cda96bf113c9a01bd6 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Fri, 11 Aug 2017 12:45:15 +0300 Subject: distrodata.bbclass: add UPSTREAM_VERSION_UNKNOWN and UPSTREAM_CHECK_UNRELIABLE These are optional per-recipe variables with the following meaning: UPSTREAM_VERSION_UNKNOWN - set if the upstream version check fails reliably, e.g. absent git tags, or weird version format used on our or on upstream side. If this variable is not set and version check fails, or if it is set and the version check succeeds, then the checkpkg selftest for the recipe will fail. UPSTREAM_CHECK_UNRELIABLE - set if the upstream check cannot be reliably performed due to transient network failures, or server behaving weirdly. This one should be used sparingly, as it completely excludes a recipe from upstream checking, and thus we don't get automatically notified about new upstream releases. Also the upstream status string in the checkpkg csv output is clarified with the following possible values: MATCH - recipe is providing the latest upstream version UPDATE - there is a new version released by upstream, recipe should be updated CHECK_IS_UNRELIABLE - an upstream check was skipped as requested by recipe via UPSTREAM_CHECK_UNRELIABLE UNKNOWN - upstream version check was performed, but the upstream verison could not be determined. The recipe acknowledges this via UPSTREAM_VERSION_UNKNOWN setting. UNKNWON_BROKEN - same as previous, but the recipe does not include the acknowledgement and should be fixed. KNOWN_BROKEN - upstream check worked, but recipe claims it shouldn't; to fix this remove UPSTREAM_VERSION_UNKNOWN from recipe. [YOCTO #11896] Signed-off-by: Alexander Kanavin Signed-off-by: Richard Purdie --- meta/classes/distrodata.bbclass | 73 ++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 34 deletions(-) (limited to 'meta/classes/distrodata.bbclass') diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass index 5e34441610..c85f7b3474 100644 --- a/meta/classes/distrodata.bbclass +++ b/meta/classes/distrodata.bbclass @@ -261,12 +261,44 @@ python do_checkpkg() { from bb.utils import vercmp_string from bb.fetch2 import FetchError, NoMethodError, decodeurl - """first check whether a uri is provided""" - src_uri = (d.getVar('SRC_URI') or '').split() - if src_uri: - uri_type, _, _, _, _, _ = decodeurl(src_uri[0]) - else: - uri_type = "none" + def get_upstream_version_and_status(): + + # set if the upstream check fails reliably, e.g. absent git tags, or weird version format used on our or on upstream side. + upstream_version_unknown = localdata.getVar('UPSTREAM_VERSION_UNKNOWN') + # set if the upstream check cannot be reliably performed due to transient network failures, or server behaving weirdly. + # This one should be used sparingly, as it completely excludes a recipe from upstream checking. + upstream_check_unreliable = localdata.getVar('UPSTREAM_CHECK_UNRELIABLE') + + if upstream_check_unreliable == "1": + return "N/A", "CHECK_IS_UNRELIABLE" + + try: + uv = oe.recipeutils.get_recipe_upstream_version(localdata) + pupver = uv['version'] if uv['version'] else "N/A" + except Exception as e: + pupver = "N/A" + + if pupver == "N/A": + pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" + else: + src_uri = (localdata.getVar('SRC_URI') or '').split() + if src_uri: + uri_type, _, _, _, _, _ = decodeurl(src_uri[0]) + else: + uri_type = "none" + pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type) + upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type) + + cmp = vercmp_string(pv, upv) + if cmp == -1: + pstatus = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN" + elif cmp == 0: + pstatus = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN" + else: + pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN" + + return pupver, pstatus + """initialize log files.""" logpath = d.getVar('LOG_DIR') @@ -313,34 +345,7 @@ python do_checkpkg() { psrcuri = localdata.getVar('SRC_URI') maintainer = localdata.getVar('RECIPE_MAINTAINER') - """ Get upstream version version """ - pupver = "" - pstatus = "" - - try: - uv = oe.recipeutils.get_recipe_upstream_version(localdata) - - pupver = uv['version'] - except Exception as e: - if e is FetchError: - pstatus = "ErrAccess" - elif e is NoMethodError: - pstatus = "ErrUnsupportedProto" - else: - pstatus = "ErrUnknown" - - """Set upstream version status""" - if not pupver: - pupver = "N/A" - else: - pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type) - upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type) - - cmp = vercmp_string(pv, upv) - if cmp == -1: - pstatus = "UPDATE" - elif cmp == 0: - pstatus = "MATCH" + pupver, pstatus = get_upstream_version_and_status() if psrcuri: psrcuri = psrcuri.split()[0] -- cgit 1.2.3-korg