From owner-svn-ports-all@FreeBSD.ORG Mon Aug 11 20:16:29 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9EC95AFA for ; Mon, 11 Aug 2014 20:16:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6ECD52DED for ; Mon, 11 Aug 2014 20:16:29 +0000 (UTC) Received: from adamw (uid 959) (envelope-from adamw@FreeBSD.org) id 2ff5 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 11 Aug 2014 20:16:29 +0000 From: Adam Weinberger Date: Mon, 11 Aug 2014 20:16:29 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r364652 - in head/net/GeoIP: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e9249d.2ff5.7e273fc4@svn.freebsd.org> X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Aug 2014 20:16:29 -0000 Author: adamw Date: Mon Aug 11 20:16:28 2014 New Revision: 364652 URL: http://svnweb.freebsd.org/changeset/ports/364652 QAT: https://qat.redports.org/buildarchive/r364652/ Log: Ensure that DATADIR exists before attempting to fetch the data files into it. Also, make the script more robust and ask fewer questions in adverse conditions. PORTREVISION bump. PR: 192597 Submitted by: mandree Modified: head/net/GeoIP/Makefile head/net/GeoIP/files/geoipupdate.sh.in Modified: head/net/GeoIP/Makefile ============================================================================== --- head/net/GeoIP/Makefile Mon Aug 11 20:07:24 2014 (r364651) +++ head/net/GeoIP/Makefile Mon Aug 11 20:16:28 2014 (r364652) @@ -3,7 +3,7 @@ PORTNAME= GeoIP PORTVERSION= 1.6.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net geography MASTER_SITES= http://geolite.maxmind.com/download/geoip/api/c/ Modified: head/net/GeoIP/files/geoipupdate.sh.in ============================================================================== --- head/net/GeoIP/files/geoipupdate.sh.in Mon Aug 11 20:07:24 2014 (r364651) +++ head/net/GeoIP/files/geoipupdate.sh.in Mon Aug 11 20:16:28 2014 (r364652) @@ -1,31 +1,31 @@ #!/bin/sh +set -eu echo Fetching GeoIP.dat and GeoIPv6.dat... -TEMPFILE=`mktemp %%DATADIR%%/GeoIP.dat-XXXXXX` -if fetch -o - http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | gunzip >> $TEMPFILE ; then - chmod 644 $TEMPFILE - if ! mv $TEMPFILE %%DATADIR%%/GeoIP.dat ; then - rm $TEMPFILE - echo Unable to overwrite %%DATADIR%%/GeoIP.dat - exit 2 +# arguments: +# $1 URL +# $2 output file name +_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 + else + echo "$2 download failed" + return 1 fi -else - rm $TEMPFILE - echo GeoIP.dat download failed - exit 1 -fi + rm -f "$TEMPFILE" + trap - 0 + return 0 +} -TEMPFILE=`mktemp %%DATADIR%%/GeoIPv6.dat-XXXXXX` -if fetch -o - http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz | gunzip >> $TEMPFILE ; then - chmod 644 $TEMPFILE - if ! mv $TEMPFILE %%DATADIR%%/GeoIPv6.dat ; then - rm $TEMPFILE - echo Unable to overwrite %%DATADIR%%/GeoIPv6.dat - exit 2 - fi -else - rm $TEMPFILE - echo GeoIPv6.dat download failed - exit 1 -fi +_fetch "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz" GeoIP.dat + +_fetch "http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz" GeoIPv6.dat