Cleaned up function calls a bit
This commit is contained in:
parent
6b570b62c2
commit
b3e9505fab
|
|
@ -892,20 +892,22 @@ def mount_mountpoints(drive, bootpartition, mountpoint='/mnt/boot', *positionals
|
|||
return True
|
||||
|
||||
def re_rank_mirrors(top=10, *positionals, **kwargs):
|
||||
if sys_command(('/usr/bin/rankmirrors -n {top} /root/mirrorlist > /etc/pacman.d/mirrorlist')).exit_code == 0:
|
||||
if sys_command(('/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist')).exit_code == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
def filter_mirrors_by_country(countries, top=10, *positionals, **kwargs):
|
||||
def filter_mirrors_by_country_list(countries, top=None, *positionals, **kwargs):
|
||||
## TODO: replace wget with urllib.request (no point in calling syscommand)
|
||||
country_list = []
|
||||
for country in countries.split(','):
|
||||
country_list.append(f'country={country}')
|
||||
o = b''.join(sys_command((f"/usr/bin/wget 'https://www.archlinux.org/mirrorlist/?{'&'.join(country_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' -O /root/mirrorlist")))
|
||||
o = b''.join(sys_command(("/usr/bin/sed -i 's/#Server/Server/' /root/mirrorlist")))
|
||||
o = b''.join(sys_command(("/usr/bin/mv /root/mirrorlist /etc/pacman.d/")))
|
||||
|
||||
if not re_rank_mirrors(top, *positionals, **kwargs) or not os.path.isfile('/etc/pacman.d/mirrorlist'):
|
||||
o = b''.join(sys_command(("/usr/bin/mv /root/mirrorlist /etc/pacman.d/")))
|
||||
if top:
|
||||
re_rank_mirrors(top, *positionals, **kwargs) or not os.path.isfile('/etc/pacman.d/mirrorlist')
|
||||
|
||||
return True
|
||||
|
||||
def strap_in_base(*positionals, **kwargs):
|
||||
|
|
@ -1167,7 +1169,7 @@ if __name__ == '__main__':
|
|||
|
||||
if 'mirrors' in args and args['mirrors'] and 'country' in args and get_default_gateway_linux():
|
||||
print('[N] Reordering mirrors.')
|
||||
filter_mirrors_by_country(args['country'])
|
||||
filter_mirrors_by_country_list([args['country']])
|
||||
|
||||
pre_conf = {}
|
||||
if 'pre' in instructions:
|
||||
|
|
|
|||
Loading…
Reference in New Issue