diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 6dfc897a2..2557be1fa 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,5 +1,5 @@ pkgname=postmarketos-mkinitfs -pkgver=0.13.0 +pkgver=0.13.1 pkgrel=0 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://postmarketos.org" @@ -40,7 +40,7 @@ check() { sha512sums="5037cb7285bb7c0c40ca9e6df332d882ef9a8b379756c785f921e062dab1b7e7f3139d00897f69323a916d709ced4297fea8cbd3a13ebae575b873ec9e2cbfae 00-default.modules 995b4d15e6b248d55d53221ec52674e62d74f0be539ac2ab26d4279544e2bece7aa58810dd831e1b2f08f0520fc9a8dff3ad4df52a46ef73f61e462f74f68c48 init.sh.in -683b1784cc6572717dd805caabea38fac1780b03ff3540b888aab4fd91ccae404634874e6c9fa39f723186821a849844c6df1235bdcbf47b2de6b7f483c42178 init_functions.sh +40c48c0b6d499dbe316cbb41dc2c02bdc188444c549f1545135479cd6ead5c318496b5c03a11ff81fdaeddef5f8fa473264a380afc6109a3d54790a489f16c1c init_functions.sh 7201d4640a3e9ead8a47ffd9916b068476b7d950760a84c37e02268c942d49896bc986da6bdee27e832639c90775354d68046a6475205d8d1da995b068120d8f mkinitfs.sh d593b921bd6c0204af874266060667d78a232c0131ce7f0ad4124f9b240fcbb6ac2a8a2b8ee30d27d78bed8c1a506c4e6cb13b57c33cee3a00a7d96eca45a7f3 mkinitfs_functions.sh c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh" diff --git a/main/postmarketos-mkinitfs/init_functions.sh b/main/postmarketos-mkinitfs/init_functions.sh index 5fbfe7be5..b3c268d7c 100644 --- a/main/postmarketos-mkinitfs/init_functions.sh +++ b/main/postmarketos-mkinitfs/init_functions.sh @@ -211,6 +211,13 @@ wait_root_partition() { done } +# $1: path to device +has_unallocated_space() { + # Check if there is unallocated space at the end of the device + parted -s "$1" print free | tail -n2 | \ + head -n1 | grep -qi "free space" +} + resize_root_partition() { partition=$(find_root_partition) @@ -228,9 +235,7 @@ resize_root_partition() { # Get physical device partition_dev=$(dmsetup deps -o devname "$partition" | \ awk -F "[()]" '{print "/dev/"$2}') - # Check if there is unallocated space at the end of the device - if parted -s "$partition_dev" print free | tail -n2 | \ - head -n1 | grep -qi "free space"; then + if has_unallocated_space "$partition_dev"; then echo "Resize root partition ($partition)" # unmount subpartition, resize and remount it kpartx -d "$partition" @@ -242,9 +247,12 @@ resize_root_partition() { # except for QEMU devices (where PMOS_FORCE_PARTITION_RESIZE gets passed as # kernel parameter). if grep -q PMOS_FORCE_PARTITION_RESIZE /proc/cmdline; then - echo "Resize root partition ($partition)" - parted -s "$(echo "$partition" | sed -E 's/p?2$//')" resizepart 2 100% - partprobe + partition_dev="$(echo "$partition" | sed -E 's/2$//')" + if has_unallocated_space "$partition_dev"; then + echo "Resize root partition ($partition)" + parted -s "$partition_dev" resizepart 2 100% + partprobe + fi fi }