#!/bin/sh
#
# CSW pkg installation
#
#
BASEDIR=/a
MNT=/a/mnt
ADMIN_FILE=/a/tmp/admin
CSW=opencsw/stable/`mach`/`uname -r`

PATH=$PATH:/bin:/usr/bin
export PATH

# these pkgs are installed on all systems
PKGLIST="sudo amanda"

#
[ ! -d ${MNT} ] && mkdir -p ${MNT}
mount -f nfs local_server:/pub/solaris/packages ${MNT}

# pkgadd admin file
cat >${ADMIN_FILE} <<DONT_ASK
mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default
DONT_ASK

# pkg-get needs to be installed first, it installs the other packages
echo yes | /usr/sbin/pkgadd -a ${ADMIN_FILE} -R ${BASEDIR} -d ${MNT}/${CSW}/pkg_get-*-all-CSW.pkg CSWpkgget

# configure pkg-get
echo "# opencsw.org mirror for package deployment
url=http://local_server/pub/solaris/packages/opencsw/stable
use_gpg=false
use_md5=false
" > $BASEDIR/opt/csw/etc/pkg-get.conf 

# for uninterupted pkg-get installs
cd $BASEDIR/var/pkg-get && ln -s admin-fullauto admin

# unmount
cd /tmp
umount ${MNT}

# /etc/mnttab needs to be copied into the newroot of pkgadd fails
cp /etc/mnttab /a/etc/mnttab

for ii in $PKGLIST
do
  chroot /a /opt/csw/bin/pkg-get install $ii
done

exit

