*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-util / buildbot / buildbot-1.3.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5 PYTHON_REQ_USE="sqlite"
6 PYTHON_COMPAT=( python2_7 python3_6 )
7
8 EGIT_REPO_URI="https://github.com/buildbot/${PN}.git"
9
10 [[ ${PV} == *9999 ]] && inherit git-r3
11 inherit readme.gentoo-r1 user systemd distutils-r1
12
13 MY_PV="${PV/_p/.post}"
14 MY_P="${PN}-${MY_PV}"
15
16 DESCRIPTION="BuildBot build automation system"
17 HOMEPAGE="https://buildbot.net/ https://github.com/buildbot/buildbot https://pypi.org/project/buildbot/"
18 [[ ${PV} == *9999 ]] || SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${MY_P}.tar.gz"
19
20 LICENSE="GPL-2"
21 SLOT="0"
22 if [[ ${PV} == *9999 ]]; then
23         KEYWORDS=""
24 else
25         KEYWORDS="~amd64 ~amd64-linux ~x86-linux"
26 fi
27
28 IUSE="crypt doc docker examples irc test"
29 RESTRICT="!test? ( test )"
30
31 RDEPEND="
32         >=dev-python/jinja-2.1[${PYTHON_USEDEP}]
33         >=dev-python/twisted-17.9.0[${PYTHON_USEDEP}]
34         >=dev-python/autobahn-0.16.0[${PYTHON_USEDEP}]
35         >=dev-python/sqlalchemy-0.8[${PYTHON_USEDEP}]
36         >=dev-python/sqlalchemy-migrate-0.9[${PYTHON_USEDEP}]
37         dev-python/future[${PYTHON_USEDEP}]
38         >=dev-python/python-dateutil-1.5[${PYTHON_USEDEP}]
39         >=dev-python/txaio-2.2.2[${PYTHON_USEDEP}]
40         dev-python/pyjwt[${PYTHON_USEDEP}]
41         >=dev-python/zope-interface-4.1.1[${PYTHON_USEDEP}]
42         ~dev-util/buildbot-worker-${PV}[${PYTHON_USEDEP}]
43         crypt? (
44                 >=dev-python/twisted-17.9.0[${PYTHON_USEDEP},crypt]
45                 >=dev-python/pyopenssl-16.0.0[${PYTHON_USEDEP}]
46                 dev-python/idna[${PYTHON_USEDEP}]
47                 dev-python/service_identity[${PYTHON_USEDEP}]
48         )
49         irc? (
50                 dev-python/txrequests[${PYTHON_USEDEP}]
51         )
52         docker? (
53                 >=dev-python/docker-py-2.2.0[${PYTHON_USEDEP}]
54         )
55 "
56 DEPEND="${RDEPEND}
57         >=dev-python/setuptools-21.2.1[${PYTHON_USEDEP}]
58         doc? (
59                 >=dev-python/sphinx-1.4.3[${PYTHON_USEDEP}]
60                 dev-python/sphinxcontrib-blockdiag[${PYTHON_USEDEP}]
61                 dev-python/sphinxcontrib-spelling[${PYTHON_USEDEP}]
62                 dev-python/pyenchant[${PYTHON_USEDEP}]
63                 >=dev-python/docutils-0.8[${PYTHON_USEDEP}]
64                 <dev-python/docutils-0.13.0[${PYTHON_USEDEP}]
65                 dev-python/sphinx-jinja[${PYTHON_USEDEP}]
66         )
67         test? (
68                 >=dev-python/python-dateutil-1.5[${PYTHON_USEDEP}]
69                 >=dev-python/mock-2.0.0[${PYTHON_USEDEP}]
70                 dev-python/moto[${PYTHON_USEDEP}]
71                 dev-python/boto3[${PYTHON_USEDEP}]
72                 dev-python/pyjade[${PYTHON_USEDEP}]
73                 dev-python/txgithub[${PYTHON_USEDEP}]
74                 dev-python/txrequests[${PYTHON_USEDEP}]
75                 dev-python/lz4[${PYTHON_USEDEP}]
76                 dev-python/treq[${PYTHON_USEDEP}]
77                 dev-python/setuptools_trial[${PYTHON_USEDEP}]
78                 ~dev-util/buildbot-worker-${PV}[${PYTHON_USEDEP}]
79                 >=dev-python/docker-py-2.2.0[${PYTHON_USEDEP}]
80         )"
81
82 S=${WORKDIR}/${MY_P}
83 [[ ${PV} == *9999 ]] && S=${S}/master
84
85 if [[ ${PV} != *9999 ]]; then
86         PATCHES=(
87                 "${FILESDIR}/Remove-distro-version-test.patch"
88         )
89 fi
90
91 pkg_setup() {
92         enewuser buildbot
93
94         DOC_CONTENTS="The \"buildbot\" user and the \"buildmaster\" init script has been added
95                 to support starting buildbot through Gentoo's init system. To use this,
96                 execute \"emerge --config =${CATEGORY}/${PF}\" to create a new instance.
97                 The scripts can run as a different user if desired."
98 }
99
100 src_compile() {
101         distutils-r1_src_compile
102
103         if use doc; then
104                 einfo "Generation of documentation"
105                 pushd docs > /dev/null
106                 #'man' target is currently broken
107                 emake html
108                 popd > /dev/null
109         fi
110 }
111
112 src_install() {
113         distutils-r1_src_install
114
115         doman docs/buildbot.1
116
117         if use doc; then
118                 dohtml -r docs/_build/html/
119                 # TODO: install man pages
120         fi
121
122         if use examples; then
123                 insinto /usr/share/doc/${PF}
124                 doins -r docs/examples
125         fi
126
127         newconfd "${FILESDIR}/buildmaster.confd" buildmaster
128         newinitd "${FILESDIR}/buildmaster.initd" buildmaster
129         systemd_dounit "${FILESDIR}/buildmaster.target"
130         systemd_newunit "${FILESDIR}/buildmaster_at.service" "buildmaster@.service"
131         systemd_install_serviced "${FILESDIR}/buildmaster_at.service.conf" "buildmaster@.service"
132
133         readme.gentoo_create_doc
134 }
135
136 python_test() {
137         distutils_install_for_testing
138
139         esetup.py test || die "Tests failed under ${EPYTHON}"
140 }
141
142 pkg_postinst() {
143         readme.gentoo_print_elog
144
145         if [[ -n ${REPLACING_VERSIONS} ]]; then
146                 ewarn
147                 ewarn "Starting with buildbot-0.8.12-r2, more than one instance of buildmaster"
148                 ewarn "can be run simultaneously. Note that \"BASEDIR\" in the buildbot configuration file"
149                 ewarn "is now the common base directory for all instances. If you are migrating from an older"
150                 ewarn "version, make sure that you copy the current contents of \"BASEDIR\" to a subdirectory."
151                 ewarn "The name of the subdirectory corresponds to the name of the buildmaster instance."
152                 ewarn "In order to start the service running OpenRC-based systems need to link to the init file:"
153                 ewarn "    ln --symbolic --relative /etc/init.d/buildmaster /etc/init.d/buildmaster.myinstance"
154                 ewarn "    rc-update add buildmaster.myinstance default"
155                 ewarn "    /etc/init.d/buildmaster.myinstance start"
156                 ewarn "Systems using systemd can do the following:"
157                 ewarn "    systemctl enable buildmaster@myinstance.service"
158                 ewarn "    systemctl enable buildmaster.target"
159                 ewarn "    systemctl start buildmaster.target"
160                 elog
161                 elog "Upstream recommends the following when upgrading:"
162                 elog "Each time you install a new version of Buildbot, you should run the"
163                 elog "\"buildbot upgrade-master\" command on each of your pre-existing build masters."
164                 elog "This will add files and fix (or at least detect) incompatibilities between"
165                 elog "your old config and the new code."
166         fi
167         elog
168         elog "In order to create a new instance of buildmaster, execute:"
169         elog "    emerge --config =${CATEGORY}/${PF}"
170 }
171
172 pkg_config() {
173         local buildmaster_path="/var/lib/buildmaster"
174         local log_path="/var/log/buildmaster"
175
176         einfo "This will prepare a new buildmaster instance in ${buildmaster_path}."
177         einfo "Press Control-C to abort."
178
179         einfo "Enter the name for the new instance: "
180         read instance_name
181         [[ -z "${instance_name}" ]] && die "Invalid instance name"
182
183         local instance_path="${buildmaster_path}/${instance_name}"
184         local instance_log_path="${log_path}/${instance_name}"
185
186         if [[ -e "${instance_path}" ]]; then
187                 eerror "The instance with the specified name already exists:"
188                 eerror "${instance_path}"
189                 die "Instance already exists"
190         fi
191
192         local buildbot="/usr/bin/buildbot"
193         if [[ ! -d "${buildmaster_path}" ]]; then
194                 mkdir --parents "${buildmaster_path}" || die "Unable to create directory ${buildmaster_path}"
195         fi
196         "${buildbot}" create-master "${instance_path}" &>/dev/null || die "Creating instance failed"
197         chown --recursive buildbot "${instance_path}" || die "Setting permissions for instance failed"
198         mv "${instance_path}/master.cfg.sample" "${instance_path}/master.cfg" \
199                 || die "Moving sample configuration failed"
200         ln --symbolic --relative "/etc/init.d/buildmaster" "/etc/init.d/buildmaster.${instance_name}" \
201                 || die "Unable to create link to init file"
202
203         if [[ ! -d "${instance_log_path}" ]]; then
204                 mkdir --parents "${instance_log_path}" || die "Unable to create directory ${instance_log_path}"
205         fi
206         ln --symbolic --relative "${instance_log_path}/twistd.log" "${instance_path}/twistd.log" \
207                 || die "Unable to create link to log file"
208
209         einfo "Successfully created a buildmaster instance at ${instance_path}."
210         einfo "To change the default settings edit the master.cfg file in this directory."
211 }