2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2023 Marcel Telka
16 %patch% 02-selinux.patch
17 %patch% 03-test-disable-plugins.patch
18 %patch% 05-wcwidth.patch
19 %patch% 06-dev-null.patch
20 %patch% 07-test_importlib_resources.patch
23 # ansible-core >= 2.14.0 requires Python >= 3.9
24 UNSUPPORTED_PYTHON_VERSIONS =
25 PYTHON_VERSIONS := $(filter-out $(UNSUPPORTED_PYTHON_VERSIONS), $(PYTHON_VERSIONS))
27 # ansible-core use custom testing (see below)
30 # Make sure the unversioned generic package depends on unsupported versioned package(s) too.
31 $(BUILD_DIR)/mkgeneric-python: PYTHON_VERSIONS := $(UNSUPPORTED_PYTHON_VERSIONS) $(PYTHON_VERSIONS)
34 # https://docs.ansible.com/ansible/latest/dev_guide/testing_running_locally.html#testing-ansible-core
35 COMPONENT_TEST_CMD = bin/ansible-test
37 COMPONENT_TEST_ARGS += units
38 COMPONENT_TEST_ARGS += --python $(PYTHON_VERSION)
39 COMPONENT_TEST_ARGS += --python-interpreter $(PYTHON)
40 COMPONENT_TEST_ARGS += --local
41 COMPONENT_TEST_ARGS += --color no
42 COMPONENT_TEST_ARGS += --verbose
43 COMPONENT_TEST_TARGETS =
45 # This project does not support tox so we need to provide test requirements
47 TEST_REQUIREMENTS += test/lib/ansible_test/_data/requirements/units.txt
49 # testing fails without HOME environment variable
50 COMPONENT_TEST_ENV += HOME=/tmp
52 # The ansible-test is running pytest several times in a row with pytest-xdist
53 # plugin enabled. This is hard to normalize properly, so we just pick most
54 # important lines from the test log and normalize them.
55 COMPONENT_TEST_TRANSFORMS = \
57 | $(COMPONENT_TEST_TRANSFORMER) \
58 -e 's/^\[gw.\] \[...%\] //' \
59 -e 's/\([^ ]\{1,\}\) \(.*\)$$/\2 \1/' \
60 -e 's/\(test_distribution_version\[stdin\)[0-9]*/\1/' \
61 -e 's|$(@D)|\$$(@D)|g' \
63 | $(COMPONENT_TEST_TRANSFORMER) -e ''"
65 # https://github.com/ansible/ansible/pull/80385
66 LICENSE="GPL-3.0-only"
68 # To make sure ansible-core binaries are available when the python mediator is
69 # set to an usupported Python version we need fake versioned ansible-core
70 # package(s). We do not use SINGLE_PYTHON_VERSION for ansible-core because
71 # ansible depends on ansible-core and with SINGLE_PYTHON_VERSION here the
72 # switch of ansible/ansible-core pair to newer Python version would be a bit
74 UNSUPPORTED_PYTHON_VERSIONS=$($GMAKE print-value-UNSUPPORTED_PYTHON_VERSIONS)
75 PYTHON_VERSION=$($GMAKE print-value-PYTHON_VERSION)
76 for ver in $UNSUPPORTED_PYTHON_VERSIONS ; do
78 sed -e '/path=usr\/lib/,$d' \
79 -e 's/^file \(path=usr\/bin\/\)\(.*\)-\$(PYVER)$/link mediator=python mediator-version='"$ver"' \1\2 target=\2-'"$PYTHON_VERSION"'/' \
80 -e 's/\$(PYV)/'"$v"'/' < "$DISTRIBUTION-PYVER.p5m" > "$DISTRIBUTION-$v.p5m"
81 printf "\ndepend type=require fmri=library/python/ansible-core-${PYTHON_VERSION//.}\n" >> "$DISTRIBUTION-$v.p5m"
82 git add "$DISTRIBUTION-$v.p5m"