[debian] fix: hanging when packages require manual configuration (install/upgrade)

This commit is contained in:
Vinicius Moreira
2022-04-12 17:23:38 -03:00
parent e40fe27bd1
commit 6937be8cb9
3 changed files with 19 additions and 10 deletions

View File

@@ -71,7 +71,7 @@ class SimpleProcess:
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: Optional[str] = DEFAULT_LANG, root_password: Optional[str] = None,
extra_paths: Set[str] = None, error_phrases: Set[str] = None, wrong_error_phrases: Set[str] = None,
shell: bool = False, success_phrases: Set[str] = None, extra_env: Optional[Dict[str, str]] = None,
custom_user: Optional[str] = None):
custom_user: Optional[str] = None, preserve_env: Optional[Set] = None):
pwdin, final_cmd = None, []
self.shell = shell
@@ -80,6 +80,11 @@ class SimpleProcess:
final_cmd.extend(['runuser', '-u', custom_user, '--'])
elif isinstance(root_password, str):
final_cmd.extend(['sudo', '-S'])
if preserve_env:
for var in preserve_env:
final_cmd.append(f'--preserve-env={var}')
pwdin = self._new(['echo', root_password], cwd, global_interpreter, lang).stdout
final_cmd.extend(cmd)