forked from rickyrockrat/parcellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scmversion.sh
executable file
·48 lines (48 loc) · 1018 Bytes
/
scmversion.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
42
43
44
45
46
47
48
#!/bin/sh
LOG="scmversion.log"
TMP=_scmversion_test
echo "$0">$LOG
if [ -n "$1" ]; then
echo "Immediate Mode">>$LOG
IM=1
else
IM=0
fi
which svnversion > $TMP
which git >> $TMP
if [ $? -ne 0 ] ;then
echo "svn"
else
CWD=$(pwd)
#path supplied?
D=$(dirname $0)
if [ "." = "$D" ]; then
PPATH="$CWD" #no
else
PPATH="$D"
fi
cd "$PPATH"
# are we lndired?
LINK=$(readlink configure.ac)
if [ -n "$LINK" ]; then #link
FULLPATH=$(dirname "$LINK")
else
FULLPATH="$CWD"
fi
cd "$FULLPATH"
echo "Using $FULLPATH">>"$CWD/$LOG"
if [ -e .svn ]; then
SVER=$(svn info .|grep -i "revision"|sed 's!.*: !!'|tr -d ' ')
SVER="svn-$SVER"
elif [ -e .git ]; then
SVER="git-$(git log -n1 --pretty=format:%h)"
fi
echo -n "$SVER"
cd $CWD
if [ "$IM" = "1" ]; then
sed -i "s#\(.*VERSION \).*#\1\"$SVER\"#" config.h
echo "Make sure to do scm update in source scm to update local scm info, then run again."
rm src/main.o
echo "Removed src/main.o. Recompile."
fi
fi