Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jan 2019 07:08:22 +0000 (UTC)
From:      Dirk Meyer <dinoex@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r490700 - in head: . www/geolizer www/webalizer www/webalizer/files
Message-ID:  <201901190708.x0J78MPd044747@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dinoex
Date: Sat Jan 19 07:08:22 2019
New Revision: 490700
URL: https://svnweb.freebsd.org/changeset/ports/490700

Log:
  - fix option GEOIP to use GeoLite2-Country

Modified:
  head/UPDATING
  head/www/geolizer/Makefile
  head/www/webalizer/Makefile
  head/www/webalizer/files/patch-output.c
  head/www/webalizer/files/patch-webalizer.c

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Sat Jan 19 04:19:26 2019	(r490699)
+++ head/UPDATING	Sat Jan 19 07:08:22 2019	(r490700)
@@ -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

Modified: head/www/geolizer/Makefile
==============================================================================
--- head/www/geolizer/Makefile	Sat Jan 19 04:19:26 2019	(r490699)
+++ head/www/geolizer/Makefile	Sat Jan 19 07:08:22 2019	(r490700)
@@ -5,7 +5,7 @@ MAINTAINER=	dinoex@FreeBSD.org
 
 MASTERDIR?=	${.CURDIR}/../webalizer
 
-OPTIONS_DEFAULT=BDB1
+OPTIONS_DEFAULT=BDB1 GEOIP
 
 WEBALIZER_SUFFIX=	-geoip
 

Modified: head/www/webalizer/Makefile
==============================================================================
--- head/www/webalizer/Makefile	Sat Jan 19 04:19:26 2019	(r490699)
+++ head/www/webalizer/Makefile	Sat Jan 19 07:08:22 2019	(r490700)
@@ -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}${PORTNA
 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

Modified: head/www/webalizer/files/patch-output.c
==============================================================================
--- head/www/webalizer/files/patch-output.c	Sat Jan 19 04:19:26 2019	(r490699)
+++ head/www/webalizer/files/patch-output.c	Sat Jan 19 07:08:22 2019	(r490700)
@@ -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 */

Modified: head/www/webalizer/files/patch-webalizer.c
==============================================================================
--- head/www/webalizer/files/patch-webalizer.c	Sat Jan 19 04:19:26 2019	(r490699)
+++ head/www/webalizer/files/patch-webalizer.c	Sat Jan 19 07:08:22 2019	(r490700)
@@ -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) */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901190708.x0J78MPd044747>