1#! /bin/sh 2# check-testfiles.sh -- Check we distributed all the test files we need 3# Copyright (C) 2007, 2010, 2019 Free Software Foundation, Inc. 4# 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18rv=0 19 20 21# $1: a directory (source or dest) to make a list of files for. 22# $2: a single filename suffix to check 23makelist () { 24 ls "${1}"/*/*"${2}" | sed -e 's/.*\///' | sort 25} 26 27# $1: a single filename suffix to check 28diagnose () { 29 makelist "${distdir}" "$1" > dist"${1}".txt && 30 makelist "${srcdir}" "$1" > src"${1}".txt && 31 diff src"${1}".txt dist"${1}".txt 32 rm -f src"${1}".txt dist"${1}".txt 33 echo 34} 35 36 37check_shipfiles () { 38 distcount=`ls ${distdir}/*/*${suffix} | wc -l` 39 srccount=`ls ${srcdir}/*/*${suffix} | wc -l` 40 if test $distcount -eq $srccount ; then 41 echo "All $srccount of the $suffix files are accounted for" 42 else 43 echo "ERROR: Missing $suffix files: source $srccount distributed $distcount" >&2 44 rv=1 45 diagnose "${suffix}" 46 fi 47} 48 49 50main () { 51 distdir="$1" 52 srcdir="$2" 53 shift 2 54 if test "$#" -gt 0 ; then 55 for suffix ; do 56 check_shipfiles "$suffix" 57 done 58 exit $rv 59 else 60 echo "You did not specify any test file suffixes." >&2 61 exit 1 62 fi 63} 64 65main "$@" 66