summaryrefslogtreecommitdiff
path: root/sysutils/py-ansible-base/Makefile
blob: c7919eb4f6b6ab4fe70594fc3f1b6feff74fc4f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
PORTNAME=	ansible-base
DISTVERSION=	2.10.15
CATEGORIES=	sysutils python
MASTER_SITES=	CHEESESHOP
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
PATCH_SITES=	https://github.com/ansible/ansible/commit/
PATCHFILES=	6459fbb7bcf792aac9208d7851bf1edeb0495295.patch:-p1

MAINTAINER=	0mp@FreeBSD.org
COMMENT=	Radically simple IT automation

LICENSE=	GPLv3+
LICENSE_FILE=	${WRKSRC}/COPYING

RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}cryptography>0:security/py-cryptography@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}resolvelib05>0:devel/py-resolvelib05@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}yaml>0:devel/py-yaml@${PY_FLAVOR}
TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}bcrypt>=0:security/py-bcrypt@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}boto3>0:www/py-boto3@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}nose>0:devel/py-nose@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}passlib>0:security/py-passlib@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pycrypto>=0:security/py-pycrypto@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pytest-mock>0:devel/py-pytest-mock@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pytest-xdist>0:devel/py-pytest-xdist@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR}

USES=		ansible:env cpe gmake python:3.6+ shebangfix
CPE_VENDOR=	redhat
CPE_PRODUCT=	ansible
USE_PYTHON=	autoplist concurrent distutils

SHEBANG_REGEX=	[.]/test/.*[.]py

TEST_ARGS=	VERSION=${DISTVERSION} \
		PYTHON=${PYTHON_CMD} \
		DATE=
TEST_ENV=	PYTHON_VERSION=${PYTHON_VER} \
		TEST_FLAGS=-vv
TEST_TARGET=	tests

CONFLICTS=	py*-ansible-core

NO_ARCH=	yes

PLIST_FILES=	share/man/man1/ansible-config.1.gz \
		share/man/man1/ansible-console.1.gz \
		share/man/man1/ansible-doc.1.gz \
		share/man/man1/ansible-galaxy.1.gz \
		share/man/man1/ansible-inventory.1.gz \
		share/man/man1/ansible-playbook.1.gz \
		share/man/man1/ansible-pull.1.gz \
		share/man/man1/ansible-vault.1.gz \
		share/man/man1/ansible.1.gz
PORTEXAMPLES=	ansible.cfg hosts

OPTIONS_DEFINE=	DOCS EXAMPLES

post-patch:
# Preserve the original paths in
# test/units/cli/galaxy/test_execute_list_collection.py.
# Replacing /usr/share/ansible breaks tests.
	${FIND} ${WRKSRC} -not -regex '${WRKSRC}/test/units/cli/galaxy/test_execute_list_collection.py' -type f -print0 | \
		${XARGS} -0 ${REINPLACE_CMD} \
			-e 's|/etc/ansible|${ETCDIR}|g' \
			-e 's|/usr/share/ansible|${DATADIR}|g'
	${FIND} ${WRKSRC} -type f -name "*.bak" -delete

post-install:
	@${MKDIR} ${STAGEDIR}${MAN1PREFIX}/man/man1
	${INSTALL_MAN} ${WRKSRC}/docs/man/man1/*.1 \
		${STAGEDIR}${MAN1PREFIX}/share/man/man1

post-install-EXAMPLES-on:
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
	${INSTALL_DATA} ${WRKSRC}/examples/ansible.cfg ${STAGEDIR}${EXAMPLESDIR}
	${INSTALL_DATA} ${WRKSRC}/examples/hosts ${STAGEDIR}${EXAMPLESDIR}

post-stage:
	${FIND} ${STAGEDIR}${PREFIX}/bin -type l -name ansible-\* -lname ansible \
		-execdir ${RLN} ansible-${PYTHON_VER} {} \;
# USE_PYTHON=autoplist doesn't add this file to pkg-plist.
	${RM} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/ansible_test/_data/injector/ansible-inventory

pre-test:
# This one file does not get its paths replaced correctly in post-patch.
	${REINPLACE_CMD} 's|"/etc"|"${ETCDIR:H}"|g' \
		${WRKSRC}/test/units/playbook/test_helpers.py
# This test constructs a Python script inline and uses an invalid path to it.
	${REINPLACE_CMD} 's|/usr/bin/python|${PYTHON_CMD}|' \
		${WRKSRC}/test/units/modules/test_async_wrapper.py
# Disable some tests:
# - Skip the SELinux tests, it's not present on FreeBSD.
	${RM} ${WRKSRC}/test/units/module_utils/basic/test_selinux.py
# - Failure detecting that emojis are of width 2 instead of 1.
	${RM} ${WRKSRC}/test/units/utils/test_display.py

.include <bsd.port.mk>

# Make sure that we override the unique DATADIR and ETCDIR set
# by the implicit USES=uniquefiles.
DATADIR=	${ANSIBLE_DATADIR}
ETCDIR=		${ANSIBLE_ETCDIR}