From 48595a35abd25e235543f9d319fdc28a4062e21f Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Mon, 25 Sep 2017 18:38:09 +0000 Subject: [PATCH] Add test "partuuid" --- .travis.yml | 3 ++- test/partuuid.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/partuuid.sh diff --git a/.travis.yml b/.travis.yml index 97ff6e2..d421604 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,5 @@ install: - sudo ./run ./mkimg.sh script: - - ./run ./test/partition_alignment.sh + - sudo ./run ./test/partition_alignment.sh + - sudo ./run ./test/partuuid.sh diff --git a/test/partuuid.sh b/test/partuuid.sh new file mode 100644 index 0000000..ee77f5e --- /dev/null +++ b/test/partuuid.sh @@ -0,0 +1,40 @@ +#!/bin/false + +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) + +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") + +MOUNT_DIR="$(mktemp --directory)" + +mkdir -p "$MOUNT_DIR" +mount -v $ROOT_DEV "$MOUNT_DIR" -t ext4 + +mkdir -p "$MOUNT_DIR/boot/" +mount -v $BOOT_DEV "$MOUNT_DIR/boot/" -t vfat + +IMGID="$(fdisk -l "$IMG_FILE" | sed -n 's/Disk identifier: 0x\([^ ]*\)/\1/p')" + +BOOT_PARTUUID="$IMGID-01" +ROOT_PARTUUID="$IMGID-02" + +echo + +grep --color "PARTUUID=$BOOT_PARTUUID" "$MOUNT_DIR/etc/fstab" +grep --color "PARTUUID=$ROOT_PARTUUID" "$MOUNT_DIR/etc/fstab" +grep --color "PARTUUID=$ROOT_PARTUUID" "$MOUNT_DIR/boot/cmdline.txt" + +echo + +umount -v "$MOUNT_DIR/boot/" +umount -v "$MOUNT_DIR" + +rmdir "$MOUNT_DIR" + +losetup -d "$BOOT_DEV" +losetup -d "$ROOT_DEV"