www-servers/apache: x86 stable (bug #682306)
[gentoo.git] / www-servers / apache / apache-2.4.34-r2.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
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="20180716"
8 GENTOO_DEVELOPER="polynomial-c"
9 GENTOO_PATCHNAME="gentoo-apache-2.4.34"
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
34 authn_alias authn_anon authn_core authn_dbd authn_dbm authn_file 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_fcgi  proxy_wstunnel rewrite ratelimit remoteip reqtimeout setenvif
42 slotmem_shm speling socache_shmcb status substitute unique_id userdir usertrack
43 unixd version vhost_alias watchdog xml2enc"
44 # The following are also in the source as of this version, but are not available
45 # for user selection:
46 # bucketeer case_filter case_filter_in echo http isapi optional_fn_export
47 # optional_fn_import optional_hook_export optional_hook_import
48
49 # inter-module dependencies
50 # TODO: this may still be incomplete
51 MODULE_DEPENDS="
52         brotli:filter
53         dav_fs:dav
54         dav_lock:dav
55         deflate:filter
56         cache_disk:cache
57         ext_filter:filter
58         file_cache:cache
59         lbmethod_byrequests:proxy_balancer
60         lbmethod_byrequests:slotmem_shm
61         lbmethod_bytraffic:proxy_balancer
62         lbmethod_bybusyness:proxy_balancer
63         lbmethod_heartbeat:proxy_balancer
64         log_forensic:log_config
65         logio:log_config
66         cache_disk:cache
67         cache_socache:cache
68         md:watchdog
69         mime_magic:mime
70         proxy_ajp:proxy
71         proxy_balancer:proxy
72         proxy_balancer:slotmem_shm
73         proxy_connect:proxy
74         proxy_ftp:proxy
75         proxy_html:proxy
76         proxy_html:xml2enc
77         proxy_http:proxy
78         proxy_scgi:proxy
79         proxy_fcgi:proxy
80         proxy_wstunnel:proxy
81         substitute:filter
82 "
83
84 # module<->define mappings
85 MODULE_DEFINES="
86         auth_digest:AUTH_DIGEST
87         authnz_ldap:AUTHNZ_LDAP
88         cache:CACHE
89         cache_disk:CACHE
90         cache_socache:CACHE
91         dav:DAV
92         dav_fs:DAV
93         dav_lock:DAV
94         file_cache:CACHE
95         http2:HTTP2
96         info:INFO
97         ldap:LDAP
98         md:SSL
99         proxy:PROXY
100         proxy_ajp:PROXY
101         proxy_balancer:PROXY
102         proxy_connect:PROXY
103         proxy_ftp:PROXY
104         proxy_html:PROXY
105         proxy_http:PROXY
106         proxy_fcgi:PROXY
107         proxy_scgi:PROXY
108         proxy_wstunnel:PROXY
109         socache_shmcb:SSL
110         ssl:SSL
111         status:STATUS
112         suexec:SUEXEC
113         userdir:USERDIR
114 "
115
116 # critical modules for the default config
117 MODULE_CRITICAL="
118         authn_core
119         authz_core
120         authz_host
121         dir
122         mime
123         unixd
124 "
125 inherit apache-2 systemd tmpfiles toolchain-funcs
126
127 DESCRIPTION="The Apache Web Server"
128 HOMEPAGE="https://httpd.apache.org/"
129
130 # some helper scripts are Apache-1.1, thus both are here
131 LICENSE="Apache-2.0 Apache-1.1"
132 SLOT="2"
133 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"
134
135 # Enable http2 by default (bug #563452)
136 # FIXME: Move to apache-2.eclass once this has reached stable.
137 IUSE="${IUSE/apache2_modules_http2/+apache2_modules_http2}"
138 # New suexec options (since 2.4.34)
139 IUSE="${IUSE} +suexec-caps suexec-syslog"
140
141 CDEPEND="apache2_modules_brotli? ( >=app-arch/brotli-0.6.0:= )
142         apache2_modules_http2? ( >=net-libs/nghttp2-1.2.1 )
143         apache2_modules_md? ( >=dev-libs/jansson-2.10 )"
144
145 DEPEND+="${CDEPEND}
146         suexec? ( suexec-caps? ( sys-libs/libcap ) )"
147 RDEPEND+="${CDEPEND}"
148
149 REQUIRED_USE="apache2_modules_http2? ( ssl )
150         apache2_modules_md? ( ssl )"
151
152 PATCHES=(
153         "${FILESDIR}/${PN}-2.4.34-suexec_parallel_install.patch" #661358
154         "${FILESDIR}"/${P}-PR62557.patch #663312
155 )
156
157 pkg_setup() {
158         # dependend critical modules which are not allowed in global scope due
159         # to USE flag conditionals (bug #499260)
160         use ssl && MODULE_CRITICAL+=" socache_shmcb"
161         use doc && MODULE_CRITICAL+=" alias negotiation setenvif"
162         apache-2_pkg_setup
163 }
164
165 src_configure() {
166         # Brain dead check.
167         tc-is-cross-compiler && export ap_cv_void_ptr_lt_long="no"
168
169         apache-2_src_configure
170 }
171
172 src_compile() {
173         if tc-is-cross-compiler; then
174                 # This header is the same across targets, so use the build compiler.
175                 pushd server >/dev/null
176                 emake gen_test_char
177                 tc-export_build_env BUILD_CC
178                 ${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} \
179                         gen_test_char.c -o gen_test_char $(apr-1-config --includes) || die
180                 popd >/dev/null
181         fi
182
183         default
184 }
185
186 src_install() {
187         apache-2_src_install
188         local i
189         local apache_tools_prune_list=(
190                 /usr/bin/{htdigest,logresolve,htpasswd,htdbm,ab,httxt2dbm}
191                 /usr/sbin/{checkgid,fcgistarter,htcacheclean,rotatelogs}
192                 /usr/share/man/man1/{logresolve.1,htdbm.1,htdigest.1,htpasswd.1,dbmmanage.1,ab.1}
193                 /usr/share/man/man8/{rotatelogs.8,htcacheclean.8}
194         )
195         for i in ${apache_tools_prune_list[@]} ; do
196                 rm "${ED%/}"/$i || die "Failed to prune apache-tools bits"
197         done
198
199         # install apxs in /usr/bin (bug #502384) and put a symlink into the
200         # old location until all ebuilds and eclasses have been modified to
201         # use the new location.
202         dobin support/apxs
203         dosym ../bin/apxs /usr/sbin/apxs
204
205         # Note: wait for mod_systemd to be included in some forthcoming release,
206         # Then apache2.4.service can be used and systemd support controlled
207         # through --enable-systemd
208         systemd_newunit "${FILESDIR}/apache2.2-hardened.service" "apache2.service"
209         systemd_dotmpfilesd "${FILESDIR}/apache.conf"
210         #insinto /etc/apache2/modules.d
211         #doins "${FILESDIR}/00_systemd.conf"
212
213         # Install http2 module config
214         insinto /etc/apache2/modules.d
215         doins "${FILESDIR}"/41_mod_http2.conf
216
217         # Fix path to apache libdir
218         sed "s|@LIBDIR@|$(get_libdir)|" -i "${ED%/}"/usr/sbin/apache2ctl || die
219 }
220
221 pkg_postinst() {
222         apache-2_pkg_postinst || die "apache-2_pkg_postinst failed"
223
224         tmpfiles_process apache.conf #662544
225
226         # warnings that default config might not work out of the box
227         local mod cmod
228         for mod in ${MODULE_CRITICAL} ; do
229                 if ! use "apache2_modules_${mod}"; then
230                         echo
231                         ewarn "Warning: Critical module not installed!"
232                         ewarn "Modules 'authn_core', 'authz_core' and 'unixd'"
233                         ewarn "are highly recomended but might not be in the base profile yet."
234                         ewarn "Default config for ssl needs module 'socache_shmcb'."
235                         ewarn "Enabling the following flags is highly recommended:"
236                         for cmod in ${MODULE_CRITICAL} ; do
237                                 use "apache2_modules_${cmod}" || \
238                                         ewarn "+ apache2_modules_${cmod}"
239                         done
240                         echo
241                         break
242                 fi
243         done
244         # warning for proxy_balancer and missing load balancing scheduler
245         if use apache2_modules_proxy_balancer; then
246                 local lbset=
247                 for mod in lbmethod_byrequests lbmethod_bytraffic lbmethod_bybusyness lbmethod_heartbeat; do
248                         if use "apache2_modules_${mod}"; then
249                                 lbset=1 && break
250                         fi
251                 done
252                 if [ ! ${lbset} ] ; then
253                         echo
254                         ewarn "Info: Missing load balancing scheduler algorithm module"
255                         ewarn "(They were split off from proxy_balancer in 2.3)"
256                         ewarn "In order to get the ability of load balancing, at least"
257                         ewarn "one of these modules has to be present:"
258                         ewarn "lbmethod_byrequests lbmethod_bytraffic lbmethod_bybusyness lbmethod_heartbeat"
259                         echo
260                 fi
261         fi
262 }