diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 007fc3e87..b775588e5 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,5 +1,5 @@ pkgname=postmarketos-mkinitfs -pkgver=0.7.1 +pkgver=0.7.2 pkgrel=0 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://postmarketos.org" @@ -23,6 +23,7 @@ package() { "$pkgdir/sbin/mkinitfs" mkdir -p "$pkgdir/etc/postmarketos-mkinitfs/hooks/" } -sha512sums="d5abfe9a1298069e6722555c6e16223b09b36af65d879feb64d540aa6cbc009a3aa7f00528bcf656370ec37cc64f925c72ebb77813961cd6ebf22107b57ea029 init.sh.in -4515bc6891110e9c8b1ed8d31a89818c7c222a364bdbdf90097d5d6bbdb97eb889d4dbaec78dc928aa5ff698a8e89a76338e7c63017bf8dfb93f44a293848ca0 init_functions.sh + +sha512sums="c8ed2697ba0368b907eaefe7544bff8539adc7e8247af6bd425c722e3cedeb34e303f6bd9e00f283921352bc43dff3db83f3b3c1f427ef597ac15323f1e9c3eb init.sh.in +8ca82bfa1e092885882df36a3628d653457522b39f60457f29d7cddfc81df470e479d8e7bb51011de2d312ffdf35b785c511f1a32e5952403be819548b2ace23 init_functions.sh 4c8a999009bc7e909bc1848c8c2421cb5f79f2603ee210b8f8c145f47c31a9e56e1861cffe742fcfd3c7bbb315e37dbe347bb5ac602f45eeccc0e40516889618 mkinitfs.sh" diff --git a/main/postmarketos-mkinitfs/init.sh.in b/main/postmarketos-mkinitfs/init.sh.in index 40ba357f1..99c4fb5bd 100644 --- a/main/postmarketos-mkinitfs/init.sh.in +++ b/main/postmarketos-mkinitfs/init.sh.in @@ -12,11 +12,10 @@ mount_proc_sys_dev setup_log # shellcheck disable=SC2154,SC2086 [ -d /lib/modules ] && modprobe -a ${deviceinfo_modules_initfs} ext4 + setup_mdev mount_subpartitions - -# Fix for framebuffer drivers, which do not have a default mode -set_framebuffer_mode +setup_framebuffer # Hooks for hook in /etc/postmarketos-mkinitfs/hooks/*.sh; do diff --git a/main/postmarketos-mkinitfs/init_functions.sh b/main/postmarketos-mkinitfs/init_functions.sh index a0c0db841..4a480b62e 100644 --- a/main/postmarketos-mkinitfs/init_functions.sh +++ b/main/postmarketos-mkinitfs/init_functions.sh @@ -42,25 +42,34 @@ mount_subpartitions() { # Do not create subpartition mappings if pmOS_boot # already exists (e.g. installed on an sdcard) blkid |grep -q "pmOS_boot" && return - - for i in /dev/mmcblk*; do - case "$(kpartx -l "$i" 2>/dev/null | wc -l)" in - 2) - echo "Mount subpartitions of $i" - kpartx -afs "$i" - # Ensure that this was the *correct* subpartition - # Some devices have mmc partitions that appear to have - # subpartitions, but aren't our subpartition. - if blkid | grep -q "pmOS_boot"; then - break - fi - kpartx -d "$i" - continue - ;; - *) - continue - ;; - esac + attempt_count=0 + echo "Trying to mount subpartitions for 10 seconds..." + while [ -z "$(find_boot_partition)" ]; do + for i in /dev/mmcblk*; do + case "$(kpartx -l "$i" 2>/dev/null | wc -l)" in + 2) + echo "Mount subpartitions of $i" + kpartx -afs "$i" + # Ensure that this was the *correct* subpartition + # Some devices have mmc partitions that appear to have + # subpartitions, but aren't our subpartition. + if blkid | grep -q "pmOS_boot"; then + break + fi + kpartx -d "$i" + continue + ;; + *) + continue + ;; + esac + done + attempt_count=$(( attempt_count + 1 )); + if [ "$attempt_count" -gt "100" ]; then + echo "ERROR: failed to mount subpartitions!" + return; + fi + sleep 0.1; done } @@ -335,6 +344,30 @@ set_framebuffer_mode() { echo "$_mode" > /sys/class/graphics/fb0/mode } +setup_framebuffer() { + # Skip for non-framebuffer devices + # shellcheck disable=SC2154 + if [ "$deviceinfo_no_framebuffer" = "true" ]; then + echo "NOTE: Skipping framebuffer setup (deviecinfo_no_framebuffer)" + return + fi + + # Wait for /dev/fb0 + echo "NOTE: Waiting 10 seconds for the framebuffer /dev/fb0." + echo "If your device does not have a framebuffer, disable this with:" + echo "no_framebuffer=true in " + for i in $(seq 1 100); do + [ -e "/dev/fb0" ] && break + sleep 0.1 + done + if ! [ -e "/dev/fb0" ]; then + echo "ERROR: /dev/fb0 did not appear!" + return + fi + + set_framebuffer_mode +} + loop_forever() { while true; do sleep 1