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
|
#!/bin/bash -efu
# Update the copyright year.
shopt -s extglob
readonly SCRIPTNAME="$0"
function print_usage_message_and_exit {
cat <<END >&$1
usage: $SCRIPTNAME [-?] YEARS
example: $SCRIPTNAME 2021-2024
This optional helper script updates the year or years of copyright in
various spots in the source. It is for the regular maintainer's use.
Please do not run it if you are making a Non-Maintainer Upload (NMU).
If you are a user or deriver modifying Mirrorrib for your own purpose
and wish to append your own copyright notice to your changes, you can
do that, of course. However, running this helper would not append your
copyright notice. It would only deface the maintainer's.
If on the other hand you have succeeded the author and are now serving
as Mirrorrib's regular maintainer, then you will presumably have
extended the copyright notice's format to include your own copyright.
However, this helper has not anticipated your format, so if you wish to
use the helper, then you'll need to modify it first.
END
exit $(($1 - 1))
}
readonly -f print_usage_message_and_exit
(($# == 1)) || print_usage_message_and_exit 2
[ "$1" = '-?' -o "$1" = '--help' ] && print_usage_message_and_exit 1
[[ "$1" = [[:digit:]][[:digit:]][[:digit:]][[:digit:]]?(-[[:digit:]][[:digit:]][[:digit:]][[:digit:]]) ]]\
|| print_usage_message_and_exit 2
readonly SCRIPT_DIR="$(dirname -- "$(realpath -e -- "$0")")"
readonly TOP_DIR="$(realpath -e -- "$SCRIPT_DIR/../..")"
readonly SED_PAT1='^(Copyright(:|\s+\(C\)|:\s+\(C\))\s+)'
readonly SED_PAT2='[[:digit:]]{4}(-[[:digit:]]{4})?\b'
readonly SED_PATTERN="$SED_PAT1$SED_PAT2"
for F in\
"$TOP_DIR/COPYRIGHT"\
"$TOP_DIR/debian/copyright"\
"$TOP_DIR/usr/share/mirrorrib/scripts/05option-processing.bash"
do
sed -r "s/${SED_PATTERN}/\\1${1}/;T;:a;n;ba;" -i "$F"
done
|