Commit 95849aa8 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Check that each file has a copyright statement

For legalese, we need to check that each source file has a copyright
information at the top and a reminder that there is a license and no
warranty.
parent 811ab39b
......@@ -45,6 +45,7 @@ include debian/Makefile.am
include flatpak/Makefile.am
include model/Makefile.am
include git-check.am
include copyright/Makefile.am
AM_CPPFLAGS += \
-DLOCALEDIR="\"$(localedir)\"" \
......
# tarot implements the rules of the tarot game
# Copyright (C) 2019 Vivien Kraus
# 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 3 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, see <http://www.gnu.org/licenses/>.
EXTRA_DIST += %reldir%/check-copyright
#!/bin/sh
# tarot implements the rules of the tarot game
# Copyright (C) 2019 Vivien Kraus
# 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 3 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, see <http://www.gnu.org/licenses/>.
EXPECTED_FIRSTLINE="tarot implements the rules of the tarot game"
EXPECTED_COPYRIGHT=$(cat <<EOF
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 3 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, see <http://www.gnu.org/licenses/>.
EOF
)
FIRSTLINE=$(head -n 1 "$1")
SECONDLINE=$(head -n 2 "$1" | tail -n 1)
REST=$(tail -n +4 "$1")
case "$1" in
*.png | ./model/*.model | ./nsi/*.rc | ./doc/fdl.texi | ./doc/style.css | ./doc/convergence.csv \
| ./valgrind.supp | ./debian/tarot.doc-base.manual | ./debian/tarot-docs.docs \
| ./debian/control | ./debian/copyright | ./COPYING | ./src/libtarot/cnn/tarot/first_filters.h \
| ./src/libtarot/cnn/tarot/fully_connected.h | ./src/libtarot/cnn/tarot/second_filters.h \
| ./src/libtarot/gobject/Tarot.metadata | ./src/libtarot/features/features-header.txt.in \
| ./src/libtarot/features/features-header-encoded.txt.in | ./NEWS | ./.gitignore | ./.git/* \
| ./po/LINGUAS | ./po/*.po | ./po/*.pot | ./src/libtarot/xml/check_xml_*.xml \
| ./debian/source/format | ./debian/compat)
exit 0
;;
*.am | *.desktop.in | *.org | ./debian/source/format | ./debian/compat | ./configure.ac \
| *.pc | *.pc.in | *.yml | ./po/Rules-* | ./po/Makevars | ./po/POTFILES.in)
EXPECTED_FIRSTLINE="# $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/# /g' | sed 's/^# $/#/g')
;;
*.el|*.el.in)
EXPECTED_FIRSTLINE=";; $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/;; /g' | sed 's/^;; $/;;/g')
;;
*.nsi | *.nsi.in)
EXPECTED_FIRSTLINE="; $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/; /g' | sed 's/^; $/;/g')
;;
*.c | *.h | *.c.in | *.h.in | *.css)
EXPECTED_FIRSTLINE="/* $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/ * /g' | sed 's/^ \* $/ */g')
;;
*.vala)
EXPECTED_FIRSTLINE="// $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/\/\/ /g' | sed 's/^\/\/ $/\/\//g')
;;
*.svg | *.xsl | *.xml | *.tarot | *.ui | *.tarottest | *.xslt)
FIRSTLINE=$(head -n 2 "$1" | tail -n 1)
SECONDLINE=$(head -n 3 "$1" | tail -n 1)
REST=$(tail -n +5 "$1")
EXPECTED_FIRSTLINE="<!-- $EXPECTED_FIRSTLINE"
;;
*)
FIRSTLINE=$(head -n 2 "$1" | tail -n 1)
SECONDLINE=$(head -n 3 "$1" | tail -n 1)
REST=$(tail -n +5 "$1")
EXPECTED_FIRSTLINE="# $EXPECTED_FIRSTLINE"
EXPECTED_COPYRIGHT=$(echo "$EXPECTED_COPYRIGHT" | sed 's/^/# /g' | sed 's/^# $/#/g')
esac
ACTUAL_COPYRIGHT=$(echo "$REST" | head -c $(echo "$EXPECTED_COPYRIGHT" | wc -c))
if test "x$EXPECTED_FIRSTLINE" = "x$FIRSTLINE"
then
true
else
>&2 echo "Error: first line of $1 not OK. Expected:"
>&2 echo "$EXPECTED_FIRSTLINE"
>&2 echo "Got:"
>&2 echo "$FIRSTLINE"
exit 1
fi
if test "x$EXPECTED_COPYRIGHT" = "x$ACTUAL_COPYRIGHT"
then
true
else
>&2 echo "Error: copyright statement of $1 not OK. Expected:"
>&2 echo "$EXPECTED_COPYRIGHT"
>&2 echo "Got:"
>&2 echo "$ACTUAL_COPYRIGHT"
exit 1
fi
if echo "$SECONDLINE" | grep "Copyright (C)" >/dev/null 2>&1
then
true
else
>&2 echo "Error: copyright line of $1 not OK"
exit 1
fi
......@@ -25,6 +25,11 @@ git-check:
@rm -rf .gitcheck
$(MKDIR_P) .gitcheck
$(git_clone_verbose) $(GIT) clone $(srcdir) .gitcheck/clean/
(cd .gitcheck/clean \
&& for source in $$(find . -type f) ; \
do \
./copyright/check-copyright "$$source" || exit 1; \
done)
$(git_clone_verbose) $(GIT) clone $(srcdir) .gitcheck/source/
$(MKDIR_P) .gitcheck/build
(cd .gitcheck/source && ./autogen.sh)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment