forked from SilentCircle/scpf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscpf_version.sh
More file actions
executable file
·39 lines (31 loc) · 972 Bytes
/
Copy pathscpf_version.sh
File metadata and controls
executable file
·39 lines (31 loc) · 972 Bytes
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
#!/bin/bash
# Try to figure out SCPF version
GIT=$(which git)
DPKG_PARSE=$(which dpkg-parsechangelog)
file_version() {
local dsc=$(find .. -maxdepth 1 -type f -name 'scpf_*.dsc' | sort | tail -1)
if [[ -n $dsc ]]; then
echo -n $(basename $dsc .dsc | sed 's/^scpf_//')
fi
}
find_version() {
# Default to current UTC date/time
local vsn=$(date -u +"%Y%m%d%H%M%S")
if [[ -r ./APP_VERSION ]]; then
vsn=$(< ./APP_VERSION)
elif [[ -n $GIT ]] && [[ -d ./.git ]]; then
vsn=$($GIT describe --always --long)
elif [[ -n $DPKG_PARSE ]] && [[ -r ./debian/changelog ]]; then
vsn=$($DPKG_PARSE --count 0 | awk '/^Version:/ { print $$2 }')
else
local fvsn=$(file_version)
if [[ -n $fvsn ]]; then
vsn=$fvsn
else
# Last-ditch effort - write current datetime to APP_VERSION file
echo $vsn > ./APP_VERSION
fi
fi
echo -n $vsn
}
find_version