#!/bin/sh
#
# Generic INSTALL/REMOVE script. Arguments passed to this script:
#
# $1 = ACTION	[pre/post]
# $2 = PKGNAME
# $3 = VERSION
# $4 = UPDATE	[yes/no]
# $5 = CONF_FILE (path to xbps.conf)
# $6 = ARCH (uname -m)
#
# Note that paths must be relative to CWD, to avoid calling
# host commands if /bin/sh (dash) is not installed and it's
# not possible to chroot(3).
#

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"

TRIGGERSDIR="./usr/libexec/xbps-triggers"
ACTION="$1"
PKGNAME="$2"
VERSION="$3"
UPDATE="$4"
CONF_FILE="$5"
ARCH="$6"

#
# The following code will run the triggers.
#

case ${ACTION} in
post)
	[ ! -d etc/ca-certificates/update.d ] && \
		install -d etc/ca-certificates/update.d
	[ ! -d etc/ssl/certs ] && install -d etc/ssl/certs
	env DESTDIR="$(pwd -P)" usr/bin/update-ca-certificates --fresh >/dev/null 2>&1
	;;
esac

exit 0
