|
1 | 1 | # -*- mode:sh -*- |
2 | 2 |
|
3 | | -# Detect version of the software |
4 | | - |
5 | | -get_version_string() |
6 | | -{ |
7 | | - DIR=$1 |
8 | | - |
9 | | - grep '^[^a-zA-Z0-9_]VERSION=[^$]*$' $BASEDIR/$DIR/configure \ |
10 | | - | cut -d= -f2 \ |
11 | | - | tr -d \' |
12 | | -} |
13 | | - |
14 | | -# Generate VERSION in the form of MAIN~SUPP, where SUPP is going in the |
15 | | -# "release" tag of RPMs (see "package" script). |
16 | | -ci_version() |
17 | | -{ |
18 | | - VERSION_IN=`get_version_string core` |
19 | | - echo "Got VERSION: $VERSION_IN" |
20 | | - |
21 | | - # The version string is usually taken from git tags, thus it can be |
22 | | - # 3.10.0b1-build1. Or from determine-version.py and then it can be |
23 | | - # 3.10.0a.abcdef. |
24 | | - |
25 | | - # 3.10.0b1-build1: Replace dash with tilde and separate |
26 | | - # MAIN from SUPPlementary version. Dashes confuse deb/rpm |
27 | | - # packagers, and we use the tilde later to split it again. |
28 | | - |
29 | | - # 3.10.0a.abcdef: Here the MAIN version is all of the string, and |
30 | | - # there is no SUPPlementary version. |
31 | | - |
32 | | - VERSION=$(echo "$VERSION_IN" | tr '-' '~') |
33 | | - |
34 | | - # Is it in correct form until the tilde? |
35 | | - if echo "$VERSION" | egrep '^[0-9]+\.[0-9]+\.[0-9]+([ab][0-9]*)?(\.[0-9a-f]+)?(~.*)?$' |
36 | | - then |
37 | | - : # correct |
38 | | - else |
39 | | - echo "Unable to parse version $VERSION_IN. Bailing out." |
40 | | - exit 42 |
41 | | - fi |
42 | | - |
43 | | - echo "Setting VERSION: $VERSION" |
44 | | -} |
45 | | - |
46 | | -release_version() |
47 | | -{ |
48 | | - VERSION=`get_version_string core` |
49 | | - echo "Using VERSION: $VERSION" |
50 | | -} |
51 | | - |
52 | | -continuous_version() |
53 | | -{ |
54 | | - MONTH=`date +"%m"` |
55 | | - YEAR=`date +"%g"` |
56 | | - MY_BUILD_NUMBER=$BUILD_NUMBER |
57 | | - MY_MAJOR_VERSION=$MAJOR_VERSION |
58 | | - echo "version is $MY_MAJOR_VERSION.$YEAR.$MONTH-$MY_BUILD_NUMBER" |
59 | | - VERSION=$MY_MAJOR_VERSION.$YEAR.$MONTH-$MY_BUILD_NUMBER |
60 | | -} |
61 | | - |
62 | | -if [ -z "$EXPLICIT_VERSION" ] |
63 | | -then |
64 | | - case "$BUILD_TYPE" in |
65 | | - RELEASE) |
66 | | - release_version |
67 | | - ;; |
68 | | - DEBUG) |
69 | | - ci_version |
70 | | - ;; |
71 | | - CODE_COVERAGE) |
72 | | - ci_version |
73 | | - VERSION="$VERSION.code_coverage" |
74 | | - ;; |
75 | | - *) |
76 | | - echo "Unknown build type: $BUILD_TYPE" |
77 | | - exit 42 |
78 | | - ;; |
79 | | - esac |
80 | | -else |
81 | | - VERSION=$EXPLICIT_VERSION |
82 | | -fi |
83 | | - |
84 | | -# resolving release number is easy |
| 3 | +# This script determines the RELEASE & VERSION number uses when packaging |
| 4 | +# CFEngine. |
| 5 | +# |
| 6 | +# The script expects the following repositories to exist side by side: |
| 7 | +# . |
| 8 | +# ├── buildscripts |
| 9 | +# └── core |
| 10 | +# |
| 11 | +# Source this file, don`t execute it. Also source the functions script before |
| 12 | +# the version script. E.g.: |
| 13 | +# |
| 14 | +# . `dirname "$0"`/functions |
| 15 | +# . `dirname "$0"`/version |
| 16 | + |
| 17 | + |
| 18 | +# The CFVERSION file is generated by the determine-version.sh script in the core |
| 19 | +# repository. The script is executed when you run the autogen.sh. |
| 20 | +VERSION=$(cat "$BASEDIR"/core/CFVERSION) |
| 21 | +echo "$(basename $0): Debug: Detected CFEngine version number $VERSION" |
| 22 | + |
| 23 | +# The RELEASE number is the actual release of the package. It starts as 1 and |
| 24 | +# would incremented each time you create a new release of the CFEngine package |
| 25 | +# of the same version. |
85 | 26 | RELEASE="${EXPLICIT_RELEASE:-1}" |
86 | 27 | export RELEASE |
| 28 | +echo "$(basename $0): Debug: Detected CFEngine package release number $RELEASE" |
0 commit comments