#!/bin/sh -e

##########################################################################
#   Title:
#       Optional, defaults to the name of the script sans extention
#
#   Section:
#       8
#
#   Synopsis:
#       
#   Description:
#       Install native pkgsrc tree
#       
#   Arguments:
#       
#   Returns:
#
#   Examples:
#
#   Files:
#
#   Environment:
#
#   See also:
#       
#   History:
#   Date        Name        Modification
#   2012-10-10  Jason Bacon Begin
#   2024-11-12  Jason Bacon Add man page template and usage
##########################################################################

##########################################################################
#   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
