dev-db/mariadb-connector-c: remove unused patch
[gentoo.git] / net-vpn / i2pd / i2pd-2.21.1.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 inherit systemd user cmake-utils eapi7-ver toolchain-funcs
6
7 DESCRIPTION="A C++ daemon for accessing the I2P anonymous network"
8 HOMEPAGE="https://github.com/PurpleI2P/i2pd"
9 SRC_URI="https://github.com/PurpleI2P/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
10 LICENSE="BSD"
11 SLOT="0"
12 KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~ppc ~ppc64 ~x86"
13 IUSE="cpu_flags_x86_aes cpu_flags_x86_avx i2p-hardening libressl static +upnp websocket"
14
15 # if using libressl, require >=boost-1.65, see #597798
16 RDEPEND="
17         !static? (
18                 dev-libs/boost[threads]
19                 !libressl? ( dev-libs/openssl:0[-bindist] )
20                 libressl? (
21                         dev-libs/libressl:0
22                         >=dev-libs/boost-1.65
23                 )
24                 upnp? ( net-libs/miniupnpc )
25         )"
26 DEPEND="${RDEPEND}
27         static? (
28                 dev-libs/boost[static-libs,threads]
29                 !libressl? ( dev-libs/openssl:0[static-libs] )
30                 libressl? (
31                         dev-libs/libressl:0[static-libs]
32                         >=dev-libs/boost-1.65
33                 )
34                 sys-libs/zlib[static-libs]
35                 upnp? ( net-libs/miniupnpc[static-libs] )
36         )
37         websocket? ( dev-cpp/websocketpp )"
38
39 I2PD_USER=i2pd
40 I2PD_GROUP=i2pd
41
42 CMAKE_USE_DIR="${S}/build"
43
44 DOCS=( README.md contrib/i2pd.conf contrib/tunnels.conf )
45
46 PATCHES=( "${FILESDIR}/${PN}-2.14.0-fix_installed_components.patch" )
47
48 pkg_pretend() {
49         if tc-is-gcc && ! ver_test "$(gcc-version)" -ge "4.7"; then
50                 die "At least gcc 4.7 is required"
51         fi
52         if use i2p-hardening && ! tc-is-gcc; then
53                 die "i2p-hardening requires gcc"
54         fi
55 }
56
57 src_configure() {
58         mycmakeargs=(
59                 -DWITH_AESNI=$(usex cpu_flags_x86_aes ON OFF)
60                 -DWITH_AVX=$(usex cpu_flags_x86_avx ON OFF)
61                 -DWITH_HARDENING=$(usex i2p-hardening ON OFF)
62                 -DWITH_PCH=OFF
63                 -DWITH_STATIC=$(usex static ON OFF)
64                 -DWITH_UPNP=$(usex upnp ON OFF)
65                 -DWITH_WEBSOCKETS=$(usex websocket ON OFF)
66                 -DWITH_LIBRARY=ON
67                 -DWITH_BINARY=ON
68         )
69         cmake-utils_src_configure
70 }
71
72 src_install() {
73         cmake-utils_src_install
74
75         # config
76         insinto /etc/i2pd
77         doins contrib/i2pd.conf
78         doins contrib/tunnels.conf
79
80         # grant i2pd group read and write access to config files
81         fowners "root:${I2PD_GROUP}" \
82                 /etc/i2pd/i2pd.conf \
83                 /etc/i2pd/tunnels.conf
84         fperms 660 \
85                 /etc/i2pd/i2pd.conf \
86                 /etc/i2pd/tunnels.conf
87
88         # working directory
89         keepdir /var/lib/i2pd
90         insinto /var/lib/i2pd
91         doins -r contrib/certificates
92         fowners "${I2PD_USER}:${I2PD_GROUP}" /var/lib/i2pd/
93         fperms 700 /var/lib/i2pd/
94
95         # add /var/lib/i2pd/certificates to CONFIG_PROTECT
96         doenvd "${FILESDIR}/99i2pd"
97
98         # openrc and systemd daemon routines
99         newconfd "${FILESDIR}/i2pd-2.6.0-r3.confd" i2pd
100         newinitd "${FILESDIR}/i2pd-2.6.0-r3.initd" i2pd
101         systemd_newunit "${FILESDIR}/i2pd-2.6.0-r3.service" i2pd.service
102
103         # logrotate
104         insinto /etc/logrotate.d
105         newins "${FILESDIR}/i2pd-2.6.0-r3.logrotate" i2pd
106 }
107
108 pkg_setup() {
109         enewgroup "${I2PD_GROUP}"
110         enewuser "${I2PD_USER}" -1 -1 /var/lib/run/i2pd "${I2PD_GROUP}"
111 }
112
113 pkg_postinst() {
114         if [[ -f ${EROOT%/}/etc/i2pd/subscriptions.txt ]]; then
115                 ewarn
116                 ewarn "Configuration of the subscriptions has been moved from"
117                 ewarn "subscriptions.txt to i2pd.conf. We recommend updating"
118                 ewarn "i2pd.conf accordingly and deleting subscriptions.txt."
119         fi
120 }