*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-util / buildbot-worker / buildbot-worker-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_COMPAT=( python2_7 python3_6 )
6
7 EGIT_REPO_URI="https://github.com/buildbot/buildbot.git"
8
9 [[ ${PV} == *9999 ]] && inherit git-r3
10 inherit readme.gentoo-r1 user distutils-r1
11
12 DESCRIPTION="BuildBot Worker (slave) Daemon"
13 HOMEPAGE="https://buildbot.net/ https://github.com/buildbot/buildbot https://pypi.org/project/buildbot-worker/"
14
15 MY_V="${PV/_p/.post}"
16 MY_P="${PN}-${MY_V}"
17 [[ ${PV} == *9999 ]] || SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${MY_P}.tar.gz"
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 if [[ ${PV} == *9999 ]]; then
22         KEYWORDS=""
23 else
24         KEYWORDS="~amd64"
25 fi
26 IUSE="test"
27 RESTRICT="!test? ( test )"
28
29 RDEPEND=">=dev-python/setuptools-21.2.1[${PYTHON_USEDEP}]
30         >=dev-python/twisted-17.9.0[${PYTHON_USEDEP}]
31         dev-python/future[${PYTHON_USEDEP}]
32         !<dev-util/buildbot-0.9.7
33 "
34 DEPEND="${RDEPEND}
35         test? (
36                 dev-python/mock[${PYTHON_USEDEP}]
37                 dev-python/setuptools_trial[${PYTHON_USEDEP}]
38         )
39 "
40
41 S="${WORKDIR}/${MY_P}"
42 [[ ${PV} == *9999 ]] && S=${S}/worker
43
44 pkg_setup() {
45         enewuser buildbot
46
47         DOC_CONTENTS="The \"buildbot\" user and the \"buildbot_worker\" init script has been added
48                 to support starting buildbot_worker through Gentoo's init system. To use this,
49                 execute \"emerge --config =${CATEGORY}/${PF}\" to create a new instance.
50                 Set up your build worker following the documentation, make sure the
51                 resulting directories are owned by the \"buildbot\" user and point
52                 \"${ROOT}etc/conf.d/buildbot_worker.myinstance\" at the right location.
53                 The scripts can run as a different user if desired."
54 }
55
56 python_test() {
57         distutils_install_for_testing
58
59         esetup.py test || die "Tests failed under ${EPYTHON}"
60 }
61
62 python_install_all() {
63         distutils-r1_python_install_all
64
65         doman docs/buildbot-worker.1
66
67         newconfd "${FILESDIR}/buildbot_worker.confd2" buildbot_worker
68         newinitd "${FILESDIR}/buildbot_worker.initd2" buildbot_worker
69
70         dodir /var/lib/buildbot_worker
71         cp "${FILESDIR}/buildbot.tac.sample" "${D}/var/lib/buildbot_worker"|| die "Install failed!"
72
73         readme.gentoo_create_doc
74 }
75
76 pkg_postinst() {
77         readme.gentoo_print_elog
78
79         if [[ -n ${REPLACING_VERSIONS} ]]; then
80                 ewarn
81                 ewarn "Starting with buildbot-worker-0.9.10-r1, more than one instance of a buildbot_worker"
82                 ewarn "can be run simultaneously. Note that \"BASEDIR\" in the buildbot_worker configuration file"
83                 ewarn "is now the common base directory for all instances. If you are migrating from an older"
84                 ewarn "version, make sure that you copy the current contents of \"BASEDIR\" to a subdirectory."
85                 ewarn "The name of the subdirectory corresponds to the name of the buildbot_worker instance."
86                 ewarn "In order to start the service running OpenRC-based systems need to link to the init file:"
87                 ewarn "    ln --symbolic --relative /etc/init.d/buildbot_worker /etc/init.d/buildbot_worker.myinstance"
88                 ewarn "    rc-update add buildbot_worker.myinstance default"
89                 ewarn "    /etc/init.d/buildbot_worker.myinstance start"
90                 ewarn "Systems using systemd can do the following:"
91                 ewarn "    systemctl enable buildbot_worker@myinstance.service"
92                 ewarn "    systemctl enable buildbot_worker.target"
93                 ewarn "    systemctl start buildbot_worker.target"
94         fi
95 }
96
97 pkg_config() {
98         local buildworker_path="/var/lib/buildbot_worker"
99         local log_path="/var/log/buildbot_worker"
100
101         einfo "This will prepare a new buildbot_worker instance in ${buildworker_path}."
102         einfo "Press Control-C to abort."
103
104         einfo "Enter the name for the new instance: "
105         read instance_name
106         [[ -z "${instance_name}" ]] && die "Invalid instance name"
107
108         local instance_path="${buildworker_path}/${instance_name}"
109         local instance_log_path="${log_path}/${instance_name}"
110
111         if [[ -e "${instance_path}" ]]; then
112                 eerror "The instance with the specified name already exists:"
113                 eerror "${instance_path}"
114                 die "Instance already exists"
115         fi
116
117         if [[ ! -d "${instance_path}" ]]; then
118                 mkdir --parents "${instance_path}" || die "Unable to create directory ${buildworker_path}"
119         fi
120         chown --recursive buildbot "${instance_path}" || die "Setting permissions for instance failed"
121         cp "${buildworker_path}/buildbot.tac.sample" "${instance_path}/buildbot.tac" \
122                 || die "Moving sample configuration failed"
123         ln --symbolic --relative "/etc/init.d/buildbot_worker" "/etc/init.d/buildbot_worker.${instance_name}" \
124                 || die "Unable to create link to init file"
125
126         if [[ ! -d "${instance_log_path}" ]]; then
127                 mkdir --parents "${instance_log_path}" || die "Unable to create directory ${instance_log_path}"
128         fi
129         ln --symbolic --relative "${instance_log_path}/twistd.log" "${instance_path}/twistd.log" \
130                 || die "Unable to create link to log file"
131
132         einfo "Successfully created a buildbot_worker instance at ${instance_path}."
133         einfo "To change the default settings edit the buildbot.tac file in this directory."
134 }