summaryrefslogtreecommitdiff
blob: 9734ebb09383301b758fb7ec93e9fc2c9fe0e8c6 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/x86-chroot/x86-chroot-2006.1.ebuild,v 1.7 2007/08/28 11:58:41 angelos Exp $

inherit linux-info

DESCRIPTION="Provides a 32bit chroot for amd64 users"
HOMEPAGE="http://amd64.gentoo.org/"
SRC_URI="http://distfiles.gentoo.org/releases/x86/${PV}/stages/stage3-i686-${PV}.tar.bz2"

LICENSE="GPL-2"
SLOT="${PV}"
KEYWORDS="-* ~amd64"
IUSE="X"

RDEPEND="X? ( x11-apps/xhost )"

RESTRICT="userpriv" #178935

CONFIG_CHECK="IA32_EMULATION"
CHROOT_LOCATION=${CHROOT_LOCATION:-/opt/x86-chroot}

pkg_setup() {
	if [[ -e ${CHROOT_LOCATION} && -z ${IKNOWMYSHIT} ]] ; then
		eerror "ATTENTION! The location you are going to install the chroot to"
		eerror "already exists and probably contains a chroot. Re-merging ${PN}"
		eerror "will overwrite files in the chroot and likely result in a broken"
		eerror "chroot. If you still want to merge it, execute:"
		eerror ""
		eerror "export IKNOWMYSHIT=breakmychroot"
		die "Previous chroot instance found!"
	fi
	linux-info_pkg_setup
}

src_unpack() {
	cd ${WORKDIR}
	mkdir -p ".${CHROOT_LOCATION}"
	cd ".${CHROOT_LOCATION}"
	unpack ${A}
}

src_compile() {
	cat <<- EOF > "${WORKDIR}/${CHROOT_LOCATION}/etc/make.conf"
		CFLAGS="-O2 -march=i686 -msse2 -pipe"
		CHOST="i686-pc-linux-gnu"
		CXXFLAGS="\${CFLAGS}"
	EOF

	echo -e "env-update\nsource /etc/profile" >> "${WORKDIR}/${CHROOT_LOCATION}/root/.bashrc"
	echo "CHROOT_LOCATION=${CHROOT_LOCATION}" >	"${WORKDIR}/${CHROOT_LOCATION}/etc/conf.d/${PN}"
}

src_install() {
	mv ${WORKDIR}/* ${D}/ || die "moving chroot failed!"
	newinitd ${FILESDIR}/initd ${PN} || die "could not install init.d file!"
	mkdir -p "${D}/etc/conf.d"
	echo "CHROOT_LOCATION=${CHROOT_LOCATION}" > "${D}/etc/conf.d/${PN}" || die "could not install conf.d file!"
	dobin ${FILESDIR}/${PN} || die "couldn't install x86-chroot"
}

pkg_postinst() {
	elog "Your chroot system is now installed. To do all the necessary setup"
	elog "work, run '/etc/init.d/x86-chroot start'. To start a chroot session,"
	elog "run 'x86-chroot'."
}

pkg_prerm() {
	[[ -f /etc/conf.d/${PN} ]] && source /etc/conf.d/${PN}
	ewarn "There are still files around in ${CHROOT_LOCATION}; make sure you
	manually"
	ewarn "remove that directory *after* checking the mounts for it"
}