1 | #!/bin/sh |
---|
2 | # svnrevision.sh - figure out SVN revision and update buildsvnrevision file, if needed |
---|
3 | # |
---|
4 | # Copyright (c) 2007, Felix L. Winkelmann |
---|
5 | # Copyright (c) 2008-2009, The Chicken Team |
---|
6 | # All rights reserved. |
---|
7 | # |
---|
8 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following |
---|
9 | # conditions are met: |
---|
10 | # |
---|
11 | # Redistributions of source code must retain the above copyright notice, this list of conditions and the following |
---|
12 | # disclaimer. |
---|
13 | # Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following |
---|
14 | # disclaimer in the documentation and/or other materials provided with the distribution. |
---|
15 | # Neither the name of the author nor the names of its contributors may be used to endorse or promote |
---|
16 | # products derived from this software without specific prior written permission. |
---|
17 | # |
---|
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
---|
19 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
20 | # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR |
---|
21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
22 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
---|
23 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
25 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
26 | # POSSIBILITY OF SUCH DAMAGE. |
---|
27 | |
---|
28 | |
---|
29 | LANG="C" |
---|
30 | |
---|
31 | if test -d ".svn" ; |
---|
32 | then |
---|
33 | if test -x "`which svn`" ; |
---|
34 | then |
---|
35 | rev="`svn info | sed -n -e 's/Revision: \([0-9]*\)/\1/p'`" |
---|
36 | else |
---|
37 | rev="`cat .svn/entries | sed -n -e '4 s/^\([0-9]*\)$/\1/p'`" |
---|
38 | fi |
---|
39 | else |
---|
40 | rev="0" |
---|
41 | fi |
---|
42 | |
---|
43 | if test -e "buildsvnrevision" ; |
---|
44 | then |
---|
45 | if test "`cat buildsvnrevision`" \!= "${rev}" ; |
---|
46 | then |
---|
47 | echo "${rev}" > buildsvnrevision |
---|
48 | fi |
---|
49 | else |
---|
50 | echo "${rev}" > buildsvnrevision |
---|
51 | fi |
---|