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

EAPI=7

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

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
	virtual/libcrypt
	openssl? ( dev-libs/openssl )
"

DEPEND="${RDEPEND}"

PATCHES=(
	"${FILESDIR}/${PN}-defines-v4.patch"
)

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

src_install() {
	newsbin "${BUILD_DIR}/hin9" $PN
	newinitd "${S}/external/packaging/$PN.initd.sh" $PN
	newconfd "${S}/external/packaging/$PN.confd.sh" $PN
	systemd_dounit "${FILESDIR}/$PN.service" # not tested

	# config
	insinto /etc/$PN
	doins "${S}/workdir/main.lua"
	doins "${S}/workdir/lib.lua"
	doins "${S}/workdir/default_config.lua"

	# logrotate
	insinto /etc/logrotate.d
	newins "${S}/external/packaging/$PN.logrotate.sh" $PN

	keepdir /var/www/localhost/htdocs
}

pkg_postinst() {
	fcaps CAP_NET_BIND_SERVICE /usr/sbin/$PN

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

	ewarn ""
	ewarn "hinsightd requires a higher than default RLIMIT_MEMLOCK for"
	ewarn "things like graceful restarting"
	ewarn "memory limit can be increased in /etc/security/limits.conf"
	ewarn ""
}