Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/disk.py1
-rw-r--r--archinstall/lib/installer.py3
-rw-r--r--archinstall/lib/profiles.py53
-rw-r--r--examples/guided.py6
-rw-r--r--profiles/52-54-00-12-34-56.py8
-rw-r--r--profiles/applications/mariadb.py11
-rw-r--r--profiles/applications/nginx.py9
-rw-r--r--profiles/applications/postgresql.py11
8 files changed, 54 insertions, 48 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index ff924f62..49bef1be 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -471,7 +471,6 @@ class Filesystem():
def raw_parted(self, string:str):
x = sys_command(f'/usr/bin/parted -s {string}')
- log(f"'parted -s {string}' returned: {b''.join(x)}", level=logging.DEBUG)
return x
def parted(self, string:str):
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index dbc6d1b4..a7b36481 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -196,6 +196,9 @@ class Installer():
return sys_command(f'/usr/bin/arch-chroot {self.target} {cmd}')
def arch_chroot(self, cmd, *args, **kwargs):
+ if 'runas' in kwargs:
+ cmd = f"su - {kwargs['runas']} -c \"{cmd}\""
+
return self.run_command(cmd)
def drop_to_shell(self):
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index ad5d3bac..06237c1c 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -92,6 +92,9 @@ class Script():
if len(args) >= 2 and args[1]:
raise args[1]
+ if self.original_namespace:
+ self.namespace = self.original_namespace
+
def localize_path(self, profile_path):
if (url := urllib.parse.urlparse(profile_path)).scheme and url.scheme in ('https', 'http'):
if not self.converted_path:
@@ -202,51 +205,14 @@ class Profile(Script):
with open(self.path, 'r') as source:
source_data = source.read()
- # TODO: I imagine that there is probably a better way to write this.
- return 'top_level_profile = True' in source_data
-
- @property
- def packages(self) -> list:
- """
- Returns a list of packages baked into the profile definition.
- If no package definition has been done, .packages() will return None.
- """
- with open(self.path, 'r') as source:
- source_data = source.read()
-
- # Some crude safety checks, make sure the imported profile has
- # a __name__ check before importing.
- #
- # If the requirements are met, import with .py in the namespace to not
- # trigger a traditional:
- # if __name__ == 'moduleName'
- if '__name__' in source_data and '__packages__' in source_data:
- with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
- if hasattr(imported, '__packages__'):
- return imported.__packages__
- return None
-
-
- def has_post_install(self):
- with open(self.path, 'r') as source:
- source_data = source.read()
-
- # Some crude safety checks, make sure the imported profile has
- # a __name__ check and if so, check if it's got a _prep_function()
- # we can call to ask for more user input.
- #
- # If the requirements are met, import with .py in the namespace to not
- # trigger a traditional:
- # if __name__ == 'moduleName'
- if '__name__' in source_data and '_post_install' in source_data:
+ if '__name__' in source_data and 'is_top_level_profile' in source_data:
with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
- if hasattr(imported, '_post_install'):
- return True
+ if hasattr(imported, 'is_top_level_profile'):
+ return imported.is_top_level_profile
- def is_top_level_profile(self):
- with open(self.path, 'r') as source:
- source_data = source.read()
- return 'top_level_profile = True' in source_data
+ # Default to True if nothing is specified,
+ # since developers like less code - omitting it should assume they want to present it.
+ return True
@property
def packages(self) -> list:
@@ -268,7 +234,6 @@ class Profile(Script):
if hasattr(imported, '__packages__'):
return imported.__packages__
return None
-
class Application(Profile):
def __repr__(self, *args, **kwargs):
diff --git a/examples/guided.py b/examples/guided.py
index 2b8a06f5..c281d033 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -136,12 +136,14 @@ def ask_user_questions():
archinstall.log('Using existing partition table reported above.')
elif option == 'format-all':
- archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
+ if not archinstall.arguments.get('filesystem', None):
+ archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
archinstall.arguments['harddrive'].keep_partitions = False
elif archinstall.arguments['harddrive']:
# If the drive doesn't have any partitions, safely mark the disk with keep_partitions = False
# and ask the user for a root filesystem.
- archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
+ if not archinstall.arguments.get('filesystem', None):
+ archinstall.arguments['filesystem'] = archinstall.ask_for_main_filesystem_format()
archinstall.arguments['harddrive'].keep_partitions = False
# Get disk encryption password (or skip if blank)
diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py
index 442e053c..a3347760 100644
--- a/profiles/52-54-00-12-34-56.py
+++ b/profiles/52-54-00-12-34-56.py
@@ -4,6 +4,11 @@ import urllib.request
__packages__ = ['nano', 'wget', 'git']
+if __name__ == '52-54-00-12-34-56':
+ awesome = archinstall.Application(installation, 'postgresql')
+ awesome.install()
+
+"""
# Unmount and close previous runs (Mainly only used for re-runs, but won't hurt.)
archinstall.sys_command(f'umount -R /mnt', suppress_errors=True)
archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_errors=True)
@@ -51,4 +56,5 @@ with archinstall.Filesystem(harddrive) as fs:
try:
urllib.request.urlopen(req, timeout=5)
except:
- pass \ No newline at end of file
+ pass
+""" \ No newline at end of file
diff --git a/profiles/applications/mariadb.py b/profiles/applications/mariadb.py
new file mode 100644
index 00000000..e458a45a
--- /dev/null
+++ b/profiles/applications/mariadb.py
@@ -0,0 +1,11 @@
+import archinstall
+
+# Define the package list in order for lib to source
+# which packages will be installed by this profile
+__packages__ = ["mariadb"]
+
+installation.add_additional_packages(__packages__)
+
+installation.arch_chroot("mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql")
+
+installation.enable_service('mariadb')
diff --git a/profiles/applications/nginx.py b/profiles/applications/nginx.py
new file mode 100644
index 00000000..50eb0506
--- /dev/null
+++ b/profiles/applications/nginx.py
@@ -0,0 +1,9 @@
+import archinstall
+
+# Define the package list in order for lib to source
+# which packages will be installed by this profile
+__packages__ = ["nginx"]
+
+installation.add_additional_packages(__packages__)
+
+installation.enable_service('nginx')
diff --git a/profiles/applications/postgresql.py b/profiles/applications/postgresql.py
new file mode 100644
index 00000000..fcdce824
--- /dev/null
+++ b/profiles/applications/postgresql.py
@@ -0,0 +1,11 @@
+import archinstall
+
+# Define the package list in order for lib to source
+# which packages will be installed by this profile
+__packages__ = ["postgresql"]
+
+installation.add_additional_packages(__packages__)
+
+installation.arch_chroot("initdb -D /var/lib/postgres/data", runas='postgres')
+
+installation.enable_service('postgresql') \ No newline at end of file