Last active
January 22, 2025 16:33
-
-
Save jlebon/fb6e7c6dcc3ce17d3e2a86f5938ec033 to your computer and use it in GitHub Desktop.
mock-mount.sh -- compat script for bwrap in mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# This is a small compatibility script that ensures mock | |
# chroots are compatible with applications that expect / to | |
# be a mount point, such as bubblewrap. | |
cleanup() { | |
for mnt in sys proc; do | |
umount /mnt/mock-mount/$mnt | |
done | |
umount /mnt/mock-mount | |
umount /mnt/mock-mount | |
} | |
trap cleanup EXIT | |
# The parent of mount in which we'll chroot can't be shared | |
# or pivot_root will barf. So we just remount onto itself, | |
# but make sure to make the first parent mount private. | |
mkdir -p /mnt/mock-mount | |
mount --bind / /mnt/mock-mount | |
mount --make-private /mnt/mock-mount | |
mount --bind /mnt/mock-mount /mnt/mock-mount | |
for mnt in proc sys; do | |
mount --bind /$mnt /mnt/mock-mount/$mnt | |
done | |
chroot /mnt/mock-mount "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment