Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Apt install command to install all packages at once #953

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/rosdep2/platforms/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,11 @@ def get_version_strings(self):
return ['apt-get {}'.format(version)]

def _get_install_commands_for_package(self, base_cmd, package_or_list):
def pkg_command(p):
return self.elevate_priv(base_cmd + [p])

if isinstance(package_or_list, list):
return [pkg_command(p) for p in package_or_list]
if isinstance(package_or_list, str):
return self.elevate_priv(base_cmd + [package_or_list])
else:
return pkg_command(package_or_list)
# sort to make the output deterministic
return self.elevate_priv(base_cmd + sorted(package_or_list))

def get_install_command(self, resolved, interactive=True, reinstall=False, quiet=False):
packages = self.get_packages_to_install(resolved, reinstall=reinstall)
Expand All @@ -312,4 +310,9 @@ def get_install_command(self, resolved, interactive=True, reinstall=False, quiet
if quiet:
base_cmd.append('-qq')

return [self._get_install_commands_for_package(base_cmd, p) for p in _iterate_packages(packages, reinstall)]
return [
self._get_install_commands_for_package(
base_cmd,
_iterate_packages(packages, reinstall),
)
]
6 changes: 2 additions & 4 deletions test/test_rosdep_debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,11 @@ def test(expected_prefix, mock_get_packages_to_install, mock_read_stdout):
assert [] == installer.get_install_command(['fake'])

mock_get_packages_to_install.return_value = ['a', 'b']
expected = [expected_prefix + ['apt-get', 'install', '-y', 'a'],
expected_prefix + ['apt-get', 'install', '-y', 'b']]
expected = [expected_prefix + ['apt-get', 'install', '-y', 'a', 'b']]
val = installer.get_install_command(['whatever'], interactive=False)
print('VAL', val)
assert val == expected, val
expected = [expected_prefix + ['apt-get', 'install', 'a'],
expected_prefix + ['apt-get', 'install', 'b']]
expected = [expected_prefix + ['apt-get', 'install', 'a', 'b']]
val = installer.get_install_command(['whatever'], interactive=True)
assert val == expected, val
try:
Expand Down
5 changes: 2 additions & 3 deletions test/test_rosdep_installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ def test_RosdepInstaller_install_resolved(mock_geteuid):
raise
return True
stdout_lines = [x.strip() for x in stdout.getvalue().split('\n') if x.strip()]
assert len(stdout_lines) == 3
assert len(stdout_lines) == 2
assert stdout_lines[0] == '#[apt] Installation commands:'
assert 'sudo -H apt-get install rosdep-fake1' in stdout_lines, 'stdout_lines: %s' % stdout_lines
assert 'sudo -H apt-get install rosdep-fake2' in stdout_lines, 'stdout_lines: %s' % stdout_lines
assert 'sudo -H apt-get install rosdep-fake1 rosdep-fake2' in stdout_lines, 'stdout_lines: %s' % stdout_lines
10 changes: 3 additions & 7 deletions test/test_rosdep_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,11 @@ def read_stdout(cmd, capture_stderr=False):
'--from-paths', catkin_tree
] + cmd_extras)
stdout, stderr = b
# the output is sorted in ascending order
expected = [
'#[apt] Installation commands:',
' sudo -H apt-get install ros-fuerte-catkin',
' sudo -H apt-get install libboost1.40-all-dev',
' sudo -H apt-get install libeigen3-dev',
' sudo -H apt-get install libtinyxml-dev',
' sudo -H apt-get install libltdl-dev',
' sudo -H apt-get install libtool',
' sudo -H apt-get install libcurl4-openssl-dev',
' sudo -H apt-get install libboost1.40-all-dev libcurl4-openssl-dev'
' libeigen3-dev libltdl-dev libtinyxml-dev libtool ros-fuerte-catkin',
]
lines = stdout.getvalue().splitlines()
assert set(lines) == set(expected), lines
Expand Down