File: copyright-year-gen

package info (click to toggle)
strace 5.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 49,332 kB
  • sloc: ansic: 113,177; sh: 8,831; makefile: 3,108; awk: 364; perl: 267; sed: 9
file content (39 lines) | stat: -rwxr-xr-x 727 bytes parent folder | download
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
#!/bin/sh
#
# Copyright (c) 2017-2019 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: LGPL-2.1-or-later

: ${YEAR_FILE:=$1}
: ${DEFAULT_YEAR:=$2}
LC_TIME=C; export LC_TIME

year=

[ -n "${YEAR_FILE}" ] || {
	echo >&2 "$0 $(dirname "$0")/.year [DEFAULT_YEAR]"
	exit 1
}

[ -f "${YEAR_FILE}" ] && year="$(cat "${YEAR_FILE}")"

[ -n "${year}" ] ||
	year="$(date -u +%Y -d "$(git show -s --format=format:%cD)")"

[ -n "${year}" ] ||
	year="${DEFAULT_YEAR}"

[ -n "${year}" ] ||
	[ -z "${SOURCE_DATE_EPOCH-}" ] ||
	year="$(date -u +%Y -d "@${SOURCE_DATE_EPOCH}")"

[ -n "${year}" ] ||
	year="$(date -u +%Y)"

[ -n "${year}" ] || {
	printf >&2 "%s: Undefined year.\n" "$0"
	exit 1
}

printf "%s" "${year}"