postmarketos-initramfs: handle empty hooks dir (MR 5000)

For some reason globbing doesn't work properly for empty directories,
adjust the check in run_hooks to ensure the directory both exists and
contains something, otherwise we get an error about
"/hooks-cleanup/*.sh" not existing.

/ # mkdir blah
/ # for x in blah/*; do echo $x; done
blah/*
/ # touch blah/beep
/ # for x in blah/*; do echo $x; done
blah/beep

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-14 20:55:05 +02:00 committed by Clayton Craft
parent 5a27482c20
commit f66238f045
No known key found for this signature in database
GPG key ID: 4A4CED6D7EDF950A
2 changed files with 3 additions and 3 deletions

View file

@ -91,8 +91,8 @@ sha512sums="
9c0e8f6f61d5da191e03a1aa9d5d0ceb5baf1eae6dbb9bfb0af59817783525119ac8394b135f303f7b6434a3eab0b49185fb90379e06823db847a4999c75ce33 00-initramfs-base.dirs
ab41b45b0613f25a61114ed8c8b92bc53c60838f6e2e0ba18c76e5369b2984e6023a0661887692673aca3f647f268c468a468f6b1ac424cfee609017a89481dd 00-initramfs-base.files
8a4adad3785af474b36a09a05f6a3b2c4b4f43aac331a53b903abfa51ea12be1e3d1d807b7a6e66a1346815f3b0044daf8cd62e21e2dc75d2db13ee265a72985 00-initramfs-extra-base.files
917a3e995c50d510d242413e76752b75cdd8e673a5e433481a3cbe883d917980cda50996a714d4be24b09ce19196184a487632dfa6d76d74d2cc3ec6513473aa init.sh
df53083f74b8824c3e537ddd84cb45a2470a129ba1060efac75661eb2fb86602a942ee4d34c9fb03a07e82a3c87cf37f16e690725e1f667a24c8920fe45042ee init_functions.sh
6bda477e9898420d4d9ef09a0abe4660f9d6bb483982df768e7142c94a14110fa1eee613c6cd12df5387250ce6ceee3061e7fffeac789a652ed0ac69a5e57f58 init.sh
cd2405db17311ee31ac0b8c968a916ec2bb7919b38c56269d01229a4d7a82559e4abd7199d66954c8fde70713b5458b4b4656da8f713e15375864b1b256c5e4f init_functions.sh
ba3275a9af788c7c782322a22a0f144d5e50e3498ea6886486a29331f23ae89cd32d500a3635cfa7cab369afba92edc18aeca64ccbf0cd589061cce23d15b46c unudhcpd.conf
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf
"

View file

@ -582,7 +582,7 @@ mount_root_partition() {
run_hooks() {
scriptsdir="$1"
if ! [ -d "$scriptsdir" ]; then
if [ -z "$(ls -A "$scriptsdir")" ]; then
return
fi