#
# 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-shebang.patch
%patch% 03-skip-p4-tests.patch

%include-2%
# https://hellosplat.com/s/beanbag/tickets/4993/
# https://hellosplat.com/s/beanbag/tickets/4995/
COMPONENT_SRC_1 =		rbtools-release-$(HUMAN_VERSION)
COMPONENT_ARCHIVE_1 =		release-$(HUMAN_VERSION).tar.gz
COMPONENT_ARCHIVE_URL_1 =	\
	https://github.com/reviewboard/rbtools/archive/refs/tags/$(COMPONENT_ARCHIVE_1)
COMPONENT_ARCHIVE_HASH_1 =	\
	sha256:7efd4efa3966830532b71f8408ff2ed0d11c7aff9fdf6021f261b9380cfcd37a
CLEAN_PATHS += $(COMPONENT_SRC_1)
# https://hellosplat.com/s/beanbag/tickets/4993/
COMPONENT_POST_UNPACK_ACTION_1 += \
	$(RM) -r $(COMPONENT_SRC)/rbtools/clients/tests/testdata ; \
	$(CP) -a $(COMPONENT_SRC_1)/rbtools/clients/tests/testdata $(COMPONENT_SRC)/rbtools/clients/tests/testdata ;
# https://hellosplat.com/s/beanbag/tickets/4995/
COMPONENT_POST_UNPACK_ACTION_1 += \
	$(RM) -r $(COMPONENT_SRC)/rbtools/testing/scripts ; \
	$(CP) -a $(COMPONENT_SRC_1)/rbtools/testing/scripts $(COMPONENT_SRC)/rbtools/testing/scripts ;
%include-3%
# Tests needs GNU tools
COMPONENT_TEST_ENV += PATH=$(PATH.gnu)

# Testing needs HOME environment variable (the directory does not need to
# exist)
COMPONENT_TEST_ENV += HOME="$(@D)/.test_home"

# Manually added dependencies
TEST_REQUIRED_PACKAGES += developer/versioning/cvs
TEST_REQUIRED_PACKAGES += developer/versioning/mercurial
TEST_REQUIRED_PACKAGES += developer/versioning/subversion
TEST_REQUIRED_PACKAGES += developer/versioning/git
# see setup.cfg
TEST_REQUIRED_PACKAGES.python += library/python/pytest-env
%hook-manifest%
# Do not generate dependencies on importlib_metadata for usr/bin files otherwise we would end with duplicate dependencies on importlib-metadata.
printf '<transform file path=usr/bin -> add pkg.depend.bypass-generate .*/importlib_metadata.* >\n' >> "$DISTRIBUTION-PYVER.p5m"
# Do not generate dependencies on pkg_resources for usr/bin files otherwise we would end with duplicate dependencies on setuptools.
printf '<transform file path=usr/bin -> add pkg.depend.bypass-generate .*/pkg_resources.* >\n' >> "$DISTRIBUTION-PYVER.p5m"