Skip to content

Commit

Permalink
simplify stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
knoopx committed Mar 14, 2022
1 parent 4860ddd commit 67640b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions make-image
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -xe

mkdir -p dist /dist
mkdir -p dist

OUTPUT_IMG="/dist/target.img"

Expand Down Expand Up @@ -66,10 +66,10 @@ ROOT_MIN_SIZE=$(resize2fs -P "$ROOT_DEV" | cut -d ':' -f 2 | tr -d ' ')

# shrink fs
e2fsck -f -p "$ROOT_DEV"
resize2fs -p "$ROOT_DEV" $ROOT_MIN_SIZE
resize2fs -p "$ROOT_DEV" "$ROOT_MIN_SIZE"

# shrink partition
PART_END=$(($ROOT_PART_START + ($ROOT_MIN_SIZE * $ROOT_BLOCK_SIZE)))
PART_END=$((ROOT_PART_START + (ROOT_MIN_SIZE * ROOT_BLOCK_SIZE)))
parted ---pretend-input-tty "$OUTPUT_IMG" <<EOF
unit B
resizepart 2 $PART_END
Expand All @@ -81,7 +81,7 @@ losetup -d "$LOOP_DEV"

# truncate free space
FREE_START=$(parted -ms "$OUTPUT_IMG" unit B print free | tail -1 | cut -d ':' -f 2 | tr -d 'B')
truncate -s $FREE_START "$OUTPUT_IMG"
truncate -s "$FREE_START" "$OUTPUT_IMG"

gzip -c "$OUTPUT_IMG" > "dist/alpine-rpi-$ALPINE_BRANCH-$ARCH.img.gz"

Expand Down

0 comments on commit 67640b0

Please sign in to comment.