aboutsummaryrefslogtreecommitdiffstats
path: root/detect_distro
blob: 12251fd646f7a1e2428dbe89df66e8e5d45ddbe5 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash

function detect_distro
{

	HOST=`grep 'openSUSE\|Wind River\|Fedora\| SUSE\|Red Hat\|Ubuntu' /etc/issue| sed 's/.*\(openSUSE\|Wind River\|Fedora\| SUSE\|Red Hat\|Ubuntu\).*/\1/'`

	if [ -z "$HOST" ];then
		echo unable to determine host type
		exit 1
	fi

	TEMP=`mktemp`

	if [ "$HOST" = "Ubuntu" ]; then
		NEWEST=10.04
		VER=`cat /etc/issue|head -n1 | awk '{print $2}'`
		dpkg-query -l > $TEMP
		if [ $? != 0 ];then
			echo package listing failed
			exit 1
		fi
	elif [ "$HOST" = "Fedora" ]; then
		NEWEST=11
		VER=`cat /etc/issue|head -n1 | awk '{print $3}'`
		HOST="Fedora"
		rpm -qa > $TEMP
		if [ $? != 0 ];then
			echo package listing failed
			exit 1
		fi
	elif [ "$HOST" = "Wind River" ]; then
		HOST="Windriver"
		release_ver=`grep Wind /etc/wrs-release | awk '{print $4}'`
		clib=`grep Wind /etc/wrs-release | awk '{print $5}' | sed -e "s/_.*$//"`

		VER="${release_ver}-${clib}"
	elif [ "$HOST" = "Red Hat" ]; then
		HOST="redhat"
		release_ver=`rpm -q --queryformat "%{VERSION}" redhat-release`
MAJOR="?"
		if [ `echo ${release_ver} | grep 4` ] ; then
			MAJOR="4"
			MINOR=`cat /etc/issue|head -n1 | sed 's/.*\([0-9]\))/\1/'`
		elif [ `echo ${release_ver} | grep 5` ] ; then
			MAJOR="5"
			MINOR=`cat /etc/redhat-release  | sed -e "s/^.*\.//" -e "s/ .*$//"`
		fi
		VER="${MAJOR}.${MINOR}"
	elif [ "$HOST" = " SUSE" ]; then
		NEWEST=11.0
		HOST="SLED"
		VER=`grep SUSE /etc/issue|head -n1 | awk '{print $7}'`
		if [ "$VER" = "10" ];then
			VER=10.2
		fi
		rpm -qa > $TEMP
		if [ $? != 0 ];then
			echo package listing failed
			exit 1
		fi
	elif [ "$HOST" = "openSUSE" ]; then
		NEWEST=11.2
		VER=`grep SUSE /etc/issue|head -n1 | awk '{print $4}'`
		if [ "$VER" = "10" ];then
			VER=10.2
		fi
		rpm -qa > $TEMP
		if [ $? != 0 ];then
			echo package listing failed
			exit 1
		fi
	else
		echo unknown host type -- $HOST
		exit 1
	fi
		
	W=`tail -n1 /proc/kallsyms |awk '{print $1}'|wc -c`
	WIDTH=`echo "($W-1)*4"|bc`

	echo $HOST-$VER-${WIDTH}
}


distro_name=`detect_distro`
echo "${distro_name}"