Merge branch 'bug/ui13927' into 'belenos'

Add city level geoip database to Belenos from multiverse

The upstream package install script come utility has been modified to also download the compressed (gz,xz,zip) source CSVs to the package's directory in /usr/share/doc.  It is then possible to modify the database by editing those and rebuilding the databases with /usr/lib/geoip/geoip-generator from package geoip-bin.

The 'new' code is simply a refactored copy of the binary download code already in the install/utility script.

See https://trisquel.info/en/issues/13927

See merge request !67
This commit is contained in:
Ruben Rodriguez 2015-04-24 16:07:32 +00:00
commit 65d665744c
3 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,6 @@
Files: geoip-database-contrib_update
Copyright: 2010/2013, Ludovico Cavedon <cavedon@debian.org>
Patrick Matthäi <pmatthaei@debian.org>
2015 Andrew Lindley <andrew@andrewlindley.co.uk>
License: GPL-2+

View file

@ -0,0 +1,54 @@
# Download the compressed source CSVs for GNU FSDG compliance
GEOLITE_COUNTRY_CSV_PATH=""
GEOLITE_COUNTRY_CSV_FILE="GeoIPCountryCSV.zip"
GEOLITE_COUNTRY_IPV6_CSV_PATH=""
GEOLITE_COUNTRY_IPV6_CSV_FILE="GeoIPv6.csv.gz"
GEOLITE_CITY_CSV_PATH="GeoLiteCity_CSV/"
GEOLITE_CITY_CSV_FILE="GeoLiteCity-latest.tar.xz"
GEOLITE_CITY_IPV6_CSV_PATH="GeoLiteCityv6-beta/"
GEOLITE_CITY_IPV6_CSV_FILE="GeoLiteCityv6.csv.gz"
GEOLITE_ASNUM_CSV_PATH="asnum/"
GEOLITE_ASNUM_CSV_FILE="GeoIPASNum2.zip"
GEOLITE_ASNUM_IPV6_CSV_PATH="asnum/"
GEOLITE_ASNUM_IPV6_CSV_FILE="GeoIPASNum2v6.zip"
GEOIP_CSV_DIR="/usr/share/doc/geoip-database-contrib/csv/"
mkdir -p $GEOIP_CSV_DIR
for url in \
"$GEOIP_URL$GEOLITE_COUNTRY_CSV_PATH$GEOLITE_COUNTRY_CSV_FILE" \
"$GEOIP_URL$GEOLITE_COUNTRY_IPV6_CSV_PATH$GEOLITE_COUNTRY_IPV6_CSV_FILE" \
"$GEOIP_URL$GEOLITE_CITY_CSV_PATH$GEOLITE_CITY_CSV_FILE" \
"$GEOIP_URL$GEOLITE_CITY_IPV6_CSV_PATH$GEOLITE_CITY_IPV6_CSV_FILE" \
"$GEOIP_URL$GEOLITE_ASNUM_CSV_PATH$GEOLITE_ASNUM_CSV_FILE" \
"$GEOIP_URL$GEOLITE_ASNUM_IPV6_CSV_PATH$GEOLITE_ASNUM_IPV6_CSV_FILE"
do
echo "Downloading: $url"
# Download file in the same directory as the final one so that the "mv"
# below can be atomic.
TEMP=$(mktemp --tmpdir=$GEOIP_CSV_DIR)
FILE=$(basename $url)
/usr/bin/wget -q -t3 -T15 "$url" -O $TEMP
if [ "$?" != "0" ]
then
echo "Failed to download $url"
else
rm -f $GEOIP_CSV_DIR$FILE
mv $TEMP $GEOIP_CSV_DIR$FILE
chmod 644 $GEOIP_CSV_DIR$FILE
fi
rm -f $TEMP
done
exit 0

View file

@ -0,0 +1,41 @@
#!/bin/sh
#
# Copyright (C) 2015 Andrew M. Lindley <andrew@andrewlindley.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
VERSION=1
EXTERNAL='deb-src http://archive.ubuntu.com/ubuntu $UPSTREAM multiverse'
. ./config
sed "/^exit 0/d" -i geoip-database-contrib_update
cat $DATA/geoip-database-contrib_update.shim >> geoip-database-contrib_update
cat $DATA/copyright.shim >> debian/copyright
sed '/rm -f \/usr\/share\/GeoIP\/GeoLiteCityv6\.dat/a\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoIPCountryCSV.zip\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoIPv6.csv.gz\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoLiteCity-latest.tar.xz\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoLiteCityv6.csv.gz\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoIPASNum2.zip\
rm -f /usr/share/doc/geoip-database-contrib/csv/GeoIPASNum2v6.zip
' -i debian/postrm
changelog 'Handle CSV source in geoip-database-contrib_update and postrm #13927'
compile