fix: not accepting blank root passwords

This commit is contained in:
Vinicius Moreira
2022-02-28 11:25:41 -03:00
parent 8a0609de06
commit ff9d3be65b
22 changed files with 126 additions and 120 deletions

View File

@@ -146,7 +146,7 @@ def map_installed(names: Iterable[str] = None) -> dict: # returns a dict with w
return pkgs
def install_as_process(pkgpaths: Iterable[str], root_password: str, file: bool, pkgdir: str = '.',
def install_as_process(pkgpaths: Iterable[str], root_password: Optional[str], file: bool, pkgdir: str = '.',
overwrite_conflicting_files: bool = False, simulate: bool = False, as_deps: bool = False) -> SimpleProcess:
cmd = ['pacman', '-U'] if file else ['pacman', '-S']
cmd.extend(pkgpaths)
@@ -211,11 +211,11 @@ def verify_pgp_key(key: str) -> bool:
return False
def receive_key(key: str, root_password: str) -> SystemProcess:
def receive_key(key: str, root_password: Optional[str]) -> SystemProcess:
return SystemProcess(new_root_subprocess(['pacman-key', '-r', key], root_password=root_password), check_error_output=False)
def sign_key(key: str, root_password: str) -> SystemProcess:
def sign_key(key: str, root_password: Optional[str]) -> SystemProcess:
return SystemProcess(new_root_subprocess(['pacman-key', '--lsign-key', key], root_password=root_password), check_error_output=False)
@@ -361,7 +361,7 @@ def read_dependencies(name: str) -> Set[str]:
return depends_on
def sync_databases(root_password: str, force: bool = False) -> SimpleProcess:
def sync_databases(root_password: Optional[str], force: bool = False) -> SimpleProcess:
return SimpleProcess(cmd=['pacman', '-Sy{}'.format('y' if force else '')],
root_password=root_password)
@@ -469,15 +469,15 @@ def can_refresh_mirrors() -> bool:
return is_mirrors_available()
def refresh_mirrors(root_password: str) -> SimpleProcess:
def refresh_mirrors(root_password: Optional[str]) -> SimpleProcess:
return SimpleProcess(cmd=['pacman-mirrors', '-g'], root_password=root_password)
def update_mirrors(root_password: str, countries: List[str]) -> SimpleProcess:
def update_mirrors(root_password: Optional[str], countries: List[str]) -> SimpleProcess:
return SimpleProcess(cmd=['pacman-mirrors', '-c', ','.join(countries)], root_password=root_password)
def sort_fastest_mirrors(root_password: str, limit: int) -> SimpleProcess:
def sort_fastest_mirrors(root_password: Optional[str], limit: int) -> SimpleProcess:
cmd = ['pacman-mirrors', '--fasttrack']
if limit > 0:
@@ -529,7 +529,7 @@ def get_installed_size(pkgs: List[str]) -> Dict[str, int]: # bytes
return {}
def upgrade_system(root_password: str) -> SimpleProcess:
def upgrade_system(root_password: Optional[str]) -> SimpleProcess:
return SimpleProcess(cmd=['pacman', '-Syyu', '--noconfirm'], root_password=root_password)
@@ -717,7 +717,7 @@ def map_updates_data(pkgs: Iterable[str], files: bool = False) -> dict:
return res
def upgrade_several(pkgnames: Iterable[str], root_password: str, overwrite_conflicting_files: bool = False, skip_dependency_checks: bool = False) -> SimpleProcess:
def upgrade_several(pkgnames: Iterable[str], root_password: Optional[str], overwrite_conflicting_files: bool = False, skip_dependency_checks: bool = False) -> SimpleProcess:
cmd = ['pacman', '-S', *pkgnames, '--noconfirm']
if overwrite_conflicting_files:
@@ -732,14 +732,14 @@ def upgrade_several(pkgnames: Iterable[str], root_password: str, overwrite_confl
shell=True)
def download(root_password: str, *pkgnames: str) -> SimpleProcess:
def download(root_password: Optional[str], *pkgnames: str) -> SimpleProcess:
return SimpleProcess(cmd=['pacman', '-Swdd', *pkgnames, '--noconfirm', '--noprogressbar'],
root_password=root_password,
error_phrases={'error: failed to prepare transaction', 'error: failed to commit transaction', 'error: target not found'},
shell=True)
def remove_several(pkgnames: Iterable[str], root_password: str, skip_checks: bool = False) -> SimpleProcess:
def remove_several(pkgnames: Iterable[str], root_password: Optional[str], skip_checks: bool = False) -> SimpleProcess:
cmd = ['pacman', '-R', *pkgnames, '--noconfirm']
if skip_checks: