Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-07-07 22:24:56 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-07-07 22:24:56 +0000
commit3b3456b6f9b3ddd6be5da6a8dad53243f6793c73 (patch)
tree851dc28a9f1f09a9bc695512aa5447d54fe5b8d5
parent0bc24699c1aba583b1d98809321e2f726425f3fe (diff)
Added a raise on sys_command exit code being bad. Also updated readme to show how to test this locally
-rw-r--r--README.md33
-rw-r--r--archinstall/lib/exceptions.py2
-rw-r--r--archinstall/lib/general.py5
3 files changed, 25 insertions, 15 deletions
diff --git a/README.md b/README.md
index b092b2ec..dd66b534 100644
--- a/README.md
+++ b/README.md
@@ -48,22 +48,15 @@ This is probably what you'll need, a [minimal example](examples/main_example.py)
```python
import archinstall, getpass
-# Unmount and close previous runs
-archinstall.sys_command(f'umount -R /mnt', surpress_errors=True)
-archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', surpress_errors=True)
-
# Select a harddrive and a disk password
harddrive = archinstall.select_disk(archinstall.all_disks())
disk_password = getpass.getpass(prompt='Disk password (won\'t echo): ')
with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
- # Use the entire disk instead of setting up partitions on your own
+ # use_entire_disk() is a helper to not have to format manually
fs.use_entire_disk('luks2')
- if harddrive.partition[1].size == '512M':
- raise OSError('Trying to encrypt the boot partition for petes sake..')
harddrive.partition[0].format('fat32')
-
with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device:
unlocked_device.format('btrfs')
@@ -83,15 +76,29 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
This installer will perform the following:
* Prompt the user to select a disk and disk-password
- * Proceed to wipe said disk
- * Sets up a default 100% used disk with encryption
+ * Proceed to wipe the selected disk with a `GPT` partition table.
+ * Sets up a default 100% used disk with encryption.
* Installs a basic instance of Arch Linux *(base base-devel linux linux-firmware btrfs-progs efibootmgr)*
- * Installs and configures a bootloader
+ * Installs and configures a bootloader to partition 0.
* Install additional packages *(nano, wget, git)*
- * Installs a network-profile called `workstation` *(more on network profiles in the docs)*
+ * Installs a network-profile called [workstation](https://github.com/Torxed/archinstall/blob/master/profiles/workstation.json) *(more on network profiles in the docs)*
* Adds AUR support by compiling and installing [yay](https://github.com/Jguer/yay)
-> **Creating your own ISO:** Follow [ArchISO](https://wiki.archlinux.org/index.php/archiso)'s guide on how to create your own ISO or use a pre-built [guided ISO](https://hvornum.se/archiso/) to skip the python installation step, or to create auto-installing ISO templates. Further down are examples and cheat sheets on how to create different live ISO's.
+> **Creating your own ISO with this script on it:** Follow [ArchISO](https://wiki.archlinux.org/index.php/archiso)'s guide on how to create your own ISO or use a pre-built [guided ISO](https://hvornum.se/archiso/) to skip the python installation step, or to create auto-installing ISO templates. Further down are examples and cheat sheets on how to create different live ISO's.
+
+# Testing
+
+To test this, the simplest approach is to use a local image and create a loop device.<br>
+This can be done by installing `pacman -S arch-install-scripts util-linux` locally and do the following:
+
+ # dd if=/dev/zero of=./testimage.img bs=1G count=5
+ # losetup -fP ./testimage.img
+ # losetup -a | grep "testimage.img" | awk -F ":" '{print $1}'
+ # pip install archinstall
+ # python -m archinstall guided
+
+This will create a *5GB* `testimage.img` and create a loop device which we can use to format and install to.<br>
+`archinstall` is installed and executed in [guided mode](#docs-todo).
## End note
diff --git a/archinstall/lib/exceptions.py b/archinstall/lib/exceptions.py
index 9d033147..68ba8750 100644
--- a/archinstall/lib/exceptions.py
+++ b/archinstall/lib/exceptions.py
@@ -3,4 +3,6 @@ class RequirementError(BaseException):
class DiskError(BaseException):
pass
class ProfileError(BaseException):
+ pass
+class SysCallError(BaseException):
pass \ No newline at end of file
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index 88cfc047..31f81413 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -233,8 +233,9 @@ class sys_command():#Thread):
self.exit_code = 0
if self.exit_code != 0 and not self.kwargs['surpress_errors']:
- log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.", origin='spawn', level=3)
- log(self.trace_log.decode('UTF-8'), origin='spawn', level=3)
+ log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.")
+ log(self.trace_log.decode('UTF-8'))
+ raise SysCallError(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.\n{self.trace_log.decode('UTF-8')}")
self.ended = time.time()
with open(f'{self.cwd}/trace.log', 'wb') as fh: