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

Arch Linux: Properly invoke pacman with the correct flags. #472

Merged
Merged
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
20 changes: 14 additions & 6 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 @@ -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)]
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