From 20fae5a2adfe7b95a520f4a953c1c8864f934d93 Mon Sep 17 00:00:00 2001 From: Andre Rosa Date: Tue, 9 Apr 2019 13:25:00 -0700 Subject: [PATCH] Use the index v4 to query for active ROS and ROS 2 --- superflore/generators/bitbake/run.py | 5 ++--- superflore/generators/ebuild/gen_packages.py | 4 ++-- superflore/generators/ebuild/run.py | 5 ++--- superflore/rosdep_support.py | 5 +++++ superflore/test_integration/gentoo/main.py | 4 ++-- superflore/utils.py | 20 +++++++++++++------- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/superflore/generators/bitbake/run.py b/superflore/generators/bitbake/run.py index a0db4899..b0572c59 100644 --- a/superflore/generators/bitbake/run.py +++ b/superflore/generators/bitbake/run.py @@ -23,16 +23,15 @@ from superflore.parser import get_parser from superflore.repo_instance import RepoInstance from superflore.TempfileManager import TempfileManager -from superflore.utils import active_distros from superflore.utils import clean_up from superflore.utils import err from superflore.utils import file_pr from superflore.utils import gen_delta_msg from superflore.utils import gen_missing_deps_msg +from superflore.utils import get_distros_by_status from superflore.utils import info from superflore.utils import load_pr from superflore.utils import ok -from superflore.utils import ros2_distros from superflore.utils import save_pr from superflore.utils import url_to_repo_org from superflore.utils import warn @@ -73,7 +72,7 @@ def main(): selected_targets = [args.ros_distro] preserve_existing = False if not selected_targets: - selected_targets = active_distros + ros2_distros + selected_targets = get_distros_by_status('active') repo_org = 'allenh1' repo_name = 'meta-ros' if args.upstream_repo: diff --git a/superflore/generators/ebuild/gen_packages.py b/superflore/generators/ebuild/gen_packages.py index 75df5cb2..d50c342d 100644 --- a/superflore/generators/ebuild/gen_packages.py +++ b/superflore/generators/ebuild/gen_packages.py @@ -25,10 +25,10 @@ from superflore.generators.ebuild.metadata_xml import metadata_xml from superflore.PackageMetadata import PackageMetadata from superflore.utils import err +from superflore.utils import get_distros from superflore.utils import get_pkg_version from superflore.utils import make_dir from superflore.utils import ok -from superflore.utils import ros2_distros from superflore.utils import warn # TODO(allenh1): This is a blacklist of things that @@ -49,7 +49,7 @@ def regenerate_pkg(overlay, pkg, distro, preserve_existing=False): ebuild_name = overlay.repo.repo_dir + ebuild_name patch_path = '/ros-{}/{}/files'.format(distro.name, pkg) patch_path = overlay.repo.repo_dir + patch_path - is_ros2 = distro.name in ros2_distros + is_ros2 = get_distros()[distro.name].distribution_type == 'ros2' has_patches = os.path.exists(patch_path) pkg_names = get_package_names(distro)[0] patches = None diff --git a/superflore/generators/ebuild/run.py b/superflore/generators/ebuild/run.py index f84a162f..a24da0ad 100644 --- a/superflore/generators/ebuild/run.py +++ b/superflore/generators/ebuild/run.py @@ -22,16 +22,15 @@ from superflore.parser import get_parser from superflore.repo_instance import RepoInstance from superflore.TempfileManager import TempfileManager -from superflore.utils import active_distros from superflore.utils import clean_up from superflore.utils import err from superflore.utils import file_pr from superflore.utils import gen_delta_msg from superflore.utils import gen_missing_deps_msg +from superflore.utils import get_distros_by_status from superflore.utils import info from superflore.utils import load_pr from superflore.utils import ok -from superflore.utils import ros2_distros from superflore.utils import save_pr from superflore.utils import url_to_repo_org from superflore.utils import warn @@ -67,7 +66,7 @@ def main(): selected_targets = [args.ros_distro] preserve_existing = False if not selected_targets: - selected_targets = active_distros + ros2_distros + selected_targets = get_distros_by_status('active') repo_org = 'ros' repo_name = 'ros-overlay' if args.upstream_repo: diff --git a/superflore/rosdep_support.py b/superflore/rosdep_support.py index 6c3e4381..5ab8f1e2 100644 --- a/superflore/rosdep_support.py +++ b/superflore/rosdep_support.py @@ -33,12 +33,17 @@ from rosdep2 import create_default_installer_context from rosdep2.catkin_support import get_catkin_view from rosdep2.lookup import ResolutionError +from rosdep2.rosdistrohelper import get_index from superflore.exceptions import UnresolvedDependency DEFAULT_ROS_DISTRO = 'indigo' view_cache = {} +def get_cached_index(): + return get_index() + + def get_view(os_name, os_version, ros_distro): global view_cache key = os_name + os_version + ros_distro diff --git a/superflore/test_integration/gentoo/main.py b/superflore/test_integration/gentoo/main.py index bcc8933e..f27ea18f 100644 --- a/superflore/test_integration/gentoo/main.py +++ b/superflore/test_integration/gentoo/main.py @@ -16,7 +16,7 @@ import sys from superflore.test_integration.gentoo.build_base import GentooBuilder -from superflore.utils import active_distros +from superflore.utils import get_distros_by_status import yaml @@ -30,7 +30,7 @@ def main(): help='distro(s) to check', type=str, nargs="+", - default=active_distros, + default=get_distros_by_status('active'), ) parser.add_argument( '--pkgs', diff --git a/superflore/utils.py b/superflore/utils.py index 879ab541..a321ee29 100644 --- a/superflore/utils.py +++ b/superflore/utils.py @@ -22,15 +22,9 @@ from superflore.exceptions import UnknownLicense from superflore.exceptions import UnknownPlatform -from superflore.rosdep_support import resolve_rosdep_key +from superflore.rosdep_support import get_cached_index, resolve_rosdep_key from termcolor import colored -# Modify if a new distro is added -# TODO(nuclearsandwich) use the index v4 to query for active ROS and ROS 2 -# distributions. -active_distros = ['indigo', 'kinetic', 'lunar', 'melodic'] -ros2_distros = ['ardent', 'bouncy', 'crystal', 'dashing'] - def warn(string): # pragma: no cover print(colored('>>>> {0}'.format(string), 'yellow')) @@ -219,6 +213,18 @@ def resolve_dep(pkg, os): raise UnknownPlatform(msg) +def get_distros(): + index = get_cached_index() + return index.distributions + + +def get_distros_by_status(status='active'): + distros = get_distros() + distros_by_status = [d for d in distros.keys( + ) if distros[d].get('distribution_status') == status] + return distros_by_status + + def _resolve_dep_open_embedded(pkg): """ TODO(allenh1): integrate rosdep