From 620db3623ccf5328766656c89d023d89c4c056f6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 14 Apr 2019 23:13:19 +0200 Subject: Added support to select --drive= and it now maps to a drive. To ensure /dev/sda haven't changed location and the wrong drive gets wiped --- archinstall.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index afb22d65..734bb6d0 100644 --- a/archinstall.py +++ b/archinstall.py @@ -218,6 +218,18 @@ def simple_command(cmd, opts=None, *args, **kwargs): handle.stdout.close() return output +def get_drive_from_uuid(uuid): + if len(harddrives) <= 0: raise ValueError("No hard drives to iterate in order to find: {}".format(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): + return drive + + return None + def update_git(): default_gw = get_default_gateway_linux() if(default_gw): @@ -387,6 +399,10 @@ if __name__ == '__main__': if not 'profile' in args: args['profile'] = None if not 'profiles-path' in args: args['profiles-path'] = profiles_path + if args['drive'][0] != '/': + ## Remap the selected UUID to the device to be formatted. + args['drive'] = get_drive_from_uuid(args['drive']) + ## == If we got networking, # Try fetching instructions for this box and execute them. instructions = {} -- cgit v1.2.3-70-g09d2