Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2019-04-14 23:20:39 +0200
committerAnton Hvornum <anton.feeds@gmail.com>2019-04-14 23:20:39 +0200
commitd0de593976a913c9b6f1742f5f960c65ca740d7c (patch)
treea294f036dae0eaf94d55b509e44962a37fb67df4 /archinstall.py
parent620db3623ccf5328766656c89d023d89c4c056f6 (diff)
Added support to select --drive=<UUID> and it now maps to a drive. To ensure /dev/sda haven't changed location and the wrong drive gets wiped
Diffstat (limited to 'archinstall.py')
-rw-r--r--archinstall.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/archinstall.py b/archinstall.py
index 734bb6d0..9fb0f22c 100644
--- a/archinstall.py
+++ b/archinstall.py
@@ -224,12 +224,23 @@ def get_drive_from_uuid(uuid):
for drive in harddrives:
#for partition in psutil.disk_partitions('/dev/{}'.format(name)):
# pass #blkid -s PARTUUID -o value /dev/sda2
- o = simple_command('blkid -s PTUUID -o value /dev/sda')
- if len(o):
+ o = simple_command(f'blkid -s PTUUID -o value /dev/{drive}')
+ if len(o) and o == uuid:
return drive
return None
+def get_drive_from_part_uuid(partuuid):
+ if len(harddrives) <= 0: raise ValueError("No hard drives to iterate in order to find: {}".format(uuid))
+
+ for drive in harddrives:
+ for partition in grab_partitions(f'/dev/{drive}'):
+ o = simple_command(f'blkid -s PARTUUID -o value /dev/{drive}')
+ if len(o) and o == partuuid:
+ return drive
+
+ return None
+
def update_git():
default_gw = get_default_gateway_linux()
if(default_gw):
@@ -401,7 +412,16 @@ if __name__ == '__main__':
if args['drive'][0] != '/':
## Remap the selected UUID to the device to be formatted.
- args['drive'] = get_drive_from_uuid(args['drive'])
+ drive = get_drive_from_uuid(args['drive'])
+ if not drive:
+ print(f'[N] Could not map UUID "{args["drive"]}" to a device. Trying to match via PARTUUID instead!')
+
+ drive = get_drive_from_part_uuid(args['drive'])
+ if not drive:
+ print(f'[E] Could not map UUID "{args["drive"]}" to a device. Aborting!')
+ exit(1)
+
+ args['drive'] = drive
## == If we got networking,
# Try fetching instructions for this box and execute them.