# vim: ft=zsh noet
if [[ $1 == info ]]; then
FSB_INFO_DEPEND=gentoo_init
FSB_INFO_BASE=%s
FSB_INFO_DIR=%s-gcc
return
elif [[ $1 != build ]]; then
die "unimplemented action: $*"
fi
local pkgcache
pkgcache=$FSB_BASE_DIR/cache/gcc-$STAGE_GENTOO_MACHINE${STAGE_GENTOO_PKGCACHE_SUFFIX:-}
if [[ -d $pkgcache ]]; then
rsync -r $pkgcache/ $build_dir/var/portage/packages/ || die "error copying packages from cache"
fi
local gcc_pkg
if (($+STAGE_GENTOO_GCC)); then
echo "=sys-devel/gcc-$STAGE_GENTOO_GCC **" >>$build_dir/etc/portage/package.keywords/fsb
echo "=sys-devel/gcc-$STAGE_GENTOO_GCC" >>$build_dir/etc/portage/package.unmask/fsb
gcc_pkg=sys-devel/gcc-$STAGE_GENTOO_GCC
else
gcc_pkg=sys-devel/gcc
fi
if ! $build_dir/chroot.sh /usr/bin/binutils-config -l; then
fsb_emerge -1bk --binpkg-changed-deps=y --backtrack=50 binutils
fsb_emerge -1bk --binpkg-changed-deps=y --backtrack=50 $gcc_pkg
else
fsb_emerge -1ubk --binpkg-changed-deps=y --backtrack=50 binutils $gcc_pkg
fi
fsb_emerge -1ubk sys-apps/texinfo
fsb_chroot_bash perl-cleaner --all
mkdir -p $pkgcache
rsync -r $build_dir/var/portage/packages/ $pkgcache/ || die "error copying packages to cache"
fsb_gentoo_set_gcc