#!/bin/zsh -x
# bootstrap Arch Linux System from within Gentoo
# Michael Weber 2012
# utilizes uses sys-apps/pacman::gentoo and
# https://github.com/falconindy/arch-install-scripts
# as sys-apps/arch-install-scripts::xmw 

#cat >> /etc/pacman.conf <<EOF
#[core]
#Server = http://archmirror.fs.lmu.de/archlinux/$repo/os/$arch
#
#[community]
#Server = http://archmirror.fs.lmu.de/archlinux/$repo/os/$arch
#
#[extra]
#Server = http://archmirror.fs.lmu.de/archlinux/$repo/os/$arch
#EOF

ROOT=$1
[ -z $ROOT ] && exit 1

#mount -t tmpfs none $ROOT
mkdir -p $ROOT/var/lib/pacman
pacman --sync --root $ROOT --refresh --needed --noconfirm base base-devel jshon zsh vim

cat > $ROOT/root/install << EOF
#!/bin/zsh -x
#pacman-key --init
#echo -e "Y\nY\nY\nY\nY\nY" | pacman-key --populate archlinux
echo Server = http://archmirror.fs.lmu.de/archlinux/\\\$repo/os/\\\$arch \
	>> /etc/pacman.d/mirrorlist
sed -e '/^SigLevel/d' \
    -e '/^\[options\]/aSigLevel = Never' \
    -i /etc/pacman.conf

curl https://raw.github.com/keenerd/packer/master/packer > /usr/local/bin/packer
chmod +x /usr/local/bin/packer
packer -S --noconfirm --noedit packer
rm /usr/local/bin/packer

packer -S --noconfirm --noedit runit-musl
cd /usr/local/src
git clone git://github.com/chneukirchen/ignite.git
cd ignite/ignite-git
makepkg --log --asroot
pacman -U --noconfirm ignite-git-*.pkg.tar*
sed -e '/^SigLevel = Never/d' -i /etc/pacman.conf
EOF

chmod +x $ROOT/root/install
arch-chroot /archlinux /root/install

#have fun w/o /etc/rc.conf
