mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
build_library: make a loop only for losetup in PartitionLoop
Fix a bug in PartitionLoop that ends up returning a false string, which results in FormatPartition failing.
This commit is contained in:
parent
074a4a4498
commit
a8cafdb31c
@ -435,6 +435,7 @@ def PartitionLoop(options, partition):
|
||||
"""Allocate (and automatically free) loop devices for a partition."""
|
||||
|
||||
attempts = 0
|
||||
loop_dev = ''
|
||||
|
||||
while attempts < 10:
|
||||
try:
|
||||
@ -443,14 +444,14 @@ def PartitionLoop(options, partition):
|
||||
'--sizelimit', str(partition['bytes']),
|
||||
'--find', '--show', options.disk_image])
|
||||
loop_dev = loop_dev.strip()
|
||||
|
||||
yield loop_dev
|
||||
|
||||
except:
|
||||
attempts += 1
|
||||
time.sleep(1)
|
||||
finally:
|
||||
Sudo(['losetup', '--detach', loop_dev])
|
||||
|
||||
try:
|
||||
yield loop_dev
|
||||
finally:
|
||||
Sudo(['losetup', '--detach', loop_dev])
|
||||
|
||||
def FormatPartition(options, part):
|
||||
print "Formatting partition %s (%s) as %s" % (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user