1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python2_7 python3_6 )
7 EGIT_REPO_URI="https://github.com/buildbot/buildbot.git"
9 [[ ${PV} == *9999 ]] && inherit git-r3
10 inherit readme.gentoo-r1 user distutils-r1
12 DESCRIPTION="BuildBot Worker (slave) Daemon"
13 HOMEPAGE="https://buildbot.net/ https://github.com/buildbot/buildbot https://pypi.org/project/buildbot-worker/"
17 [[ ${PV} == *9999 ]] || SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${MY_P}.tar.gz"
21 if [[ ${PV} == *9999 ]]; then
27 RESTRICT="!test? ( test )"
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
36 dev-python/mock[${PYTHON_USEDEP}]
37 dev-python/setuptools_trial[${PYTHON_USEDEP}]
41 S="${WORKDIR}/${MY_P}"
42 [[ ${PV} == *9999 ]] && S=${S}/worker
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."
57 distutils_install_for_testing
59 esetup.py test || die "Tests failed under ${EPYTHON}"
62 python_install_all() {
63 distutils-r1_python_install_all
65 doman docs/buildbot-worker.1
67 newconfd "${FILESDIR}/buildbot_worker.confd2" buildbot_worker
68 newinitd "${FILESDIR}/buildbot_worker.initd2" buildbot_worker
70 dodir /var/lib/buildbot_worker
71 cp "${FILESDIR}/buildbot.tac.sample" "${D}/var/lib/buildbot_worker"|| die "Install failed!"
73 readme.gentoo_create_doc
77 readme.gentoo_print_elog
79 if [[ -n ${REPLACING_VERSIONS} ]]; then
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"
98 local buildworker_path="/var/lib/buildbot_worker"
99 local log_path="/var/log/buildbot_worker"
101 einfo "This will prepare a new buildbot_worker instance in ${buildworker_path}."
102 einfo "Press Control-C to abort."
104 einfo "Enter the name for the new instance: "
106 [[ -z "${instance_name}" ]] && die "Invalid instance name"
108 local instance_path="${buildworker_path}/${instance_name}"
109 local instance_log_path="${log_path}/${instance_name}"
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"
117 if [[ ! -d "${instance_path}" ]]; then
118 mkdir --parents "${instance_path}" || die "Unable to create directory ${buildworker_path}"
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"
126 if [[ ! -d "${instance_log_path}" ]]; then
127 mkdir --parents "${instance_log_path}" || die "Unable to create directory ${instance_log_path}"
129 ln --symbolic --relative "${instance_log_path}/twistd.log" "${instance_path}/twistd.log" \
130 || die "Unable to create link to log file"
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."