#!/bin/sh
#
# $NetBSD: header,v 1.3 2014/12/30 15:13:20 wiz 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="mv -f"
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"

CURDIR=`${PWD_CMD}`
: ${PKG_METADATA_DIR=${CURDIR}}
PKGBASE="deforaos-surfer"

LOCALBASE="/usr/pkg"
X11BASE="/usr/X11R7"
PREFIX="/usr/pkg"

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

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

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: icon-themes,v 1.1 2017/06/14 16:23:09 prlw1 Exp $
#
# Generate an +ICON_THEMES script that handles the icon theme cache for
# the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+ICON_THEMES)
	${CAT} > ./+ICON_THEMES << 'EOF'
#!/bin/sh
#
# +ICON_THEMES - icon theme cache management script
#
# Usage: ./+ICON_THEMES ADD|REMOVE [metadatadir]
#
# This script supports two actions, UPDATE and REMOVE, that will update or
# remove cache files for icon themes from the package associated with
# <metadatadir>.
#
# Lines starting with "# ICON_THEME: " are data read by this script that
# name the icon theme and directory containing the "index.theme".
#
#	# ICON_THEME: hicolor
#	# ICON_THEME: gnome
#
# For each ICON_THEME entry, if the path is relative, that it is taken to be
# relative to ${PKG_PREFIX}/share/icons.
#

ECHO="echo"
GREP="/usr/bin/grep"
INSTALL_INFO=""
MKDIR="/bin/mkdir -p"
PWD_CMD="/bin/pwd"
RM="/bin/rm"
RMDIR="/bin/rmdir"
SED="/usr/bin/sed"
SORT="/usr/bin/sort"
TEST="test"
GTK2_UPDATE_ICON_CACHE="/usr/pkg/bin/gtk2-update-icon-cache"
GTK3_UPDATE_ICON_CACHE="/usr/pkg/bin/gtk-update-icon-cache"
: ${GTK_UPDATE_ICON_CACHE=true}

SELF=$0
ACTION=$1

CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=/usr/pkg}

for _t in ${GTK3_UPDATE_ICON_CACHE} ${GTK2_UPDATE_ICON_CACHE}; do
	if ${TEST} -x $_t; then
		GTK_UPDATE_ICON_CACHE=$_t;
		break;
	fi
done

update_icon_cache()
{
	_dir="$1"
	if ${TEST} ! -f "$_dir/index.theme"; then
		:
	else
		${GTK_UPDATE_ICON_CACHE}  -f -q "$_dir"
	fi
}

exitcode=0
case $ACTION in
UPDATE)
	${SED} -n "/^\# ICON_THEME: /{s/^\# ICON_THEME: //;p;}" ${SELF} | \
	${SORT} -u |
	while read theme; do
		case $theme in
		"")	continue ;;
		[!/]*)	theme="${PKG_PREFIX}/share/icons/$theme" ;;
		esac

		update_icon_cache $theme
	done
	;;

REMOVE)
	${SED} -n "/^\# ICON_THEME: /{s/^\# ICON_THEME: //;p;}" ${SELF} | \
	${SORT} -u |
	while read theme; do
		case $theme in
		"")	continue ;;
		[!/]*)	theme="${PKG_PREFIX}/share/icons/$theme" ;;
		esac

		${RM} -f "$theme/icon-theme.cache"
	done
	;;
esac
exit $exitcode

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

# $NetBSD: install,v 1.5 2017/06/14 16:23:09 prlw1 Exp $

case ${STAGE} in
PRE-INSTALL)
	#
	# Unpack the helper scriptlets.
	#
	${SH} ${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; }
	${TEST} ! -x ./+DIRS ||
		./+DIRS ADD ${PKG_METADATA_DIR}
	${TEST} ! -x ./+DIRS ||
		./+DIRS PERMS ${PKG_METADATA_DIR}
        ;;

POST-INSTALL)
	#
	# Rebuild the system run-time library search path database.
	#
	${TEST} ! -x ./+SHLIBS ||
		./+SHLIBS ADD ${PKG_METADATA_DIR}
	#
	# Copy configuration/support files into place.
	#
        ${TEST} ! -x ./+FILES ||
		./+FILES ADD ${PKG_METADATA_DIR}
        ${TEST} ! -x ./+FILES ||
		./+FILES PERMS ${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}

	#
	# Update any icon theme caches.
	#
	${TEST} ! -x ./+ICON_THEMES ||
		./+ICON_THEMES UPDATE ${PKG_METADATA_DIR}

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

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

  #
  # Register package into ocaml-findlib.
  #
  ${TEST} ! -x ./+OCAML_FINDLIB_REGISTER ||
    ./+OCAML_FINDLIB_REGISTER ADD ${PKG_METADATA_DIR}
	;;
esac

# $NetBSD: install.tmpl,v 1.2 2022/08/19 22:05:10 abs Exp $

APPLICATIONS_PATH="/share/applications"
UPDATE_DESKTOPDB="/bin/update-desktop-database"

case ${STAGE} in
POST-INSTALL|DEINSTALL)
        # desktop-file-utils may not be installed
        if [ -x ${UPDATE_DESKTOPDB} ] ; then
                ${UPDATE_DESKTOPDB} ${APPLICATIONS_PATH}
        fi
	;;
esac
# $NetBSD: footer,v 1.1 2006/05/21 23:50:15 jlam Exp $

exit 0

# ICON_THEME: hicolor
