e146bb877647bb9a1ab634a86c1315c88076bde9
[gentoo.git] / net-misc / crossbar / crossbar-17.6.1_p3-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 # Not quite ready for py3, unconditionally deps on too many backported
6 # pkgs installed in newer pythons that shouldn't need them.
7 PYTHON_COMPAT=( python2_7 )
8
9 inherit  user systemd distutils-r1
10
11 MY_PV="17.6.1.post3"
12 MY_P="${PN}-${MY_PV}"
13
14 DESCRIPTION="Crossbar.io - The Unified Application Router for the twisted framework"
15 HOMEPAGE="https://crossbar.io/ https://github.com/crossbario/crossbar https://pypi.org/project/crossbar/"
16 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${MY_P}.tar.gz"
17
18 LICENSE="AGPL-3"
19 SLOT="0"
20 KEYWORDS="~amd64"
21 IUSE="test"
22
23 RDEPEND="
24         >=dev-python/setuptools-36.0.1[${PYTHON_USEDEP}]
25         >=dev-python/twisted-17.1.0[${PYTHON_USEDEP}]
26         $(python_gen_cond_dep '>=dev-python/enum34-1.1.6[${PYTHON_USEDEP}]' python2_7)
27         >=dev-python/txaio-2.8.0[${PYTHON_USEDEP}]
28         >=dev-python/pyasn1-0.2.3[${PYTHON_USEDEP}]
29         >=dev-python/pyasn1-modules-0.0.9[${PYTHON_USEDEP}]
30         >=dev-python/incremental-17.5.0[${PYTHON_USEDEP}]
31         >=dev-python/zope-interface-4.4.2[${PYTHON_USEDEP}]
32         <dev-python/hyper-h2-3.0.0[${PYTHON_USEDEP}]
33         >=dev-python/priority-1.3.0[${PYTHON_USEDEP}]
34         >=dev-python/service_identity-17.0.0[${PYTHON_USEDEP}]
35         >=dev-python/pyopenssl-17.1.0[${PYTHON_USEDEP}]
36         >=dev-python/cryptography-1.9.0[${PYTHON_USEDEP}]
37         >=dev-python/autobahn-17.6.2[${PYTHON_USEDEP}]
38         >=dev-python/jinja-2.9.6[${PYTHON_USEDEP}]
39         >=dev-python/treq-17.3.1[${PYTHON_USEDEP}]
40         >=dev-python/pyyaml-3.12[${PYTHON_USEDEP}]
41         >=dev-python/click-6.7[${PYTHON_USEDEP}]
42         >=dev-python/attrs-17.2.0[${PYTHON_USEDEP}]
43         >=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
44         $(python_gen_cond_dep '>=dev-python/ipaddress-1.0.18[${PYTHON_USEDEP}]' python2_7)
45         >=dev-python/cbor-1.0.0[${PYTHON_USEDEP}]
46         >=dev-python/bitstring-3.1.5[${PYTHON_USEDEP}]
47         >=dev-python/pygments-2.2.0[${PYTHON_USEDEP}]
48         >=dev-python/pytrie-0.3[${PYTHON_USEDEP}]
49         >=dev-python/psutil-5.2.2[${PYTHON_USEDEP}]
50         >=dev-python/py-ubjson-0.9.0[${PYTHON_USEDEP}]
51         >=dev-python/pynacl-1.1.2[${PYTHON_USEDEP}]
52         >=dev-python/pyqrcode-1.2.1[${PYTHON_USEDEP}]
53         >=dev-python/lmdb-0.92[${PYTHON_USEDEP}]
54         >=dev-python/mistune-0.7.4[${PYTHON_USEDEP}]
55         >=dev-python/netaddr-0.7.19[${PYTHON_USEDEP}]
56         >=dev-python/setproctitle-1.1.10[${PYTHON_USEDEP}]
57         >=dev-python/sdnotify-0.3.1[${PYTHON_USEDEP}]
58         >=dev-python/shutilwhich-1.1.0[${PYTHON_USEDEP}]
59         >=dev-python/u-msgpack-2.4.1[${PYTHON_USEDEP}]
60         >=dev-python/watchdog-0.8.3[${PYTHON_USEDEP}]
61 "
62 DEPEND="
63         !dev-python/crossbar
64         >=dev-python/setuptools-36.0.1[${PYTHON_USEDEP}]
65         >=dev-python/twisted-17.1.0[${PYTHON_USEDEP}]
66         test? (
67                 dev-python/mock[${PYTHON_USEDEP}]
68         )
69 "
70 DOCS=(
71         README.rst LICENSE-FOR-API LICENSE COPYRIGHT
72 )
73
74 S="${WORKDIR}"/${MY_P}
75
76 python_prepare_all() {
77         # don't install the copyright, license... let dodoc do it
78         sed -e "s/^    data_files=.*//" -i setup.py || die
79
80         distutils-r1_python_prepare_all
81 }
82
83 pkg_setup() {
84         enewuser crossbar
85 }
86
87 python_test() {
88         pushd "${TEST_DIR}" > /dev/null || die
89         /usr/bin/trial crossbar || die "Tests failed with ${EPYTHON}"
90         popd > /dev/null || die
91 }
92
93 python_install_all() {
94         distutils-r1_python_install_all
95
96         keepdir /var/lib/crossbar
97         insinto /var/lib/crossbar
98         doins "${FILESDIR}/config.json.sample"
99
100         newconfd "${FILESDIR}/confd" crossbar
101         newinitd "${FILESDIR}/initd" crossbar
102 }
103
104 pkg_posinst() {
105         einfo "For exapmle configurations and scripts"
106         einfo "See: https://github.com/crossbario/crossbar-examples"
107
108         if [[ -n ${REPLACING_VERSIONS} ]]; then
109                 ewarn
110                 ewarn "Starting with net-misc/crossbar-17.6.1_p3-r1, more than one instance of crossbar"
111                 ewarn "can be run simultaneously. Note that \"BASEDIR\" in the crossbar conf.d/crossbar file"
112                 ewarn "is the common base directory for all instances. If you are migrating from an older"
113                 ewarn "version, make sure that you copy the current contents of \"BASEDIR\" to a subdirectory."
114                 ewarn "The name of the subdirectory corresponds to the name of the buildbot_worker instance."
115                 ewarn "In order to start the service running OpenRC-based systems need to link to the init file:"
116                 ewarn "    ln --symbolic --relative /etc/init.d/crossbar /etc/init.d/crossbar.myinstance"
117                 ewarn "    rc-update add crossbar.myinstance default"
118                 ewarn "    /etc/init.d/crossbar.myinstance start"
119                 ewarn "Systems using systemd can do the following:"
120                 ewarn "    systemctl enable crossbar@myinstance.service"
121                 ewarn "    systemctl enable crossbar.target"
122                 ewarn "    systemctl start crossbar.target"
123         fi
124 }
125
126 pkg_config() {
127         local crossbar_path="/var/lib/crossbar"
128         local log_path="/var/log/crossbar"
129         einfo "This will prepare a new crossbar instance in ${crossbar_path}."
130         einfo "Press Control-C to abort."
131
132         einfo "Enter the name for the new instance: "
133         read instance_name
134         [[ -z "${instance_name}" ]] && die "Invalid instance name"
135
136         local instance_path="${crossbar_path}/${instance_name}"
137         local instance_log_path="${log_path}/${instance_name}"
138
139         if [[ -e "${instance_path}" ]]; then
140                 eerror "The instance with the specified name already exists:"
141                 eerror "${instance_path}"
142                 die "Instance already exists"
143         fi
144
145         if [[ ! -d "${instance_path}" ]]; then
146                 mkdir --parents "${instance_path}" || die "Unable to create directory ${crossbar_path}"
147         fi
148         chown --recursive crossbar "${instance_path}" || die "Setting permissions for instance failed"
149         cp "${crossbar_path}/config.json.sample" "${instance_path}/config.json" \
150                 || die "Moving sample configuration failed"
151         ln --symbolic --relative "/etc/init.d/crossbar" "/etc/init.d/crossbar.${instance_name}" \
152                 || die "Unable to create link to init file"
153
154         if [[ ! -d "${instance_log_path}" ]]; then
155                 mkdir --parents "${instance_log_path}" || die "Unable to create directory ${instance_log_path}"
156         fi
157         ln --symbolic --relative "${instance_log_path}/node.log" "${instance_path}/node.log" \
158                 || die "Unable to create link to log file"
159
160         einfo "Successfully created a crossbar instance at ${instance_path}."
161         einfo "To change the default settings edit the config.json file in this directory."
162 }