Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-apps/netbox/, www-apps/netbox/files/
Date: Thu, 11 Apr 2019 21:03:35
Message-Id: 1555016504.70e9b5c3ac83e8d6a0c61c6415c4a20358f9d596.williamh@gentoo
1 commit: 70e9b5c3ac83e8d6a0c61c6415c4a20358f9d596
2 Author: William Hubbs <william.hubbs <AT> sony <DOT> com>
3 AuthorDate: Thu Apr 11 21:01:16 2019 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 11 21:01:44 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70e9b5c3
7
8 www-apps/netbox: IP address and data center infra management tool
9
10 Copyright: Sony Interactive Entertainment Inc.
11 Package-Manager: Portage-2.3.62, Repoman-2.3.12
12 Signed-off-by: William Hubbs <williamh <AT> gentoo.org>
13
14 www-apps/netbox/Manifest | 1 +
15 www-apps/netbox/files/gunicorn_config.py | 5 ++
16 www-apps/netbox/files/netbox-2.5.10-no-pip.patch | 27 ++++++
17 www-apps/netbox/files/netbox-rqworker.initd | 11 +++
18 www-apps/netbox/files/netbox.initd | 10 +++
19 www-apps/netbox/metadata.xml | 11 +++
20 www-apps/netbox/netbox-2.5.10.ebuild | 100 +++++++++++++++++++++++
21 7 files changed, 165 insertions(+)
22
23 diff --git a/www-apps/netbox/Manifest b/www-apps/netbox/Manifest
24 new file mode 100644
25 index 00000000000..1b395a70295
26 --- /dev/null
27 +++ b/www-apps/netbox/Manifest
28 @@ -0,0 +1 @@
29 +DIST netbox-2.5.10.tar.gz 2363340 BLAKE2B 9bc946398ac75b585f2bc6fdb01bfb7545c92ccbb239e9ac0309b66be435134a87cde5fcf876cec4c3354e7aedf5af1d9e1976574689dfb0af34404e9c9f907f SHA512 ed71b0efaffd8bad6e53f7b281d1933234161f031110fa901e1b789a964f000f2ff13897685e79193cbee9294c1f50b8c6edef7d0ef6f829a7357640c8034525
30
31 diff --git a/www-apps/netbox/files/gunicorn_config.py b/www-apps/netbox/files/gunicorn_config.py
32 new file mode 100644
33 index 00000000000..4cb7111fac4
34 --- /dev/null
35 +++ b/www-apps/netbox/files/gunicorn_config.py
36 @@ -0,0 +1,5 @@
37 +command = '/usr/bin/gunicorn'
38 +pythonpath = '/opt/netbox/netbox'
39 +bind = '127.0.0.1:8001'
40 +workers = 3
41 +user = 'netbox'
42
43 diff --git a/www-apps/netbox/files/netbox-2.5.10-no-pip.patch b/www-apps/netbox/files/netbox-2.5.10-no-pip.patch
44 new file mode 100644
45 index 00000000000..5d1fa595f4e
46 --- /dev/null
47 +++ b/www-apps/netbox/files/netbox-2.5.10-no-pip.patch
48 @@ -0,0 +1,27 @@
49 +diff --git a/upgrade.sh b/upgrade.sh
50 +index 24e79f5b..248e1cb5 100755
51 +--- a/upgrade.sh
52 ++++ b/upgrade.sh
53 +@@ -8,22 +8,6 @@
54 + PYTHON="python3"
55 + PIP="pip3"
56 +
57 +-# TODO: Remove this in v2.6 as it is no longer needed under Python 3
58 +-# Delete stale bytecode
59 +-COMMAND="find . -name \"*.pyc\" -delete"
60 +-echo "Cleaning up stale Python bytecode ($COMMAND)..."
61 +-eval $COMMAND
62 +-
63 +-# Uninstall any Python packages which are no longer needed
64 +-COMMAND="${PIP} uninstall -r old_requirements.txt -y"
65 +-echo "Removing old Python packages ($COMMAND)..."
66 +-eval $COMMAND
67 +-
68 +-# Install any new Python packages
69 +-COMMAND="${PIP} install -r requirements.txt --upgrade"
70 +-echo "Updating required Python packages ($COMMAND)..."
71 +-eval $COMMAND
72 +-
73 + # Apply any database migrations
74 + COMMAND="${PYTHON} netbox/manage.py migrate"
75 + echo "Applying database migrations ($COMMAND)..."
76
77 diff --git a/www-apps/netbox/files/netbox-rqworker.initd b/www-apps/netbox/files/netbox-rqworker.initd
78 new file mode 100644
79 index 00000000000..2973e471e03
80 --- /dev/null
81 +++ b/www-apps/netbox/files/netbox-rqworker.initd
82 @@ -0,0 +1,11 @@
83 +#!/sbin/openrc-run
84 +# Copyright 2019 Sony Interactive Entertainment Inc.
85 +# Distributed under the terms of the GNU General Public License v2
86 +
87 +name="netbox-rqworker daemon"
88 +description="nnetbox-rqworker daemon"
89 +command=/usr/bin/python3
90 +command_args="/opt/netbox/netbox/manage.py rqworker"
91 +command_user=netbox:netbox
92 +directory=/opt/netbox/netbox
93 +supervisor=supervise-daemon
94
95 diff --git a/www-apps/netbox/files/netbox.initd b/www-apps/netbox/files/netbox.initd
96 new file mode 100644
97 index 00000000000..d0457a8372f
98 --- /dev/null
99 +++ b/www-apps/netbox/files/netbox.initd
100 @@ -0,0 +1,10 @@
101 +#!/sbin/openrc-run
102 +# Copyright 2019 Sony Interactive Entertainment Inc.
103 +# Distributed under the terms of the GNU General Public License v2
104 +
105 +description="netbox daemon"
106 +command=/usr/bin/gunicorn
107 +command_args="-c /etc/netbox/gunicorn_config.py netbox.wsgi"
108 +command_user=netbox:netbox
109 +directory=/opt/netbox/netbox
110 +supervisor=supervise-daemon
111
112 diff --git a/www-apps/netbox/metadata.xml b/www-apps/netbox/metadata.xml
113 new file mode 100644
114 index 00000000000..f53806a2283
115 --- /dev/null
116 +++ b/www-apps/netbox/metadata.xml
117 @@ -0,0 +1,11 @@
118 +<?xml version="1.0" encoding="UTF-8"?>
119 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
120 +<pkgmetadata>
121 + <maintainer type="person">
122 + <email>williamh@g.o</email>
123 + <name>William Hubbs</name>
124 + </maintainer>
125 + <use>
126 + <flag name="webhooks">Enable webhooks via django-rq</flag>
127 + </use>
128 +</pkgmetadata>
129
130 diff --git a/www-apps/netbox/netbox-2.5.10.ebuild b/www-apps/netbox/netbox-2.5.10.ebuild
131 new file mode 100644
132 index 00000000000..efa1ca65e92
133 --- /dev/null
134 +++ b/www-apps/netbox/netbox-2.5.10.ebuild
135 @@ -0,0 +1,100 @@
136 +# Copyright 1999-2019 Gentoo Authors
137 +# Distributed under the terms of the GNU General Public License v2
138 +
139 +EAPI=7
140 +PYTHON_COMPAT=( python3_6 )
141 +inherit python-single-r1 user readme.gentoo-r1
142 +
143 +DESCRIPTION="IP address and data center infrastructure management tool"
144 +HOMEPAGE="https://github.com/digitalocean/netbox"
145 +SRC_URI="https://github.com/digitalocean/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
146 +
147 +LICENSE="Apache-2.0"
148 +SLOT="0"
149 +KEYWORDS="~amd64"
150 +IUSE="ldap webhooks"
151 +
152 +RDEPEND=">=dev-python/django-2.1.5[${PYTHON_USEDEP}]
153 + >=dev-python/django-cors-headers-2.4.0[${PYTHON_USEDEP}]
154 + >=dev-python/django-debug-toolbar-1.11[${PYTHON_USEDEP}]
155 + >=dev-python/django-filter-2.0.0[${PYTHON_USEDEP}]
156 + >=dev-python/django-mptt-0.9.1[${PYTHON_USEDEP}]
157 + >=dev-python/django-tables2-2.0.3[${PYTHON_USEDEP}]
158 + >=dev-python/django-taggit-0.23.0[${PYTHON_USEDEP}]
159 + >=dev-python/django-taggit-serializer-0.1.7[${PYTHON_USEDEP}]
160 + >=dev-python/django-timezone-field-3.0[${PYTHON_USEDEP}]
161 + >=dev-python/djangorestframework-3.9.0[${PYTHON_USEDEP}]
162 + >=dev-python/drf-yasg-1.14.0[${PYTHON_USEDEP},validation]
163 + >=dev-python/graphviz-0.10.1[${PYTHON_USEDEP}]
164 + >=dev-python/jinja-2.10[${PYTHON_USEDEP}]
165 + >=dev-python/markdown-2.6.11[${PYTHON_USEDEP}]
166 + >=dev-python/netaddr-0.7.19[${PYTHON_USEDEP}]
167 + >=dev-python/pillow-5.3.0[${PYTHON_USEDEP}]
168 + >=dev-python/psycopg-2.7.6.1[${PYTHON_USEDEP}]
169 + >=dev-python/py-gfm-0.1.4[${PYTHON_USEDEP}]
170 + >=dev-python/pycryptodome-3.7.2[${PYTHON_USEDEP}]
171 + www-servers/gunicorn[${PYTHON_USEDEP}]
172 + ldap? ( >=dev-python/django-auth-ldap-1.7[${PYTHON_USEDEP}] )
173 + webhooks? ( dev-python/django-rq )"
174 +DEPEND="${RDEPEND}"
175 +
176 +PATCHES=(
177 + "${FILESDIR}"/${P}-no-pip.patch
178 + )
179 +
180 +DISABLE_AUTOFORMATTING=YES
181 +DOC_CONTENTS="
182 +netbox is installed on your system. However, there are some manual steps
183 +you need to complete.
184 +
185 +If this is a new installation, please follow these instructions:
186 +
187 +From the installation instructions [1], you need to configure postgres
188 +ldap and webhooks if you want to use them. Then, you need to
189 +configure and install a web server. Gunicorn is already installed, so
190 +skip that step.
191 +
192 +Once that is done, you should be able to add the netbox service to the
193 +default runlevel and start it.
194 +
195 +If you have webhooks turned on, you should also add the netbox-rqworker
196 + to the default runlevel and start it.
197 +
198 +The files you need to edit are located in /etc/netbox, not /opt/netbox,
199 +as shown in the installation instructions.
200 +
201 +If this is an upgrade, you just need to stop the netbox service,
202 + run the /opt/netbox/upgrade.sh script, check for new configuration
203 + options in the installation documentation [1] then restart the
204 + service.
205 +
206 +[1] https://netbox.readthedocs.io/en/stable/installation/
207 +"
208 +
209 +pkg_setup() {
210 + enewgroup ${PN}
211 + enewuser ${PN} -1 -1 /opt/${PN} ${PN}
212 +}
213 +
214 +src_install() {
215 + dodir /opt
216 + cp -a ../${P} "${ED}"/opt
217 + dosym ${P} /opt/netbox
218 +dosym ../../etc/netbox/gunicorn_config.py /opt/netbox/gunicorn_config.py
219 + dosym ../../../../etc/netbox/configuration.py \
220 + /opt/netbox/netbox/netbox/configuration.py
221 + dodir /etc/netbox
222 + insinto /etc/netbox
223 + newins netbox/netbox/configuration.example.py configuration.py
224 + doins "${FILESDIR}"/gunicorn_config.py
225 + fowners -R netbox:netbox /etc/netbox
226 + fperms o= /etc/netbox/configuration.py /etc/netbox/gunicorn_config.py
227 + newinitd "${FILESDIR}"/${PN}.initd ${PN}
228 + use webhooks &&
229 + newinitd "${FILESDIR}"/${PN}-rqworker.initd ${PN}-rqworker
230 + readme.gentoo_create_doc
231 +}
232 +
233 +pkg_postinst() {
234 + readme.gentoo_print_elog
235 +}