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

EAPI=7

SSL_DEPS_SKIP=1
SSL_DAYS=36500

inherit ssl-cert toolchain-funcs

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

if [[ ${PV} == "9999" ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://git.omarpolo.com/${PN}"
else
	SRC_URI="https://git.omarpolo.com/${PN}/snapshot/${P}.tar.gz"
	KEYWORDS="~amd64 ~x86"
fi

LICENSE="ISC"
SLOT="0"
IUSE="libressl"

PATCHES=( "${FILESDIR}"/${P}-make-pidfile.patch )

DEPEND="acct-user/gemini
	dev-libs/libevent
	!libressl? ( dev-libs/libretls )
	libressl? ( dev-libs/libressl )"
BDEPEND="sys-devel/flex
	virtual/yacc"
RDEPEND="${DEPEND}"

DOCS=( README.md ChangeLog )

src_prepare() {
	default

	# QA Notice: command not found
	# remove `etags` from the "all" target
	sed \
		-e "s/^\(all: .*\) TAGS \(.*\)$/\1 \2/" \
		-i Makefile || die
}

src_configure() {
	# note: not an autoconf configure script
	./configure \
		CC="$(tc-getCC)" \
		PREFIX="${EPREFIX}"/usr/share \
		BINDIR="${EPREFIX}"/usr/bin \
		CFLAGS="${CFLAGS}" \
		LDFLAGS="${LDFLAGS} -ltls -lssl -lcrypto -levent" || die
}

src_install() {
	default

	dodir /etc/gmid
	cp "${FILESDIR}"/gmid.conf "${ED}"/etc/gmid/gmid.conf || die

	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)."
}