aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Meyer <dinoex@FreeBSD.org>2019-01-19 07:08:22 +0000
committerDirk Meyer <dinoex@FreeBSD.org>2019-01-19 07:08:22 +0000
commit646449a4bdccd7bccebcc75de8d253027824e5d3 (patch)
tree9ff5098c74943c0a904ece6a2b963619e516a69c
parent281e6649ea18505e0c0617ae4563ef70a290b335 (diff)
downloadports-646449a4bdccd7bccebcc75de8d253027824e5d3.tar.gz
ports-646449a4bdccd7bccebcc75de8d253027824e5d3.zip
- fix option GEOIP to use GeoLite2-Country
Notes
Notes: svn path=/head/; revision=490700
-rw-r--r--UPDATING8
-rw-r--r--www/geolizer/Makefile2
-rw-r--r--www/webalizer/Makefile26
-rw-r--r--www/webalizer/files/patch-output.c52
-rw-r--r--www/webalizer/files/patch-webalizer.c59
5 files changed, 138 insertions, 9 deletions
diff --git a/UPDATING b/UPDATING
index 42cfeb862818..dbaa03e73681 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,14 @@ they are unavoidable.
You should get into the habit of checking this file for changes each time
you update your ports collection, before attempting any port upgrades.
+20190119:
+ AFFECTS: users of german/webalizer2, japanese/webalizer, polish/webalizer2, portuguese/webalizer-pt_BR, portuguese/webalizer-pt_PT, ukrainian/webalizer, www/geolizer, www/webalizer
+ AUTHOR: dinoex@FreeBSD.org
+
+ The option GEOIP has beeen changed to used the new datebase.
+ Either copy GeoLite2-Country.mmdb in the working directory,
+ or set the GeoIPDatabase option to the location of the file.
+
20190114:
AFFECTS: users of graphics/qgis
AUTHOR: rhurlin@gwdg.de
diff --git a/www/geolizer/Makefile b/www/geolizer/Makefile
index 47800dc529fc..3aaa7041a500 100644
--- a/www/geolizer/Makefile
+++ b/www/geolizer/Makefile
@@ -5,7 +5,7 @@ MAINTAINER= dinoex@FreeBSD.org
MASTERDIR?= ${.CURDIR}/../webalizer
-OPTIONS_DEFAULT=BDB1
+OPTIONS_DEFAULT=BDB1 GEOIP
WEBALIZER_SUFFIX= -geoip
diff --git a/www/webalizer/Makefile b/www/webalizer/Makefile
index 2955fbe37c74..3384f37d4f11 100644
--- a/www/webalizer/Makefile
+++ b/www/webalizer/Makefile
@@ -2,7 +2,7 @@
PORTNAME= webalizer
PORTVERSION= 2.23.8
-PORTREVISION= 7
+PORTREVISION= 8
CATEGORIES+= www
MASTER_SITES= ftp://ftp.mrunix.net/pub/webalizer/:main \
ftp://ftp.mrunix.net/pub/webalizer/geodb/:geodb \
@@ -24,14 +24,14 @@ DOCSDIR?= ${PREFIX}/share/doc/${PKGNAMEPREFIX}${PORTNAME}
EXAMPLESDIR?= ${PREFIX}/share/examples/${PKGNAMEPREFIX}${PORTNAME}
GD_PORT?= graphics/gd
-CONFLICTS= geolizer-2* ${PKGNAMEPREFIX}webalizer-geoip-2*
+CONFLICTS= geolizer-2*
.if defined(BATCH)
# no cosmetique spaces allowed
WEBALIZER_LANG?=english
.endif
-OPTIONS_DEFINE= GEODB WEBALIZER_CONV \
+OPTIONS_DEFINE= GEOIP GEODB WEBALIZER_CONV \
FULL_CGI_REFS CLICKABLE_REFERER \
IP_AS_HOSTNAME LARGE_URL \
DOCS EXAMPLES
@@ -47,6 +47,10 @@ CLICKABLE_REFERER_DESC=Make referers clickable
IP_AS_HOSTNAME_DESC=Show IP as hostname when IP does not resolve
LARGE_URL_DESC=Enable URLs longer 512 bytes
+GEOIP_CONFIGURE_ON= --enable-geoip \
+ --with-geoip-lib=${LOCALBASE}/lib \
+ --with-geoip-inc=${LOCALBASE}/include
+GEOIP_LIB_DEPENDS= libmaxminddb.so:net/libmaxminddb
BDB1_CFLAGS= -DUSE_DB185
BDB_USES= bdb
BDB_LDFLAGS= -L${BDB_LIB_DIR}
@@ -61,7 +65,7 @@ IP_AS_HOSTNAME_CFLAGS= -DUSE_IP_AS_HOSTNAME
.include <bsd.port.options.mk>
-.if ${PORT_OPTIONS:MGEODB} || make(makesum) || defined(FETCH_ALL)
+.if ${PORT_OPTIONS:MGEODB} || ${PORT_OPTIONS:MGEOIP} || make(makesum) || defined(FETCH_ALL)
DISTFILES+= webalizer-flags.tgz:main
.endif
.if ${PORT_OPTIONS:MGEODB} || make(makesum) || defined(FETCH_ALL)
@@ -73,7 +77,13 @@ DISTFILES+= webalizer-geodb-20170201.tgz:geodb
LIB_DEPENDS+= libgd.so:${GD_PORT}
.endif
-.if ${PORT_OPTIONS:MGEODB}
+.if ${PORT_OPTIONS:MGEOIP}
+CONFLICTS+= ${PKGNAMEPREFIX}webalizer-2*
+.else
+CONFLICTS+= ${PKGNAMEPREFIX}webalizer-geoip-2*
+.endif
+
+.if ${PORT_OPTIONS:MGEODB} || ${PORT_OPTIONS:MGEOIP}
PLIST_SUB+= WITH_ICONS=""
.else
PLIST_SUB+= WITH_ICONS="@comment "
@@ -130,9 +140,13 @@ pre-configure:
.endif
.if ${PORT_OPTIONS:MBDB}
${REINPLACE_CMD} -e "s|-ldb|-l${BDB_LIB_NAME}|" \
+ -e "s|GeoIP[.]h|maxminddb.h|" \
+ -e "s|-lGeoIP|-lmaxminddb|" \
${WRKSRC}/configure
.else
${REINPLACE_CMD} -e "s|-ldb||" \
+ -e "s|GeoIP[.]h|maxminddb.h|" \
+ -e "s|-lGeoIP|-lmaxminddb|" \
${WRKSRC}/configure
.endif
@@ -155,7 +169,7 @@ do-install:
.for i in ${LMAN1}
${INSTALL_MAN} ${WRKSRC}/${i:S/^${PKGNAMEPREFIX}//} ${STAGEDIR}${PREFIX}/man/man1/${i}
.endfor
-.if ${PORT_OPTIONS:MGEODB}
+.if ${PORT_OPTIONS:MGEODB} || ${PORT_OPTIONS:MGEOIP}
${MKDIR} ${STAGEDIR}${PREFIX}/share/geolizer
${INSTALL_DATA} ${WRKDIR}/flags/* ${STAGEDIR}${PREFIX}/share/geolizer/
.endif
diff --git a/www/webalizer/files/patch-output.c b/www/webalizer/files/patch-output.c
index ef4a9063f316..433d797063e9 100644
--- a/www/webalizer/files/patch-output.c
+++ b/www/webalizer/files/patch-output.c
@@ -1,5 +1,14 @@
--- output.c.orig 2013-02-26 05:37:27 UTC
+++ output.c
+@@ -54,7 +54,7 @@
+ #endif
+
+ #ifdef USE_GEOIP
+-#include <GeoIP.h>
++#include <maxminddb.h>
+ #endif
+
+ #include "webalizer.h" /* main header */
@@ -992,6 +992,20 @@ int all_sites_page(u_int64_t h_reg, u_in
hptr=*pointer++;
if (hptr->flag == OBJ_REG)
@@ -21,3 +30,46 @@
fprintf(out_fp,
"%-8llu %6.02f%% %8llu %6.02f%% %8.0f %6.02f%% " \
"%8llu %6.02f%% %s\n",
+@@ -1948,7 +1962,7 @@ void top_ctry_table()
+
+ #ifdef USE_GEOIP
+ extern int geoip;
+- extern GeoIP *geo_fp;
++ extern MMDB_s mmdb;
+ const char *geo_rc=NULL;
+ #endif
+ char geo_ctry[3]="--";
+@@ -1981,19 +1995,26 @@ void top_ctry_table()
+ if (geoip)
+ {
+ /* Lookup IP address here, turn into idx */
+- geo_rc=GeoIP_country_code_by_addr(geo_fp, hptr->string);
+- if (geo_rc==NULL||geo_rc[0]=='\0'||geo_rc[0]=='-')
++ MMDB_lookup_result_s result;
++ MMDB_entry_data_s entry_data;
++ int gai_error, mmdb_error, rc;
++ result=MMDB_lookup_string(&mmdb, hptr->string, &gai_error, &mmdb_error);
++ if (gai_error!=0||mmdb_error!=MMDB_SUCCESS||!result.found_entry)
+ {
+ if (debug_mode)
+ fprintf(stderr,"GeoIP: %s unknown (returns '%s')\n",
+- hptr->string,(geo_rc==NULL)?"null":geo_rc);
++ hptr->string,MMDB_strerror(mmdb_error));
+ }
+ else
+ {
+- /* index returned geo_ctry */
+- geo_ctry[0]=tolower(geo_rc[0]);
+- geo_ctry[1]=tolower(geo_rc[1]);
+- idx=ctry_idx(geo_ctry);
++ rc = MMDB_get_value(&result.entry, &entry_data, "country", "iso_code", NULL);
++ if (rc==MMDB_SUCCESS&&entry_data.has_data)
++ {
++ /* index returned geo_ctry */
++ geo_ctry[0]=tolower(entry_data.utf8_string[0]);
++ geo_ctry[1]=tolower(entry_data.utf8_string[1]);
++ idx=ctry_idx(geo_ctry);
++ }
+ }
+ }
+ #endif /* USE_GEOIP */
diff --git a/www/webalizer/files/patch-webalizer.c b/www/webalizer/files/patch-webalizer.c
index f748467f3640..435c3e23d076 100644
--- a/www/webalizer/files/patch-webalizer.c
+++ b/www/webalizer/files/patch-webalizer.c
@@ -1,6 +1,49 @@
--- webalizer.c.orig 2013-08-26 04:52:15 UTC
+++ webalizer.c
-@@ -942,7 +942,11 @@ int main(int argc, char *argv[])
+@@ -72,7 +72,7 @@
+ #endif /* USE_DNS */
+
+ #ifdef USE_GEOIP
+-#include <GeoIP.h>
++#include <maxminddb.h>
+ #endif
+
+ #ifdef USE_BZIP
+@@ -172,7 +172,8 @@ char *flag_dir = "flags";
+ #ifdef USE_GEOIP
+ int geoip = 0; /* Use GeoIP (0=no) */
+ char *geoip_db = NULL; /* GeoIP database filename */
+-GeoIP *geo_fp = NULL; /* GeoIP database handle */
++int mmdb_open = MMDB_FILE_OPEN_ERROR; /* GeoIP database open */
++MMDB_s mmdb; /* GeoIP database handle */
+ #endif
+
+ int ntop_sites = 30; /* top n sites to display */
+@@ -619,20 +620,17 @@ int main(int argc, char *argv[])
+ if (geoip)
+ {
+ if (geoip_db!=NULL)
+- geo_fp=GeoIP_open(geoip_db, GEOIP_MEMORY_CACHE);
++ mmdb_open = MMDB_open(geoip_db, MMDB_MODE_MMAP, &mmdb);
+ else
+- geo_fp=GeoIP_new(GEOIP_MEMORY_CACHE);
++ mmdb_open = MMDB_open("GeoLite2-Country.mmdb", MMDB_MODE_MMAP, &mmdb);
+
+ /* Did we open one? */
+- if (geo_fp==NULL)
++ if (mmdb_open!=MMDB_SUCCESS)
+ {
+ /* couldn't open.. warn user */
+ if (verbose) printf("GeoIP %s\n",msg_geo_nolu);
+ geoip=0;
+ }
+- else if (verbose>1) printf("%s %s (%s)\n",msg_geo_use,
+- GeoIPDBDescription[(int)geo_fp->databaseType],
+- (geoip_db==NULL)?msg_geo_dflt:geo_fp->file_path);
+ }
+ #endif /* USE_GEOIP */
+
+@@ -942,7 +940,11 @@ int main(int argc, char *argv[])
{
/* Save query portion in log.rec.srchstr */
strncpy(log_rec.srchstr,(char *)cp1,MAXSRCH);
@@ -12,7 +55,7 @@
break;
}
else cp1++;
-@@ -1089,6 +1093,13 @@ int main(int argc, char *argv[])
+@@ -1089,6 +1091,13 @@ int main(int argc, char *argv[])
{
freeaddrinfo(ares);
resolve_dns(&log_rec);
@@ -26,3 +69,15 @@
}
}
#endif
+@@ -1487,7 +1496,10 @@ int main(int argc, char *argv[])
+
+ #ifdef USE_GEOIP
+ /* Close GeoIP database */
+- if (geo_fp) GeoIP_delete(geo_fp);
++ if (mmdb_open==MMDB_SUCCESS) {
++ MMDB_close(&mmdb);
++ mmdb_open=MMDB_FILE_OPEN_ERROR;
++ }
+ #endif
+
+ /* Whew, all done! Exit with completion status (0) */