summaryrefslogtreecommitdiff
blob: b43ae3df098648853738cd78b11b3a7c2955d407 (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
# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
inherit go-module systemd

DESCRIPTION="MQTT broker library with cluster support that implements MQTT V5.0 and V3.1.1"
HOMEPAGE="https://github.com/DrmagicE/gmqtt"
SRC_URI="https://github.com/DrmagicE/gmqtt/archive/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://dev.gentoo.org/~zmedico/dist/${P}-deps.tar.xz"

LICENSE="MIT Apache-2.0 BSD BSD-2 ISC MPL-2.0"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""
RESTRICT="test"

src_compile() {
	GOBIN=${S}/bin CGO_ENABLED=0 go install ./... || die
}

src_install() {
	dobin bin/{gmqctl,gmqttd}
	keepdir /etc/${PN}
	systemd_dounit "${FILESDIR}/${PN}d.service"
	newinitd "${FILESDIR}/initd" "${PN}d"
	newconfd "${FILESDIR}/confd" "${PN}d"
	insinto /etc/logrotate.d
	newins "${FILESDIR}/logrotated" "${PN}"
	docompress -x /usr/share/doc/${PF}/default_config.yml
	dodoc CONTRIBUTING.md README*.md cmd/gmqttd/default_config.yml
	docinto federation
	dodoc -r plugin/federation/{examples,README.md}
}

pkg_postinst() {
	local config=/etc/gmqtt/gmqttd.yml dest=${ROOT}/
	if [[ ! ${REPLACING_VERSIONS} && ! -e ${ROOT}${config} ]]; then
		einfo "Copying default config to ${config} for first install"
		cp "${ROOT}/usr/share/doc/${PF}/default_config.yml" "${ROOT}${config}"
	fi
}