diff options
| author | Serge Schneider <serge@raspberrypi.com> | 2022-11-11 08:58:33 +0000 |
|---|---|---|
| committer | Serge Schneider <serge@raspberrypi.com> | 2022-11-11 08:58:33 +0000 |
| commit | 366bc2c8f34e71507d9c6293cfbda27081a5ee7b (patch) | |
| tree | 5a1034e71ce5255e5ff64645db46ef5c48be518f /export-image/prerun.sh | |
| parent | bd2cf0e0e4bac19f6966bc9ffaaca3e5044c5de3 (diff) | |
| parent | 1d13a292a79f151b06ff84823b9e41781120ce6f (diff) | |
Merge branch 'master' into arm64
Diffstat (limited to 'export-image/prerun.sh')
| -rwxr-xr-x | export-image/prerun.sh | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/export-image/prerun.sh b/export-image/prerun.sh index 145d61e..c3412c2 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -33,41 +33,21 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${BOOT_PART_START}" "$((BOOT_PART_START + BOOT_PART_SIZE - 1))" parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${ROOT_PART_START}" "$((ROOT_PART_START + ROOT_PART_SIZE - 1))" - PARTED_OUT=$(parted -sm "${IMG_FILE}" unit b print) - BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 2 | tr -d B) - BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 4 | tr -d B) - - ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 2 | tr -d B) - ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 4 | tr -d B) - - echo "Mounting BOOT_DEV..." - cnt=0 - until BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}"); do - if [ $cnt -lt 5 ]; then - cnt=$((cnt + 1)) - echo "Error in losetup for BOOT_DEV. Retrying..." - sleep 5 - else - echo "ERROR: losetup for BOOT_DEV failed; exiting" - exit 1 - fi - done - - echo "Mounting ROOT_DEV..." + echo "Creating loop device..." cnt=0 - until ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}"); do + until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do if [ $cnt -lt 5 ]; then cnt=$((cnt + 1)) - echo "Error in losetup for ROOT_DEV. Retrying..." + echo "Error in losetup. Retrying..." sleep 5 else - echo "ERROR: losetup for ROOT_DEV failed; exiting" + echo "ERROR: losetup failed; exiting" exit 1 fi done - echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" - echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH" + BOOT_DEV="${LOOP_DEV}p1" + ROOT_DEV="${LOOP_DEV}p2" ROOT_FEATURES="^huge_file" for FEATURE in 64bit; do |
