From 3474e9ee0e6246d28eab976685305365d972c71a Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sun, 16 May 2021 12:20:11 +0200 Subject: [PATCH] test00_specsyntax.in: add curl check for URL; automatic replace if redirect, error if url not orking (response code != 200) --- tests/test00_specsyntax.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test00_specsyntax.in b/tests/test00_specsyntax.in index ff43c1e..35305ad 100644 --- a/tests/test00_specsyntax.in +++ b/tests/test00_specsyntax.in @@ -42,6 +42,30 @@ function specfile.checksyntax() { 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 # (skip this test if no '%setup' section has been found) test.skip $test_number || {