Imported Debian patch 4.8.10-2

This commit is contained in:
Timo Aaltonen
2020-11-23 20:48:56 +02:00
committed by Mario Fetka
parent 8bc559c5a1
commit 358acdd85f
917 changed files with 1185414 additions and 1069733 deletions

View File

@@ -81,7 +81,7 @@ As a result, you can redirect the advice's output directly to a script file.
DEFAULT_INDENTATION_INCREMENT = 2
class _IndentationTracker(object):
class _IndentationTracker:
"""
A simple wrapper that tracks the indentation level of the generated bash
commands
@@ -130,7 +130,7 @@ class _IndentationTracker(object):
self._recompute_indentation_level()
class CompoundStatement(object):
class CompoundStatement:
"""
Wrapper around indented blocks of Bash statements.
@@ -221,12 +221,13 @@ class ForLoop(CompoundStatement):
self.advice_output.command('done')
class _AdviceOutput(object):
class _AdviceOutput:
def __init__(self):
self.content = []
self.prefix = '# '
self.options = None
self.pkgmgr_detected = False
self._indentation_tracker = _IndentationTracker(
spaces_per_indent=DEFAULT_INDENTATION_INCREMENT)
@@ -312,6 +313,41 @@ class _AdviceOutput(object):
self.command('exit 1')
def detect_pkgmgr(self):
self.commands_on_predicate(
'which yum >/dev/null',
commands_to_run_when_true=['PKGMGR=yum'],
commands_to_run_when_false=['PKGMGR=dnf']
)
self.pkgmgr_detected = True
def install_packages(self, names, error_message_lines):
assert isinstance(names, list)
self.detect_pkgmgr()
self.command('rpm -qi {} > /dev/null'.format(' '.join(names)))
self.commands_on_predicate(
'[ "$?" -ne "0" ]',
['$PKGMGR install -y {}'.format(' '.join(names))]
)
self.exit_on_predicate(
'[ "$?" -ne "0" ]',
error_message_lines
)
def remove_package(self, name, error_message_lines):
# remove only supports one package name
assert ' ' not in name
self.detect_pkgmgr()
self.command('rpm -qi {} > /dev/null'.format(name))
self.commands_on_predicate(
'[ "$?" -eq "0" ]',
['$PKGMGR remove -y {} || exit 1'.format(name)]
)
self.exit_on_predicate(
'[ "$?" -ne "0" ]',
error_message_lines
)
@contextmanager
def unbranched_if(self, predicate):
with self._compound_statement(UnbranchedIfStatement, predicate):