File: get_svn_revision.sh

package info (click to toggle)
smtube 18.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,384 kB
  • sloc: cpp: 3,547; makefile: 216; sh: 21
file content (21 lines) | stat: -rwxr-xr-x 887 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

# This file is taken from the MPlayer sources, and adapted a little bit.
# It gets the SVN revision number and then saves it in two files:
# src/svn_revision.h and svn_revision

test "$1" && extra="-$1"

svn_revision=`LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2`
test $svn_revision || svn_revision=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2`
test $svn_revision || svn_revision=`cd "$1" && sed -n -e '/^dir$/{n;p;q}' .svn/entries 2>/dev/null`
test $svn_revision || svn_revision=0UNKNOWN

NEW_REVISION="#define SVN_REVISION \"SVN-r${svn_revision}${extra}\""
OLD_REVISION=`cat src/svn_revision.h 2> /dev/null`

# Update version.h only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
    echo "$NEW_REVISION" > src/svn_revision.h
    echo "SVN-r${svn_revision}${extra}" > svn_revision
fi