aboutsummaryrefslogtreecommitdiff
blob: a7e45d69382c115da7552ebc2cabeaa1bfc6b522 (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
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

LUA_COMPAT=( lua5-{1..4} )

inherit fcaps lua-single systemd cmake linux-info

DESCRIPTION="hinsightd a http/1.1 webserver with (hopefully) minimal goals"
HOMEPAGE="https://gitlab.com/tiotags/hin9"

if [[ ${PV} == *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://gitlab.com/tiotags/hin9.git"
else
	SRC_URI="https://gitlab.com/tiotags/hin9/-/archive/v${PV}/hin9-v${PV}.tar.gz"
	S="${WORKDIR}/hin9-v${PV}"
	KEYWORDS="~amd64"
fi

LICENSE="BSD"
SLOT="0"

IUSE="+openssl"
REQUIRED_USE="${LUA_REQUIRED_USE}"

BDEPEND="
	dev-util/cmake
	virtual/pkgconfig
"

RDEPEND="
	${LUA_DEPS}
	acct-user/hinsightd
	acct-group/hinsightd
	sys-libs/liburing
	sys-libs/zlib
	openssl? ( dev-libs/openssl )
"

DEPEND="${RDEPEND}"

PATCHES=(
	"${FILESDIR}/hinsightd-redefine-directories.patch"
	"${FILESDIR}/hinsightd-default-config.patch"
)

src_configure() {
	local mycmakeargs=(
		-DUSE_OPENSSL=$(usex openssl)
	)
	cmake_src_configure
}

src_install() {
	newbin "${BUILD_DIR}/hin9" hinsightd
	newinitd "${FILESDIR}/init.d.sh" hinsightd
	systemd_dounit "${FILESDIR}/hinsightd.service" # not tested

	insinto /etc/hinsightd
	newins "${S}/workdir/main.lua" hinsightd.lua

	# logrotate
	insinto /etc/logrotate.d
	newins "${FILESDIR}"/logrotate.d.sh hinsightd

	keepdir /var/www/localhost/htdocs
	keepdir /var/log/hinsightd
	keepdir /var/tmp/hinsightd
}

pkg_postinst() {
	fcaps CAP_NET_BIND_SERVICE /usr/bin/hinsightd

	if kernel_is lt 5 7; then
		ewarn ""
		ewarn "hinsightd requires io_uring and kernel ~5.6.0"
		ewarn ""
	fi
}