index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2021-05-15 17:49:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 17:49:58 +0000 |
commit | a75dd6ea3a4f961ddfeaff6b4378bd4aac5c3b39 (patch) | |
tree | 7db58a8b4e1c640dc16d0060704f3b304a4e325d /archinstall/lib/mirrors.py | |
parent | 5254ac62200bb279c855d06bea1006b323bfae87 (diff) | |
parent | 5067aaa260d218f7d1d60ada2fe8413e90970060 (diff) |
-rw-r--r-- | archinstall/lib/mirrors.py | 17 |
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index ae6c6422..e53b356a 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -1,9 +1,8 @@ -import urllib.request, logging +import urllib.request -from .exceptions import * from .general import * from .output import log -from .storage import storage + def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', tmp_dir='/root', *args, **kwargs): """ @@ -19,9 +18,10 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', tm o = b''.join(sys_command((f"/usr/bin/wget 'https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' -O {tmp_dir}/mirrorlist"))) o = b''.join(sys_command((f"/usr/bin/sed -i 's/#Server/Server/' {tmp_dir}/mirrorlist"))) o = b''.join(sys_command((f"/usr/bin/mv {tmp_dir}/mirrorlist {destination}"))) - + return True + def add_custom_mirrors(mirrors:list, *args, **kwargs): """ This will append custom mirror definitions in pacman.conf @@ -37,6 +37,7 @@ def add_custom_mirrors(mirrors:list, *args, **kwargs): return True + def insert_mirrors(mirrors, *args, **kwargs): """ This function will insert a given mirror-list at the top of `/etc/pacman.d/mirrorlist`. @@ -58,7 +59,8 @@ def insert_mirrors(mirrors, *args, **kwargs): return True -def use_mirrors(regions :dict, destination='/etc/pacman.d/mirrorlist'): + +def use_mirrors(regions: dict, destination='/etc/pacman.d/mirrorlist'): log(f'A new package mirror-list has been created: {destination}', level=logging.INFO) for region, mirrors in regions.items(): with open(destination, 'w') as mirrorlist: @@ -67,11 +69,13 @@ def use_mirrors(regions :dict, destination='/etc/pacman.d/mirrorlist'): mirrorlist.write(f'Server = {mirror}\n') return True + def re_rank_mirrors(top=10, *positionals, **kwargs): if sys_command((f'/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist')).exit_code == 0: return True return False + def list_mirrors(): url = f"https://archlinux.org/mirrorlist/?protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" regions = {} @@ -82,7 +86,6 @@ def list_mirrors(): log(f'Could not fetch an active mirror-list: {err}', level=logging.WARNING, fg="yellow") return regions - region = 'Unknown region' for line in response.readlines(): if len(line.strip()) == 0: @@ -97,4 +100,4 @@ def list_mirrors(): url = line.lstrip('#Server = ') regions[region][url] = True - return regions
\ No newline at end of file + return regions |