From ac7d980f8920b90e213acf95ca87b459eb072f3a Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 08:37:39 -0400 Subject: Add minimal profile and implement idea of 'top-level' profiles --- profiles/awesome.py | 2 ++ profiles/cinnamon.py | 2 ++ profiles/desktop.py | 2 ++ profiles/gnome.py | 2 ++ profiles/i3-gaps.py | 2 ++ profiles/i3-wm.py | 2 ++ profiles/kde.py | 2 ++ profiles/minimal.py | 23 +++++++++++++++++++++++ profiles/xfce4.py | 2 ++ profiles/xorg.py | 2 ++ 10 files changed, 41 insertions(+) create mode 100644 profiles/minimal.py diff --git a/profiles/awesome.py b/profiles/awesome.py index 6b1167bf..0d133962 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -2,6 +2,8 @@ import archinstall +is_top_level_profile = False + # New way of defining packages for a profile, which is iterable and can be used out side # of the profile to get a list of "what packages will be installed". __packages__ = ['nano', 'nemo', 'gpicview-gtk3', 'openssh', 'sshfs', 'htop', 'scrot', 'wget'] diff --git a/profiles/cinnamon.py b/profiles/cinnamon.py index 528158d8..1a796bc7 100644 --- a/profiles/cinnamon.py +++ b/profiles/cinnamon.py @@ -1,6 +1,8 @@ # A desktop environment using "Cinnamon" import archinstall +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/desktop.py b/profiles/desktop.py index b8270881..9f9e7cc2 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -2,6 +2,8 @@ import archinstall, os +is_top_level_profile = True + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/gnome.py b/profiles/gnome.py index b37679de..c75cafee 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -2,6 +2,8 @@ import archinstall +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index 50511dce..e900117a 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -1,5 +1,7 @@ import archinstall, subprocess +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index cd6cbc81..a2449e39 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -1,5 +1,7 @@ import archinstall, subprocess +is_top_level_profile = False + def _prep_function(*args, **kwargs): """ Magic function called by the importing installer diff --git a/profiles/kde.py b/profiles/kde.py index e1449d81..10ef3766 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -2,6 +2,8 @@ import archinstall, os +is_top_level_profile = False + # TODO: Remove hard dependency of bash (due to .bash_profile) def _prep_function(*args, **kwargs): diff --git a/profiles/minimal.py b/profiles/minimal.py new file mode 100644 index 00000000..0e27bdab --- /dev/null +++ b/profiles/minimal.py @@ -0,0 +1,23 @@ +# Used to do a minimal install + +import archinstall, os + +is_top_level_profile = True + +def _prep_function(*args, **kwargs): + """ + Magic function called by the importing installer + before continuing any further. It also avoids executing any + other code in this stage. So it's a safe way to ask the user + for more input before any other installer steps start. + """ + + # Do nothing here for now + +if __name__ == 'minimal': + """ + This "profile" is a meta-profile. + It is used for a custom minimal installation, without any desktop-specific packages. + """ + + # Do nothing here for now diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 36c9958a..c8637eda 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -1,6 +1,8 @@ # A desktop environment using "Xfce4" +is_top_level_profile = False + import archinstall def _prep_function(*args, **kwargs): diff --git a/profiles/xorg.py b/profiles/xorg.py index 1282b8a5..e905d533 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -2,6 +2,8 @@ import archinstall, os +is_top_level_profile = True + AVAILABLE_DRIVERS = { # Sub-dicts are layer-2 options to be selected # and lists are a list of packages to be installed -- cgit v1.2.3-70-g09d2 From f85fb66bc61ee9b90537da59be00b37f49e5ffb8 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 09:12:33 -0400 Subject: Add filtration on top level profile --- archinstall/lib/profiles.py | 8 ++++++++ examples/guided.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 39411553..1948a819 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -177,6 +177,7 @@ class Profile(Script): if hasattr(imported, '_prep_function'): return True return False + def has_post_install(self): with open(self.path, 'r') as source: source_data = source.read() @@ -193,6 +194,13 @@ class Profile(Script): if hasattr(imported, '_post_install'): return True + def is_top_level_profile(self): + 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: """ diff --git a/examples/guided.py b/examples/guided.py index 0a655e8a..a7cc7edc 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,6 +1,7 @@ import getpass, time, json, sys, signal, os import archinstall from archinstall.lib.hardware import hasUEFI +from archinstall.lib.profiles import Profile """ This signal-handler chain (and global variable) @@ -167,7 +168,7 @@ def ask_user_questions(): # Ask for archinstall-specific profiles (such as desktop environments etc) if not archinstall.arguments.get('profile', None): - archinstall.arguments['profile'] = archinstall.select_profile(archinstall.list_profiles()) + archinstall.arguments['profile'] = archinstall.select_profile(filter(lambda profile: (Profile(None, profile).is_top_level_profile()), archinstall.list_profiles())) else: archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['profile']] -- cgit v1.2.3-70-g09d2 From 9756d9ed2daea533930e24a799ff9bf55891c203 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 09:23:21 -0400 Subject: Add i3 selections to desktop file --- archinstall/lib/profiles.py | 3 +-- profiles/desktop.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 1948a819..5f69c8c6 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -196,9 +196,8 @@ class Profile(Script): def is_top_level_profile(self): with open(self.path, 'r') as source: - source_data = source.read() - # TODO: I imagine that there is probably a better way to write this. + source_data = source.read() return 'top_level_profile = True' in source_data @property diff --git a/profiles/desktop.py b/profiles/desktop.py index 9f9e7cc2..389198d6 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -12,7 +12,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - supported_desktops = ['gnome', 'kde', 'awesome', 'xfce4', 'cinnamon'] + supported_desktops = ['gnome', 'kde', 'awesome', 'xfce4', 'cinnamon', 'i3-gaps', 'i3-wm'] desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ') # Temporarily store the selected desktop profile -- cgit v1.2.3-70-g09d2 From 99917807bd926185a8feb38185f0e4b09b3e0738 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 11:33:01 -0400 Subject: Fix issue with prep function --- profiles/minimal.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/profiles/minimal.py b/profiles/minimal.py index 0e27bdab..26a3c75c 100644 --- a/profiles/minimal.py +++ b/profiles/minimal.py @@ -11,13 +11,11 @@ def _prep_function(*args, **kwargs): other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - - # Do nothing here for now + return True # Do nothing here for now if __name__ == 'minimal': """ This "profile" is a meta-profile. It is used for a custom minimal installation, without any desktop-specific packages. """ - # Do nothing here for now -- cgit v1.2.3-70-g09d2 From e7a140248cff32ce89d0470dd6fdd4eee490694d Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 7 Apr 2021 11:52:49 -0400 Subject: Remove TODO line - it's functional and tested to work. --- archinstall/lib/profiles.py | 1 - 1 file changed, 1 deletion(-) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 5f69c8c6..7e76c891 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -196,7 +196,6 @@ class Profile(Script): def is_top_level_profile(self): with open(self.path, 'r') as source: - # TODO: I imagine that there is probably a better way to write this. source_data = source.read() return 'top_level_profile = True' in source_data -- cgit v1.2.3-70-g09d2 From bf91c66ba89121ab062a5c40fdb2249a5522ec8a Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 7 Apr 2021 11:54:10 -0400 Subject: Clean up comments a bit --- profiles/minimal.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/profiles/minimal.py b/profiles/minimal.py index 26a3c75c..79821a89 100644 --- a/profiles/minimal.py +++ b/profiles/minimal.py @@ -7,15 +7,14 @@ is_top_level_profile = True def _prep_function(*args, **kwargs): """ Magic function called by the importing installer - before continuing any further. It also avoids executing any - other code in this stage. So it's a safe way to ask the user - for more input before any other installer steps start. + before continuing any further. For minimal install, + we don't need to do anything special here, but it + needs to exist and return True. """ - return True # Do nothing here for now + return True # Do nothing and just return True if __name__ == 'minimal': """ This "profile" is a meta-profile. It is used for a custom minimal installation, without any desktop-specific packages. """ - # Do nothing here for now -- cgit v1.2.3-70-g09d2 From 2d797e781957ff6edce89adea5980a9429b92e00 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 12:09:11 -0400 Subject: Remove ,newline='\n' so this branch works for testing This change is already merged but add to this branch for testing --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index c99d0017..657a1f8d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -153,7 +153,7 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): -- cgit v1.2.3-70-g09d2