[mod_geoip] Fix compilation error with httpd-2.4 (#809698)
jorton
jorton at fedoraproject.org
Mon Apr 16 14:39:27 UTC 2012
commit b3f6f0ddb20e27cdac6fdcacfa908a455b68a6dc
Author: Joe Orton <jorton at redhat.com>
Date: Mon Apr 16 15:39:17 2012 +0100
Fix compilation error with httpd-2.4 (#809698)
Resolves: rhbz#809698
.gitignore | 1 +
mod_geoip-httpd24.patch | 35 +++++++++++++++++++++++++++++++++++
mod_geoip.spec | 38 +++++++++++++++++++++++++++++++++-----
3 files changed, 69 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index d4ddbb8..bf50f3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
mod_geoip2_1.2.5.tar.gz
+/mod_geoip2_1.2.5/
diff --git a/mod_geoip-httpd24.patch b/mod_geoip-httpd24.patch
new file mode 100644
index 0000000..563e35b
--- /dev/null
+++ b/mod_geoip-httpd24.patch
@@ -0,0 +1,35 @@
+--- mod_geoip.c.geoip
++++ mod_geoip.c
+@@ -66,6 +66,7 @@
+ #include "http_config.h"
+ #include "http_protocol.h"
+ #include "http_log.h"
++#include "util_script.h"
+ #include "ap_config.h"
+ #include "apr_strings.h"
+ #include <GeoIP.h>
+@@ -320,7 +321,11 @@
+ return DECLINED;
+
+ if (!cfg->scanProxyHeaders) {
++#if AP_MODULE_MAGIC_AT_LEAST(20111130,0)
++ ipaddr = r->useragent_ip;
++#else
+ ipaddr = r->connection->remote_ip;
++#endif
+ }
+ else {
+ ap_add_common_vars(r);
+@@ -338,7 +343,11 @@
+ }
+ if (!ipaddr_ptr) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, "[mod_geoip]: Error while getting ipaddr from proxy headers. Using REMOTE_ADDR.");
+- ipaddr = r->connection->remote_ip;
++#if AP_MODULE_MAGIC_AT_LEAST(20111130,0)
++ ipaddr = r->useragent_ip;
++#else
++ ipaddr = r->connection->remote_ip;
++#endif
+ }
+ else {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server, "[mod_geoip]: IPADDR_PTR: %s", ipaddr_ptr);
diff --git a/mod_geoip.spec b/mod_geoip.spec
index e3ed349..2b90961 100644
--- a/mod_geoip.spec
+++ b/mod_geoip.spec
@@ -1,7 +1,14 @@
+%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}}
+%{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn || echo missing-httpd-devel)}}
+# /etc/httpd/conf.d with httpd < 2.4 and defined as /etc/httpd/conf.modules.d with httpd >= 2.4
+%{!?_httpd_modconfdir: %{expand: %%global _httpd_modconfdir %%{_sysconfdir}/httpd/conf.d}}
+%{!?_httpd_confdir: %{expand: %%global _httpd_confdir %%{_sysconfdir}/httpd/conf.d}}
+%{!?_httpd_moddir: %{expand: %%global _httpd_moddir %%{_libdir}/httpd/modules}}
+
Summary: GeoIP module for the Apache HTTP Server
Name: mod_geoip
Version: 1.2.5
-Release: 6%{?dist}
+Release: 7%{?dist}
License: ASL 1.1
Group: System Environment/Daemons
URL: http://www.maxmind.com/app/mod_geoip
@@ -9,6 +16,8 @@ Source: http://www.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_%{versio
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: GeoIP httpd httpd-mmn = %([ -a %{_includedir}/httpd/.mmn ] && cat %{_includedir}/httpd/.mmn || echo missing)
BuildRequires: httpd-devel GeoIP-devel
+# Not upstream
+Patch0: mod_geoip-httpd24.patch
%description
mod_geoip is an Apache module for finding the country that a web request
@@ -18,17 +27,21 @@ the lookup. It is free software, licensed under the Apache license.
%prep
%setup -q -n mod_geoip2_%{version}
+%patch0 -p0 -b .geoip
%build
-/usr/sbin/apxs -Wc,"%{optflags}" -Wl,"-lGeoIP" -c mod_geoip.c
+%{_httpd_apxs} -Wc,"%{optflags}" -Wl,"-lGeoIP" -c mod_geoip.c
%install
-mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d/
-install -Dp .libs/mod_geoip.so %{buildroot}%{_libdir}/httpd/modules/mod_geoip.so
+mkdir -p %{buildroot}%{_httpd_confdir} %{buildroot}%{_httpd_modconfdir} \
+ %{buildroot}%{_httpd_moddir}
+install -Dp .libs/mod_geoip.so %{buildroot}%{_httpd_moddir}
-cat << EOF > %{buildroot}%{_sysconfdir}/httpd/conf.d/mod_geoip.conf
+cat << EOF > 10-mod_geoip.conf
LoadModule geoip_module modules/mod_geoip.so
+EOF
+cat << EOF > mod_geoip.conf
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
@@ -36,6 +49,15 @@ LoadModule geoip_module modules/mod_geoip.so
EOF
+%if "%{_httpd_modconfdir}" != "%{_httpd_confdir}"
+# 2.4-style
+install 10-mod_geoip.conf %{buildroot}%{_httpd_modconfdir}
+install mod_geoip.conf %{buildroot}%{_httpd_confdir}
+%else
+# old-style
+cat 10-mod_geoip.conf mod_geoip.conf > %{buildroot}%{_httpd_confdir}/mod_geoip.conf
+%endif
+
%clean
rm -rf %{buildroot}
@@ -44,8 +66,14 @@ rm -rf %{buildroot}
%doc INSTALL README* Changes
%{_libdir}/httpd/modules/mod_geoip.so
%config(noreplace) %{_sysconfdir}/httpd/conf.d/mod_geoip.conf
+%if "%{_httpd_modconfdir}" != "%{_httpd_confdir}"
+%config(noreplace) %{_sysconfdir}/httpd/conf.modules.d/10-mod_geoip.conf
+%endif
%changelog
+* Wed Apr 04 2012 Jan Kaluza <jkaluza at redhat.com> - 1.2.5-7
+- Fix compilation error with httpd-2.4 (#809698)
+
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.2.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list