dev-python/thumbor: Add this image-thumbnailing service
authorW. Trevor King <wking@tremily.us>
Tue, 30 Sep 2014 19:10:12 +0000 (12:10 -0700)
committerW. Trevor King <wking@tremily.us>
Wed, 22 Oct 2014 22:35:30 +0000 (15:35 -0700)
files/init.d/thumbor [new file with mode: 0755]
thumbor-9999.ebuild [new file with mode: 0644]

diff --git a/files/init.d/thumbor b/files/init.d/thumbor
new file mode 100755 (executable)
index 0000000..247c5c3
--- /dev/null
@@ -0,0 +1,50 @@
+#!/sbin/runscript
+
+PC_USER="${PC_USER:-thumbor}"
+PC_GROUP="${PC_GROUP:-thumbor}"
+CONFIG="${CONFIG:-/etc/thumbor/${SVCNAME}.conf}"
+HOME="/var/lib/thumbor"
+HOST="${HOST:-0.0.0.0}"
+PORT="${PORT:-80}"
+KEYFILE="${KEYFILE:-}"
+command="/usr/bin/thumbor"
+pidfile="/run/${SVCNAME}.pid"
+
+depend() {
+       need net
+}
+
+start() {
+       ebegin "Starting ${SVCNAME}"
+       if [[ -n "${KEYFILE}" ]] && [[ ! -f "${KEYFILE}" ]]; then
+               eend 1 "configured KEYFILE does not exist (${KEYFILE})"
+       fi
+       KEYFILE="${KEYFILE:-/etc/thumbor/${SVCNAME}.key}"
+       KEYFILE_OPTS=()
+       if [[ -f "${KEYFILE}" ]]; then
+               KEYFILE_OPTS+=( --keyfile "${KEYFILE}" )
+       fi
+       start-stop-daemon --start \
+               --user "${PC_USER}:${PC_GROUP}" \
+               --chdir "${HOME}" \
+               --exec "${command}" \
+               --background \
+               --pidfile "${pidfile}" \
+               --make-pidfile \
+               -- \
+               --syslog \
+               --ip "${HOST}" \
+               --port "${PORT}" \
+               "${KEYFILE_OPTS[@]}" \
+               ${PC_OPTS:+${PC_OPTS}}
+       eend $?
+}
+
+stop() {
+       ebegin "Stopping ${SVCNAME}"
+       start-stop-daemon --stop \
+               --user "${PC_USER}:${PC_GROUP}" \
+               --exec "${command}" \
+               --pidfile "${pidfile}"
+       eend $?
+}
diff --git a/thumbor-9999.ebuild b/thumbor-9999.ebuild
new file mode 100644 (file)
index 0000000..011aeac
--- /dev/null
@@ -0,0 +1,80 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=5
+PYTHON_COMPAT=( python2_7 )
+
+inherit distutils-r1 user
+
+if [[ "${PV}" == "9999" ]]; then
+       inherit git-2
+       EGIT_REPO_URI="git://github.com/thumbor/thumbor.git"
+       SRC_URI=""
+else
+       SRC_URI="mirror://pypi/${P:0:1}/${PN}/${P}.tar.gz"
+fi
+
+DESCRIPTION="An an open-source photo thumbnail service"
+HOMEPAGE="https://github.com/thumbor/thumbor https://pypi.python.org/pypi/thumbor"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="test"
+
+RDEPEND="
+       >=dev-python/derpconf-0.2.0[${PYTHON_USEDEP}]
+       >=dev-python/pillow-2.1.0[${PYTHON_USEDEP}]
+       <dev-python/pillow-2.4.0[${PYTHON_USEDEP}]
+       >=dev-python/pycrypto-2.1.0[${PYTHON_USEDEP}]
+       >=dev-python/pycurl-7.19.0[${PYTHON_USEDEP}]
+       <dev-python/pycurl-7.20.0[${PYTHON_USEDEP}]
+       >=dev-python/python-magic-0.4.3[${PYTHON_USEDEP}]
+       >=dev-python/thumbor-pexif-0.14[${PYTHON_USEDEP}]
+       <dev-python/thumbor-pexif-1.0[${PYTHON_USEDEP}]
+       media-libs/opencv[${PYTHON_USEDEP}]
+       >=www-servers/tornado-2.3.0[${PYTHON_USEDEP}]
+       <www-servers/tornado-3.3.0[${PYTHON_USEDEP}]
+       "
+DEPEND="
+       dev-python/setuptools[${PYTHON_USEDEP}]
+       test? (
+               ${RDEPEND}
+               dev-python/colorama[${PYTHON_USEDEP}]
+               dev-python/coverage[${PYTHON_USEDEP}]
+               dev-python/gevent[${PYTHON_USEDEP}]
+               dev-python/mock[${PYTHON_USEDEP}]
+               dev-python/nose[${PYTHON_USEDEP}]
+               dev-python/numpy[${PYTHON_USEDEP}]
+               >=dev-python/preggy-0.6.2[${PYTHON_USEDEP}]
+               >=dev-python/pymongo-2.1.1[${PYTHON_USEDEP}]
+               >=dev-python/pyvows-2.0.4[${PYTHON_USEDEP}]
+               dev-python/raven[${PYTHON_USEDEP}]
+               >=dev-python/redis-py-2.4.9[${PYTHON_USEDEP}]
+               >=dev-python/tornado-pyvows-0.5.2[${PYTHON_USEDEP}]
+       )
+       "
+
+pkg_setup() {
+       P_HOME="${EPREFIX}/var/lib/${PN}"
+       ebegin "Creating ${PN} user and group"
+       enewgroup "${PN}"
+       enewuser "${PN}" -1 -1 "${P_HOME}" "${PN}"
+       eend $?
+}
+
+python_test() {
+       make test || die "Testsuite failed under ${EPYTHON}"
+}
+
+python_install_all() {
+       distutils-r1_python_install_all
+       doinitd "${FILESDIR}/init.d/${PN}"
+       mkdir "${ED}etc/${PN}" || die "Failed to make ${EPREFIX}/etc/${PN}"
+       PYTHONPATH="${ED}/usr/lib64/python2.7/site-packages" "${ED}/usr/lib/python-exec/python2.7/thumbor-config" \
+               > "${ED}etc/${PN}/${PN}.conf" ||
+               die "Failed to run thumbor-config"
+       mkdir -p "${ED}var/lib/${PN}" || die "Failed to make ${EPREFIX}/var/lib/${PN}"
+       chown -R "${PN}:${PN}" "${ED}etc/${PN}" "${ED}var/lib/${PN}" || die "Failed to chown ${PN}:${PN}"
+}