]> jfr.im git - irc/weechat/weechat.git/blob - version.sh
Version 4.0.3
[irc/weechat/weechat.git] / version.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2015-2023 Sébastien Helleu <flashcode@flashtux.org>
4 #
5 # This file is part of WeeChat, the extensible chat client.
6 #
7 # WeeChat is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # WeeChat is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
19 #
20
21 #
22 # Returns current stable or devel version of WeeChat.
23 #
24 # Syntax:
25 # version.sh <name>
26 #
27 # name is one of:
28 #
29 # stable the current stable (e.g. "4.0.2")
30 # stable-major the major version of stable ("4" for "4.0.2")
31 # stable-minor the minor version of stable ("0" for "4.0.2")
32 # stable-patch the patch version of stable ("2" for "4.0.2")
33 # stable-number the stable version as hex number ("0x04000200" for "4.0.2")
34 # devel the devel with only digits/dots (e.g. "4.1.0")
35 # devel-full the full devel (e.g. "4.1.0-dev")
36 # devel-major the major version of devel ("4" for "4.1.0-dev")
37 # devel-minor the minor version of devel ("1" for "4.1.0-dev")
38 # devel-patch the patch version of devel ("0-dev" for "4.1.0-dev")
39 # devel-number the devel version as hex number ("0x04010000" for "4.1.0-dev")
40 #
41
42 WEECHAT_STABLE="4.0.3"
43 WEECHAT_DEVEL="4.0.3"
44
45 STABLE_MAJOR=$(echo "${WEECHAT_STABLE}" | cut -d"." -f1)
46 STABLE_MINOR=$(echo "${WEECHAT_STABLE}" | cut -d"." -f2)
47 STABLE_PATCH=$(echo "${WEECHAT_STABLE}" | cut -d"." -f3-)
48 STABLE_PATCH_DIGITS=$(echo "${WEECHAT_STABLE}" | cut -d"." -f3- | cut -d"-" -f1)
49
50 DEVEL_MAJOR=$(echo "${WEECHAT_DEVEL}" | cut -d"." -f1)
51 DEVEL_MINOR=$(echo "${WEECHAT_DEVEL}" | cut -d"." -f2)
52 DEVEL_PATCH=$(echo "${WEECHAT_DEVEL}" | cut -d"." -f3-)
53 DEVEL_PATCH_DIGITS=$(echo "${WEECHAT_DEVEL}" | cut -d"." -f3- | cut -d"-" -f1)
54
55 if [ $# -lt 1 ]; then
56 echo >&2 "Syntax: $0 <name>"
57 echo >&2 "name: stable, stable-major, stable-minor, stable-patch, stable-number,"
58 echo >&2 " devel, devel-full, devel-major, devel-minor, devel-patch, devel-number"
59 exit 1
60 fi
61
62 case $1 in
63 # stable
64 stable ) echo "${WEECHAT_STABLE}" ;;
65 stable-major ) echo "${STABLE_MAJOR}" ;;
66 stable-minor ) echo "${STABLE_MINOR}" ;;
67 stable-patch ) echo "${STABLE_PATCH}" ;;
68 stable-number ) printf "0x%02d%02d%02d00\n" "${STABLE_MAJOR}" "${STABLE_MINOR}" "${STABLE_PATCH_DIGITS}" ;;
69 # devel
70 devel ) echo "${WEECHAT_DEVEL}" | cut -d"-" -f1 ;;
71 devel-full ) echo "${WEECHAT_DEVEL}" ;;
72 devel-major ) echo "${DEVEL_MAJOR}" ;;
73 devel-minor ) echo "${DEVEL_MINOR}" ;;
74 devel-patch ) echo "${DEVEL_PATCH}" ;;
75 devel-number ) printf "0x%02d%02d%02d00\n" "${DEVEL_MAJOR}" "${DEVEL_MINOR}" "${DEVEL_PATCH_DIGITS}" ;;
76 # error
77 * ) echo >&2 "ERROR: unknown version."
78 exit 1 ;;
79 esac