mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
Merge pull request #46 from flatcar-linux/kai/flatcar-build-2387.0.0-pick
Pick commits from flatcar-master for alpha branch
This commit is contained in:
commit
b085b38ef4
@ -11,6 +11,7 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import uuid
|
||||
|
||||
# First sector we can use.
|
||||
@ -433,11 +434,22 @@ def FormatFat(part, device):
|
||||
def PartitionLoop(options, partition):
|
||||
"""Allocate (and automatically free) loop devices for a partition."""
|
||||
|
||||
loop_dev = subprocess.check_output(['sudo', 'losetup',
|
||||
'--offset', str(partition['first_byte']),
|
||||
'--sizelimit', str(partition['bytes']),
|
||||
'--find', '--show', options.disk_image])
|
||||
loop_dev = loop_dev.strip()
|
||||
for i in range(0,5):
|
||||
try:
|
||||
loop_dev = subprocess.check_output(['sudo', 'losetup',
|
||||
'--offset', str(partition['first_byte']),
|
||||
'--sizelimit', str(partition['bytes']),
|
||||
'--find', '--show', options.disk_image])
|
||||
loop_dev = loop_dev.strip()
|
||||
err = None
|
||||
break
|
||||
except subprocess.CalledProcessError as error:
|
||||
print("Failed to set up loopback, attempt %d" % i)
|
||||
err = error
|
||||
time.sleep(5)
|
||||
|
||||
if err is not None:
|
||||
raise err
|
||||
|
||||
try:
|
||||
yield loop_dev
|
||||
@ -586,9 +598,22 @@ def Mount(options):
|
||||
mount_opts.append('subvol=%s' % mount['fs_subvolume'])
|
||||
|
||||
Sudo(['mkdir', '-p', full_path])
|
||||
Sudo(['mount', '-t', mount.get('fs_type', 'auto'),
|
||||
'-o', ','.join(mount_opts),
|
||||
options.disk_image, full_path])
|
||||
# This tends to fail, retry if it does
|
||||
err = None
|
||||
for i in range(0,5):
|
||||
try:
|
||||
Sudo(['mount', '-t', mount.get('fs_type', 'auto'),
|
||||
'-o', ','.join(mount_opts),
|
||||
options.disk_image, full_path])
|
||||
err = None
|
||||
break
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error mounting %s, attempt %d" % (full_path, i))
|
||||
err = e
|
||||
time.sleep(5)
|
||||
|
||||
if err is not None:
|
||||
raise err
|
||||
|
||||
for src, dst in mount.get('binds', {}).iteritems():
|
||||
# src may be relative or absolute, os.path.join handles this.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user