Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
13 changes: 10 additions & 3 deletions bin/shrink-img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function shrink() {
check_bin resize2fs
check_bin parted
check_bin truncate
check_bin fatlabel

local OLD_SIZE
local BLOCK_SIZE
Expand All @@ -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}')

Expand All @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions goss/goss_system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading