]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
update-geoip: xtables-geoip: extract version from attachment filename
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 30 Oct 2018 23:33:24 +0000 (01:33 +0200)
committerElan Ruusamäe <glen@pld-linux.org>
Tue, 30 Oct 2018 23:33:57 +0000 (01:33 +0200)
update-geoip.sh

index 1642aa54a7112fcb6521902d4b09cde0245966cf..2e3bf20ee8f0a8de519638aaa0cb6e14bd5e5e8b 100755 (executable)
@@ -124,6 +124,25 @@ version_from_files() {
        esac
 }
 
+version_from_attachment() {
+       local url fn dt d t
+       t=$(mktemp)
+
+       for url in "$@"; do
+               curl -Is "$url" -o "$t"
+               fn=$(awk 'BEGIN {FS=": "}/^Content-Disposition/{sub(/.*filename=/, "", $2); print $2}' "$t")
+               fn=${fn#GeoLite2-Country-CSV_}
+               d=$(echo "$fn" | sed -e 's/[^0-9-]//g')
+
+               if [ "$d" -gt "$dt" ]; then
+                       dt=$d
+               fi
+       done
+
+       rm -f $t
+       version=$dt
+}
+
 dir=$(dirname "$0")
 APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
 PATH=$APPDIR:$PATH
@@ -139,8 +158,13 @@ for pkg in ${*:-$pkgs}; do
        specfile=*.spec
 
        urls=$(get_urls $specfile)
-       update_urls $urls
-       version_from_files $pkg $urls
+       if [ "$pkg" = "xtables-geoip" ]; then
+               version_from_attachment $urls
+       else
+               update_urls $urls
+               version_from_files $pkg $urls
+       fi
+
        oldvers=$(awk '/^Version:[      ]+/{print $NF}' $specfile)
        if [ "$oldvers" != "$version" ]; then
                update_version $specfile $version
This page took 0.059066 seconds and 4 git commands to generate.