#!/bin/sh -e

##########################################################################
#   Script description:
#       Install native pkgsrc tree
#       
#   History:
#   Date        Name        Modification
#   2012-10-10  Jason Bacon Begin
##########################################################################

##########################################################################
#   Main
##########################################################################
    
case $(auto-ostype) in
NetBSD)
    # Install source tree for same release
    save_cwd=`pwd`
    
    . /usr/pkgsrc.shrc
    
    # FIXME: Don't assume /usr
    cd /usr
    distname=pkgsrc-${PKGSRC_QUARTER}
    archive=$distname.tar.bz2
    
    if [ ! -e $archive ]; then
	printf 'Fetching...\n'
	fetch http://ftp.netbsd.org/pub/pkgsrc/$distname/$archive
    fi
    
    if [ ! -e pkgsrc ]; then
	printf "Unpacking...\n"
	tar -jxf $archive
    fi
    
    cd $save_cwd
    ;;
    
*)
    auto-unsupported-os $0
    exit 1
    ;;

esac
