/[gentoo-x86]/eclass/linux-mod.eclass
Gentoo

Contents of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Thu Nov 25 19:47:18 2004 UTC (9 years, 9 months ago) by johnm
Branch: MAIN
Changes since 1.1: +1 -4 lines
Fixing permissions

1 johnm 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 johnm 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.1 2004/11/24 16:36:38 johnm Exp $
4 johnm 1.1
5     # This eclass provides functions for compiling external kernel modules
6     # from source.
7    
8     inherit linux-info
9     ECLASS=linux-mod
10     INHERITED="$INHERITED $ECLASS"
11     EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile
12    
13     DESCRIPTION="Based on the $ECLASS eclass"
14     SLOT=0
15     DEPEND="virtual/linux-sources
16     sys-apps/sed"
17    
18    
19     # This eclass is designed to help ease the installation of external kernel
20     # modules into the kernel tree.
21    
22     # eclass utilities
23     # ----------------------------------
24    
25     use_m() {
26     # if we haven't determined the version yet, we need too.
27     get_version;
28    
29     # if the kernel version is greater than 2.6.6 then we should use
30     # M= instead of SUBDIR=
31     [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
32     return 0 || return 1
33     }
34    
35     convert_to_m() {
36     [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument"
37     if use_m
38     then
39     ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIR="
40     sed -i 's:SUBDIRS=:M=:g' ${1}
41     eend $?
42     fi
43     }
44    
45     update_depmod() {
46     # if we haven't determined the version yet, we need too.
47     get_version;
48    
49     ebegin "Updating module dependencies for ${KV_FULL}"
50     if [ -r ${KV_DIR}/System.map ]
51     then
52     depmod -ae -F ${KV_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
53     else
54     ewarn
55     ewarn "${KV_DIR}/System.map not found."
56     ewarn "You must manually update the kernel module dependencies using depmod."
57     ewarn
58     fi
59     eend $?
60     }
61    
62     set_kvobj() {
63     if kernel_is 2 6
64     then
65     KV_OBJ="ko"
66     else
67     KV_OBJ="o"
68     fi
69     einfo "Using KV_OBJ=${KV_OBJ}"
70     }
71    
72     display_postinst() {
73     # if we haven't determined the version yet, we need too.
74     get_version;
75    
76     local modulename moduledir sourcedir module_temp file i
77    
78     file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}
79     file=${file/\/\///}
80    
81     einfo "If you would like to load this module automatically upon boot"
82     einfo "please type the following as root:"
83     for i in ${MODULE_NAMES}
84     do
85     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
86     modulename="${i/(*/}"
87     moduledir="${module_temp/:*/}"
88     moduledir="${moduledir:-misc}"
89     sourcedir="${module_temp/*:/}"
90     sourcedir="${sourcedir:-${S}}"
91    
92     einfo " # echo \"${modulename}\" >> ${file}"
93     done
94     echo
95     }
96    
97     # default ebuild functions
98     # --------------------------------
99    
100     linux-mod_pkg_setup() {
101     get_version;
102     check_kernel_built
103     check_modules_supported;
104     set_kvobj;
105     }
106    
107     linux-mod_src_compile() {
108     local modulename moduledir sourcedir module_temp xarch i
109     xarch="${ARCH}"
110     unset ARCH
111    
112     for i in ${MODULE_NAMES}
113     do
114     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
115     modulename="${i/(*/}"
116     moduledir="${module_temp/:*/}"
117     moduledir="${moduledir:-misc}"
118     sourcedir="${module_temp/*:/}"
119     sourcedir="${sourcedir:-${S}}"
120    
121     einfo "Preparing ${modulename} module"
122     cd ${sourcedir}
123     make clean
124     make ${BUILD_PARAMS} module
125     done
126     ARCH="${xarch}"
127     }
128    
129     linux-mod_src_install() {
130     local modulename moduledir sourcedir module_temp i
131    
132     for i in "${MODULE_NAMES}"
133     do
134     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
135     modulename="${i/(*/}"
136     moduledir="${module_temp/:*/}"
137     moduledir="${moduledir:-misc}"
138     sourcedir="${module_temp/*:/}"
139     sourcedir="${sourcedir:-${S}}"
140    
141     einfo "Installing ${modulename} module"
142     cd ${sourcedir}
143     insinto /lib/modules/${KV_FULL}/${moduledir}
144     doins ${modulename}.${KV_OBJ}
145     done
146     }
147    
148     linux-mod_pkg_postinst() {
149     update_depmod;
150     display_postinst;
151     }

  ViewVC Help
Powered by ViewVC 1.1.20