test00_specsyntax.in: add curl check for URL; automatic replace if redirect, error if url not orking (response code != 200)

This commit is contained in:
Silvan Calarco 2021-05-16 12:20:11 +02:00
parent 459b367e95
commit 3474e9ee0e

View File

@ -42,6 +42,30 @@ function specfile.checksyntax() {
local total_issues=0 local total_issues=0
# 0. checking if 'Source[0]' is a valid internet address
# (skip this test if no '%setup' section has been found)
test.skip $test_number || {
notify.note "$(test.num2str). ${NOTE}"\
"url""${NORM}..."
if [[ "$SPEC_URL" ]]; then
http_code=`curl -s -o /dev/null -w "%{http_code}" $SPEC_URL`
if [ "$http_code" != "200" ]; then
if [ "${http_code:0:2}" == "30" ]; then
http_effective_url=`curl -w "%{url_effective}" -I -L -s -o /dev/null -S $SPEC_URL`
{ notify.warning "\
\`url': "$"redirect detected: replacing from \`$SPEC_URL' to \`${http_effective_url}'"
let "total_issues += 1";
}
sed -i "s|^\(URL:[[:space:]]*\)$SPEC_URL.*|\1${http_effective_url}|" $specfile
else
{ notify.error "\
\`url': "$"invalid return code for \`$SPEC_URL': $http_code"
let "total_issues += 1"; }
fi
fi
fi; }
test_number=$(($test_number + 1))
# 1. checking if 'Source[0]' is a valid internet address # 1. checking if 'Source[0]' is a valid internet address
# (skip this test if no '%setup' section has been found) # (skip this test if no '%setup' section has been found)
test.skip $test_number || { test.skip $test_number || {