]>
git.wh0rd.org - home.git/blob - .bin/custom-chroot
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 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 -*) echo "unknown option $1"; exit 1 ;;
45 local src
=/$1 dst
=${chroot}/${2:-$1}
46 [[ -d ${src} ]] ||
return 0
48 grep -sq "${dst}" /proc/mounts || mount ${mount_args} --bind "${src}" "${dst}"
50 for m
in ${mounts} ; do
56 *x86-64
*) echo x86_64
;;
57 *"Intel 80386"*) echo i386
;;
58 *32-bit*PowerPC
*) echo ppc
;;
59 *64-bit*PowerPC
*) echo ppc64
;;
62 bin_dst
=$
(get_type bin
/bash
)
64 if [[ -n ${bin_dst} ]] && type -P setarch
&>/dev
/null
; then
65 setarch
="setarch ${bin_dst}"
68 if [[ ! -L etc
/mtab
]] ; then
70 ln -sf /proc
/mounts etc
/mtab
85 $
(printf 'etc/%s ' ${etc}) \
87 if [ -e "/${f}" ] ; then
95 unset LS_COLORS
# format changes over time
96 [[ $# -eq 0 ]] && set -- env HOME
=/root
/bin
/bash
-l