summaryrefslogtreecommitdiff
blob: cec2ec12b67cf481c256f4527dbf769b7ab0ccba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

if [[ ${PV} == "9999" ]] ; then
	EGIT_REPO_URI="https://github.com/scylladb/scylla-jmx.git"
	inherit git-r3
else
	MY_PV="${PV/_rc/.rc}"
	MY_P="${PN}-${MY_PV}"
	SRC_URI="https://github.com/scylladb/${PN}/archive/scylla-${MY_PV}.tar.gz -> ${MY_P}.tar.gz"
	KEYWORDS="~amd64"
	S="${WORKDIR}/scylla-jmx-scylla-${MY_PV}"
fi

PYTHON_COMPAT=( python3_6 )

inherit java-pkg-2 python-r1 systemd user

DESCRIPTION="Scylla JMX"
HOMEPAGE="https://github.com/scylladb/scylla-jmx"

LICENSE="Apache-2.0"
SLOT="0"

CDEPEND="dev-java/maven-bin:3.3"

REQUIRED_USE="${PYTHON_REQUIRED_USE}"

RDEPEND="
	${CDEPEND}
	${PYTHON_DEPS}
	>=virtual/jre-1.8"

DEPEND="
	${CDEPEND}
	>=virtual/jdk-1.8
	dev-python/pystache[${PYTHON_USEDEP}]"

RESTRICT="test"

pkg_setup() {
	enewgroup scylla
	enewuser scylla -1 -1 /var/lib/${PN} scylla
}

src_prepare() {
	default

	# fix symlink runtime error on scylla-jmx script
	# * scylla-jmx is not available for oracle-jdk-bin-1.8 on x86_64
	# * IMPORTANT: some Java tools are not available on some VMs on some architectures
	sed -e 's@"$LOCATION_SCRIPTS"/symlinks/scylla-jmx@/usr/bin/java@g' -i scripts/scylla-jmx || die
}

src_compile() {
	mvn -B install || die
}

src_install() {
	default

	insinto /etc/default
	doins dist/common/sysconfig/scylla-jmx

	insinto /usr/lib/scylla/jmx
	doins target/scylla-jmx-1.0.jar

	# removed because of src_prepare fix
	#dodir /usr/lib/scylla/jmx/symlinks
	#dosym /usr/bin/java /usr/lib/scylla/jmx/symlinks/scylla-jmx

	exeinto /usr/lib/scylla/jmx
	doexe scripts/scylla-jmx

	newinitd "${FILESDIR}/scylla-jmx.initd" ${PN}
	newconfd "${FILESDIR}/scylla-jmx.confd" ${PN}

	local MUSTACHE_DIST="\"debian\": true"
	pystache dist/common/systemd/scylla-jmx.service.mustache "{ $MUSTACHE_DIST }" > scylla-jmx.service
	systemd_dounit scylla-jmx.service
}

pkg_postinst() {
	ping -c1 `hostname` > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		ewarn
		ewarn "**************************************************************"
		ewarn "* WARNING: You need to add hostname on /etc/hosts, otherwise *"
		ewarn "*          scylla-jmx will not able to start up.             *"
		ewarn "**************************************************************"
		ewarn
	fi
}