blob: 8994aa80adc5da08401b62aa1db89182e93a66fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/sh
# TODO:
# - dbus?
# - init?
if [ -z "$@" ]; then
echo "missing operand" >&2
exit 1
fi
if [ ! -d "$@"/dev ]; then
echo "no valid chroot environment" >&2
exit 1
fi
: ${PORTDIR="$(portageq portdir)"}
: ${DISTDIR="$(portageq envvar DISTDIR)"}
: ${PKGDIR="$(portageq envvar PKGDIR)"}
mount --rbind /dev "$@"/dev
mount --bind /sys "$@"/sys
mkdir -p "$@"/usr/portage
mount --bind "${PORTDIR}" "$@"/usr/portage
mkdir -p "$@"/{packages,distfiles}
mount --bind "${DISTDIR}" "$@"/distfiles
mount --bind "${PKGDIR}" "$@"/packages
mount -t proc none "$@"/proc
cp /etc/resolv.conf "$@"/etc
if [ -x "$@${SHELL}" ]; then
exe=${SHELL}
else
exe=/bin/bash
fi
chroot "$@" ${exe}
|