3 [[ -w / ]] || exec sudo env HOME="$HOME" "$0" "$@"
5 if [[ -z ${UNSHARE} ]] ; then
7 if type -P unshare >&/dev/null ; then
8 UNSHARE=true exec unshare -m -- "$0" "$@"
15 mounts="proc sys tmp dev dev/pts usr/portage usr/portage/distfiles"
20 ./*) chroot=${PWD}/${chroot#./} ;;
25 mounts=$(mount | grep ${chroot} | awk '{print $3}' | tac)
26 for m in ${mounts} ; do
30 if [[ -z ${mounts} ]] ; then
31 echo "nothing mounted in ${chroot}"
36 while [[ -n $1 ]] ; do
39 -m) mounts+=" $2"; shift ;;
40 -*) echo "unknown option $1"; exit 1 ;;
47 local src=/$1 dst=${chroot}/${2:-$1}
48 [[ -d ${src} ]] || return 0
50 grep -sq "${dst}" /proc/mounts || mount ${mount_args} --bind "${src}" "${dst}"
52 for m in ${mounts} ; do
58 *x86-64*) echo x86_64;;
59 *"Intel 80386"*) echo i386;;
60 *32-bit*PowerPC*) echo ppc;;
61 *64-bit*PowerPC*) echo ppc64;;
64 bin_dst=$(get_type bin/bash)
66 if [[ -n ${bin_dst} ]] && type -P setarch &>/dev/null ; then
67 setarch="setarch ${bin_dst}"
70 if [[ ! -L etc/mtab ]] ; then
72 ln -sf /proc/mounts etc/mtab
87 $(printf 'etc/%s ' ${etc}) \
89 if [ -e "/${f}" ] ; then
97 unset LS_COLORS # format changes over time
98 [[ $# -eq 0 ]] && set -- env HOME=/root /bin/bash -l