File: version.sh

package info (click to toggle)
liquid-dsp 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,216 kB
  • sloc: ansic: 115,859; sh: 3,513; makefile: 1,350; python: 274; asm: 11
file content (55 lines) | stat: -rwxr-xr-x 1,236 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh

# This script parses the global header and extracts the major.minor.patch version for
# liquid-dsp and prints to the screen. This is a simplified version of:
# https://github.com/tinyalsa/tinyalsa/blob/master/scripts/version.sh

INCLUDE_FILE="include/liquid.h"

# exit program with error
die()
{
    echo "error: $@" 1>&2
    exit 1
}

# check that file exists
check_files()
{
    [ -f ${INCLUDE_FILE}   ] || die "No ${INCLUDE_FILE} found!";
}

# get a part of the version from the header, e.g. LIQUID_VERSION_MAJOR
get_version_part()
{
    set -- "$1" "$(grep -m 1 "^#define\([ \t]*\)$1" ${INCLUDE_FILE} | sed 's/[^0-9]*//g')"

    if [ -z "$2" ]; then
        die "Could not get $1 from ${INCLUDE_FILE}"
    fi

    echo "$2"
}

# gets the complete version from the include file
get_version()
{
    VERSION_MAJOR=$(get_version_part "LIQUID_VERSION_MAJOR")
    VERSION_MINOR=$(get_version_part "LIQUID_VERSION_MINOR")
    VERSION_PATCH=$(get_version_part "LIQUID_VERSION_PATCH")
}

print_version()
{
    printf "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${LF}"
    return 0
}

check_files
get_version
print_version "$2"
exit $?

# The script should never reach this place.
die "Internal error. Please report this."