-
Notifications
You must be signed in to change notification settings - Fork 1
/
rcsrev
executable file
·55 lines (48 loc) · 1.34 KB
/
rcsrev
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#/bin/sh
topdir=`dirname $0`/..
extract_revision()
{
revstr=$(svn info $1 | grep "^Last Changed Rev: ")
if [ -z "$revstr" ]; then
revstr=$(svn info $1 | grep "^Revision: ")
fi
echo $revstr | sed -e s/^[^0-9]*//
}
compute_rel_rev()
{
rev_offset=`cat $topdir/include/csver.h.template | grep "//CS_RCSREV_OFFSET" | sed -e "s/[^0-9]*//"`
base_rev=`extract_revision $topdir/include/csver.h.template`
checkout_rev=`extract_revision $topdir`
echo $(($checkout_rev-$base_rev+$rev_offset))
}
update_header()
{
rev_offset=`cat $topdir/include/csver.h.template | grep "//CS_RCSREV_OFFSET" | sed -e "s/[^0-9]*//"`
csver_rev=`extract_revision $topdir/include/csver.h`
checkout_rev=`extract_revision $topdir`
if [ $checkout_rev -gt $csver_rev ] ; then
base_rev=`extract_revision $topdir/include/csver.h.template`
rel_rev=$(($checkout_rev-$base_rev+$rev_offset))
echo "/* ATTENTION: This file is generated from csver.h.template," > $topdir/include/csver.h
echo " make changes _there_ instead */" >> $topdir/include/csver.h
cat $topdir/include/csver.h.template | sed -e "s/@CS_VERSION_RCSREV@/$rel_rev/" >> $topdir/include/csver.h
fi
}
print_help()
{
echo "Syntax:"
echo " $0 [print|update_header]"
}
action=$1
case $action in
print)
compute_rel_rev
;;
update_header)
update_header
;;
*)
print_help
exit 1
;;
esac