Skip to content

Commit

Permalink
Merge pull request #234 from enen92/master
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee authored May 2, 2020
2 parents 83b7b6a + d598d48 commit 0d1a4a5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 19 deletions.
4 changes: 2 additions & 2 deletions kodi_addon_checker/check_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
check_files, check_addon_branches, check_py3_compatibility,
check_string, check_url, common, handle_files,
schema_validation, ValidKodiVersions)
from .addons.Addon import Addon
from .addons.Repository import Repository
from .versions import KodiVersion
from .record import INFORMATION, Record
Expand Down Expand Up @@ -47,8 +48,7 @@ def start(addon_path, args, all_repo_addons, config=None):
addon_xml = check_files.check_addon_xml(addon_report, addon_path, parsed_xml, args.allow_folder_id_mismatch)

if addon_xml is not None:
check_addon_branches.check_for_existing_addon(addon_report, addon_path, all_repo_addons, args.PR,
KodiVersion(args.branch))
check_addon_branches.check_for_existing_addon(addon_report, Addon(parsed_xml), all_repo_addons, args)

if not addon_xml.findall("*//broken"):
file_index = handle_files.create_file_index(addon_path)
Expand Down
44 changes: 28 additions & 16 deletions kodi_addon_checker/check_addon_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"""

import logging
import os
import xml.etree.ElementTree as ET

from .addons.Addon import Addon
from .check_dependencies import VERSION_ATTRB
from .record import INFORMATION, PROBLEM, Record, WARNING
from .report import Report
Expand All @@ -19,17 +19,22 @@
LOGGER = logging.getLogger(__name__)


def check_for_existing_addon(report: Report, addon_path: str, all_repo_addons: dict, pr: bool,
kodi_version: KodiVersion):
def check_for_existing_addon(report: Report, addon: Addon, all_repo_addons: dict, args):
"""Check if addon submitted already exists or not
:addon_path: path of the addon
:report: the report object
:addon: the Addon object (contains id and version)
:all_repo_addons: dictionary return by all_repo_addon() function
:args: the args object passed to addon-checker
"""

addon_xml = os.path.join(addon_path, "addon.xml")
addon_name, addon_version = _get_addon_name(addon_xml)
# addon details
addon_name = addon.id
addon_version = addon.version
addon_details = {'name': addon_name, 'version': addon_version}

# args
pr = bool(args.PR)
kodi_version = KodiVersion(args.branch)

is_new_addon = True
for branch, repo in sorted(all_repo_addons.items(), reverse=True):

Expand All @@ -41,9 +46,9 @@ def check_for_existing_addon(report: Report, addon_path: str, all_repo_addons: d

# Addon submission must be lower than the versions already available in upper repo branches
# if that branch corresponds to a breaking change (e.g. version of addon in matrix version >
# version of addon in gotham) since xbmc.python is not backwards compatible.
# version of addon in gotham) since there might be dependencies not abi-backward compatible.
elif KodiVersion(branch) > kodi_version and addon_name in repo and \
not _is_pythonabi_compatible(repr(kodi_version), branch):
not _is_xbmcabi_compatible(addon.dependencies, repr(kodi_version), branch):
is_new_addon = False
_check_version_lower(report, addon_details, branch, repo.find(addon_name).version, pr)

Expand All @@ -60,14 +65,20 @@ def _get_addon_name(xml_path: str):
return (tree.get("id"), tree.get("version"))


def _is_pythonabi_compatible(target_branch, upper_branch):
def _is_xbmcabi_compatible(dependencies: list, target_branch: str, upper_branch: str):
"""returns true if the target_branch for this addon is backwards compatible with a
given upper branch. E.g. if kodi isengard python abi is compatible with leia python abi.
given upper branch. E.g. if there are dependencies on the addon that are ABI incompatible
with the migration to an upper kodi version (resulting in the addon being incompatible)
:dependencies: the list of dependencies of the addon
:target_branch: the branch the addon lives in (or is being PR'd to)
: upper_branch: an upper branch that also contains an addon with the same addon id
:upper_branch: an upper branch that also contains an addon with the same addon id
"""
return VERSION_ATTRB['xbmc.python'][upper_branch]["min_compatible"] == \
VERSION_ATTRB['xbmc.python'][target_branch]["min_compatible"]
for dependency in dependencies:
if dependency.id in VERSION_ATTRB.keys():
if AddonVersion(VERSION_ATTRB[dependency.id][upper_branch]["min_compatible"]) > \
AddonVersion(VERSION_ATTRB[dependency.id][target_branch]["min_compatible"]):
return False
return True


def _check_version_higher(report: Report, addon_details, branch, repo_addons_version, pr):
Expand Down Expand Up @@ -117,8 +128,9 @@ def _check_version_lower(report: Report, addon_details, branch, repo_addons_vers
report.add(
Record(
PROBLEM if pr else WARNING,
"%s addon already exists with a lower or equal version: %s in %s branch. Users migrating " \
"to kodi version %s won't be able to receive the addon update"
"%s addon already exists with a lower or equal version: %s in %s branch " \
"and the addon has non forward abi compatible dependencies. Users migrating " \
"to kodi version %s won't be able to receive the addon update."
% (addon_name, repo_addons_version, branch, branch)
)
)
Expand Down
38 changes: 37 additions & 1 deletion kodi_addon_checker/check_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,43 @@
'krypton': {'min_compatible': '2.1.0', 'advised': '2.25.0'},
'leia': {'min_compatible': '2.1.0', 'advised': '2.26.0'},
'matrix': {'min_compatible': '3.0.0', 'advised': '3.0.0'}
}
},
'xbmc.gui': {
'gotham': {'min_compatible': '5.0.0', 'advised': '5.0.0'},
'helix': {'min_compatible': '5.3.0', 'advised': '5.3.0'},
'isengard': {'min_compatible': '5.3.0', 'advised': '5.9.0'},
'jarvis': {'min_compatible': '5.10.0', 'advised': '5.10.0'},
'krypton': {'min_compatible': '5.12.0', 'advised': '5.12.0'},
'leia': {'min_compatible': '5.14.0', 'advised': '5.14.0'},
'matrix': {'min_compatible': '5.14.0', 'advised': '5.15.0'}
},
'xbmc.json': {
'gotham': {'min_compatible': '6.0.0', 'advised': '5.0.0'},
'helix': {'min_compatible': '6.0.0', 'advised': '6.20.0'},
'isengard': {'min_compatible': '6.0.0', 'advised': '6.25.1'},
'jarvis': {'min_compatible': '6.0.0', 'advised': '6.32.4'},
'krypton': {'min_compatible': '6.0.0', 'advised': '7.0.0'},
'leia': {'min_compatible': '6.0.0', 'advised': '9.7.2'},
'matrix': {'min_compatible': '6.0.0', 'advised': '11.2.0'}
},
'xbmc.addon': {
'gotham': {'min_compatible': '12.0.0', 'advised': '13.0.0'},
'helix': {'min_compatible': '12.0.0', 'advised': '14.0.0'},
'isengard': {'min_compatible': '12.0.0', 'advised': '15.0.0'},
'jarvis': {'min_compatible': '12.0.0', 'advised': '16.0.0'},
'krypton': {'min_compatible': '12.0.0', 'advised': '17.0.0'},
'leia': {'min_compatible': '12.0.0', 'advised': '17.9.910'},
'matrix': {'min_compatible': '12.0.0', 'advised': '18.9.701'}
},
'xbmc.metadata': {
'gotham': {'min_compatible': '1.0', 'advised': '2.1.0'},
'helix': {'min_compatible': '1.0', 'advised': '2.1.0'},
'isengard': {'min_compatible': '1.0', 'advised': '2.1.0'},
'jarvis': {'min_compatible': '1.0', 'advised': '2.1.0'},
'krypton': {'min_compatible': '1.0', 'advised': '2.1.0'},
'leia': {'min_compatible': '1.0', 'advised': '2.1.0'},
'matrix': {'min_compatible': '1.0', 'advised': '2.1.0'}
},
}

LOGGER = logging.getLogger(__name__)
Expand Down

0 comments on commit 0d1a4a5

Please sign in to comment.