From d724f04358b0dd97caeca53831339a80e2dc2f6c Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Tue, 6 Sep 2016 10:30:06 +0200 Subject: [PATCH] Properly invoke pacman with the correct flags. --- src/rosdep2/platforms/arch.py | 20 ++++++++++++++------ test/test_rosdep_arch.py | 6 ++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/rosdep2/platforms/arch.py b/src/rosdep2/platforms/arch.py index 8fad48bc8..1e4135053 100644 --- a/src/rosdep2/platforms/arch.py +++ b/src/rosdep2/platforms/arch.py @@ -38,14 +38,14 @@ def register_installers(context): context.set_installer(PACMAN_INSTALLER, PacmanInstaller()) - + def register_platforms(context): context.add_os_installer_key(ARCH_OS_NAME, SOURCE_INSTALLER) context.add_os_installer_key(ARCH_OS_NAME, PACMAN_INSTALLER) context.set_default_os_installer_key(ARCH_OS_NAME, lambda self: PACMAN_INSTALLER) def pacman_detect_single(p): - return not subprocess.call(['pacman', '-Q', p], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + return not subprocess.call(['pacman', '-Q', p], stdout=subprocess.PIPE, stderr=subprocess.PIPE) def pacman_detect(packages): return [p for p in packages if pacman_detect_single(p)] @@ -56,9 +56,17 @@ def __init__(self): super(PacmanInstaller, self).__init__(pacman_detect) def get_install_command(self, resolved, interactive=True, reinstall=False, quiet=False): - #TODO: interactive switch - packages = self.get_packages_to_install(resolved, reinstall=reinstall) + packages = self.get_packages_to_install(resolved, reinstall=reinstall) if not packages: return [] - else: - return [self.elevate_priv(['pacman', '-Sy', '--needed', p]) for p in packages] + + command = ['pacman', '-S'] + + if not interactive: + command.append('--noconfirm') + if not reinstall: + command.append('--needed') + if quiet: + command.append('-q') + + return [self.elevate_priv(command + packages)] diff --git a/test/test_rosdep_arch.py b/test/test_rosdep_arch.py index a4bebe2c5..98adf338a 100644 --- a/test/test_rosdep_arch.py +++ b/test/test_rosdep_arch.py @@ -46,12 +46,10 @@ def test(mock_method): # no interactive option implemented yet mock_method.return_value = ['a', 'b'] - expected = [['sudo', '-H', 'pacman', '-Sy', '--needed', 'a'], - ['sudo', '-H', 'pacman', '-Sy', '--needed', 'b']] + expected = [['sudo', '-H', 'pacman', '-S', '--noconfirm', '--needed', 'a', 'b']] val = installer.get_install_command(['whatever'], interactive=False) assert val == expected, val - expected = [['sudo', '-H', 'pacman', '-Sy', '--needed', 'a'], - ['sudo', '-H', 'pacman', '-Sy', '--needed', 'b']] + expected = [['sudo', '-H', 'pacman', '-S', '--needed', 'a', 'b']] val = installer.get_install_command(['whatever'], interactive=True) assert val == expected, val try: