main/postmarketos-mkinitfs: change wait for subpartitions (MR 2432)

Previously it was assumed that with the counter and the sleep 0.1 the
process would take about 10 seconds to complete. On newer devices with
tens or even hundreds of partitions going through all partitions already
takes a significant amount of time, so change the logic to measure the
time elapsed instead.
This commit is contained in:
Luca Weiss 2021-08-13 11:34:43 +02:00 committed by Oliver Smith
parent 2f325b6124
commit 58eaa90874
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 11 additions and 6 deletions

View file

@ -1,6 +1,6 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
pkgname=postmarketos-mkinitfs
pkgver=0.30
pkgver=0.31
pkgrel=0
pkgdesc="Tool to generate initramfs images for postmarketOS"
url="https://postmarketos.org"
@ -54,7 +54,7 @@ check() {
sha512sums="
4717bf24bd13fd4d90f3ab000ab43f7d61529515de224ebc86458ae709ebe0b5065655457e34f5952126bac6ab45143a91cddb09a8ad2d0a55c5cecd564a0135 00-default.modules
4d718fca3b6a8c2d362003e7d57f9fa29510c05c27b372d21b8278fe76b2096ae098aa9f9a266a029f82956d165fd764e406ddaf36cec2e4f3bd30c6022d07a7 init.sh.in
6b6c2aa88ad41fde29783042addcf2fb6309791d9c92636a20ca01a56ae16fb86c94ef4bb0371105cf4ed1f306f85d3cd825b1d2094b29bf496975edfad1f8d1 init_functions.sh
a415707cbeea0612846dff3dc26ac9b2b4815fc4a59e05a1f2065010d1b004b96fd4c20ed8c171c9d614703c86b7c3354fd9aef267025182be731c35864ef831 init_functions.sh
5590087d67cf8cae0e4f2b9a0d3f055a01282ace53abe586a0117a9701287cf60a88230ba5817e77886b9496098139c025c6221c4b7404e36faac7df63adc1ee mkinitfs.sh
879223b6b608f3b26993c3536b4e6b37728f774d6e4da891ae87ef26e38603a15b09918b69963c4f65aa4551b721815fd3578a1ec598b7b9d418aa677520d55f mkinitfs_functions.sh
c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh

View file

@ -64,12 +64,18 @@ setup_mdev() {
mdev -s
}
get_uptime_seconds() {
# Get the current system uptime in seconds - ignore the two decimal places.
awk -F '.' '{print $1}' /proc/uptime
}
mount_subpartitions() {
# Do not create subpartition mappings if pmOS_boot
# already exists (e.g. installed on an sdcard)
[ -n "$(find_boot_partition)" ] && return
attempt_count=0
echo "Trying to mount subpartitions for 10 seconds..."
attempt_start=$(get_uptime_seconds)
wait_seconds=10
echo "Trying to mount subpartitions for $wait_seconds seconds..."
while [ -z "$(find_boot_partition)" ]; do
partitions="$(grep -v "loop\|ram" < /proc/diskstats |\
sed 's/\(\s\+[0-9]\+\)\+\s\+//;s/ .*//;s/^/\/dev\//')"
@ -92,8 +98,7 @@ mount_subpartitions() {
;;
esac
done
attempt_count=$(( attempt_count + 1 ));
if [ "$attempt_count" -gt "100" ]; then
if [ "$(get_uptime_seconds)" -ge $(( attempt_start + wait_seconds )) ]; then
echo "ERROR: failed to mount subpartitions!"
return;
fi