Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/installer.py26
-rw-r--r--archinstall/lib/systemd.py40
-rw-r--r--archinstall/lib/user_interaction.py4
3 files changed, 66 insertions, 4 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 775de50a..543f2ca3 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -6,6 +6,7 @@ from .general import *
from .user_interaction import *
from .profiles import Profile
from .mirrors import *
+from .systemd import Networkd
from .output import log, LOG_LEVELS
from .storage import storage
@@ -149,6 +150,24 @@ class Installer():
def arch_chroot(self, cmd, *args, **kwargs):
return self.run_command(cmd)
+ def configure_nic(self, nic, dhcp=True, ip=None, gateway=None, dns=None, *args, **kwargs):
+ if dhcp:
+ conf = Networkd(Match={"Name": nic}, Network={"DHCP": "yes"})
+ else:
+ assert ip
+
+ network = {"Address": ip}
+ if gateway:
+ network["Gateway"] = gateway
+ if dns:
+ assert type(dns) == list
+ network["DNS"] = dns
+
+ conf = Networkd(Match={"Name": nic}, Network=network)
+
+ with open(f"{self.mountpoint}/etc/systemd/network/10-{nic}.network", "a") as netconf:
+ netconf.write(str(conf))
+
def minimal_installation(self):
## Add nessecary packages if encrypting the drive
## (encrypted partitions default to btrfs for now, so we need btrfs-progs)
@@ -273,7 +292,8 @@ class Installer():
pass
def set_keyboard_language(self, language):
- with open(f'{self.mountpoint}/etc/vconsole.conf', 'w') as vconsole:
- vconsole.write(f'KEYMAP={language}\n')
- vconsole.write(f'FONT=lat9w-16\n')
+ if len(language.strip()):
+ with open(f'{self.mountpoint}/etc/vconsole.conf', 'w') as vconsole:
+ vconsole.write(f'KEYMAP={language}\n')
+ vconsole.write(f'FONT=lat9w-16\n')
return True \ No newline at end of file
diff --git a/archinstall/lib/systemd.py b/archinstall/lib/systemd.py
new file mode 100644
index 00000000..edd75098
--- /dev/null
+++ b/archinstall/lib/systemd.py
@@ -0,0 +1,40 @@
+class Ini():
+ def __init__(self, *args, **kwargs):
+ """
+ Limited INI handler for now.
+ Supports multiple keywords through dictionary list items.
+ """
+ self.kwargs = kwargs
+
+ def __str__(self):
+ result = ''
+ first_row_done = False
+ for top_level in self.kwargs:
+ if first_row_done:
+ result += f"\n[{top_level}]\n"
+ else:
+ result += f"[{top_level}]\n"
+ first_row_done = True
+
+ for key, val in self.kwargs[top_level].items():
+ if type(val) == list:
+ for item in val:
+ result += f"{key}={item}\n"
+ else:
+ result += f"{key}={val}\n"
+
+ return result
+
+class Systemd(Ini):
+ def __init__(self, *args, **kwargs):
+ """
+ Placeholder class to do systemd specific setups.
+ """
+ super(Systemd, self).__init__(*args, **kwargs)
+
+class Networkd(Systemd):
+ def __init__(self, *args, **kwargs):
+ """
+ Placeholder class to do systemd-network specific setups.
+ """
+ super(Networkd, self).__init__(*args, **kwargs) \ No newline at end of file
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 29dfaed2..fdbabe96 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -24,7 +24,9 @@ def generic_select(options, input_text="Select one of the above by index or abso
print(f"{index}: {option}")
selected_option = input(input_text)
- if selected_option.isdigit():
+ if len(selected_option.strip()) <= 0:
+ return None
+ elif selected_option.isdigit():
selected_option = options[int(selected_option)]
elif selected_option in options:
pass # We gave a correct absolute value