Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
David Runge
arch-boxes
Commits
4010f496
Verified
Commit
4010f496
authored
Sep 28, 2020
by
Sven-Hendrik Haase
Browse files
Try to call udevadm settle in order to appease the race condition
parent
b9c20e21
Changes
1
Hide whitespace changes
Inline
Side-by-side
build-inside-vm.sh
View file @
4010f496
...
@@ -40,15 +40,6 @@ function cleanup() {
...
@@ -40,15 +40,6 @@ function cleanup() {
}
}
trap
cleanup EXIT
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
# Create the disk, partitions it, format the partition and mount the filesystem
function
setup_disk
()
{
function
setup_disk
()
{
truncate
-s
"
${
DISK_SIZE
}
"
"
${
IMAGE
}
"
truncate
-s
"
${
DISK_SIZE
}
"
"
${
IMAGE
}
"
...
@@ -59,8 +50,7 @@ function setup_disk() {
...
@@ -59,8 +50,7 @@ function setup_disk() {
LOOPDEV
=
$(
losetup
--find
--partscan
--show
"
${
IMAGE
}
"
)
LOOPDEV
=
$(
losetup
--find
--partscan
--show
"
${
IMAGE
}
"
)
# Partscan is racy
# Partscan is racy
blockdev
--rereadpt
${
LOOPDEV
}
wait_until_settled
"
${
LOOPDEV
}
"
wait_until_exists
"
${
LOOPDEV
}
p2"
mkfs.btrfs
"
${
LOOPDEV
}
p2"
mkfs.btrfs
"
${
LOOPDEV
}
p2"
mount
-o
compress-force
=
zstd
"
${
LOOPDEV
}
p2"
"
${
MOUNT
}
"
mount
-o
compress-force
=
zstd
"
${
LOOPDEV
}
p2"
"
${
MOUNT
}
"
}
}
...
@@ -110,12 +100,22 @@ function image_cleanup() {
...
@@ -110,12 +100,22 @@ function image_cleanup() {
fstrim
--verbose
"
${
MOUNT
}
"
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)
# Mount image helper (loop device + mount)
function
mount_image
()
{
function
mount_image
()
{
LOOPDEV
=
$(
losetup
--find
--partscan
--show
"
${
1
:-${
IMAGE
}}
"
)
LOOPDEV
=
$(
losetup
--find
--partscan
--show
"
${
1
:-${
IMAGE
}}
"
)
# Partscan is racy
# Partscan is racy
blockdev
--rereadpt
${
LOOPDEV
}
wait_until_settled
${
LOOPDEV
}
wait_until_exists
"
${
LOOPDEV
}
p2"
mount
-o
compress-force
=
zstd
"
${
LOOPDEV
}
p2"
"
${
MOUNT
}
"
mount
-o
compress-force
=
zstd
"
${
LOOPDEV
}
p2"
"
${
MOUNT
}
"
# Setup bind mount to package cache
# Setup bind mount to package cache
mount
--bind
"/var/cache/pacman/pkg"
"
${
MOUNT
}
/var/cache/pacman/pkg"
mount
--bind
"/var/cache/pacman/pkg"
"
${
MOUNT
}
/var/cache/pacman/pkg"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment