blob: 6733af08acd5365c31423ff6a2bebceb93e9c4ce [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
Nico Huberc152f532023-01-25 23:53:18 +010016GETREVISION=$(dirname ${0})/getrevision.sh
17
Nico Huber2f6936b2019-09-24 18:31:38 +020018version() {
Nico Huberc152f532023-01-25 23:53:18 +010019 v='unknown'
20 if ${GETREVISION} -c; then
21 tmp=$(${GETREVISION} --revision)
22 if [ $? -eq 0 ]; then
23 v="${tmp}"
Nico Huber2f6936b2019-09-24 18:31:38 +020024 fi
25 fi
26
Nico Huberc152f532023-01-25 23:53:18 +010027 if [ "$v" = unknown -a -r versioninfo.inc ]; then
28 v=$(sed -n 's/^VERSION = //p' versioninfo.inc)
29 fi
30
Nico Huber2f6936b2019-09-24 18:31:38 +020031 echo ${v}
32}
33
34mandate() {
Nico Huberc152f532023-01-25 23:53:18 +010035 d='unknown'
36 if ${GETREVISION} -c flashrom.8.tmpl; then
37 tmp=$(${GETREVISION} --date flashrom.8.tmpl)
38 if [ $? -eq 0 ]; then
39 d="${tmp}"
Nico Huber2f6936b2019-09-24 18:31:38 +020040 fi
41 fi
42
Nico Huberc152f532023-01-25 23:53:18 +010043 if [ "$d" = unknown -a -r versioninfo.inc ]; then
44 d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc)
45 fi
46
Nico Huber2f6936b2019-09-24 18:31:38 +020047 echo ${d}
48}
49
50show_help() {
51 echo "Usage:
52 ${0} <command>
53
54Commands
55 -h or --help
56 this message
57 -v or --version
58 return current/release flashrom version
59 -m or --man-date
60 return current/release date of the manual page
61"
62}
63
64if [ $# -ne 1 ]; then
65 show_help
66 echo "Error: Only exactly one command allowed.">&2
67 exit 1
68fi
69
70case $1 in
71 -h|--help) show_help;;
72 -m|--man-date) mandate;;
73 -v|--version) version;;
74 *)
75 show_help
76 echo "Error: Invalid option: $1"
77 exit 1
78 ;;
79esac