From cb201ab833b79df4e329e54b9492541024e40cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Braga?= Date: Fri, 11 Dec 2015 17:37:18 +0000 Subject: [PATCH 1/2] glued-check-sources: added script to verify available sources. --- utils/glued-check-sources.bash | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 utils/glued-check-sources.bash diff --git a/utils/glued-check-sources.bash b/utils/glued-check-sources.bash new file mode 100755 index 0000000..a7251eb --- /dev/null +++ b/utils/glued-check-sources.bash @@ -0,0 +1,64 @@ +#! /bin/bash +########################################################################### +# GLUED: GNU/Linux Uniform Environment Distribution # +# Copyright (C) 2007-2015 Universidade do Porto - Faculdade de Engenharia # +# Laboratório de Sistemas e Tecnologia Subaquática (LSTS) # +########################################################################### +# 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 Street, Fifth Floor, Boston, MA # +# 02110-1301 USA. # +########################################################################### + +if [ -f 'functions.bash' ]; then + PKGS='rules' + source 'functions.bash' +elif [ -f '../functions.bash' ]; then + PKGS='../rules' + source '../functions.bash' +else + echo "ERROR: unable to find functions.bash." + exit 1 +fi + +nf=0 +list=() + +while read file; do + url=() + PKG_COMMON="$(dirname "$file")/common.bash" + source "$file" 2> /dev/null + n=0; + while [ -n "${url[$n]}" ]; do + u="${url[$n]}" + f="$(basename $u)" + nfo1 "Checking $f" + if ! [[ `wget -S --spider $u 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then + ((nf++)) + list+=("$f") + err "Not available" + fi + let n++ + done +done < <(find "$PKGS" -name '*.bash' ) + +if [ $nf -eq 0 ]; then + ok "All sources are available" +else + err "Missing sources ($nf):" + for item in ${list[*]} + do + nfo2 $item + done +fi + From 5c80630ba7f23d0965157dd3c1983e19c6497d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Braga?= Date: Fri, 11 Dec 2015 18:32:10 +0000 Subject: [PATCH 2/2] glued-check-sources: added check for ftp protocol. --- utils/glued-check-sources.bash | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/utils/glued-check-sources.bash b/utils/glued-check-sources.bash index a7251eb..07aae78 100755 --- a/utils/glued-check-sources.bash +++ b/utils/glued-check-sources.bash @@ -31,7 +31,6 @@ else exit 1 fi -nf=0 list=() while read file; do @@ -43,22 +42,31 @@ while read file; do u="${url[$n]}" f="$(basename $u)" nfo1 "Checking $f" - if ! [[ `wget -S --spider $u 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then - ((nf++)) - list+=("$f") - err "Not available" + if [[ `echo $u | grep -i 'ftp://'` ]]; then + # FTP + echo "ftp - $u" + if ! [[ `wget -S --spider $u 2>&1 | grep "File.*$f.*exists"` ]]; then + list+=("$f") + err "Not available" + fi + else + # HTTP + if ! [[ `wget -S --spider $u 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then + echo $u + list+=("$f") + err "Not available" + fi fi let n++ done done < <(find "$PKGS" -name '*.bash' ) -if [ $nf -eq 0 ]; then +if [ ${#list[@]} -eq 0 ]; then ok "All sources are available" else - err "Missing sources ($nf):" - for item in ${list[*]} + err "Missing sources (${#list[@]}):" + for item in ${list[*]}; do nfo2 $item done fi -