# SliTaz package receipt.

PACKAGE="cacerts"
VERSION="20211107"
CATEGORY="security"
SHORT_DESC="Certificate Authority Certificates"
MAINTAINER="al.bobylev@gmail.com"
LICENSE="MPL2"
WEB_SITE="http://www.linuxfromscratch.org/blfs/view/svn/postlfs/cacerts.html"
TARBALL="$PACKAGE-$VERSION.txt"
WGET_URL="https://hg.mozilla.org/releases/mozilla-release/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt"

DEPENDS="openssl"
BUILD_DEPENDS="openssl"

# Rules to configure and make the package.
compile_rules()
{
	mv -f *.txt certdata.txt
        # Insert header
        sed -i "1i\#CVS_ID @# \$ RCSfile: certdata.txt \$ \$Revision: $data_Ymd \$ \$Date: \$" certdata.txt

	cp -a $stuff/* $src
	./make-ca.sh &&
	./remove-expired-certs.sh $src/certs
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/etc/ssl/certs
	cp -a $src/certs/*.pem $fs/etc/ssl/certs
	cp -a $src/ca-bundle.crt $fs/etc/ssl
	ln -s ../ca-bundle.crt $fs/etc/ssl/certs/ca-certificates.crt
}

post_install()
{
	case "$1" in
		/cross*) return
	esac

	# Keep silence, for example, when installed on cook as build dependency
	if [ -z "$quiet" ]; then
		echo "Rehash certificates:"
		out='&1'
	else
		out='/dev/null'
	fi

	if [ -d "$1/$INSTALLED/perl" ]; then
		chroot "$1/" c_rehash >$out
	else
		tazpkg -gi microperl --root="${1:-/}"
		chroot "$1/" microperl /usr/bin/c_rehash >$out
	fi
}