Merge pull request #1267 from flatcar/krnowak/grub-install-workarounds

build_library/grub_install: Try mounting ESP directory in a loop
This commit is contained in:
Krzesimir Nowak 2023-10-13 10:06:19 +02:00 committed by GitHub
commit 612164c379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,26 +111,21 @@ trap cleanup EXIT
info "Installing GRUB ${FLAGS_target} in ${FLAGS_disk_image##*/}" info "Installing GRUB ${FLAGS_target} in ${FLAGS_disk_image##*/}"
LOOP_DEV=$(sudo losetup --find --show --partscan "${FLAGS_disk_image}") LOOP_DEV=$(sudo losetup --find --show --partscan "${FLAGS_disk_image}")
ESP_DIR=$(mktemp --directory) ESP_DIR=$(mktemp --directory)
MOUNTED=
# work around slow/buggy udev, make sure the node is there before mounting for (( i=0; i<5; ++i )); do
if [[ ! -b "${LOOP_DEV}p1" ]]; then if sudo mount -t vfat "${LOOP_DEV}p1" "${ESP_DIR}"; then
# sleep a little just in case udev is ok but just not finished yet MOUNTED=x
warn "loopback device node ${LOOP_DEV}p1 missing, waiting on udev..."
sleep 0.5
for (( i=0; i<5; i++ )); do
if [[ -b "${LOOP_DEV}p1" ]]; then
break break
fi fi
warn "looback device node still ${LOOP_DEV}p1 missing, reprobing..." warn "loopback device node ${LOOP_DEV}p1 still missing, reprobing..."
sudo blockdev --rereadpt ${LOOP_DEV} sudo blockdev --rereadpt "${LOOP_DEV}"
sleep 0.5 # sleep for 0.5, then 1, then 2, then 4, then 8 seconds.
done sleep "$(bc <<<"scale=1; (2.0 ^ ${i}) / 2.0")"
if [[ ! -b "${LOOP_DEV}p1" ]]; then done
if [[ -z ${MOUNTED} ]]; then
failboat "${LOOP_DEV}p1 where art thou? udev has forsaken us!" failboat "${LOOP_DEV}p1 where art thou? udev has forsaken us!"
fi
fi fi
sudo mount -t vfat "${LOOP_DEV}p1" "${ESP_DIR}"
sudo mkdir -p "${ESP_DIR}/${GRUB_DIR}" sudo mkdir -p "${ESP_DIR}/${GRUB_DIR}"
info "Compressing modules in ${GRUB_DIR}" info "Compressing modules in ${GRUB_DIR}"