summaryrefslogtreecommitdiff
blob: 4842e68e99e7c44f49350641947fa14be442525d (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/check-kernel.eclass,v 1.4 2004/08/28 03:24:15 vapier Exp $

# Author: Martin Schlemmer <azarah@gentoo.org>
# Eclass'd by: Seemant Kulleen <seemant@gentoo.org>
#
# The check-kernel eclass is designed to detect the kernel sources and
# report info on the versions

ECLASS=check-kernel
INHERITED="${INHERITED} ${ECLASS}"

EXPORT_FUNCTIONS check_version_h get_KV_info \
	is_2_4_kernel is_2_5_kernel is_2_6_kernel

DEPEND="sys-apps/gawk"

check_version_h() {
	if [ ! -f "${ROOT}/usr/src/linux/include/linux/version.h" ]
	then
		eerror "Please verify that your /usr/src/linux symlink is pointing"
		eerror "to your current kernel sources, and that you did run:"
		eerror
		eerror "  # make dep"
		eerror
		eerror "(${ROOT}/usr/src/linux/include/linux/version.h does not exist)"
		die "/usr/src/linux symlink not setup!"
	fi
}

get_KV_info() {
	check_version_h

	# Get the kernel version of sources in /usr/src/linux ...
	export KV_full="$(awk '/UTS_RELEASE/ { gsub("\"", "", $3); print $3 }' \
		"${ROOT}/usr/src/linux/include/linux/version.h")"
	export KV_major="$(echo "${KV_full}" | cut -d. -f1)"
	export KV_minor="$(echo "${KV_full}" | cut -d. -f2)"
	export KV_micro="$(echo "${KV_full}" | cut -d. -f3 | sed -e 's:[^0-9].*::')"
}

is_2_4_kernel() {
	get_KV_info
	
	if [ "${KV_major}" -eq 2 -a "${KV_minor}" -eq 4 ]
	then
		return 0
	else
		return 1
	fi
}

is_2_5_kernel() {
	get_KV_info
	
	if [ "${KV_major}" -eq 2 -a "${KV_minor}" -eq 5 ]
	then
		return 0
	else
		return 1
	fi
}

is_2_6_kernel() {
	get_KV_info

	if [ "${KV_major}" -eq 2 -a "${KV_minor}" -eq 6 ]
	then
		return 0
	else
		return 1
	fi
}

kernel_supports_modules() {
	grep '^CONFIG_MODULES=y$' ${ROOT}/usr/src/linux/include/linux/autoconf.h >& /dev/null
}