mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[debian] fix: hanging when packages require manual configuration (install/upgrade)
This commit is contained in:
@@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- uninstall and downgrade logs are not available [#255](https://github.com/vinifmor/bauh/issues/255)
|
- uninstall and downgrade logs are not available [#255](https://github.com/vinifmor/bauh/issues/255)
|
||||||
|
|
||||||
- Debian
|
- Debian
|
||||||
|
- install/upgrade: hanging when packages require manual configuration
|
||||||
- info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251)
|
- info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251)
|
||||||
- displaying wrong symbols among numbers in install/uninstall/upgrade outputs for systems without english encoding installed
|
- displaying wrong symbols among numbers in install/uninstall/upgrade outputs for systems without english encoding installed
|
||||||
- removing unused packages on any type of transaction (this is the default behaviour for aptitude)
|
- removing unused packages on any type of transaction (this is the default behaviour for aptitude)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class SimpleProcess:
|
|||||||
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: Optional[str] = DEFAULT_LANG, root_password: Optional[str] = None,
|
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,
|
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,
|
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, []
|
pwdin, final_cmd = None, []
|
||||||
|
|
||||||
self.shell = shell
|
self.shell = shell
|
||||||
@@ -80,6 +80,11 @@ class SimpleProcess:
|
|||||||
final_cmd.extend(['runuser', '-u', custom_user, '--'])
|
final_cmd.extend(['runuser', '-u', custom_user, '--'])
|
||||||
elif isinstance(root_password, str):
|
elif isinstance(root_password, str):
|
||||||
final_cmd.extend(['sudo', '-S'])
|
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
|
pwdin = self._new(['echo', root_password], cwd, global_interpreter, lang).stdout
|
||||||
|
|
||||||
final_cmd.extend(cmd)
|
final_cmd.extend(cmd)
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ class Aptitude:
|
|||||||
self._default_lang = ''
|
self._default_lang = ''
|
||||||
self._ignored_fields: Optional[Set[str]] = None
|
self._ignored_fields: Optional[Set[str]] = None
|
||||||
self._re_none: Optional[Pattern] = None
|
self._re_none: Optional[Pattern] = None
|
||||||
self._vars_encoding_fix: Optional[Dict[str, str]] = None
|
self._vars_fixes: Optional[Dict[str, str]] = None
|
||||||
|
self._preserve_env = {'DEBIAN_FRONTEND'}
|
||||||
|
|
||||||
def show(self, pkgs: Iterable[str], attrs: Optional[Collection[str]] = None, verbose: bool = False) \
|
def show(self, pkgs: Iterable[str], attrs: Optional[Collection[str]] = None, verbose: bool = False) \
|
||||||
-> Optional[Dict[str, Dict[str, object]]]:
|
-> Optional[Dict[str, Dict[str, object]]]:
|
||||||
@@ -129,7 +130,8 @@ class Aptitude:
|
|||||||
|
|
||||||
def upgrade(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess:
|
def upgrade(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess:
|
||||||
cmd = self.gen_transaction_cmd('upgrade', packages).split(' ')
|
cmd = self.gen_transaction_cmd('upgrade', packages).split(' ')
|
||||||
return SimpleProcess(cmd=cmd, shell=True, root_password=root_password, extra_env=self.vars_encoding_fix)
|
return SimpleProcess(cmd=cmd, shell=True, root_password=root_password, extra_env=self.vars_fixes,
|
||||||
|
preserve_env=self._preserve_env)
|
||||||
|
|
||||||
def update(self, root_password: Optional[str]) -> SimpleProcess:
|
def update(self, root_password: Optional[str]) -> SimpleProcess:
|
||||||
return SimpleProcess(('aptitude', 'update'), root_password=root_password, shell=True)
|
return SimpleProcess(('aptitude', 'update'), root_password=root_password, shell=True)
|
||||||
@@ -143,7 +145,8 @@ class Aptitude:
|
|||||||
|
|
||||||
def install(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess:
|
def install(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess:
|
||||||
cmd = self.gen_transaction_cmd('install', packages).split(' ')
|
cmd = self.gen_transaction_cmd('install', packages).split(' ')
|
||||||
return SimpleProcess(cmd=cmd, shell=True, root_password=root_password, extra_env=self.vars_encoding_fix)
|
return SimpleProcess(cmd=cmd, root_password=root_password, extra_env=self.vars_fixes,
|
||||||
|
preserve_env=self._preserve_env)
|
||||||
|
|
||||||
def read_installed(self) -> Generator[DebianPackage, None, None]:
|
def read_installed(self) -> Generator[DebianPackage, None, None]:
|
||||||
yield from self.search(query='~i')
|
yield from self.search(query='~i')
|
||||||
@@ -200,7 +203,7 @@ class Aptitude:
|
|||||||
|
|
||||||
def remove(self, packages: Iterable[str], root_password: Optional[str], purge: bool = False) -> SimpleProcess:
|
def remove(self, packages: Iterable[str], root_password: Optional[str], purge: bool = False) -> SimpleProcess:
|
||||||
return SimpleProcess(cmd=self.gen_remove_cmd(packages, purge).split(' '), shell=True,
|
return SimpleProcess(cmd=self.gen_remove_cmd(packages, purge).split(' '), shell=True,
|
||||||
root_password=root_password, extra_env=self.vars_encoding_fix)
|
root_password=root_password, extra_env=self.vars_fixes, preserve_env=self._preserve_env)
|
||||||
|
|
||||||
def read_installed_names(self) -> Generator[str, None, None]:
|
def read_installed_names(self) -> Generator[str, None, None]:
|
||||||
code, output = system.execute("aptitude search ~i -q -F '%p' --disable-columns",
|
code, output = system.execute("aptitude search ~i -q -F '%p' --disable-columns",
|
||||||
@@ -279,11 +282,11 @@ class Aptitude:
|
|||||||
return self._re_none
|
return self._re_none
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vars_encoding_fix(self) -> Dict[str, str]:
|
def vars_fixes(self) -> Dict[str, str]:
|
||||||
if self._vars_encoding_fix is None:
|
if self._vars_fixes is None:
|
||||||
self._vars_encoding_fix = {'LC_NUMERIC': ''}
|
self._vars_fixes = {'LC_NUMERIC': '', 'DEBIAN_FRONTEND': 'noninteractive'}
|
||||||
|
|
||||||
return self._vars_encoding_fix
|
return self._vars_fixes
|
||||||
|
|
||||||
|
|
||||||
class AptitudeOutputHandler(Thread):
|
class AptitudeOutputHandler(Thread):
|
||||||
|
|||||||
Reference in New Issue
Block a user