aboutsummaryrefslogtreecommitdiffstats
path: root/util/getversion.sh
blob: d3810d29b7b0245374c7dad745fdb8112352c6e7 (plain)
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
#!/bin/sh
#
# This file is part of the flashrom project.
#
# 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 2 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.
#

version() {
	if [ -r versioninfo.inc ]; then
		v=$(sed -n 's/^VERSION = //p' versioninfo.inc)
	else
		v=$($(dirname ${0})/getrevision.sh --revision)
		if [ $? -ne 0 ]; then
			v='unknown'
		fi
	fi

	echo ${v}
}

mandate() {
	if [ -r versioninfo.inc ]; then
		d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc)
	else
		d=$($(dirname ${0})/getrevision.sh --date flashrom.8.tmpl)
		if [ $? -ne 0 ]; then
			d='unknown'
		fi
	fi

	echo ${d}
}

show_help() {
	echo "Usage:
	${0} <command>

Commands
    -h or --help
        this message
    -v or --version
        return current/release flashrom version
    -m or --man-date
        return current/release date of the manual page
"
}

if [ $# -ne 1 ]; then
	show_help
	echo "Error: Only exactly one command allowed.">&2
	exit 1
fi

case $1 in
	-h|--help)	show_help;;
	-m|--man-date)	mandate;;
	-v|--version)	version;;
	*)
		show_help
		echo "Error: Invalid option: $1"
		exit 1
		;;
esac