From 6ade92e79b4cc5029f127cf722d98a26ac3660a2 Mon Sep 17 00:00:00 2001 From: Adam Weinberger Date: Sat, 6 Sep 2014 23:03:41 +0000 Subject: Rather than fetching the data files and piping them through gunzip, download them completely and then gunzip them. This preserves the modtimes, and is the only way of knowing the actual age of the data files. Suggested by: ache --- net/GeoIP/Makefile | 1 + net/GeoIP/files/geoipupdate.sh.in | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'net/GeoIP') diff --git a/net/GeoIP/Makefile b/net/GeoIP/Makefile index 3fbfbf240d8a..bdbc5f069025 100644 --- a/net/GeoIP/Makefile +++ b/net/GeoIP/Makefile @@ -3,6 +3,7 @@ PORTNAME= GeoIP PORTVERSION= 1.6.2 +PORTREVISION= 1 CATEGORIES= net geography MAINTAINER= adamw@FreeBSD.org diff --git a/net/GeoIP/files/geoipupdate.sh.in b/net/GeoIP/files/geoipupdate.sh.in index b80f292527cc..7d578188d547 100644 --- a/net/GeoIP/files/geoipupdate.sh.in +++ b/net/GeoIP/files/geoipupdate.sh.in @@ -9,19 +9,20 @@ echo Fetching GeoIP.dat and GeoIPv6.dat... _fetch() { url="$1" out="$2" - TEMPFILE="$(mktemp "%%DATADIR%%"/GeoIP.dat-XXXXXX)" - trap 'rc=$? ; set +e ; rm -f "'"$TEMPFILE"'" ; exit $rc' 0 - if fetch -o - "$url" | gunzip >> "$TEMPFILE" ; then - chmod 444 "$TEMPFILE" - if ! mv -f "$TEMPFILE" "%%DATADIR%%"/"$2" ; then - echo "Unable to replace %%DATADIR%%/$2" - return 2 - fi + TEMPDIR="$(mktemp -d /tmp/GeoIPupdate.XXXXXX)" + trap 'rc=$? ; set +e ; rm -rf "'"$TEMPDIR"'" ; exit $rc' 0 + if fetch -o "$TEMPDIR/$out.gz" "$url"; then + gunzip "$TEMPDIR/$out.gz" + chmod 444 "$TEMPDIR/$out" + if ! mv -f "$TEMPDIR/$out" "%%DATADIR%%"/"$2"; then + echo "Unable to replace %%DATADIR%%/$2" + return 2 + fi else - echo "$2 download failed" - return 1 + echo "$2 download failed" + return 1 fi - rm -f "$TEMPFILE" + rmdir "$TEMPDIR" trap - 0 return 0 } -- cgit v1.2.3