File: mk_VERSION

package info (click to toggle)
nagios-plugin-check-multi 0.26-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,172 kB
  • sloc: perl: 2,296; makefile: 415; sh: 239
file content (37 lines) | stat: -rwxr-xr-x 1,146 bytes parent folder | download | duplicates (7)
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
#!/bin/sh
#
# pre-commit script to create version info into CM_VERSION
# $ ln -s mk_VERSION .git/hooks/pre-commit
# 
# 1. call: 
#    - create version file CM_VERSION
#    - create flag file 
#    - exit with RC1 (error) -> return to command line
#
# 2. call:
#    - remove flag file
#    - exit with RC0 (OK) -> commit
#
if [ ! -f CM_VERSION.version_is_updated ]; then

	# the major version will be changed by 'make version'
	MAJOR_VERSION=`awk -F\_ '{print $3}' CM_VERSION`

	# the minor version is just to be increased by one
	OLD_MINOR_VERSION=`awk -F\_ '{print $4}' CM_VERSION`
	NEW_MINOR_VERSION=`expr $OLD_MINOR_VERSION + 1`

	# output
	DATESTRING=`date +%Y-%m-%d-%H:%M`
	echo "check_multi_${MAJOR_VERSION}_${NEW_MINOR_VERSION}_${DATESTRING}" > CM_VERSION
	echo "Created new version file CM_VERSION with check_multi_${MAJOR_VERSION}_${NEW_MINOR_VERSION}_${DATESTRING}"
	echo "-> Now run commit again to check it in..."
	touch CM_VERSION.version_is_updated

	#--- exit with error first time (no commit is actually done)
	exit 1
else 
	rm CM_VERSION.version_is_updated
	#--- exit with OK the second time -> git commit is done now
	exit 0
fi