*/*: Bump copyright on files touched this year
[gentoo.git] / www-servers / apache / apache-2.4.41.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 # latest gentoo apache files
7 GENTOO_PATCHSTAMP="20190402"
8 GENTOO_DEVELOPER="polynomial-c"
9 GENTOO_PATCHNAME="gentoo-apache-2.4.39"
10
11 # IUSE/USE_EXPAND magic
12 IUSE_MPMS_FORK="prefork"
13 IUSE_MPMS_THREAD="event worker"
14
15 # << obsolete modules:
16 # authn_default authz_default mem_cache
17 # mem_cache is replaced by cache_disk
18 # ?? buggy modules
19 # proxy_scgi: startup error: undefined symbol "ap_proxy_release_connection", no fix found
20 # >> added modules for reason:
21 # compat: compatibility with 2.2 access control
22 # authz_host: new module for access control
23 # authn_core: functionality provided by authn_alias in previous versions
24 # authz_core: new module, provides core authorization capabilities
25 # cache_disk: replacement for mem_cache
26 # lbmethod_byrequests: Split off from mod_proxy_balancer in 2.3
27 # lbmethod_bytraffic: Split off from mod_proxy_balancer in 2.3
28 # lbmethod_bybusyness: Split off from mod_proxy_balancer in 2.3
29 # lbmethod_heartbeat: Split off from mod_proxy_balancer in 2.3
30 # slotmem_shm: Slot-based shared memory provider (for lbmethod_byrequests).
31 # socache_shmcb: shared object cache provider. Default config with ssl needs it
32 # unixd: fixes startup error: Invalid command 'User'
33 IUSE_MODULES="access_compat actions alias asis auth_basic auth_digest auth_form
34 authn_alias authn_anon authn_core authn_dbd authn_dbm authn_file authn_socache authz_core
35 authz_dbd authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex
36 brotli cache cache_disk cache_socache cern_meta charset_lite cgi cgid dav dav_fs dav_lock
37 dbd deflate dir dumpio env expires ext_filter file_cache filter headers http2
38 ident imagemap include info lbmethod_byrequests lbmethod_bytraffic lbmethod_bybusyness
39 lbmethod_heartbeat log_config log_forensic logio macro md mime mime_magic negotiation
40 proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_html proxy_http proxy_scgi
41 proxy_http2 proxy_fcgi  proxy_wstunnel rewrite ratelimit remoteip reqtimeout
42 session session_cookie session_crypto session_dbd setenvif slotmem_shm speling
43 socache_shmcb status substitute unique_id userdir usertrack unixd version vhost_alias
44 watchdog xml2enc"
45 # The following are also in the source as of this version, but are not available
46 # for user selection:
47 # bucketeer case_filter case_filter_in echo http isapi optional_fn_export
48 # optional_fn_import optional_hook_export optional_hook_import
49
50 # inter-module dependencies
51 # TODO: this may still be incomplete
52 MODULE_DEPENDS="
53         auth_form:session
54         brotli:filter
55         dav_fs:dav
56         dav_lock:dav
57         deflate:filter
58         cache_disk:cache
59         ext_filter:filter
60         file_cache:cache
61         lbmethod_byrequests:proxy_balancer
62         lbmethod_byrequests:slotmem_shm
63         lbmethod_bytraffic:proxy_balancer
64         lbmethod_bybusyness:proxy_balancer
65         lbmethod_heartbeat:proxy_balancer
66         log_forensic:log_config
67         logio:log_config
68         cache_disk:cache
69         cache_socache:cache
70         md:watchdog
71         mime_magic:mime
72         proxy_ajp:proxy
73         proxy_balancer:proxy
74         proxy_balancer:slotmem_shm
75         proxy_connect:proxy
76         proxy_ftp:proxy
77         proxy_html:proxy
78         proxy_html:xml2enc
79         proxy_http:proxy
80         proxy_http2:proxy
81         proxy_scgi:proxy
82         proxy_fcgi:proxy
83         proxy_wstunnel:proxy
84         session_cookie:session
85         session_dbd:dbd
86         session_dbd:session
87         substitute:filter
88 "
89
90 # module<->define mappings
91 MODULE_DEFINES="
92         auth_digest:AUTH_DIGEST
93         authnz_ldap:AUTHNZ_LDAP
94         cache:CACHE
95         cache_disk:CACHE
96         cache_socache:CACHE
97         dav:DAV
98         dav_fs:DAV
99         dav_lock:DAV
100         file_cache:CACHE
101         http2:HTTP2
102         info:INFO
103         ldap:LDAP
104         md:SSL
105         proxy:PROXY
106         proxy_ajp:PROXY
107         proxy_balancer:PROXY
108         proxy_connect:PROXY
109         proxy_ftp:PROXY
110         proxy_html:PROXY
111         proxy_http:PROXY
112         proxy_fcgi:PROXY
113         proxy_scgi:PROXY
114         proxy_wstunnel:PROXY
115         socache_shmcb:SSL
116         ssl:SSL
117         status:STATUS
118         suexec:SUEXEC
119         userdir:USERDIR
120 "
121
122 # critical modules for the default config
123 MODULE_CRITICAL="
124         authn_core
125         authz_core
126         authz_host
127         dir
128         mime
129         unixd
130 "
131 inherit apache-2 systemd tmpfiles toolchain-funcs
132
133 DESCRIPTION="The Apache Web Server"
134 HOMEPAGE="https://httpd.apache.org/"
135
136 # some helper scripts are Apache-1.1, thus both are here
137 LICENSE="Apache-2.0 Apache-1.1"
138 SLOT="2"
139 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-linux ~x64-macos ~x86-macos ~m68k-mint ~sparc64-solaris ~x64-solaris"
140
141 # Enable http2 by default (bug #563452)
142 # FIXME: Move to apache-2.eclass once this has reached stable.
143 IUSE="${IUSE/apache2_modules_http2/+apache2_modules_http2}"
144 # New suexec options (since 2.4.34)
145 IUSE="${IUSE} +suexec-caps suexec-syslog split-usr"
146
147 CDEPEND="apache2_modules_brotli? ( >=app-arch/brotli-0.6.0:= )
148         apache2_modules_http2? ( >=net-libs/nghttp2-1.2.1 )
149         apache2_modules_proxy_http2? ( >=net-libs/nghttp2-1.2.1 )
150         apache2_modules_md? ( >=dev-libs/jansson-2.10 )
151         apache2_modules_session_crypto? (
152                 libressl? ( dev-libs/apr-util[libressl] )
153                 !libressl? ( dev-libs/apr-util[openssl] )
154         )"
155
156 DEPEND+="${CDEPEND}
157         suexec? ( suexec-caps? ( sys-libs/libcap ) )"
158 RDEPEND+="${CDEPEND}"
159
160 REQUIRED_USE="apache2_modules_http2? ( ssl )
161         apache2_modules_md? ( ssl )"
162
163 PATCHES=(
164         "${FILESDIR}/${PN}-2.4.41-libressl.patch" #668060
165 )
166
167 pkg_setup() {
168         # dependend critical modules which are not allowed in global scope due
169         # to USE flag conditionals (bug #499260)
170         use ssl && MODULE_CRITICAL+=" socache_shmcb"
171         use doc && MODULE_CRITICAL+=" alias negotiation setenvif"
172         apache-2_pkg_setup
173 }
174
175 src_configure() {
176         # Brain dead check.
177         tc-is-cross-compiler && export ap_cv_void_ptr_lt_long="no"
178
179         apache-2_src_configure
180 }
181
182 src_compile() {
183         if tc-is-cross-compiler; then
184                 # This header is the same across targets, so use the build compiler.
185                 pushd server >/dev/null
186                 emake gen_test_char
187                 tc-export_build_env BUILD_CC
188                 ${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} \
189                         gen_test_char.c -o gen_test_char $(apr-1-config --includes) || die
190                 popd >/dev/null
191         fi
192
193         default
194 }
195
196 src_install() {
197         apache-2_src_install
198         local i
199         local apache_tools_prune_list=(
200                 /usr/bin/{htdigest,logresolve,htpasswd,htdbm,ab,httxt2dbm}
201                 /usr/sbin/{checkgid,fcgistarter,htcacheclean,rotatelogs}
202                 /usr/share/man/man1/{logresolve.1,htdbm.1,htdigest.1,htpasswd.1,dbmmanage.1,ab.1}
203                 /usr/share/man/man8/{rotatelogs.8,htcacheclean.8}
204         )
205         for i in ${apache_tools_prune_list[@]} ; do
206                 rm "${ED%/}"/${i} || die "Failed to prune apache-tools bits"
207         done
208
209         # install apxs in /usr/bin (bug #502384) and put a symlink into the
210         # old location until all ebuilds and eclasses have been modified to
211         # use the new location.
212         dobin support/apxs
213         use split-usr && dosym ../bin/apxs /usr/sbin/apxs
214
215         # Note: wait for mod_systemd to be included in some forthcoming release,
216         # Then apache2.4.service can be used and systemd support controlled
217         # through --enable-systemd
218         systemd_newunit "${FILESDIR}/apache2.2-hardened.service" "apache2.service"
219         systemd_dotmpfilesd "${FILESDIR}/apache.conf"
220         #insinto /etc/apache2/modules.d
221         #doins "${FILESDIR}/00_systemd.conf"
222
223         # Install http2 module config
224         insinto /etc/apache2/modules.d
225         doins "${FILESDIR}"/41_mod_http2.conf
226
227         # Fix path to apache libdir
228         sed "s|@LIBDIR@|$(get_libdir)|" -i "${ED%/}"/usr/sbin/apache2ctl || die
229 }
230
231 pkg_postinst() {
232         apache-2_pkg_postinst || die "apache-2_pkg_postinst failed"
233
234         tmpfiles_process apache.conf #662544
235
236         # warnings that default config might not work out of the box
237         local mod cmod
238         for mod in ${MODULE_CRITICAL} ; do
239                 if ! use "apache2_modules_${mod}"; then
240                         echo
241                         ewarn "Warning: Critical module not installed!"
242                         ewarn "Modules 'authn_core', 'authz_core' and 'unixd'"
243                         ewarn "are highly recomended but might not be in the base profile yet."
244                         ewarn "Default config for ssl needs module 'socache_shmcb'."
245                         ewarn "Enabling the following flags is highly recommended:"
246                         for cmod in ${MODULE_CRITICAL} ; do
247                                 use "apache2_modules_${cmod}" || \
248                                         ewarn "+ apache2_modules_${cmod}"
249                         done
250                         echo
251                         break
252                 fi
253         done
254         # warning for proxy_balancer and missing load balancing scheduler
255         if use apache2_modules_proxy_balancer; then
256                 local lbset=
257                 for mod in lbmethod_byrequests lbmethod_bytraffic lbmethod_bybusyness lbmethod_heartbeat; do
258                         if use "apache2_modules_${mod}"; then
259                                 lbset=1 && break
260                         fi
261                 done
262                 if [ ! ${lbset} ] ; then
263                         echo
264                         ewarn "Info: Missing load balancing scheduler algorithm module"
265                         ewarn "(They were split off from proxy_balancer in 2.3)"
266                         ewarn "In order to get the ability of load balancing, at least"
267                         ewarn "one of these modules has to be present:"
268                         ewarn "lbmethod_byrequests lbmethod_bytraffic lbmethod_bybusyness lbmethod_heartbeat"
269                         echo
270                 fi
271         fi
272 }