Merge pull request #129 from kmpm/fix/parted

Fail with error message on parted error
This commit is contained in:
Drew Bonasera 2020-04-19 16:33:24 -04:00 committed by GitHub
commit 24c6f57efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -178,7 +178,12 @@ trap cleanup ERR EXIT
#Gather info #Gather info
info "Gathering data" info "Gathering data"
beforesize="$(ls -lh "$img" | cut -d ' ' -f 5)" beforesize="$(ls -lh "$img" | cut -d ' ' -f 5)"
parted_output="$(parted -ms "$img" unit B print | tail -n 1)" if ! parted_output=$(parted -ms "$img" unit B print); then
rc=$?
error $LINENO "parted failed with rc $rc"
info "Possibly invalid image. Run 'parted $img unit B print' manually to investigate"
exit -6
fi
partnum="$(echo "$parted_output" | cut -d ':' -f 1)" partnum="$(echo "$parted_output" | cut -d ':' -f 1)"
partstart="$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')" partstart="$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')"
loopback="$(losetup -f --show -o "$partstart" "$img")" loopback="$(losetup -f --show -o "$partstart" "$img")"
@ -187,6 +192,7 @@ currentsize="$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -
blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)" blocksize="$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)"
logVariables $LINENO beforesize parted_output partnum partstart tune2fs_output currentsize blocksize logVariables $LINENO beforesize parted_output partnum partstart tune2fs_output currentsize blocksize
#Check if we should make pi expand rootfs on next boot #Check if we should make pi expand rootfs on next boot
if [ "$should_skip_autoexpand" = false ]; then if [ "$should_skip_autoexpand" = false ]; then
#Make pi expand rootfs on next boot #Make pi expand rootfs on next boot