summaryrefslogtreecommitdiff
path: root/export-image
diff options
context:
space:
mode:
authorAndrew Scheller <github@loowis.durge.org>2019-03-18 14:49:18 +0000
committerXECDesign <XECDesign@users.noreply.github.com>2019-03-18 14:49:18 +0000
commit30a1528ae13f993291496ac8e73b5ac0a6f82585 (patch)
tree99c1ef0e0e4fc9ba0709174627eed6cc6d4ab52b /export-image
parentfb23b8ba92ffc893fe257375ce79e56d3dbe7504 (diff)
Switch to using parted's machine parseable output (#270)
Diffstat (limited to 'export-image')
-rwxr-xr-xexport-image/prerun.sh16
1 files changed, 6 insertions, 10 deletions
diff --git a/export-image/prerun.sh b/export-image/prerun.sh
index 7345792..7e0d1eb 100755
--- a/export-image/prerun.sh
+++ b/export-image/prerun.sh
@@ -37,16 +37,12 @@ p
w
EOF
-PARTED_OUT=$(parted -s "${IMG_FILE}" unit b print)
-BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
-| cut -d" " -f 2 | tr -d B)
-BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 1'| xargs echo -n \
-| cut -d" " -f 4 | tr -d B)
-
-ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
-| cut -d" " -f 2 | tr -d B)
-ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^ 2'| xargs echo -n \
-| cut -d" " -f 4 | tr -d B)
+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)
BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}")
ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}")