Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-11-01 10:42:04 +0000
committerAnton Hvornum <anton.feeds@gmail.com>2021-11-01 10:42:04 +0000
commit0d691fc487e561de93033d4e537f42a4e4c91a13 (patch)
tree9629a38f44556e945e240066344bd50b9b02db01 /archinstall
parentb8808491937a6140c9b4df00b4f27ef0405344a4 (diff)
Added a wrapper to create files inside the installation as/for a specified used
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/installer.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 0bdddb2e..bf892826 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -14,6 +14,18 @@ from .exceptions import DiskError, ServiceException
__packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "linux-zen", "linux-hardened"]
+class InstallationFile:
+ def __init__(self, installation, filename, owner):
+ self.installation = installation
+ self.filename = filename
+ self.owner = owner
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self):
+ self.installation.chown(owner, self.filename)
+
class Installer:
"""
`Installer()` is the wrapper for most basic installation steps.
@@ -623,6 +635,12 @@ class Installer:
o = b''.join(SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\""))
pass
+ 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):