]> git.ipfire.org Git - thirdparty/openssl.git/blob - dev/release-aux/release-version-fn.sh
Rename NOTES*, README*, VERSION, HACKING, LICENSE to .md or .txt
[thirdparty/openssl.git] / dev / release-aux / release-version-fn.sh
1 #! /bin/sh
2 # Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9 # These functions load, manipulate and store the current version information
10 # for OpenSSL 3.0 and on.
11 # They are meant to be minimalistic for easy refactoring depending on OpenSSL
12 # version.
13 #
14 # Version information is stored in the following variables:
15 #
16 # |MAJOR|, |MINOR|, |PATCH| are the three parts of a version number.
17 # |MAJOR| is to be increased for new major releases, |MINOR| for new
18 # minor releases, and |PATCH| for update releases.
19 #
20 # |SERIES| tells what release series the current version belongs to, and
21 # is composed from |MAJOR| and |MINOR|.
22 # |VERSION| tells what the current version is, and is composed from |MAJOR|,
23 # |MINOR| and |PATCH|.
24 # |TYPE| tells what state the source is in. It may have an empty value
25 # for released source, or 'dev' for "in development".
26 # |PRE_LABEL| may be "alpha" or "beta" to signify an ongoing series of
27 # alpha or beta releases. |PRE_NUM| is a pre-release counter for the
28 # alpha and beta release series, but isn't necessarily strictly tied
29 # to the prerelease label.
30 #
31 # Scripts loading this file are not allowed to manipulate these
32 # variables directly. They must use functions such as fixup_version()
33 # below, or next_release_state(), found in release-state-fn.sh.
34
35 # These functions depend on |SOURCEDIR|, which must have the intended
36 # OpenSSL source directory as value.
37
38 get_version () {
39 eval $(git cat-file blob HEAD:VERSION.dat)
40 VERSION="$MAJOR.$MINOR.$PATCH"
41 SERIES="$MAJOR.$MINOR"
42 TYPE=$( echo "$PRE_RELEASE_TAG" \
43 | sed -E \
44 -e 's|^dev$|dev|' \
45 -e 's|^alpha([0-9]+)(-(dev))?$|\3|' \
46 -e 's|^beta([0-9]+)(-(dev))?$|\3|' )
47 PRE_LABEL=$( echo "$PRE_RELEASE_TAG" \
48 | sed -E \
49 -e 's|^dev$||' \
50 -e 's|^alpha([0-9]+)(-(dev))?$|alpha|' \
51 -e 's|^beta([0-9]+)(-(dev))?$|beta|' )
52 PRE_NUM=$( echo "$PRE_RELEASE_TAG" \
53 | sed -E \
54 -e 's|^dev$|0|' \
55 -e 's|^alpha([0-9]+)(-(dev))?$|\1|' \
56 -e 's|^beta([0-9]+)(-(dev))?$|\1|' )
57 }
58
59 # $1 is one of "alpha", "beta", "final", "", or "minor"
60 fixup_version () {
61 local new_label="$1"
62
63 case "$new_label" in
64 alpha | beta )
65 if [ "$new_label" != "$PRE_LABEL" ]; then
66 PRE_LABEL="$new_label"
67 PRE_NUM=1
68 elif [ "$TYPE" = 'dev' ]; then
69 PRE_NUM=$(expr $PRE_NUM + 1)
70 fi
71 ;;
72 final | '' )
73 if [ "$TYPE" = 'dev' ]; then
74 PATCH=$(expr $PATCH + 1)
75 fi
76 PRE_LABEL=
77 PRE_NUM=0
78 ;;
79 minor )
80 if [ "$TYPE" = 'dev' ]; then
81 MINOR=$(expr $MINOR + 1)
82 PATCH=0
83 fi
84 PRE_LABEL=
85 PRE_NUM=0
86 ;;
87 esac
88
89 VERSION="$MAJOR.$MINOR.$PATCH"
90 SERIES="$MAJOR.$MINOR"
91 }
92
93 set_version () {
94 case "$TYPE+$PRE_LABEL+$PRE_NUM" in
95 *++* )
96 PRE_RELEASE_TAG="$TYPE"
97 ;;
98 dev+* )
99 PRE_RELEASE_TAG="$PRE_LABEL$PRE_NUM-dev"
100 ;;
101 +* )
102 PRE_RELEASE_TAG="$PRE_LABEL$PRE_NUM"
103 ;;
104 esac
105 cat > "$SOURCEDIR/VERSION.dat" <<EOF
106 MAJOR=$MAJOR
107 MINOR=$MINOR
108 PATCH=$PATCH
109 PRE_RELEASE_TAG=$PRE_RELEASE_TAG
110 BUILD_METADATA=$BUILD_METADATA
111 RELEASE_DATE="$RELEASE_DATE"
112 SHLIB_VERSION=$SHLIB_VERSION
113 EOF
114 }