blob: d3810d29b7b0245374c7dad745fdb8112352c6e7 [file] [log] [blame]
Nico Huber2f6936b2019-09-24 18:31:38 +02001#!/bin/sh
2#
3# This file is part of the flashrom project.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15
16version() {
17 if [ -r versioninfo.inc ]; then
18 v=$(sed -n 's/^VERSION = //p' versioninfo.inc)
19 else
20 v=$($(dirname ${0})/getrevision.sh --revision)
21 if [ $? -ne 0 ]; then
22 v='unknown'
23 fi
24 fi
25
26 echo ${v}
27}
28
29mandate() {
30 if [ -r versioninfo.inc ]; then
31 d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc)
32 else
33 d=$($(dirname ${0})/getrevision.sh --date flashrom.8.tmpl)
34 if [ $? -ne 0 ]; then
35 d='unknown'
36 fi
37 fi
38
39 echo ${d}
40}
41
42show_help() {
43 echo "Usage:
44 ${0} <command>
45
46Commands
47 -h or --help
48 this message
49 -v or --version
50 return current/release flashrom version
51 -m or --man-date
52 return current/release date of the manual page
53"
54}
55
56if [ $# -ne 1 ]; then
57 show_help
58 echo "Error: Only exactly one command allowed.">&2
59 exit 1
60fi
61
62case $1 in
63 -h|--help) show_help;;
64 -m|--man-date) mandate;;
65 -v|--version) version;;
66 *)
67 show_help
68 echo "Error: Invalid option: $1"
69 exit 1
70 ;;
71esac