-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
check_distribution.sh
executable file
·78 lines (69 loc) · 1.89 KB
/
check_distribution.sh
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
#!/bin/sh
PERL_FILES="check_updates t/*.t"
FILES="${PERL_FILES} AUTHORS.md COPYING COPYRIGHT Changes INSTALL Makefile.PL NEWS check_distribution.sh"
MARKDOWN_FILES="README.md"
FAILED=
# shellcheck disable=SC2250
for file in $FILES $PERL_FILES $MARKDOWN_FILES; do
if ! [ -r "${file}" ]; then
echo "${file} is missing"
FAILED=1
fi
done
if [ -n "${FAILED}" ]; then
# skip the next tests as at leadt file is missing
echo "Skipping the next tests as not all the files are present"
exit 1
fi
# shellcheck disable=SC2086
if ! perlcritic -1 ${PERL_FILES}; then
echo "Perl Critic failed"
FAILED=1
fi
if uname -a | grep -q '^Linux'; then
# shellcheck disable=SC2086
if grep -P -q '\t' ${FILES} ${MARKDOWN_FILES}; then
echo "Tabs"
# shellcheck disable=SC2086
grep -P -n '\t' ${FILES} ${MARKDOWN_FILES}
FAILED=1
fi
elif uname -a | grep -q '^Darwin'; then
# shellcheck disable=SC2086
if grep -E -q '\t' ${FILES} ${MARKDOWN_FILES}; then
echo "Tabs"
# shellcheck disable=SC2086
grep -E -n '\t' ${FILES} ${MARKDOWN_FILES}
FAILED=1
fi
else
echo "Unable to check for tabs"
FAILED=1
fi
# shellcheck disable=SC2086
if grep -q '[[:blank:]]$' ${FILES}; then
echo "Blanks at the end of a line"
# shellcheck disable=SC2086
grep -n '[[:blank:]]$' ${FILES}
FAILED=1
fi
YEAR=$(date +"%Y")
if ! grep -q "© Matteo Corti, 2007-${YEAR}" README.md; then
echo "Wrong (c) in README.md"
FAILED=1
fi
if ! grep -q "Copyright (c) 2007-${YEAR} Matteo Corti" COPYRIGHT; then
echo "Wrong (c) in COPYRIGHT"
FAILED=1
fi
if ! grep -q "Copyright (c) 2007-${YEAR} Matteo Corti <[email protected]>" check_updates; then
echo "Wrong (c) in check_updates"
FAILED=1
fi
if [ -n "${FAILED}" ]; then
echo "Distribution check failed"
exit 1
else
echo "Distribution check OK"
exit 0
fi