File: version.sh

package info (click to toggle)
libcork 0.15.0%2Bds-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,696 kB
  • sloc: ansic: 12,216; python: 95; sh: 90; makefile: 10
file content (33 lines) | stat: -rwxr-xr-x 1,185 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# ----------------------------------------------------------------------
# Copyright © 2011-2013, RedJack, LLC.
# All rights reserved.
#
# Please see the COPYING file in this distribution for license
# details.
# ----------------------------------------------------------------------

# Calculates the current version number.  If possible, this is the
# output of “git describe”.  If “git describe” returns an error (most
# likely because we're in an unpacked copy of a release tarball, rather
# than in a git working copy), then we fall back on reading the contents
# of the RELEASE-VERSION file.
#
# This will automatically update the RELEASE-VERSION file, if necessary.
# Note that the RELEASE-VERSION file should *not* be checked into git;
# please add it to your top-level .gitignore file.

version=$(dpkg-parsechangelog --show-field Version)
if [ -n ${version} ]; then
    # If we got something from git-describe, write the version to the
    # output file.
    echo ${version} > RELEASE-VERSION
else
    version=$(cat RELEASE-VERSION)
    if [ -z ${version} ]; then
        echo "Cannot find the version number!" >&2
        exit 1
    fi
fi

echo ${version}