Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/mirrors.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/mirrors.py')
-rw-r--r--archinstall/lib/mirrors.py51
1 files changed, 23 insertions, 28 deletions
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py
index 74cdd0aa..61f3c568 100644
--- a/archinstall/lib/mirrors.py
+++ b/archinstall/lib/mirrors.py
@@ -5,7 +5,7 @@ from typing import Dict, Any, List, Optional, TYPE_CHECKING
from .menu import AbstractSubMenu, Selector, MenuSelectionType, Menu, ListManager, TextInput
from .networking import fetch_data_from_url
-from .output import info, warn, FormattedOutput
+from .output import warn, FormattedOutput
from .storage import storage
if TYPE_CHECKING:
@@ -77,6 +77,28 @@ class MirrorConfiguration:
'custom_mirrors': [c.json() for c in self.custom_mirrors]
}
+ def mirrorlist_config(self) -> str:
+ config = ''
+
+ for region, mirrors in self.mirror_regions.items():
+ for mirror in mirrors:
+ config += f'\n\n## {region}\nServer = {mirror}\n'
+
+ for cm in self.custom_mirrors:
+ config += f'\n\n## {cm.name}\nServer = {cm.url}\n'
+
+ return config
+
+ def pacman_config(self) -> str:
+ config = ''
+
+ for mirror in self.custom_mirrors:
+ config += f'\n\n[{mirror.name}]\n'
+ config += f'SigLevel = {mirror.sign_check.value} {mirror.sign_option.value}\n'
+ config += f'Server = {mirror.url}\n'
+
+ return config
+
@classmethod
def parse_args(cls, args: Dict[str, Any]) -> 'MirrorConfiguration':
config = MirrorConfiguration()
@@ -273,33 +295,6 @@ def select_custom_mirror(prompt: str = '', preset: List[CustomMirror] = []):
return custom_mirrors
-def add_custom_mirrors(mirrors: List[CustomMirror]):
- """
- This will append custom mirror definitions in pacman.conf
-
- :param mirrors: A list of custom mirrors
- :type mirrors: List[CustomMirror]
- """
- with open('/etc/pacman.conf', 'a') as pacman:
- for mirror in mirrors:
- pacman.write(f"\n\n[{mirror.name}]\n")
- pacman.write(f"SigLevel = {mirror.sign_check.value} {mirror.sign_option.value}\n")
- pacman.write(f"Server = {mirror.url}\n")
-
-
-def use_mirrors(
- regions: Dict[str, List[str]],
- destination: str = '/etc/pacman.d/mirrorlist'
-):
- with open(destination, 'w') as fp:
- for region, mirrors in regions.items():
- for mirror in mirrors:
- fp.write(f'## {region}\n')
- fp.write(f'Server = {mirror}\n')
-
- info(f'A new package mirror-list has been created: {destination}')
-
-
def _parse_mirror_list(mirrorlist: str) -> Dict[str, List[str]]:
file_content = mirrorlist.split('\n')
file_content = list(filter(lambda x: x, file_content)) # filter out empty lines