]> git.ipfire.org Git - thirdparty/openssl.git/blame - util/openssl-update-copyright
Properly process the "Availablein" keyword for evp_test
[thirdparty/openssl.git] / util / openssl-update-copyright
CommitLineData
433a2e03 1#!/usr/bin/env bash
b26d696c
DMSP
2#
3# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
4#
9059ab42 5# Licensed under the Apache License 2.0 (the "License"). You may not use
b26d696c
DMSP
6# this file except in compliance with the License. You can obtain a copy
7# in the file LICENSE in the source distribution or at
8# https://www.openssl.org/source/license.html
9
10
11myname="$(basename $0)"
12
13this_year="$(date '+%Y')"
14some_year="[12][0-9][0-9][0-9]"
433a2e03 15year_range="(${some_year})(-${some_year})?"
b26d696c
DMSP
16
17copyright_owner="The OpenSSL Project"
433a2e03 18copyright="Copyright .*${year_range} .*${copyright_owner}"
b26d696c 19
433a2e03
DMSP
20# sed_script:
21# for all lines that contain ${copyright} : {
22# replace years yyyy-zzzz (or year yyyy) by yyyy-${this_year}
23# replace repeated years yyyy-yyyy by yyyy
24# }
25sed_script="/${copyright}/{ s/${year_range}/\1-${this_year}/ ; s/(${some_year})-\1/\1/ }"
b26d696c
DMSP
26
27function usage() {
28 cat >&2 <<EOF
29usage: $myname [-h|--help] [file|directory] ...
30
31Updates the year ranges of all OpenSSL copyright statements in the given
32files or directories. (Directories are traversed recursively.)
33EOF
34}
35
36if [ $# -eq 0 ]; then
37 usage
38 exit 0
39fi
40
41
42for arg in "$@"; do
43 case $arg in
44 -h|--help)
45 usage
46 exit 0
47 ;;
48 -*)
49 echo -e "illegal option: $arg\n" >& 2
50 usage
51 exit 1
52 ;;
53 *)
54 if [ -f "$arg" ]; then
433a2e03 55 sed -E -i "${sed_script}" "$arg"
b26d696c 56 elif [ -d "$arg" ]; then
433a2e03 57 find "$arg" -name '.[a-z]*' -prune -o -type f -exec sed -E -i "${sed_script}" {} +
b26d696c
DMSP
58 else
59 echo "$arg: no such file or directory" >&2
60 fi
61 ;;
62 esac
63done