[packages/rpm-build-tools] geoip: handle xtables-geoip having same filename

glen glen at pld-linux.org
Thu Nov 1 10:17:26 CET 2018


commit e0a4d2b9978188d3a909a6b7862b9f1a1afb0b0c
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Thu Nov 1 11:16:49 2018 +0200

    geoip: handle xtables-geoip having same filename
    
    url hacking with query string doesn't work, the remote server gives
    2015 year version out then.... pff!

 update-geoip.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/update-geoip.sh b/update-geoip.sh
index 2e3bf20..b58932e 100755
--- a/update-geoip.sh
+++ b/update-geoip.sh
@@ -30,6 +30,11 @@ while [ $# -gt 0 ]; do
 	esac
 done
 
+die() {
+	echo >&2 "$0: ERROR: $*"
+	exit 1
+}
+
 # get file DATE in GMT timezone
 filedate() {
 	local file="$1"
@@ -82,6 +87,7 @@ update_version() {
 		s/^\(Release:[ \t]\+\)[.0-9]\+\$/\11/
 	" $specfile
 
+	rm *.zip *.gz *.xz
 	# update md5
 	out=$(md5 -p1 $specfile 2>&1) || echo "$out"
 
@@ -129,8 +135,10 @@ version_from_attachment() {
 	t=$(mktemp)
 
 	for url in "$@"; do
+		# remove querystring to receive proper headers
+		url=${url%\?*}
 		curl -Is "$url" -o "$t"
-		fn=$(awk 'BEGIN {FS=": "}/^Content-Disposition/{sub(/.*filename=/, "", $2); print $2}' "$t")
+		fn=$(awk 'BEGIN {FS=": "}/^[Cc]ontent-[Dd]isposition/{sub(/.*filename=/, "", $2); print $2}' "$t")
 		fn=${fn#GeoLite2-Country-CSV_}
 		d=$(echo "$fn" | sed -e 's/[^0-9-]//g')
 
@@ -139,6 +147,8 @@ version_from_attachment() {
 		fi
 	done
 
+	test -n "$dt" || die "Failed to find date from $*"
+
 	rm -f $t
 	version=$dt
 }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/e0a4d2b9978188d3a909a6b7862b9f1a1afb0b0c



More information about the pld-cvs-commit mailing list