-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathverextr.sh
54 lines (38 loc) · 1.24 KB
/
verextr.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
49
50
51
52
53
#! /bin/sh
#stringextr: | sed -n -e 's/^[^"]*"\([^"]*\)".*$/\1/p'`
if test "x$1" = x-g; then mode=gen; shift; fi
if test "x$1" = x-j; then shift; juicy=$1; shift; fi
i=$1; shift; set - `echo $i | tr , " "` $*
if test -r $2; then
gen=`grep " GENERATION " $2 | sed -n -e 's/^[^0-9]*\([0-9]*\)[^0-9]*$/\1/p'`
if test "x$gen" = x; then gen=1; else gen=`expr $gen + 1`; fi
else
gen=1
fi
ver=`head -25 $1 | sed -n -e 's/^\* \([^ ]*\) .*$/\1/p' | head -1`
if test "x$ver" = x; then ver=UNKNOWN; fi
creat=`date +%a\ %b\ %d\ %Y\ %X\ %Z`
line=`head -25 ${juicy:-$1} | grep '^= History ==' | head -1`
fruit=`echo "$line" | sed -n -e 's/^[^#]*#\([^#]*\)#$/\1/p' | head -1`
vend=`echo "$line" | sed -n -e 's/^=[^=]*=[=]*[ ]*\([^ ]*\)[ ]*.*$/\1/p' | head -1`
if grep HYBRID /etc/redhat-release >/dev/null 2>&1; then
tropic=define
echo "version $ver $fruit #$gen by $vend at $creat"
else
tropic=undef
echo "version $ver GENERIC #$gen by $vend at $creat"
fi
if test x$mode != xgen; then exit 0; fi
cat >${3:-$2} <<EOF
/*
* This file was generated by verextr.sh. Any changes made will go away.
*/
#ifndef VERSION_H
#define VERSION_H
#define VERSION "$ver"
#define BUILDDATE "$creat"
#define GENERATION $gen
#define FRUIT "$fruit"
#$tropic $fruit
#endif
EOF