media/tagtele.lua: Relicense under AGPLv3+
[libquvi-scripts.git] / gen-ver.sh
blobf7b5549963935c691757a858c0aa213b933d95a3
1 #!/bin/sh
3 # libquvi-scripts
4 # Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
6 # This file part of libquvi-scripts <http://quvi.sourceforge.net/>.
8 # This program is free software: you can redistribute it and/or
9 # modify it under the terms of the GNU Affero General Public
10 # License as published by the Free Software Foundation, either
11 # version 3 of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General
19 # Public License along with this program. If not, see
20 # <http://www.gnu.org/licenses/>.
22 dir=`dirname $0`
24 # flags:
25 m= # dump major and minor only
26 c= # strip off the 'v' prefix
28 # VERSION file is part of the dist tarball.
29 from_VERSION_file()
31 o=`cat "$dir/VERSION" 2>/dev/null`
34 from_git_describe()
36 [ -d "$dir/.git" -o -f "$dir/.git" ] && {
37 o=`git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null`
41 make_vn_mm()
43 j=`expr "$o" : 'v\([0-9]\)'`
44 n=`expr "$o" : 'v[0-9]\.\([0-9]*[0-9]\)'`
45 o="v$j.$n"
48 dump_vn()
50 [ -n "$m" ] && make_vn_mm
51 [ -n "$c" ] && o=${o#v} # strip off the 'v' prefix.
52 echo $o
53 exit 0
56 help()
58 echo "$0 [OPTIONS]
59 -h Show this help and exit
60 -c Strip off the 'v' prefix from the output
61 -m Output the major.minor -pair only"
62 exit 0
65 while [ $# -gt 0 ]
67 case "$1" in
68 -m) m=1;;
69 -c) c=1;;
70 -h) help;;
71 *) break;;
72 esac
73 shift
74 done
76 from_VERSION_file
77 [ -z "$o" ] && from_git_describe
78 [ -n "$o" ] && dump_vn
79 exit 1
81 # vim: set ts=2 sw=2 tw=72 expandtab: