I don't mind it being a shell script. So is arch-chroot, which is an amazing little tool.
> > I have some concerns about binding /tmp and /dev the way you do...
> Can you elaborate what exactly the issues is? I use this quite often.
It's a container escape. The chroot shouldn't be able to access the hosts tmp files. Creating a tmpfs and using that is a safer method. If you can read and write the hosts tmpfs, then you can impact the behaviour of the host.
The cheap way would be making a directory in /var/shm and symlinking to it.
The better way is creating a ramfs and mounting it.
For /dev it's just because it has to be a proper bind, and I haven't looked deeply enough to check that happens.
> bchroot mounts the hosts resolv.conf over it anyway.
I'll still wait til you fix that symlink problem you've noted in the source - my resolv is definitely a symlink.
> Then you'll have to call 'bchroot ./rootfs /bin/ash' instead of just 'bchroot ./rootfs', just like with the regular chroot.
/bin/sh is generally guaranteed to exist (more often than /bin/bash). That's all. (Though technically the path /bin/sh isn't guaranteed by POSIX. You're supposed to use /etc/passwd to find the shell.)
> At least for myself it's already good enough to use it.
The goal of all software, if it works for you, fantastic.