Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples/only_hd.py
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2022-02-06 11:54:13 +0100
committerGitHub <noreply@github.com>2022-02-06 11:54:13 +0100
commit1ea6fea1d838f3b4646c9e4eebc9ffbdf45f3149 (patch)
treeaa4c7c4df9ec1ce5d46df17b14e2406c87be7ea1 /examples/only_hd.py
parent9fb8d3164ce07e6cd08fe60f2e6f1203ccb8991a (diff)
Flexible menu 2 (#916)
* Correct definition of btrfs standard layout * New version of the FlexibleMenu * Added new functionality to Selector * Created a GeneralMenu class * GlobalMenu is made a child of GeneralMenu * Some refining in GeneralMenu secret is now a general function * log is invoked in GeneralMenu directly * Correction at GeneralMenu * Materialize again _setup_selection_menu_options. Gives more room to play * Callbacks converted as methods Synch() (data area and menu) decoupled from enable() and made general before any run * script swiss added to the patch set * Only_hd gets a new implementation of the menu flake8 corrections * swiss.py description added * New version of the FlexibleMenu * Added new functionality to Selector * Created a GeneralMenu class * GlobalMenu is made a child of GeneralMenu * changes from the rebase left dangling * Modify order of execution between exec_menu and post_processing. Added selector_name as parameter for exec_menu * minor corrections to the scripts * Adapt to PR #874 * Solve issue #936 * make ask_for_a_timezone as synonym to ask_timezone * Adapted to nationalization framework (PR 893). String still NOT adapted * flake8 complains * Use of archinstall.output_config instead of local copy at swiss.py * Problems with the last merge * more flake8 complains. caused by reverted changes re. ask*timezone * git complains Co-authored-by: Anton Hvornum <anton@hvornum.se>
Diffstat (limited to 'examples/only_hd.py')
-rw-r--r--examples/only_hd.py71
1 files changed, 37 insertions, 34 deletions
diff --git a/examples/only_hd.py b/examples/only_hd.py
index 835c4292..cc60a3b9 100644
--- a/examples/only_hd.py
+++ b/examples/only_hd.py
@@ -4,41 +4,41 @@ import pathlib
import archinstall
-def ask_harddrives():
- # Ask which harddrives/block-devices we will install to
- # and convert them into archinstall.BlockDevice() objects.
- if archinstall.arguments.get('harddrives', None) is None:
- archinstall.arguments['harddrives'] = archinstall.generic_multi_select(archinstall.all_disks(),
- text="Select one or more harddrives to use and configure (leave blank to skip this step): ",
- allow_empty=True)
-
- if not archinstall.arguments['harddrives']:
- archinstall.log("You decided to skip harddrive selection",fg="red",level=logging.INFO)
- archinstall.log(f"and will use whatever drive-setup is mounted at {archinstall.storage['MOUNT_POINT']} (experimental)",fg="red",level=logging.INFO)
- archinstall.log("WARNING: Archinstall won't check the suitability of this setup",fg="red",level=logging.INFO)
- if input("Do you wish to continue ? [Y/n]").strip().lower() == 'n':
- exit(1)
- else:
- if archinstall.arguments.get('disk_layouts', None) is None:
- archinstall.arguments['disk_layouts'] = archinstall.select_disk_layout(archinstall.arguments['harddrives'], archinstall.arguments.get('advanced', False))
-
+class OnlyHDMenu(archinstall.GlobalMenu):
+ def _setup_selection_menu_options(self):
+ super()._setup_selection_menu_options()
+ options_list = []
+ mandatory_list = []
+ options_list = ['harddrives', 'disk_layouts', '!encryption-password','swap']
+ mandatory_list = ['harddrives']
+ options_list.extend(['install','abort'])
+
+ for entry in self._menu_options:
+ if entry in options_list:
+ # for not lineal executions, only self.option(entry).set_enabled and set_mandatory are necessary
+ if entry in mandatory_list:
+ self.enable(entry,mandatory=True)
+ else:
+ self.enable(entry)
+ else:
+ self.option(entry).set_enabled(False)
+ self._update_install()
+
+ def _missing_configs(self):
+ """ overloaded method """
+ def check(s):
+ return self.option(s).has_selection()
+
# Get disk encryption password (or skip if blank)
if archinstall.arguments.get('!encryption-password', None) is None:
if passwd := archinstall.get_password(prompt=str(_('Enter disk encryption password (leave blank for no encryption): '))):
archinstall.arguments['!encryption-password'] = passwd
- if archinstall.arguments.get('!encryption-password', None):
- # If no partitions was marked as encrypted, but a password was supplied and we have some disks to format..
- # Then we need to identify which partitions to encrypt. This will default to / (root).
- if len(list(archinstall.encrypted_partitions(archinstall.arguments['disk_layouts']))) == 0:
- archinstall.arguments['disk_layouts'] = archinstall.select_encrypted_partitions(archinstall.arguments['disk_layouts'], archinstall.arguments['!encryption-password'])
-
- # Ask which boot-loader to use (will only ask if we're in BIOS (non-efi) mode)
- if not archinstall.arguments.get("bootloader", None):
- archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader(archinstall.arguments.get('advanced', False))
-
- if not archinstall.arguments.get('swap', None):
- archinstall.arguments['swap'] = archinstall.ask_for_swap()
+ _, missing = self.mandatory_overview()
+ if check('harddrives'):
+ if not self.option('harddrives').is_empty() and not check('disk_layouts'):
+ missing += 1
+ return missing
def ask_user_questions():
"""
@@ -46,7 +46,11 @@ def ask_user_questions():
Not until we're satisfied with what we want to install
will we continue with the actual installation steps.
"""
- ask_harddrives()
+ with OnlyHDMenu(data_store=archinstall.arguments) as menu:
+ # We select the execution language separated
+ menu.exec_option('archinstall-language')
+ menu.option('archinstall-language').set_enabled(False)
+ menu.run()
def perform_disk_operations():
"""
@@ -56,7 +60,6 @@ def perform_disk_operations():
if archinstall.arguments.get('harddrives', None):
print(f" ! Formatting {archinstall.arguments['harddrives']} in ", end='')
archinstall.do_countdown()
-
"""
Setup the blockdevice, filesystem (and optionally encryption).
Once that's done, we'll hand over to perform_installation()
@@ -66,9 +69,9 @@ def perform_disk_operations():
mode = archinstall.MBR
for drive in archinstall.arguments.get('harddrives', []):
- if dl_disk := archinstall.arguments.get('disk_layouts', {}).get(drive.path):
+ if archinstall.arguments.get('disk_layouts', {}).get(drive.path):
with archinstall.Filesystem(drive, mode) as fs:
- fs.load_layout(dl_disk)
+ fs.load_layout(archinstall.arguments['disk_layouts'][drive.path])
def perform_installation(mountpoint):
"""