1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#!/bin/bash
set -e
shopt -s extglob
PROGNAME=${0##*/}
# The following extglob matches all non-binary, non-debian-directory files known
# at the time of packaging.
FILES=!(*.cmd|*.dct|*.dsk|*.hex|*.tgz|debian)
DEBIAN_DIR=debian
COPYRIGHT=$DEBIAN_DIR/copyright
INFO_EXPECTED=$DEBIAN_DIR/copyright-info.expected
INFO_ACTUAL=$DEBIAN_DIR/copyright-info.actual
NO_INFO_EXPECTED=$DEBIAN_DIR/no-copyright-info.expected
NO_INFO_ACTUAL=$DEBIAN_DIR/no-copyright-info.actual
# Some generated files have no copyright info.
NO_INFO_GENERATED=+(cpmutil|dskspec).txt
if ! [ -d $DEBIAN_DIR ]; then
echo "$PROGNAME: fatal error: no \"$DEBIAN_DIR\" directory found; run" \
"this script from the top of the upstream source tree, as packaged" \
"for Debian" >&2
exit 1
fi
{
grep -n Copyright $FILES;
for PATTERN in \
'Permission is granted to any individual or institution to use, copy,' \
'or redistribute this software, provided this copyright notice is retained.' \
'This software is provided "as is" without any expressed or implied' \
'warranty. If this software brings on any sort of damage -- physical,' \
'monetary, emotional, or brain -- too bad. You'"'"'ve got no one to blame' \
'but yourself.' \
'The software may be modified for your own purposes, but modified versions' \
'must retain this notice.' \
'This software may be copied, modified, and used for any' \
'without fee, provided that (1) the above copyright notice is' \
'retained, and (2) modified versions are clearly marked as having' \
'purpose without fee, provided that (1) the above copyright' \
'notice is retained, and (2) modified versions are clearly' \
'the date included.'; do
grep -Fn "$PATTERN" $FILES;
done;
} | sort --field-separator=: --key=1,1 --key=2n,2n > $INFO_ACTUAL
grep -FLi copyright $FILES > $NO_INFO_ACTUAL
if ! [ -r $INFO_EXPECTED ]; then
echo "$PROGNAME: warning: \"$INFO_EXPECTED\" does not exist or is not" \
"readable; if \"$INFO_ACTUAL\" exists and is sane, move it to" \
"\"$INFO_EXPECTED\", and ensure that \"$COPYRIGHT\" is correct" >&2
exit 2
fi
if ! cmp --silent $INFO_EXPECTED $INFO_ACTUAL; then
echo "$PROGNAME: error: \"$INFO_EXPECTED\" and \"$INFO_ACTUAL\" differ;" \
"check \"$INFO_ACTUAL\" for sanity, and update \"$INFO_EXPECTED\" and" \
"\"$COPYRIGHT\" as necessary" >&2
exit 3
fi
# We could proceed with the no-copyright-info checks even if the copyright-info
# checks fail, but I am lazy.
# If this extglob match does NOT expand to its literal self, files match.
if [[ $(echo $NO_INFO_GENERATED) != "$NO_INFO_GENERATED" ]]; then
echo "$PROGNAME: error: generated files" $NO_INFO_GENERATED "exist; clean" \
"the source tree and try again" >&2
exit 4
fi
if ! [ -r $NO_INFO_EXPECTED ]; then
echo "$PROGNAME: warning: \"$NO_INFO_EXPECTED\" does not exist or is not" \
"readable; if \"$NO_INFO_ACTUAL\" exists and is sane, move it to" \
"\"$NO_INFO_EXPECTED\", and ensure that \"$COPYRIGHT\" is correct" >&2
exit 5
fi
if ! cmp --silent $NO_INFO_EXPECTED $NO_INFO_ACTUAL; then
echo "$PROGNAME: error: \"$NO_INFO_EXPECTED\" and \"$NO_INFO_ACTUAL\"" \
"differ; check \"$NO_INFO_ACTUAL\" for sanity, and update" \
"\"$NO_INFO_EXPECTED\" and \"$COPYRIGHT\" as necessary" >&2
exit 6
fi
exit 0
# vim:set ai et sw=4 ts=4 tw=80:
|