index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2021-11-06 09:50:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-06 09:50:12 +0000 |
commit | d363bad27c047cbefd60c1b93181067df74c6188 (patch) | |
tree | 7c86893ab3776a6806241a74a75052e448c6cad3 /archinstall/lib/installer.py | |
parent | 17fe62c641607cc460e6c6590192ad8de0a21b1a (diff) | |
parent | 129326b93fc58a00d15ed89fe4e701d07b0385bf (diff) |
-rw-r--r-- | archinstall/lib/installer.py | 32 |
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index b400e741..c2c30f7c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1,4 +1,5 @@ import time +from typing import Union import logging import os import shutil @@ -24,6 +25,31 @@ from .exceptions import DiskError, ServiceException, RequirementError, HardwareI __packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "linux-zen", "linux-hardened"] +class InstallationFile: + def __init__(self, installation, filename, owner, mode="w"): + self.installation = installation + self.filename = filename + self.owner = owner + self.mode = mode + self.fh = None + + def __enter__(self): + self.fh = open(self.filename, self.mode) + return self + + def __exit__(self, *args): + self.fh.close() + self.installation.chown(self.owner, self.filename) + + def write(self, data :Union[str, bytes]): + return self.fh.write(data) + + def read(self, *args): + return self.fh.read(*args) + + def poll(self, *args): + return self.fh.poll(*args) + class Installer: """ `Installer()` is the wrapper for most basic installation steps. @@ -658,6 +684,12 @@ class Installer: SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"") + def chown(self, owner, path, options=[]): + return SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c 'chown {' '.join(options)} {owner} {path}") + + def create_file(self, filename, owner=None): + return InstallationFile(self, filename, owner) + def set_keyboard_language(self, language: str) -> bool: if len(language.strip()): if not verify_keyboard_layout(language): |