Skip to content

Commit

Permalink
[update] Allow to process single ROS distro, fix 723 (#738)
Browse files Browse the repository at this point in the history
* [update] skip other distro if --rosdistro passed

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>

* ignore argument if specified distro doesnt exist

* address review comments

* update help message for rosdistro

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
  • Loading branch information
mikaelarguedas authored and wjwwood committed Jan 24, 2020
1 parent edb89c4 commit 2977726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def setup_environment_variables(ros_distro):
"""
Set environment variables needed to find ROS packages and evaluate conditional dependencies.
:param rosdistro: The requested ROS distro passed on the CLI, or None
:param ros_distro: The requested ROS distro passed on the CLI, or None
"""
if ros_distro is not None:
if 'ROS_DISTRO' in os.environ and os.environ['ROS_DISTRO'] != ros_distro:
Expand Down Expand Up @@ -355,7 +355,9 @@ def _rosdep_main(args):
parser.add_option('--rosdistro', dest='ros_distro', default=None,
help='Explicitly sets the ROS distro to use, overriding '
'the normal method of detecting the ROS distro '
'using the ROS_DISTRO environment variable.')
'using the ROS_DISTRO environment variable. '
"When used with the 'update' verb, "
'only the specified distro will be updated.')
parser.add_option('--as-root', default=[], action='append',
metavar='INSTALLER_KEY:<bool>', help='Override '
'whether sudo is used for a specific installer, '
Expand Down Expand Up @@ -643,14 +645,18 @@ def update_error_handler(data_source, exc):
pass
update_sources_list(success_handler=update_success_handler,
error_handler=update_error_handler,
skip_eol_distros=not options.include_eol_distros)
skip_eol_distros=not options.include_eol_distros,
ros_distro=options.ros_distro)
print('updated cache in %s' % (sources_cache_dir))
except InvalidData as e:
print('ERROR: invalid sources list file:\n\t%s' % (e), file=sys.stderr)
return 1
except IOError as e:
print('ERROR: error loading sources list:\n\t%s' % (e), file=sys.stderr)
return 1
except ValueError as e:
print('ERROR: invalid argument value provided:\n\t%s' % (e), file=sys.stderr)
return 1
if error_occured:
print('ERROR: Not all sources were able to be updated.\n[[[')
for e in error_occured:
Expand Down
19 changes: 14 additions & 5 deletions src/rosdep2/sources_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _generate_key_from_urls(urls):

def update_sources_list(sources_list_dir=None, sources_cache_dir=None,
success_handler=None, error_handler=None,
skip_eol_distros=False):
skip_eol_distros=False, ros_distro=None):
"""
Re-downloaded data from remote sources and store in cache. Also
update the cache index based on current sources.
Expand Down Expand Up @@ -487,12 +487,21 @@ def update_sources_list(sources_list_dir=None, sources_cache_dir=None,
python_versions = {}

print('Query rosdistro index %s' % get_index_url())
for dist_name in sorted(get_index().distributions.keys()):
distribution_names = get_index().distributions.keys()
if ros_distro is not None and ros_distro not in distribution_names:
raise ValueError(
'Requested distribution "%s" is not in the index.' % ros_distro)

for dist_name in sorted(distribution_names):
distribution = get_index().distributions[dist_name]
if skip_eol_distros:
if distribution.get('distribution_status') == 'end-of-life':
print('Skip end-of-life distro "%s"' % dist_name)
if dist_name != ros_distro:
if ros_distro is not None:
print('Skip distro "%s" different from requested "%s"' % (dist_name, ros_distro))
continue
if skip_eol_distros:
if distribution.get('distribution_status') == 'end-of-life':
print('Skip end-of-life distro "%s"' % dist_name)
continue
print('Add distro "%s"' % dist_name)
rds = RosDistroSource(dist_name)
rosdep_data = get_gbprepo_as_rosdep_data(dist_name)
Expand Down

0 comments on commit 2977726

Please sign in to comment.