Skip to content

Commit 196d4a1

Browse files
committed
Added add_custom_mirrors(). The function appends custom mirrors to /etc/pacman.conf
1 parent 5b0f4f9 commit 196d4a1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

archinstall/lib/mirrors.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ def filter_mirrors_by_region(regions, *args, **kwargs):
1818

1919
return True
2020

21+
def add_custom_mirrors(mirrors:list, *args, **kwargs):
22+
"""
23+
This will append custom mirror definitions in pacman.conf
24+
25+
:param mirrors: A list of mirror data according to: `{'url': 'http://url.com', 'signcheck': 'Optional', 'signoptions': 'TrustAll', 'name': 'testmirror'}`
26+
:type mirrors: dict
27+
"""
28+
with open('/etc/pacman.conf', 'a') as pacman:
29+
for mirror in mirrors:
30+
pacman.write(f"[{mirror['name']}]\n")
31+
pacman.write(f"SigLevel = {mirror['signcheck']} {mirror['signoptions']}\n")
32+
pacman.write(f"Server = {mirror['url']}\n")
33+
34+
return True
35+
2136
def insert_mirrors(mirrors, *args, **kwargs):
2237
"""
2338
This function will insert a given mirror-list at the top of `/etc/pacman.d/mirrorlist`.

0 commit comments

Comments
 (0)