diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 939211c..80960a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,10 +29,10 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 - - name: install kpartx + - name: install kpartx and dosfstools run: | sudo apt update - sudo apt install -y kpartx + sudo apt install -y kpartx dosfstools - name: install qemu build dependencies run: | diff --git a/bin/shrink-img.sh b/bin/shrink-img.sh index 9c25ee1..ccc807c 100644 --- a/bin/shrink-img.sh +++ b/bin/shrink-img.sh @@ -24,6 +24,7 @@ function shrink() { check_bin resize2fs check_bin parted check_bin truncate + check_bin fatlabel local OLD_SIZE local BLOCK_SIZE @@ -45,10 +46,16 @@ function shrink() { LOOP_DEV=$(losetup -O NAME,BACK-FILE -l -n | grep "$IMG_FILE" | sed "s#^/dev/\(loop[0-9]*\) *.*#\1#") - local PART_NUM=2 - local ROOT_PART=/dev/mapper/${LOOP_DEV}p${PART_NUM} + local BOOT_PART_NUM=1 + local ROOT_PART_NUM=2 + local BOOT_PART=/dev/mapper/${LOOP_DEV}p${BOOT_PART_NUM} + local ROOT_PART=/dev/mapper/${LOOP_DEV}p${ROOT_PART_NUM} e2fsck -fy "$ROOT_PART" + # Make sure partitions have the expected label so we can mount them using LABEL in fstab + tune2fs -L rootfs "$ROOT_PART" + fatlabel "$BOOT_PART" "boot" + BLOCK_SIZE=$(tune2fs -l "$ROOT_PART" | awk '/^Block size/ {print $NF}') MIN_BLOCKS=$(resize2fs -P "$ROOT_PART" | awk -F': ' '{print $2}') @@ -63,7 +70,7 @@ function shrink() { FIRST_BYTE=$(parted -m "$IMG_FILE" unit B print | tail -1 | cut -d':' -f2 | tr -d 'B') LAST_BYTE=$(echo "$FIRST_BYTE + $SIZE_BYTES" | bc) - parted "$IMG_FILE" rm "$PART_NUM" + parted "$IMG_FILE" rm "$ROOT_PART_NUM" parted "$IMG_FILE" unit B mkpart primary "$FIRST_BYTE" "$LAST_BYTE" FINAL_SIZE=$(parted -m "$IMG_FILE" unit B print free | tail -1 | cut -d':' -f2 | tr -d 'B') truncate --size "$FINAL_SIZE" "$IMG_FILE" diff --git a/goss/goss_system.yaml b/goss/goss_system.yaml index c40fea1..5df38d3 100644 --- a/goss/goss_system.yaml +++ b/goss/goss_system.yaml @@ -27,3 +27,19 @@ file: contents: [ 'root=/dev/mmcblk0p2' ] +command: + 'rootfs label': + exit-status: 0 + exec: "findmnt -n -o LABEL /" + stdout: + - rootfs + stderr: [] + timeout: 1000 + skip: false + 'bootfs label': + exit-status: 0 + exec: "findmnt -n -o LABEL /boot" + stdout: + - boot + stderr: [] + timeout: 1000 \ No newline at end of file