File: versionString.sh

package info (click to toggle)
libmlocale 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,412 kB
  • sloc: cpp: 29,597; sh: 631; perl: 350; python: 220; makefile: 26; sed: 7
file content (23 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
set -e

cd $1

SHA1="unknown"
# check if we are working with a git checkout
if [ -e .git/logs/HEAD ]; then
  # if git is not installed extract sha1 manually
  if $(type -P git > /dev/null); then
    SHA1=$(git log --pretty=format:%H -n 1)
  else
    SHA1=$(awk 'END { print $2 }' .git/logs/HEAD)
  fi
fi

# extract debian version number
DEBIAN_VERSION="unknown"
if $(type -P dpkg-parsechangelog > /dev/null); then \
  DEBIAN_VERSION=$(dpkg-parsechangelog | grep '^Version: ' | sed 's/^Version: \(.*\)/\1/')
fi

echo "Git revision: ${SHA1} Debian Version: ${DEBIAN_VERSION}"