Check if the SD card is writable before starting the install (!1772)

This commit is contained in:
Martijn Braam 2019-03-30 15:07:23 +01:00
parent 1fffe83df3
commit cea6e70209
No known key found for this signature in database
GPG Key ID: C4280ACB000B060F
1 changed files with 13 additions and 0 deletions

View File

@ -357,6 +357,15 @@ def embed_firmware(args):
"bs=" + str(step), "seek=" + str(offset)])
def sanity_check_sdcard(device):
device_name = os.path.basename(device)
if os.path.isdir('/sys/class/block/{}'.format(device_name)):
with open('/sys/class/block/{}/ro'.format(device_name), 'r') as handle:
ro = handle.read()
if ro == '1\n':
raise RuntimeError("{} is read-only, Is the sdcard locked?".format(device))
def install_system_image(args):
# Partition and fill image/sdcard
logging.info("*** (3/5) PREPARE INSTALL BLOCKDEVICE ***")
@ -449,6 +458,10 @@ def install_recovery_zip(args):
def install(args):
# Sanity checks
if not args.android_recovery_zip and args.sdcard:
sanity_check_sdcard(args.sdcard)
# Number of steps for the different installation methods.
steps = 4 if args.android_recovery_zip else 5