Skip to content
Snippets Groups Projects
Verified Commit 4010f496 authored by Sven-Hendrik Haase's avatar Sven-Hendrik Haase
Browse files

Try to call udevadm settle in order to appease the race condition

parent b9c20e21
No related tags found
No related merge requests found
......@@ -40,15 +40,6 @@ function cleanup() {
}
trap cleanup EXIT
# Helper function: wait until a file path exists
# ${1} - file path
function wait_until_exists() {
until test -e "${1}"; do
echo "${1} doesn't exist yet..."
sleep 1
done
}
# Create the disk, partitions it, format the partition and mount the filesystem
function setup_disk() {
truncate -s "${DISK_SIZE}" "${IMAGE}"
......@@ -59,8 +50,7 @@ function setup_disk() {
LOOPDEV=$(losetup --find --partscan --show "${IMAGE}")
# Partscan is racy
blockdev --rereadpt ${LOOPDEV}
wait_until_exists "${LOOPDEV}p2"
wait_until_settled "${LOOPDEV}"
mkfs.btrfs "${LOOPDEV}p2"
mount -o compress-force=zstd "${LOOPDEV}p2" "${MOUNT}"
}
......@@ -110,12 +100,22 @@ function image_cleanup() {
fstrim --verbose "${MOUNT}"
}
# Helper function: wait until a given loop device has settled
# ${1} - loop device
function wait_until_settled() {
udevadm settle
blockdev --flushbufs --rereadpt ${1}
until test -e "${1}p2"; do
echo "${1}p2 doesn't exist yet..."
sleep 1
done
}
# Mount image helper (loop device + mount)
function mount_image() {
LOOPDEV=$(losetup --find --partscan --show "${1:-${IMAGE}}")
# Partscan is racy
blockdev --rereadpt ${LOOPDEV}
wait_until_exists "${LOOPDEV}p2"
wait_until_settled ${LOOPDEV}
mount -o compress-force=zstd "${LOOPDEV}p2" "${MOUNT}"
# Setup bind mount to package cache
mount --bind "/var/cache/pacman/pkg" "${MOUNT}/var/cache/pacman/pkg"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment