#!/bin/sh
#
# $NetBSD: header,v 1.36 2006/03/19 23:58:14 jlam Exp $

SELF="$0"
PKGNAME="$1"
STAGE="$2"
shift 2

AWK="/usr/bin/awk"
BASENAME="/usr/bin/basename"
CAT="/bin/cat"
CHGRP="/usr/bin/chgrp"
CHMOD="/bin/chmod"
CHOWN="/usr/sbin/chown"
CMP="/usr/bin/cmp"
CP="/bin/cp"
DIRNAME="/usr/bin/dirname"
ECHO="echo"
ECHO_N="echo -n"
EGREP="/usr/bin/egrep"
EXPR="/bin/expr"
FALSE="false"
FIND="/usr/bin/find"
GREP="/usr/bin/grep"
GTAR=""
HEAD="/usr/bin/head"
ID="/usr/bin/id"
LINKFARM="/usr/sbin/linkfarm"
LN="/bin/ln"
LS="/bin/ls"
MKDIR="/bin/mkdir -p"
MV="/bin/mv"
PERL5="/usr/pkg/bin/perl"
PKG_ADMIN="/usr/sbin/pkg_admin"
PKG_INFO="/usr/sbin/pkg_info"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SETENV="/usr/bin/env"
SH="/bin/sh"
SORT="/usr/bin/sort"
SU="/usr/bin/su"
TEST="test"
TOUCH="/usr/bin/touch"
TR="/usr/bin/tr"
TRUE="true"
XARGS="/usr/bin/xargs"

: ${PKG_METADATA_DIR=`${PWD_CMD}`}
PKGBASE="ion3"

LOCALBASE="/usr/pkg"
X11BASE="/usr/X11R6"
DEPOTBASE="/usr/pkg/packages"
PREFIX="/usr/pkg"
case ${PKG_PREFIX} in
${LOCALBASE}/*)	VIEW="${PKG_PREFIX#${LOCALBASE}/}" ;;
*)		VIEW="" ;;
esac

PKG_SYSCONFBASE="/usr/pkg/etc"
PKG_SYSCONFDEPOTBASE=""
PKG_SYSCONFBASEDIR="/usr/pkg/etc"
PKG_SYSCONFDIR="/usr/pkg/etc/ion3"
CONF_DEPENDS=""

case ${VIEW} in
"")	PKG_SYSCONFVIEWBASE="${PKG_SYSCONFBASE}" ;;
*)	PKG_SYSCONFVIEWBASE="${PKG_SYSCONFBASE}/${VIEW}" ;;
esac

CONF_IGNORE_FILES="*[~#] *.OLD *.orig *,v .pkgsrc */.pkgsrc"

PKG_INSTALLATION_TYPE="overwrite"

case "${PKG_CONFIG:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_CONFIG=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_CONFIG=yes
	;;
esac

# $NetBSD: files,v 1.10 2006/03/19 23:58:14 jlam Exp $
#
# Generate a +FILES script that reference counts config files that are
# required for the proper functioning of the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+FILES)
	${CAT} > ./+FILES << 'EOF'
#!/bin/sh
#
# +FILES - reference-counted configuration file management script
#
# Usage: ./+FILES ADD|REMOVE [metadatadir]
#        ./+FILES VIEW-REMOVE depotdir viewdir
#        ./+FILES CHECK-ADD|CHECK-REMOVE [metadatadir]
#
# This script supports two actions, ADD and REMOVE, that will add or
# remove the configuration files needed by the package associated with
# <metadatadir>.  The CHECK-ADD action will check whether any files
# needed by the package are missing, and print an informative message
# noting those files.  The CHECK-REMOVE action will check whether
# any files needed by the package still exist, and print an informative
# message noting those files.  The CHECK-ADD and CHECK-REMOVE actions
# return non-zero if they detect either missing or existing files,
# respectively.  The VIEW-REMOVE action will remove from <viewdir> the
# links to the configuration files in <depotdir>.
#
# Lines starting with "# FILE: " are data read by this script that
# name the files that this package requires to exist to function
# correctly, along with the locations of the example files, e.g.
#
#	# FILE: /etc/bar.conf c /example/bar.conf
#	# FILE: /etc/baz/conf c /example/baz.conf 0600 foo-user foo-group
#
# For each FILE entry, if the file path is relative, then it is taken to
# be relative to ${PKG_PREFIX}.
#
# The second field in each FILE entry is a set of flags with the following
# meaning:
#
#	c	file is copied into place
#	f	ignore ${PKG_CONFIG}
#	r	file is an rc.d script (consider ${PKG_RCD_SCRIPTS})
#
CAT="/bin/cat"
CP="/bin/cp"
CHGRP="/usr/bin/chgrp"
CHMOD="/bin/chmod"
CHOWN="/usr/sbin/chown"
CMP="/usr/bin/cmp"
ECHO="echo"
GREP="/usr/bin/grep"
MKDIR="/bin/mkdir -p"
MV="/bin/mv"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SORT="/usr/bin/sort"
TEST="test"
TRUE="true"

SELF=$0
ACTION=$1

: ${PKG_PREFIX=/usr/pkg}

case "${PKG_CONFIG:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_CONFIG=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_CONFIG=no
	;;
esac
case "${PKG_RCD_SCRIPTS:-NO}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_RCD_SCRIPTS=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_RCD_SCRIPTS=no
	;;
esac

case $ACTION in
VIEW-REMOVE)
	DEPOTDIR="$2"
	VIEWDIR="$3"
        ${TEST} -n "${DEPOTDIR}" -a -n "${VIEWDIR}" || exit 0
	;;
*)
	PKG_METADATA_DIR="${2-`${PWD_CMD}`}"
	: ${PKGNAME=${PKG_METADATA_DIR##*/}}
	: ${PKG_DBDIR=${PKG_METADATA_DIR%/*}}
	: ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}
	PKG_REFCOUNT_FILES_DBDIR="${PKG_REFCOUNT_DBDIR}/files"
	;;
esac

exitcode=0
case $ACTION in
ADD)
	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u |
	{ while read file f_flags f_eg f_mode f_user f_group; do
		case $file in
		"")	continue ;;
		[!/]*)	file="${PKG_PREFIX}/$file" ;;
		esac
		case $f_flags in
		*c*)	;;
		*)	continue ;;
		esac
		case $f_eg in
		"")	continue ;;
		[!/]*)	f_eg="${PKG_PREFIX}/$f_eg" ;;
		esac

		shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
		perms="$shadow_dir/+PERMISSIONS"
		preexist="$shadow_dir/+PREEXISTING"
		token="$shadow_dir/${PKGNAME}"
		if ${TEST} ! -d "$shadow_dir"; then
			${MKDIR} $shadow_dir
			${TEST} ! -f "$file" ||
				${ECHO} "${PKGNAME}" > $preexist
		fi
		if ${TEST} -f "$token" && \
		   ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
			:
		else
			${ECHO} "${PKG_METADATA_DIR}" >> $token
		fi

		case $f_mode$f_user$f_group in
		"")	;;
	 	*)	${ECHO} "$f_mode $f_user $f_group" > $perms ;;
		esac
		if ${TEST} ! -f "$file" -a ! -f "$f_eg"; then
			:
		else
			case "$f_flags/$_PKG_CONFIG/$_PKG_RCD_SCRIPTS" in
			*f*/*/*|[!r]/yes/*|[!r][!r]/yes/*|[!r][!r][!r]/yes/*|*r*/yes/yes)
				case "$printed_header" in
				yes)	;;
				*)	printed_header=yes
					${ECHO} "==========================================================================="
					${ECHO} "Installing files needed by ${PKGNAME}:"
					;;
				esac
				if ${TEST} -f "$file"; then
					${ECHO} ""
					${ECHO} "	$file already exists."
				elif ${TEST} -f "$f_eg"; then
					${ECHO} ""
					${ECHO} "	$file"
					${ECHO} "	    [$f_eg]"
					${CP} $f_eg $file
					case $f_user in
					"")	;;
					*)	${CHOWN} $f_user $file ;;
					esac
					case $f_group in
					"")	;;
					*)	${CHGRP} $f_group $file ;;
					esac
					case $f_mode in
					"")	;;
					*)	${CHMOD} $f_mode $file ;;
					esac
				fi
				;;
			esac
		fi
	done
	case "$printed_header" in
	yes)	${ECHO} ""
		${ECHO} "==========================================================================="
		;;
	esac; }
	;;

REMOVE)
	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
	while read file f_flags f_eg f_mode f_user f_group; do
		case $file in
		"")	continue ;;
		[!/]*)	file="${PKG_PREFIX}/$file" ;;
		esac
		case $f_flags in
		*c*)	;;
		*)	continue ;;
		esac
		case $f_eg in
		"")	continue ;;
		[!/]*)	f_eg="${PKG_PREFIX}/$f_eg" ;;
		esac

		shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
		perms="$shadow_dir/+PERMISSIONS"
		preexist="$shadow_dir/+PREEXISTING"
		token="$shadow_dir/${PKGNAME}"
		tokentmp="$token.tmp.$$"
		if ${TEST} -f "$token" && \
		   ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
			${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" > $tokentmp
			case `${CAT} $tokentmp | ${SED} -n "$="` in
			"")
				if ${TEST} -f "$preexist"; then
					:
				elif ${TEST} -f "$file" -a -f "$f_eg" && \
				     ${CMP} -s "$file" "$f_eg"; then
					case "$f_flags/$_PKG_CONFIG/$_PKG_RCD_SCRIPTS" in
					*f*/*/*|[!r]/yes/*|[!r][!r]/yes/*|[!r][!r][!r]/yes/*|*r*/yes/yes)
						${RM} -f "$file"
						;;
					esac
				fi
				${RM} -f $perms $preexist $token $token.tmp.*
				${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE}
				;;
			*)
				${MV} -f $tokentmp $token
				;;
			esac
		fi
	done
	;;

VIEW-REMOVE)
	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
	while read file f_flags f_eg f_mode f_user f_group; do
		case $file in
		${DEPOTDIR}/*)	link="${VIEWDIR}/${file#${DEPOTDIR}/}" ;;
		[!/]*)		link="${VIEWDIR}/$file" ;;
		*)		continue ;;
		esac
		dir="${link%[^/]*}"
		if ${TEST} -h "$link"; then
			${RM} -f $link
			${RMDIR} -p $dir 2>/dev/null || ${TRUE}
		fi
	done
	;;

CHECK-ADD)
	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
	{ while read file f_flags f_eg f_mode f_user f_group; do
		case $file in
		"")	continue ;;
		[!/]*)	file="${PKG_PREFIX}/$file" ;;
		esac
		${TEST} ! -f "$file" || continue
		case $f_flags in
		*c*)	;;
		*)	continue ;;
		esac
		case $f_eg in
		"")	continue ;;
		[!/]*)	f_eg="${PKG_PREFIX}/$f_eg" ;;
		esac

		case "$printed_header" in
		yes)	;;
		*)	printed_header=yes
			${ECHO} "==========================================================================="
			${ECHO} "The following files should be created for ${PKGNAME}:"
			;;
		esac
		${ECHO} ""
		case $f_mode/$f_user/$f_group in
		//)
			${ECHO} "	$file"
			;;
		[!/]*//)
			${ECHO} "	$file (m=$f_mode)"
			;;
		[!/]*/[!/]*/)
			${ECHO} "	$file (o=$f_user, m=$f_mode)"
			;;
		[!/]*/[!/]*/[!/]*)
			${ECHO} "	$file (o=$f_user, g=$f_group, m=$f_mode)"
			;;
		esac
		${TEST} ! -f "$f_eg" || ${ECHO} "	    [$f_eg]"
	done
	case "$printed_header" in
	yes)	${ECHO} ""
		${ECHO} "==========================================================================="
		exit 1
		;;
	esac; }
	${TEST} $? -eq 0 || exitcode=1
	;;

CHECK-REMOVE)
	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
	{ while read file f_flags f_eg f_mode f_user f_group; do
		case $file in
		"")	continue ;;
		[!/]*)	file="${PKG_PREFIX}/$file" ;;
		esac
		${TEST} -f "$file" || continue
		shadow_dir="${PKG_REFCOUNT_FILES_DBDIR}$file"
		${TEST} ! -d "$shadow_dir" || continue	# refcount isn't zero
		case "$printed_header" in
		yes)	;;
		*)	printed_header=yes
			${ECHO} "==========================================================================="
			${ECHO} "The following files are no longer being used by ${PKGNAME},"
			${ECHO} "and they can be removed if no other packages are using them:"
			${ECHO} ""
			;;
		esac
		${ECHO} "	$file"
	done
	case "$printed_header" in
	yes)	${ECHO} ""
		${ECHO} "==========================================================================="
		exit 1
		;;
	esac; }
	${TEST} $? -eq 0 || exitcode=1
	;;

*)
	${ECHO} "Usage: ./+FILES ADD|REMOVE [metadatadir]"
	${ECHO} "       ./+FILES VIEW-REMOVE depotdir viewdir"
	${ECHO} "       ./+FILES CHECK-ADD|CHECK-REMOVE [metadatadir]"
	;;
esac
exit $exitcode

EOF
	${SED} -n "/^\# FILE: /p" ${SELF} >> ./+FILES
	${CHMOD} +x ./+FILES
	;;
esac

# $NetBSD: dirs,v 1.10 2006/03/19 23:58:14 jlam Exp $
#
# Generate a +DIRS script that reference counts directories that are
# required for the proper functioning of the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+DIRS)
	${CAT} > ./+DIRS << 'EOF'
#!/bin/sh
#
# +DIRS - reference-counted directory management script
#
# Usage: ./+DIRS ADD|REMOVE [metadatadir]
#        ./+DIRS CHECK-ADD|CHECK-REMOVE [metadatadir]
#
# This script supports two actions, ADD and REMOVE, that will add or
# remove the directories needed by the package associated with
# <metadatadir>.  The CHECK-ADD action will check whether any directories
# needed by the package are missing, and print an informative message
# noting those directories.  The CHECK-REMOVE action will check whether
# any directories needed by the package still exist, and print an
# informative message noting those directories.  The CHECK-ADD and
# CHECK-REMOVE actions return non-zero if they detect either missing
# or existing directories, respectively.
#
# Lines starting with "# DIR: " are data read by this script that
# name the directories that this package requires to exist to function
# correctly, e.g.
#
#	# DIR: /etc/foo m
#	# DIR: /var/log/foo/tmp mo foo-user foo-group 0700
#	# DIR: share/foo-plugins fm
#
# For each DIR entry, if the directory path is relative, then it is taken
# to be relative to ${PKG_PREFIX}.
#
# The second field in each DIR entry is a set of flags with the following
# meanings:
#
#	f	ignore ${PKG_CONFIG}
#	m	create (make) the directory when ADDing
#	o	directory is owned by the package
#
CAT="/bin/cat"
CHGRP="/usr/bin/chgrp"
CHMOD="/bin/chmod"
CHOWN="/usr/sbin/chown"
ECHO="echo"
GREP="/usr/bin/grep"
MKDIR="/bin/mkdir -p"
MV="/bin/mv"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SORT="/usr/bin/sort"
TEST="test"
TRUE="true"

SELF=$0
ACTION=$1
PKG_METADATA_DIR="${2-`${PWD_CMD}`}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_DBDIR=${PKG_METADATA_DIR%/*}}
: ${PKG_REFCOUNT_DBDIR=${PKG_DBDIR}.refcount}
: ${PKG_PREFIX=/usr/pkg}

PKG_REFCOUNT_DIRS_DBDIR="${PKG_REFCOUNT_DBDIR}/dirs"

case "${PKG_CONFIG:-YES}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	_PKG_CONFIG=yes
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	_PKG_CONFIG=no
	;;
esac

exitcode=0
case $ACTION in
ADD)
	${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -u |
	while read dir d_flags d_user d_group d_mode; do
		case $dir in
		"")	continue ;;
		[!/]*)	dir="${PKG_PREFIX}/$dir" ;;
		esac
		case $d_flags in
		*m*)	;;
		*)	continue ;;
		esac
		shadow_dir="${PKG_REFCOUNT_DIRS_DBDIR}$dir"
		perms="$shadow_dir/+PERMISSIONS"
		preexist="$shadow_dir/+PREEXISTING"
		token="$shadow_dir/${PKGNAME}"
		if ${TEST} ! -d "$shadow_dir"; then
			${MKDIR} $shadow_dir
			${TEST} ! -d "$dir" ||
				${ECHO} "${PKGNAME}" > $preexist
		fi
		if ${TEST} -f "$token" && \
		   ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
			:
		else
			${ECHO} "${PKG_METADATA_DIR}" >> $token
		fi
		case $d_user/$d_group/$d_mode in
		[!/]*/[!/]*/[!/]*)
			${ECHO} "$d_user $d_group $d_mode" > $perms
			;;
		esac
		case $d_flags/$_PKG_CONFIG in
		*f*/*|*/yes)
			${MKDIR} $dir
			case $d_user/$d_group/$d_mode in
			[!/]*/[!/]*/[!/]*)
				${CHOWN} $d_user $dir
				${CHGRP} $d_group $dir
				${CHMOD} $d_mode $dir
				;;
			esac
			;;
		esac
	done
	;;

REMOVE)
	${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -ru |
	while read dir d_flags d_user d_group d_mode; do
		case $dir in
		"")	continue ;;
		[!/]*)	dir="${PKG_PREFIX}/$dir" ;;
		esac
		case $d_flags in
		*m*)	;;
		*)	continue ;;
		esac
		shadow_dir="${PKG_REFCOUNT_DIRS_DBDIR}$dir"
		perms="$shadow_dir/+PERMISSIONS"
		preexist="$shadow_dir/+PREEXISTING"
		token="$shadow_dir/${PKGNAME}"
		tokentmp="$token.tmp.$$"
		if ${TEST} -f "$token" && \
		   ${GREP} "^${PKG_METADATA_DIR}$" $token >/dev/null; then
			${CAT} "$token" | ${GREP} -v "^${PKG_METADATA_DIR}$" > $tokentmp
			case `${CAT} $tokentmp | ${SED} -n "$="` in
			"")
				${TEST} -f "$preexist" ||
					{ case $d_flags/$_PKG_CONFIG in
					  *f*/*|*/yes)
						${RMDIR} -p $dir 2>/dev/null || ${TRUE}; 
						;;
					  esac; }
				${RM} -f $perms $preexist $token $token.tmp.*
				${RMDIR} -p $shadow_dir 2>/dev/null || ${TRUE}
				;;
			*)
				${MV} -f $tokentmp $token
				;;
			esac
		fi
	done
	;;

CHECK-ADD)
	${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -u |
	{ while read dir d_flags d_user d_group d_mode; do
		case $dir in
		"")	continue ;;
		[!/]*)	dir="${PKG_PREFIX}/$dir" ;;
		esac
		${TEST} ! -d "$dir" || continue
		case $d_flags in
		*m*)	;;
		*)	continue ;;
		esac
		case "$printed_header" in
		yes)	;;
		*)	printed_header=yes
			${ECHO} "==========================================================================="
			${ECHO} "The following directories should be created for ${PKGNAME}:"
			${ECHO} ""
			;;
		esac
		case $d_user/$d_group/$d_mode in
		[!/]*/[!/]*/[!/]*)
			${ECHO} "	$dir (o=$d_user, g=$d_group, m=$d_mode)"
			;;
		*)
			${ECHO} "	$dir"
			;;
		esac
	done
	case "$printed_header" in
	yes)	${ECHO} ""
		${ECHO} "==========================================================================="
		exit 1
		;;
	esac; }
	${TEST} $? -eq 0 || exitcode=1
	;;

CHECK-REMOVE)
	${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -ru |
	{ while read dir d_flags d_user d_group d_mode; do
		case $dir in
		"")	continue ;;
		[!/]*)	dir="${PKG_PREFIX}/$dir" ;;
		esac
		${TEST} -d "$dir" || continue
		case $d_flags in
		*o*)	;;
		*)	continue ;;
		esac
		shadow_dir="${PKG_REFCOUNT_DIRS_DBDIR}$dir"
		${TEST} ! -d "$shadow_dir" || continue	# refcount isn't zero
		case "$printed_header" in
		yes)	;;
		*)	printed_header=yes
			${ECHO} "==========================================================================="
			${ECHO} "The following directories are no longer being used by ${PKGNAME},"
			${ECHO} "and they can be removed if no other packages are using them:"
			${ECHO} ""
			;;
		esac
		${ECHO} "	$dir"
	done
	case "$printed_header" in
	yes)	${ECHO} ""
		${ECHO} "==========================================================================="
		exit 1
		;;
	esac; }
	${TEST} $? -eq 0 || exitcode=1
	;;

*)
	${ECHO} "Usage: ./+DIRS ADD|REMOVE [metadatadir]"
	${ECHO} "       ./+DIRS CHECK-ADD|CHECK-REMOVE [metadatadir]"
	;;
esac
exit $exitcode

EOF
	${SED} -n "/^\# DIR: /p" ${SELF} >> ./+DIRS
	${CHMOD} +x ./+DIRS
	;;
esac

# $NetBSD: install,v 1.45 2006/03/19 23:58:14 jlam Exp $

case ${STAGE} in
PRE-INSTALL)
	#
	# Unpack the helper scriptlets.
	#
	${SELF} ${PKGNAME} UNPACK
	#
	# Require that necessary users and groups exist or else fail the
	# installation of the package.
	#
	${TEST} ! -x ./+USERGROUP ||
		{ ./+USERGROUP ADD ${PKG_METADATA_DIR}
		  if ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then
			:
		  else
			exit 1
		  fi; }
	#
	# Create package directories at pre-install time.
	#
	if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" -a			\
	     "${_PKG_CONFIG}" = "yes" -a -n "${CONF_DEPENDS}" ]; then
		pkg=`${PKG_ADMIN} -b -d ${DEPOTBASE} -s "" lsbest "${CONF_DEPENDS}"`
		sysconfdir=`${PKG_INFO} -B -K ${DEPOTBASE} $pkg |	\
			${AWK} '/^PKG_SYSCONFDIR=/ {			\
				gsub("^PKG_SYSCONFDIR=[ 	]*", ""); \
				print;					\
			}'						\
		`
		if [ -d $sysconfdir -a ! -d ${PKG_SYSCONFDIR} ]; then
			${MKDIR} -p `${DIRNAME} ${PKG_SYSCONFDIR}`
			${LN} -sf $sysconfdir ${PKG_SYSCONFDIR}
		fi
	fi
	${TEST} ! -x ./+DIRS ||
		./+DIRS ADD ${PKG_METADATA_DIR}
        ;;

POST-INSTALL)
	#
	# Copy configuration/support files into place.
	#
        ${TEST} ! -x ./+FILES ||
		./+FILES ADD ${PKG_METADATA_DIR}
	${TEST} ! -x ./+RCD_SCRIPTS ||
		./+RCD_SCRIPTS ADD ${PKG_METADATA_DIR}
	#
	# Set special permissions on any files/directories that need them.
	#
	${TEST} ! -x ./+PERMS ||
		./+PERMS ${PKG_METADATA_DIR}
	#
	# Update any fonts databases.
	#
	${TEST} ! -x ./+FONTS ||
		./+FONTS ${PKG_METADATA_DIR}

	# Check for any missing bits after we're finished installing.
	#
	${TEST} ! -x ./+DIRS ||
		./+DIRS CHECK-ADD ${PKG_METADATA_DIR}
	${TEST} ! -x ./+FILES ||
		./+FILES CHECK-ADD ${PKG_METADATA_DIR}
	${TEST} ! -x ./+RCD_SCRIPTS ||
		./+RCD_SCRIPTS CHECK-ADD ${PKG_METADATA_DIR}
	;;

VIEW-INSTALL)
	#
	# Register shells in /etc/shells.
	#
	${TEST} ! -x ./+SHELL ||
		./+SHELL ADD ${PKG_METADATA_DIR}
	${TEST} ! -x ./+SHELL ||
		./+SHELL CHECK-ADD ${PKG_METADATA_DIR}
	#
	# Register info files.
	#
	${TEST} ! -x ./+INFO_FILES ||
		./+INFO_FILES ADD ${PKG_METADATA_DIR}

	# If ${PKG_SYSCONFBASE} points outside of ${PREFIX}, then add the
	# package config files to the proper view.
	#
	if [ "${_PKG_CONFIG}" = "yes" -a -n "${PKG_SYSCONFDEPOTBASE}" ]; then
		${SETENV} PLIST_IGNORE_FILES="${CONF_IGNORE_FILES}" \
			${LINKFARM} -t ${PKG_SYSCONFVIEWBASE} -d ${PKG_SYSCONFDEPOTBASE} ${PKGNAME}
	fi
	;;
esac

# $NetBSD: install-post,v 1.3 2006/03/15 04:52:57 jlam Exp $

# Ensure that the VIEW-INSTALL action is called for overwrite packages.
# This is here to ensure that it's the final POST-INSTALL action (after
# any INSTALL_TEMPLATE POST-INSTALL actions).
#
case ${STAGE} in
POST-INSTALL)
	if [ "${PKG_INSTALLATION_TYPE}" = "overwrite" ]; then
		${SETENV} PKG_PREFIX="${PKG_PREFIX}" \
			$0 ${PKGNAME} VIEW-INSTALL
        fi
	;;
esac

# $NetBSD: footer,v 1.2 2006/03/15 04:52:57 jlam Exp $

exit 0

# FILE: etc/ion3/cfg_bindings.lua c share/examples/ion3/cfg_bindings.lua 0644
# FILE: etc/ion3/cfg_dock.lua c share/examples/ion3/cfg_dock.lua 0644
# FILE: etc/ion3/cfg_floatws.lua c share/examples/ion3/cfg_floatws.lua 0644
# FILE: etc/ion3/cfg_ion.lua c share/examples/ion3/cfg_ion.lua 0644
# FILE: etc/ion3/cfg_ionws.lua c share/examples/ion3/cfg_ionws.lua 0644
# FILE: etc/ion3/cfg_kludges.lua c share/examples/ion3/cfg_kludges.lua 0644
# FILE: etc/ion3/cfg_menu.lua c share/examples/ion3/cfg_menu.lua 0644
# FILE: etc/ion3/cfg_menus.lua c share/examples/ion3/cfg_menus.lua 0644
# FILE: etc/ion3/cfg_panews.lua c share/examples/ion3/cfg_panews.lua 0644
# FILE: etc/ion3/cfg_pwm.lua c share/examples/ion3/cfg_pwm.lua 0644
# FILE: etc/ion3/cfg_pwm_bindings.lua c share/examples/ion3/cfg_pwm_bindings.lua 0644
# FILE: etc/ion3/cfg_pwm_menus.lua c share/examples/ion3/cfg_pwm_menus.lua 0644
# FILE: etc/ion3/cfg_query.lua c share/examples/ion3/cfg_query.lua 0644
# FILE: etc/ion3/cfg_sp.lua c share/examples/ion3/cfg_sp.lua 0644
# FILE: etc/ion3/cfg_statusbar.lua c share/examples/ion3/cfg_statusbar.lua 0644
# FILE: etc/ion3/dock-draw.lua c share/examples/ion3/dock-draw.lua 0644
# FILE: etc/ion3/look.lua c share/examples/ion3/look.lua 0644
# FILE: etc/ion3/look_brownsteel.lua c share/examples/ion3/look_brownsteel.lua 0644
# FILE: etc/ion3/look_clean.lua c share/examples/ion3/look_clean.lua 0644
# FILE: etc/ion3/look_cleanios.lua c share/examples/ion3/look_cleanios.lua 0644
# FILE: etc/ion3/look_cleanviolet.lua c share/examples/ion3/look_cleanviolet.lua 0644
# FILE: etc/ion3/look_dusky.lua c share/examples/ion3/look_dusky.lua 0644
# FILE: etc/ion3/look_greyviolet.lua c share/examples/ion3/look_greyviolet.lua 0644
# FILE: etc/ion3/look_ios.lua c share/examples/ion3/look_ios.lua 0644
# FILE: etc/ion3/look_simpleblue.lua c share/examples/ion3/look_simpleblue.lua 0644
# FILE: etc/ion3/look_wheat2.lua c share/examples/ion3/look_wheat2.lua 0644
# FILE: etc/ion3/lookcommon_clean.lua c share/examples/ion3/lookcommon_clean.lua 0644
# FILE: etc/ion3/lookcommon_emboss.lua c share/examples/ion3/lookcommon_emboss.lua 0644
# DIR: etc/ion3 m
