#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2023 Marcel Telka
#

%patch% 01-no-question.patch

%file% public_suffix_list.dat

%hook-manifest%
mkdir -p files
curl -s https://publicsuffix.org/list/public_suffix_list.dat > files/public_suffix_list.dat
if ! cmp -s $SOURCE_DIR/effective_tld_names.dat.orig files/public_suffix_list.dat ; then
	git add files/public_suffix_list.dat
else
	rm files/public_suffix_list.dat
fi

%include-2%
COMPONENT_SRC =			$(COMPONENT_NAME)-v$(HUMAN_VERSION)
%include-3%
# sanity check to make sure we (still) update an existing file
COMPONENT_POST_UNPACK_ACTION += \
	[ -f $(SOURCE_DIR)/effective_tld_names.dat ] || exit 1 ;
# Save the original data file
COMPONENT_POST_UNPACK_ACTION += \
	$(CP) $(SOURCE_DIR)/effective_tld_names.dat $(SOURCE_DIR)/effective_tld_names.dat.orig ;
# use the up-to-date data file
COMPONENT_POST_UNPACK_ACTION += \
	[ -f $(COMPONENT_DIR)/files/public_suffix_list.dat ] && \
	$(CP) $(COMPONENT_DIR)/files/public_suffix_list.dat $(SOURCE_DIR)/effective_tld_names.dat ;