Merge pull request #353 from marineam/gptprio

disk_util: Set priority and successful attributes in new images
This commit is contained in:
Michael Marineau 2014-11-17 17:25:50 -06:00
commit 204f0024fb
2 changed files with 9 additions and 1 deletions

View File

@ -29,7 +29,8 @@
"blocks":"2097152", "blocks":"2097152",
"fs_blocks":"262144", "fs_blocks":"262144",
"fs_type":"ext2", "fs_type":"ext2",
"mount":"/usr" "mount":"/usr",
"features": ["prioritize"]
}, },
"4":{ "4":{
"label":"USR-B", "label":"USR-B",

View File

@ -278,6 +278,7 @@ def WritePartitionTable(options, config=None, partitions=None):
syslinux = False syslinux = False
hybrid = None hybrid = None
prioritize = []
for partition in partitions.itervalues(): for partition in partitions.itervalues():
if partition['type'] != 'blank': if partition['type'] != 'blank':
Cgpt('add', '-i', partition['num'], Cgpt('add', '-i', partition['num'],
@ -293,6 +294,8 @@ def WritePartitionTable(options, config=None, partitions=None):
hybrid = partition['num'] hybrid = partition['num']
if 'syslinux' in features: if 'syslinux' in features:
syslinux = True syslinux = True
if 'prioritize' in features:
prioritize.append(partition)
if hybrid: if hybrid:
# Enable legacy boot flag and generate a hybrid MBR partition table # Enable legacy boot flag and generate a hybrid MBR partition table
@ -314,6 +317,10 @@ def WritePartitionTable(options, config=None, partitions=None):
with open(options.disk_image, 'r+') as image_fd: with open(options.disk_image, 'r+') as image_fd:
image_fd.write(mbr_code) 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)
Cgpt('show', options.disk_image) Cgpt('show', options.disk_image)