#!/bin/bash -e
# http://www.gentoo.org/proj/en/gentoo-alt/prefix/
# http://dev.gentoo.org/~darkside/prefix/gentoo/bootstrap-gentoo.xml
# http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-solaris.xml
export EPREFIX=$(pwd)
export PATH="$EPREFIX/usr/bin:${EPREFIX}/bin:${EPREFIX}/tmp/usr/bin:${EPREFIX}/tmp/bin:/usr/bin:/bin:${PATH}"
wget -O bootstrap-prefix.sh "http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/scripts/bootstrap-prefix.sh?format=txt"
chmod +x bootstrap-prefix.sh
./bootstrap-prefix.sh "${EPREFIX}" latest_tree
./bootstrap-prefix.sh "${EPREFIX}" portage
hash -r
export GENTOO_MIRRORS="http://ftp.jaist.ac.jp/pub/Linux/Gentoo/ http://distfiles.gentoo.org"
export MAKEOPTS="-j4"
emerge --oneshot sed
emerge --oneshot --nodeps bash
emerge --oneshot wget
emerge --oneshot --nodeps baselayout-prefix
emerge --oneshot --nodeps xz-utils
emerge --oneshot --nodeps m4
emerge --oneshot --nodeps flex
emerge --oneshot --nodeps bison
emerge --oneshot --nodeps binutils-config
emerge --oneshot --nodeps "=binutils-2.20.1-r1"
emerge --oneshot --nodeps gcc-config
emerge --oneshot --nodeps gcc
emerge --oneshot coreutils
emerge --oneshot findutils
emerge --oneshot tar
emerge --oneshot grep
emerge --oneshot patch
emerge --oneshot gawk
emerge --oneshot make
emerge --oneshot --nodeps file
emerge --oneshot --nodeps eselect
emerge --oneshot pax-utils
env FEATURES="-collision-protect" emerge --oneshot portage
rm -Rf "${EPREFIX}"/tmp/*
hash -r
emerge --sync
USE="-git" emerge -u system
vim etc/make.conf
emerge -e system
cd "${EPREFIX}/usr/portage/scripts"
./bootstrap-prefix.sh "${EPREFIX}" startscript