forked from aabc/ipt-netflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·35 lines (30 loc) · 928 Bytes
/
version.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
#!/bin/sh
# This script determines actual module version.
PATH=$PATH:/usr/local/bin:/usr/bin:/bin
# Base version from the source.
MVERSION=`sed -n 's/^#define.*IPT_NETFLOW_VERSION.*"\(.*\)".*/\1/p' ipt_NETFLOW.c`
# GITVERSION overrides base version.
if [ -e version.h ] && grep -q GITVERSION version.h; then
MVERSION=`sed -n 's/#define GITVERSION "\(.*\)".*/\1/p' version.h`
fi
# git describe overrides version from the source.
if [ -d .git ] && which git >/dev/null 2>&1; then \
GVERSION=`git describe --dirty 2>/dev/null`
if [ "$GVERSION" ]; then
MVERSION=${GVERSION#v}
fi
else
GVERSION=
fi
if [ "$1" = --define ]; then
# called from Makefile to create version.h
# which should contain GITVERSION or be empty.
if [ "$GVERSION" ]; then
echo "#define GITVERSION \"$MVERSION\""
else
echo "/* placeholder, because kernel doesn't like empty files */"
fi
else
# normal run
echo $MVERSION
fi