summaryrefslogtreecommitdiff
blob: 75df274ca688231dd7796b3b986ee4bad3d8e77b (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Written by vapier@gentoo.org
# public-domain code ... z0r ...
# $Header: /var/cvsroot/gentoo-x86/app-shells/sandboxshell/files/sandboxshell.conf,v 1.6 2005/11/20 10:57:15 vapier Exp $

trap ":" INT QUIT TSTP

source /etc/profile

# do ebuild environment loading ... detect if we're in portage
# build area or not ... uNF uNF uNF
#sbs_pdir=$(portageq envvar PORTAGE_TMPDIR)/portage/ #portageq takes too long imo
if [[ -z ${PORTAGE_TMPDIR} ]] ; then
	sbs_gpdir=$( source /etc/make.globals && echo $PORTAGE_TMPDIR 2> /dev/null)
	sbs_cpdir=$( source /etc/make.conf && echo $PORTAGE_TMPDIR 2> /dev/null)
	[[ -z ${sbs_cpdir} ]] \
		&& sbs_pdir=${sbs_gpdir} \
		|| sbs_pdir=${sbs_cpdir}
else
	sbs_pdir=${PORTAGE_TMPDIR}
fi
[[ -z ${sbs_pdir} ]] && sbs_pdir=/var/tmp
sbs_pdir=${sbs_pdir}/portage/

if [[ ${PWD:0:${#sbs_pdir}} == "${sbs_pdir}" ]] ; then
	sbs_bdir=$(echo ${PWD:${#sbs_pdir}} | cut -d/ -f1)
	sbs_tmpenvfile=${sbs_pdir}${sbs_bdir}/temp/environment
	if [[ -e ${sbs_tmpenvfile} ]] ; then
		echo "Found environment at ${sbs_tmpenvfile}"
		printf " * Would you like to enter the portage environment ? "
		read env
		sbs_PREPWD=${PWD}
		if [[ ${env} == "y" ]] ; then
			set -a
			source "${sbs_tmpenvfile}" 2> /dev/null
			set +a
			export SANDBOX_WRITE=${SANDBOX_WRITE}:${sbs_pdir}${sbs_bdir}:${sbs_pdir}/homedir
		fi
		PWD=${sbs_PREPWD}
	fi
fi

cd ${PWD}
export PS1="[s]${PS1}"

adddeny()    { export SANDBOX_DENY=$SANDBOX_DENY:$1 ; }
addpredict() { export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1" ; }
addread()    { export SANDBOX_READ="$SANDBOX_READ:$1" ; }
addwrite()   { export SANDBOX_WRITE="$SANDBOX_WRITE:$1" ; }
sandboxon()  { export SANDBOX_ON="1" ; }
sandboxoff() { export SANDBOX_OFF="0" ; }