From b091c2d0c20c0141c5a8188d9af94754c22fd6cc Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 11 Nov 2017 14:39:02 -0800 Subject: [PATCH] disk_util: drop support for syslinux partition feature It hasn't been used since 5bfa0c8d2013d075b72907d0a9552877b66c542c. --- build_library/disk_util | 52 +---------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/build_library/disk_util b/build_library/disk_util index eecfbcdae7..a4a72b34d5 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -16,9 +16,6 @@ import uuid # First sector we can use. GPT_RESERVED_SECTORS = 34 -# Default MBR boot code for GPT -DEFAULT_MBR_BOOT_CODE = '/usr/share/syslinux/gptmbr.bin' - class ConfigNotFound(Exception): pass @@ -26,10 +23,6 @@ class PartitionNotFound(Exception): pass class InvalidLayout(Exception): pass -class InvalidAdjustment(Exception): - pass -class InvalidBootCode(Exception): - pass def LoadPartitionConfig(options): @@ -282,7 +275,6 @@ def WritePartitionTable(options, config=None, partitions=None): image_fd.truncate(config['metadata']['bytes']) Cgpt('repair', options.disk_image) - syslinux = False hybrid = None prioritize = [] for partition in partitions.itervalues(): @@ -296,10 +288,8 @@ def WritePartitionTable(options, config=None, partitions=None): options.disk_image) features = partition.get('features', []) - if not hybrid and ('syslinux' in features or 'hybrid' in features): + if not hybrid and 'hybrid' in features: hybrid = partition['num'] - if 'syslinux' in features: - syslinux = True if 'prioritize' in features: prioritize.append(partition) @@ -307,22 +297,6 @@ def WritePartitionTable(options, config=None, partitions=None): # Enable legacy boot flag and generate a hybrid MBR partition table Cgpt('add', '-i', hybrid, '-B1', options.disk_image) - if syslinux and options.mbr_boot_code: - try: - with open(options.mbr_boot_code, 'r') as mbr_fd: - mbr_code = mbr_fd.read() - except IOError, ex: - raise InvalidBootCode("Failed to read %s: %s", - options.mbr_boot_code, ex) - - # The boot code must fit in the first 440 bytes of disk - if len(mbr_code) != 440: - raise InvalidBootCode("Invalid %s size %s, must be 440 bytes", - options.mbr_boot_code, len(mbr_code)) - - with open(options.disk_image, 'r+') as image_fd: - image_fd.write(mbr_code) - prioritize.reverse() for i, partition in enumerate(prioritize): Cgpt('add', '-i', partition['num'], '-S1', '-P', i+1, options.disk_image) @@ -451,24 +425,6 @@ def FormatFat(part, device): cmd += ['-n', part['fs_label']] Sudo(cmd + [device, vfat_blocks], stdout_null=True) - if 'syslinux' in part.get('features', []): - # Install using extlinux so we can operate on the mounted filesystem and - # avoid possible issues with mtools. Also hpa told me to. :) - # cgpt uses 255 heads and 63 sectors when generating the hybrid MBR which - # doesn't actually have to match what we use here but doesn't hurt either. - vfat_mount = tempfile.mkdtemp() - syslinux_dir = os.path.join(vfat_mount, 'syslinux') - Sudo(['mount', '-t', 'vfat', device, vfat_mount]) - try: - Sudo(['mkdir', syslinux_dir]) - Sudo(['extlinux', '--heads=255', '--sectors=63', - '--install', syslinux_dir]) - finally: - Sudo(['umount', vfat_mount]) - os.rmdir(vfat_mount) - - print "Installed SYSLINUX to %s" % part['label'] - @contextlib.contextmanager def PartitionLoop(options, partition): @@ -1008,21 +964,15 @@ def main(argv): help='initialize new partition table') a.add_argument('--update', action='store_false', dest='create', help='update existing partition table') - a.add_argument('--mbr_boot_code', default=DEFAULT_MBR_BOOT_CODE, - help='path to mbr boot block, such as syslinux/gptmbr.bin') a.add_argument('disk_image', help='path to disk image file') a.set_defaults(func=WritePartitionTable) a = actions.add_parser('format', help='write gpt and filesystems to image') - a.add_argument('--mbr_boot_code', default=DEFAULT_MBR_BOOT_CODE, - help='path to mbr boot block, such as syslinux/gptmbr.bin') a.add_argument('disk_image', help='path to disk image file') a.set_defaults(func=Format, create=True) a = actions.add_parser('update', help='write gpt, resize filesystems, and format free partitions') - a.add_argument('--mbr_boot_code', default=DEFAULT_MBR_BOOT_CODE, - help='path to mbr boot block, such as syslinux/gptmbr.bin') a.add_argument('disk_image', help='path to disk image file') a.set_defaults(func=Update, create=False)