File: make_version.sh

package info (click to toggle)
skiboot 5.3.3-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 13,280 kB
  • ctags: 13,840
  • sloc: ansic: 77,199; asm: 1,002; sh: 997; cpp: 894; tcl: 408; makefile: 325; python: 166; pascal: 65
file content (60 lines) | stat: -rwxr-xr-x 1,049 bytes parent folder | download
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
54
55
56
57
58
59
60
#!/bin/bash

usage() {
	echo "$0 [ prefix ]"
	echo -e "\t Optionally specify a prefix other than 'skiboot'"
	echo
}

if [ "$1" = "-h" -o "$1" = "--help" ] ;
then
	usage
	exit 1;
fi

if test -e .git || git rev-parse --is-inside-work-tree > /dev/null 2>&1;
then
	version=`git describe --exact-match 2>/dev/null`
	if [ -z "$version" ];
	then
		version=`git describe 2>/dev/null`
	fi
	if [ -z "$version" ];
	then
		version=`git rev-parse --verify --short HEAD 2>/dev/null`
	fi
	if [ ! -z "$EXTRA_VERSION" ];
	then
		version="$version-$EXTRA_VERSION"
	fi
	if git diff-index --name-only HEAD |grep -qv '.git';
	then
		if [ ! -z "$USER" ];
		then
			version="$version-$USER"
		fi
		version="$version-dirty"
		diffsha=`git diff|sha1sum`
		diffsha=`cut -c-7 <<< "$diffsha"`
		version="$version-$diffsha"
	fi

	if [ $# -eq 1 ];
	then
		version=`echo $version | sed s/skiboot/$1/`
	fi

	echo $version
else
	if [ ! -z "$SKIBOOT_VERSION" ];
	then
		echo $SKIBOOT_VERSION
	else
		if [ ! -z "`cat .version`" ];
		then
			cat .version
		else
			exit 1;
		fi
	fi
fi