File: get-version.sh

package info (click to toggle)
nextcloud-spreed-signaling 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,620 kB
  • sloc: sh: 447; makefile: 187; python: 78
file content (31 lines) | stat: -rwxr-xr-x 902 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bash
set -e
ROOT="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"

VERSION=
if [ -s "$ROOT/../version.txt" ]; then
    VERSION=$(tr -d '[:space:]' < "$ROOT/../version.txt")
fi
if [ -f "$ROOT/../debian/changelog" ] && [ -f "$ROOT/../debian/control" ]; then
    VERSION="$(cd "$ROOT/../" && dpkg-parsechangelog -S Version).debian"
elif [ -z "$VERSION" ] && [ -d "$ROOT/../.git" ]; then
    TAG=$(git tag --points-at HEAD | sed 's/v//')
    if [ "$1" == "--tar" ]; then
        VERSION=$(git describe --dirty --tags --always | sed 's/debian\///g')
    elif [ -n "$TAG" ]; then
        VERSION="$TAG"
    else
        VERSION=$(git log -1 --pretty=%H)
    fi
    if [ -f "/.dockerenv" ]; then
        VERSION="$VERSION~docker"
    elif grep -sq 'docker\|lxc' /proc/1/cgroup; then
        VERSION="$VERSION~docker"
    fi
fi

if [ -z "$VERSION" ]; then
    VERSION=unknown
fi

echo $VERSION