Skip to content

Commit 00e4927

Browse files
committed
init_buildsystem: Fix create_devs in containers without mknod
In rootless podman containers, mknod is not allowed, but bind mounting existing devices is. By bind mounting needed devices, chroot builds can work.
1 parent da84d77 commit 00e4927

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

init_buildsystem

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,13 @@ umount_stuff() {
166166
buildroot_umount "/proc/sys/fs/binfmt_misc"
167167
buildroot_umount "/proc"
168168
buildroot_umount "/sys"
169-
buildroot_umount "/dev/pts"
170-
buildroot_umount "/dev/shm"
171169
buildroot_umount "/mnt"
170+
171+
for f in "$BUILD_ROOT"/dev/*; do
172+
if mountpoint -q "$f"; then
173+
buildroot_umount "$f"
174+
fi
175+
done
172176
fi
173177
}
174178

@@ -352,7 +356,12 @@ create_devs() {
352356
if test $com = ln ; then
353357
ln -s $arg $BUILD_ROOT/dev/$file
354358
elif test $com = mknod ; then
355-
mknod -m $mode $BUILD_ROOT/dev/$file $arg
359+
if test -z "$PREPARE_VM" && test -e /run/.containerenv; then
360+
touch $BUILD_ROOT/dev/$file
361+
mount --bind /dev/$file $BUILD_ROOT/dev/$file
362+
else
363+
mknod -m $mode $BUILD_ROOT/dev/$file $arg
364+
fi
356365
fi
357366
done << DEVLIST
358367
mknod null 666 c 1 3

0 commit comments

Comments
 (0)