oem: Always resolve all disk alias paths to their absolute paths in /dev

This resolves an issue where udev was creating different names when
running in d-i, making installations fail on this hardware.
It also in general makes the installation more robust, and fixes a bug
where we were formatting a partition twice sometimes.
merge-requests/1/head
Matthias Klumpp 7 years ago
parent 2715d7e3b2
commit 40efdec8cf

@ -175,24 +175,41 @@ def pureos_oem_setup():
# urgh... - there are better ways to detect whether a disk is an SSD, # urgh... - there are better ways to detect whether a disk is an SSD,
# but none of them worked reliably enough. # but none of them worked reliably enough.
# So we add this hack here (which we hopefully can remove at some point) # So we add this hack here (which we hopefully can remove at some point)
inst_disk_path = local_disks[0] primary_disk_path = local_disks[0]
for d in local_disks: for d in local_disks:
if '_ssd_' in d.lower(): if '_ssd_' in d.lower():
inst_disk_path = d primary_disk_path = d
break break
# resolve to node in /dev
primary_disk_path = os.path.realpath(primary_disk_path)
# resolve alias links to direct /dev nodes
# we need the real path, as sometimes udev does create different names
# when running in d-i
real_local_disks = set()
for d in local_disks:
dpath = os.path.realpath(d)
real_local_disks.update(dpath)
# we do only want to use the resolved names from now on
local_disks = list(real_local_disks)
logger.info('Found disks: {}'.format(str(local_disks)))
logger.info('Determined primary disk: {}'.format(primary_disk_path))
# create the new partition and format it # create the new partition and format it
logger.info('Partitioning primary disk...') logger.info('Partitioning primary disk...')
libremhdd = LibremDiskDevice(inst_disk_path) libremhdd = LibremDiskDevice(primary_disk_path)
libremhdd.wipe() libremhdd.wipe()
libremhdd.partition_primary_disk() libremhdd.partition_primary_disk()
if len(local_disks) > 1: if len(local_disks) > 1:
for dpath in local_disks: for dpath in local_disks:
if dpath == inst_disk_path: if dpath == primary_disk_path:
continue continue
logger.info('Partitioning secondary disk "{}"...'.format(dpath)) logger.info('Partitioning secondary disk "{}"...'.format(dpath))
extrahdd = LibremDiskDevice(inst_disk_path) extrahdd = LibremDiskDevice(primary_disk_path)
extrahdd.wipe() extrahdd.wipe()
extrahdd.partition_secondary_disk() extrahdd.partition_secondary_disk()
@ -203,7 +220,7 @@ def pureos_oem_setup():
os.makedirs(target) os.makedirs(target)
except: except:
pass pass
check_call(['mount', inst_disk_path + '-part1', target]) check_call(['mount', primary_disk_path + '-part1', target])
# copy PureOS image files and d-i # copy PureOS image files and d-i
logger.info('Copying PureOS install files...') logger.info('Copying PureOS install files...')
@ -214,7 +231,7 @@ def pureos_oem_setup():
# configure & install preseed # configure & install preseed
configure_di_preseed(os.path.join(OEM_DATA_PATH, 'di-preseed.cfg.in'), configure_di_preseed(os.path.join(OEM_DATA_PATH, 'di-preseed.cfg.in'),
os.path.join(target, 'di-preseed.cfg'), os.path.join(target, 'di-preseed.cfg'),
target_disk=inst_disk_path) target_disk=primary_disk_path)
# set up GRUB # set up GRUB
logger.info('Creating GRUB configuration...') logger.info('Creating GRUB configuration...')
@ -228,7 +245,7 @@ def pureos_oem_setup():
shutil.copy(os.path.join(OEM_DATA_PATH, 'grub', 'loopback.cfg'), grub_dir) shutil.copy(os.path.join(OEM_DATA_PATH, 'grub', 'loopback.cfg'), grub_dir)
logger.info('Installing GRUB...') logger.info('Installing GRUB...')
check_call(['grub-install', inst_disk_path, '--boot-directory=%s' % (boot_dir)]) check_call(['grub-install', primary_disk_path, '--boot-directory=%s' % (boot_dir)])
check_call(['umount', target]) check_call(['umount', target])
logger.info('Done.') logger.info('Done.')

Loading…
Cancel
Save