forked from azuwis/xreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Revision.sh
executable file
·41 lines (30 loc) · 1.49 KB
/
Revision.sh
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
# $Id: Revision.sh 74 2007-10-20 10:46:39Z soarchin $
# Copyright 2007 aeolusc
# This file is part of eReader2.
# eReader2 is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# eReader2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#!/bin/sh
test "$1" && srcdir="$1/"
svn_revision=`LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2`
test $svn_revision || svn_revision=`grep revision ${srcdir}.svn/entries 2>/dev/null | cut -d '"' -f2`
test $svn_revision || svn_revision=`sed -n -e '/^dir$/{n;p;q;}' ${srcdir}.svn/entries 2>/dev/null`
test $svn_revision && revision=$svn_revision
# check for git short hash
if ! test $svn_revision; then
revision=`cd "${srcdir}" && git log -1 --pretty=format:%h`
test $revision && revision=git-$revision
fi
NEW_REVISION="#define REVISION \"${revision}\""
OLD_REVISION=`cat ./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" > ./Revision.h
fi