Nico Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 1 | #!/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 Huber | c152f53 | 2023-01-25 23:53:18 +0100 | [diff] [blame] | 16 | GETREVISION=$(dirname ${0})/getrevision.sh |
| 17 | |
Nico Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 18 | version() { |
Nico Huber | c152f53 | 2023-01-25 23:53:18 +0100 | [diff] [blame] | 19 | v='unknown' |
| 20 | if ${GETREVISION} -c; then |
| 21 | tmp=$(${GETREVISION} --revision) |
| 22 | if [ $? -eq 0 ]; then |
| 23 | v="${tmp}" |
Nico Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 24 | fi |
| 25 | fi |
| 26 | |
Nico Huber | c152f53 | 2023-01-25 23:53:18 +0100 | [diff] [blame] | 27 | if [ "$v" = unknown -a -r versioninfo.inc ]; then |
| 28 | v=$(sed -n 's/^VERSION = //p' versioninfo.inc) |
| 29 | fi |
| 30 | |
Nico Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 31 | echo ${v} |
| 32 | } |
| 33 | |
| 34 | mandate() { |
Nico Huber | c152f53 | 2023-01-25 23:53:18 +0100 | [diff] [blame] | 35 | 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 Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 40 | fi |
| 41 | fi |
| 42 | |
Nico Huber | c152f53 | 2023-01-25 23:53:18 +0100 | [diff] [blame] | 43 | if [ "$d" = unknown -a -r versioninfo.inc ]; then |
| 44 | d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc) |
| 45 | fi |
| 46 | |
Nico Huber | 2f6936b | 2019-09-24 18:31:38 +0200 | [diff] [blame] | 47 | echo ${d} |
| 48 | } |
| 49 | |
| 50 | show_help() { |
| 51 | echo "Usage: |
| 52 | ${0} <command> |
| 53 | |
| 54 | Commands |
| 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 | |
| 64 | if [ $# -ne 1 ]; then |
| 65 | show_help |
| 66 | echo "Error: Only exactly one command allowed.">&2 |
| 67 | exit 1 |
| 68 | fi |
| 69 | |
| 70 | case $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 | ;; |
| 79 | esac |