]> jfr.im git - irc/evilnet/znc.git/blame - version.sh
Initial commit for evilnet modifications to znc 1.6.2
[irc/evilnet/znc.git] / version.sh
CommitLineData
12d9aee5
US
1#!/bin/sh
2
ce1543c5 3# When changing this file, remember also about nightlies (make-tarball.sh)
bbde9ab4 4
58a34fa5
US
5# Get the path to the source directory
6GIT_DIR=`dirname $0`
12d9aee5 7
3a7dc7aa
US
8# Our argument should be the path to git
9GIT="$1"
12d9aee5
US
10if [ "x$GIT" = "x" ]
11then
58a34fa5
US
12 EXTRA=""
13else
ce1543c5 14 GIT_HERE="${GIT}"
58a34fa5 15 GIT="${GIT} --git-dir=${GIT_DIR}/.git"
12d9aee5 16
58a34fa5
US
17 # Figure out the information we need
18 LATEST_TAG=`${GIT} describe --abbrev=0 HEAD`
19 COMMITS_SINCE=`${GIT} log --format=oneline ${LATEST_TAG}..HEAD | wc -l`
8c46fa84
AS
20 # Explicitly make it a number: on openbsd wc -l returns " 42" instead of "42"
21 let COMMITS_SINCE=COMMITS_SINCE
58a34fa5 22 SHORT_ID=`${GIT} rev-parse --short HEAD`
12d9aee5 23
58a34fa5
US
24 if [ "x$COMMITS_SINCE" = "x0" ]
25 then
10b48908
AS
26 if [ "x$LATEST_TAG" = "x" ]
27 then
28 if [ "x$SHORT_ID" = "x" ]
29 then
30 EXTRA=""
31 else
32 EXTRA="-git-${SHORT_ID}"
33 fi
34 else
35 # If this commit is tagged, don't print anything
36 # (the assumption here is: this is a release)
37 EXTRA=""
38 fi
58a34fa5
US
39 else
40 EXTRA="-git-${COMMITS_SINCE}-${SHORT_ID}"
41 fi
ce1543c5
AS
42
43 if [ 1 = `cd ${GIT_DIR}; ${GIT_HERE} status --ignore-submodules=dirty --porcelain -- third_party/Csocket | wc -l` ]
44 then
45 # Makefile redirects all errors from this script into /dev/null, but this messages actually needs to be shown
46 # So put it to 3, and then Makefile redirects 3 to stderr
47 echo "Warning: Csocket submodule looks outdated. Run: git submodule update --init --recursive" 1>&3
48 EXTRA="${EXTRA}-frankenznc"
49 fi
58a34fa5
US
50fi
51
52# Generate output file, if any
3a7dc7aa 53if [ "x$WRITE_OUTPUT" = "xyes" ]
12d9aee5 54then
3a7dc7aa 55 echo '#include <znc/version.h>' > src/version.cpp
baa798ce 56 echo "const char* ZNC_VERSION_EXTRA = VERSION_EXTRA \"$EXTRA\";" >> src/version.cpp
12d9aee5 57fi
58a34fa5
US
58
59echo "$EXTRA"