Skip to content

Commit

Permalink
Properly invoke pacman with the correct flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Sep 6, 2016
1 parent 1a80980 commit 529d46f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/rosdep2/platforms/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -57,8 +57,14 @@ def __init__(self):

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)]
6 changes: 2 additions & 4 deletions test/test_rosdep_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 529d46f

Please sign in to comment.