aboutsummaryrefslogtreecommitdiff
blob: 184d8c365e18170641f9ce6fe1302814d12e2721 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

SSL_DAYS=36500
SSL_CERT_MANDATORY=1
VERIFY_SIG_METHOD="signify"
inherit edo ssl-cert systemd toolchain-funcs verify-sig

DESCRIPTION="Simple and secure Gemini server"
HOMEPAGE="https://gmid.omarpolo.com"

if [[ ${PV} == 9999 ]]; then
	EGIT_REPO_URI="https://git.omarpolo.com/${PN} https://github.com/omar-polo/${PN}.git"
	inherit git-r3
else
	SRC_URI="https://github.com/omar-polo/${PN}/releases/download/${PV}/${P}.tar.gz
		verify-sig? ( https://github.com/omar-polo/${PN}/releases/download/${PV}/SHA256.sig -> ${P}.sha.sig )"
	KEYWORDS="~amd64 ~x86"
fi

LICENSE="BSD ISC MIT"
SLOT="0"
IUSE="seccomp test"
RESTRICT="!test? ( test )"

DEPEND="
	acct-user/gemini
	dev-libs/imsg-compat
	dev-libs/libevent:=
	dev-libs/libretls:=
	dev-libs/openssl:=
	!elibc_Darwin? ( dev-libs/libbsd )
"
RDEPEND="${DEPEND}"
BDEPEND="
	virtual/pkgconfig
	app-alternatives/yacc
	seccomp? ( sys-kernel/linux-headers )
"
if [[ ${PV} != 9999 ]]; then
	BDEPEND+="verify-sig? ( sec-keys/signify-keys-gmid:$(ver_cut 1-2) )"
fi

VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}/usr/share/signify-keys/${PN}-$(ver_cut 1-2).pub"

DOCS=( README.md ChangeLog contrib/README )

src_unpack() {
	if [[ ${PV} == 9999 ]]; then
		git-r3_src_unpack
	else
		if use verify-sig; then
			# Too many levels of symbolic links
			cp "${DISTDIR}"/${P}.{sha.sig,tar.gz} "${WORKDIR}" || die
			cd "${WORKDIR}" || die
			verify-sig_verify_signed_checksums \
				${P}.sha.sig sha256 ${P}.tar.gz
		fi
		default
	fi
}

src_configure() {
	local conf_args
	tc-export CC

	# note: not an autoconf configure script
	conf_args=(
		PREFIX="${EPREFIX}"/usr
		MANDIR="${EPREFIX}"/usr/share/man
		$(use_enable seccomp sandbox)
	)

	edo ./configure "${conf_args[@]}" || die

	if use seccomp && has usersandbox ${FEATURES} ; then
		export SKIP_RUNTIME_TESTS=1
	fi
}

src_install() {
	default

	insinto /etc/gmid
	doins "${FILESDIR}"/gmid.conf

	insinto /usr/share/vim/vimfiles
	doins -r contrib/vim/*

	systemd_dounit "${FILESDIR}"/gmid.service
	newinitd "${FILESDIR}"/gmid.initd gmid
	newconfd "${FILESDIR}"/gmid.confd gmid

	keepdir /var/gemini/localhost
}

pkg_postinst() {
	if [[ ! -f "${EROOT}"/etc/ssl/${PN}/${PN}.key ]]; then
		install_cert /etc/ssl/${PN}/${PN}
		chown gemini:gemini "${EROOT}"/etc/ssl/${PN}/${PN}.{crt,csr,key,pem}
	fi

	einfo "This gemini server can be run as a user with zero configuration.\n"
	einfo "In order to use it with the init service you will need to generate a"
	einfo "self-signed TLS certificate and a key and set up the configuration"
	einfo "file (see man 1 gmid for details)."
}