Annotation of /trunk/include/kernel.sminc
Parent Directory | Revision Log
Revision 20887 -
(hide annotations)
(download)
Wed Feb 12 09:36:45 2014 UTC (10 years, 8 months ago) by niro
File size: 14681 byte(s)
Wed Feb 12 09:36:45 2014 UTC (10 years, 8 months ago) by niro
File size: 14681 byte(s)
-using xz tarball as default and included UP2DATE uris
1 | niro | 9311 | # kernel global smage functions |
2 | # $Id$ | ||
3 | |||
4 | # needed extra vars: | ||
5 | niro | 11369 | # ${KERNEL_TYPE}: needed, 'sources', 'headers' or 'image' |
6 | # ${BRANCH}: needed, style branch of the kernel | ||
7 | # ${KERNEL_CONFIG}: optional, needed if you want to override the default | ||
8 | # searchpath ${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD} | ||
9 | niro | 9311 | # |
10 | niro | 11369 | # ${PSUBVER}: optional, only needed for 2.6.x.x naming scheme |
11 | # ${EXTRAVERSION}: optinal, extra version for the kernel name | ||
12 | # default setting is ${PSUBVER}-${BRANCH}-${PBUILD} | ||
13 | # ${KERNEL_IMAGE_PATH}: override the default KERNEL_IMAGE_PATH (to build xen images for e.g.) | ||
14 | # ${COMPRESS_MODULES}: compresses the kernel modules with given compressor (gzip|bzip2|xz) | ||
15 | # ${LINUX_FIRMWARE}: remove included firmware bits if requested | ||
16 | # set the version here like USE_LINUX_FIRMARE="20110605" | ||
17 | # version "internal" keeps the bits too | ||
18 | # | ||
19 | niro | 18719 | # ${INCLUDE_KERNELVERSION_FILE}: creates a /boot/kernelversion file (deprecated) |
20 | niro | 18720 | # ${USE_KERNEL_SYMLINKS}: creates symlinks to unversioned kernel image files |
21 | # - kernel-x.x.x.x -> /boot/vmlinuz | ||
22 | # - initrd-x.x.x.x -> /boot/initrd | ||
23 | # - config-x.x.x.x -> /boot/config | ||
24 | # - System.map-x.x.x.x -> /boot/System.map | ||
25 | niro | 9311 | |
26 | sminclude mtools | ||
27 | |||
28 | # remove me when all distris support this: | ||
29 | if [[ ${USE_KERNEL_ARCH_EXTENSION} = true ]] | ||
30 | then | ||
31 | KERNEL_ARCH_EXTENSION="-${ARCH}" | ||
32 | else | ||
33 | KERNEL_ARCH_EXTENSION="" | ||
34 | fi | ||
35 | |||
36 | niro | 9466 | if [[ ! -z ${COMPRESS_MODULES} ]] |
37 | then | ||
38 | case ${COMPRESS_MODULES} in | ||
39 | gzip) | ||
40 | COMPRESS_MODULES_CMD="gzip -9v" | ||
41 | SDEPEND="${SDEPEND} | ||
42 | >= app-arch/gzip-1.4" | ||
43 | ;; | ||
44 | bzip2) | ||
45 | COMPRESS_MODULES_CMD="bzip2 -9v" | ||
46 | SDEPEND="${SDEPEND} | ||
47 | >= app-arch/bzip2-1.0.6" | ||
48 | ;; | ||
49 | xz) | ||
50 | COMPRESS_MODULES_CMD="xz -9v" | ||
51 | SDEPEND="${SDEPEND} | ||
52 | >= app-arch/xz-5" | ||
53 | ;; | ||
54 | none) | ||
55 | echo "Disabled compressed kernel-modules!" | ||
56 | COMPRESS_MODULES_CMD="" | ||
57 | ;; | ||
58 | *) die "Unkown compression format '${COMPRESS_MODULES}'" ;; | ||
59 | esac | ||
60 | fi | ||
61 | |||
62 | niro | 9311 | # some sane defaults |
63 | niro | 9863 | : ${PCAT="sys-kernel"} |
64 | niro | 9311 | : ${HOMEPAGE="http://magellan-linux.de/"} |
65 | niro | 9743 | : ${TARBALLPVER="${PVER}"} |
66 | niro | 20887 | : ${SRCFILE="linux-${TARBALLPVER}.tar.xz"} |
67 | niro | 9311 | : ${SRCDIR="${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}"} |
68 | |||
69 | niro | 9740 | if [[ -z ${SRC_URI[*]} ]] |
70 | then | ||
71 | SRC_URI=( | ||
72 | http://www.kernel.org/pub/linux/kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} | ||
73 | http://ftp.uni-erlangen.de/pub/Linux/MIRROR.kernel/v$(echo ${PVER} | cut -d. -f1).x/${SRCFILE} | ||
74 | mirror://kernel-${BRANCH}/${SRCFILE} | ||
75 | ) | ||
76 | case ${KERNEL_TYPE} in | ||
77 | image|sources) | ||
78 | SRC_URI=( | ||
79 | ${SRC_URI[*]} | ||
80 | mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-i686 | ||
81 | mirror://kernel-${BRANCH}/config-${PVER}-${BRANCH}-${PBUILD}-x86_64 | ||
82 | ) | ||
83 | ;; | ||
84 | esac | ||
85 | fi | ||
86 | niro | 9311 | |
87 | niro | 20887 | case ${PNAME} in |
88 | *-lts) _upparam="longterm" ;; | ||
89 | *) _upparam="stable" ;; | ||
90 | esac | ||
91 | |||
92 | UP2DATE="updatecmd http://www.kernel.org/ | grep -A1 -i '${_upparam}:' | sed 's/.*:\ \([0-9]\.[0-9].*\)\ [0-9].*/\1/;q'" | ||
93 | |||
94 | niro | 9311 | case ${KERNEL_TYPE} in |
95 | image) | ||
96 | : ${PROVIDE="virtual/kernel"} | ||
97 | niro | 10194 | : ${DEPEND=">= virtual/module-tools |
98 | niro | 9311 | >= sys-fs/udev-115 |
99 | niro | 10194 | >= virtual/initramfs-tools |
100 | niro | 9311 | >= virtual/initscripts"} |
101 | niro | 11369 | if [[ ! -z ${LINUX_FIRMWARE} ]] && [[ ${LINUX_FIRMWARE} != internal ]] |
102 | then | ||
103 | DEPEND="${DEPEND} | ||
104 | >= sys-kernel/linux-firmware-${LINUX_FIRMWARE}" | ||
105 | fi | ||
106 | niro | 18718 | SDEPEND="${SDEPEND} |
107 | >= sys-dev/bc-1.06" | ||
108 | niro | 9745 | : ${DESCRIPTION="Kernel image of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel branch."} |
109 | niro | 9311 | ;; |
110 | |||
111 | sources) | ||
112 | : ${PROVIDE="virtual/kernel-sources"} | ||
113 | niro | 9745 | : ${DESCRIPTION="Kernel sources of the '${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}' kernel branch."} |
114 | niro | 9311 | ;; |
115 | |||
116 | headers) | ||
117 | : ${PROVIDE="virtual/kernel-headers"} | ||
118 | : ${DESCRIPTION="Sanitized kernel headers for libc."} | ||
119 | ;; | ||
120 | esac | ||
121 | |||
122 | EXTRAVERSION="${PSUBVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}" | ||
123 | KERNEL_CONFIG="${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD}-${ARCH}" | ||
124 | |||
125 | # special vars for mage file only | ||
126 | KPVER="${PVER}" | ||
127 | KPBUILD="${PBUILD}" | ||
128 | KBRANCH="${BRANCH}" | ||
129 | niro | 18720 | SPECIAL_VARS="${SPECIAL_VARS} KPVER KPBUILD KBRANCH USE_KERNEL_SYMLINKS" |
130 | niro | 9311 | |
131 | niro | 18717 | # dummy function to apply kernel patches |
132 | kernel_apply_patches() | ||
133 | { | ||
134 | return 0 | ||
135 | } | ||
136 | |||
137 | niro | 9311 | kernel_src_prepare() |
138 | { | ||
139 | munpack ${SRCFILE} || die | ||
140 | niro | 9743 | mv ${BUILDDIR}/linux-${TARBALLPVER} ${SRCDIR} || die |
141 | niro | 9311 | |
142 | # fix permissions | ||
143 | chown -R 0:0 ${SRCDIR} || die | ||
144 | chmod -R a+r-w+X,u+w ${SRCDIR} || die | ||
145 | |||
146 | cd ${SRCDIR} | ||
147 | niro | 18717 | kernel_apply_patches || die |
148 | niro | 9311 | |
149 | # fixes INSTALL_PATH to /boot and EXTRAVERSION | ||
150 | sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \ | ||
151 | -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile || die | ||
152 | niro | 9463 | |
153 | # fix sublevel version with 3.x kernels and higher | ||
154 | local kver=$(echo ${PVER} | sed "s:\.::g") | ||
155 | if [[ ${PVER%%.*} -gt 2 ]] | ||
156 | then | ||
157 | local sublevel="$(echo ${PVER} | cut -d. -f3)" | ||
158 | niro | 13438 | sed -i "s:^\(SUBLEVEL =\).*:\1 ${sublevel}:" Makefile || die |
159 | niro | 9463 | fi |
160 | niro | 9311 | } |
161 | |||
162 | kernel_src_compile() | ||
163 | { | ||
164 | cd ${SRCDIR} | ||
165 | |||
166 | make mrproper || die | ||
167 | |||
168 | if [[ ${KERNEL_TYPE} = sources ]] || [[ ${KERNEL_TYPE} = image ]] | ||
169 | then | ||
170 | # inject our kernel config | ||
171 | cp ${KERNEL_CONFIG} ${SRCDIR}/.config || die | ||
172 | make ARCH=${ARCH/i*86/x86} oldconfig || die | ||
173 | fi | ||
174 | |||
175 | case ${KERNEL_TYPE} in | ||
176 | image) | ||
177 | mmake ARCH=${ARCH/i*86/x86} || die | ||
178 | ;; | ||
179 | |||
180 | headers) | ||
181 | make ARCH=${ARCH/i*86/x86} headers_check || die | ||
182 | ;; | ||
183 | |||
184 | sources) | ||
185 | make clean || die | ||
186 | |||
187 | # needed to compile other programs like iptables | ||
188 | make ARCH=${ARCH/i*86/x86} prepare || die | ||
189 | # needed to cover >=2.6.14 builds | ||
190 | # but deprecated with >=2.6.21, prepare cover all targets there | ||
191 | local kver=$(echo ${PVER} | sed "s:\.::g") | ||
192 | # honor >=3.0.x; add one zero | ||
193 | if [[ ${PVER%%.*} -gt 2 ]] | ||
194 | then | ||
195 | kver="${kver}0" | ||
196 | fi | ||
197 | if [[ ${kver} < 2621 ]] | ||
198 | then | ||
199 | make ARCH=${ARCH/i*86/x86} prepare-all || die | ||
200 | fi | ||
201 | make ARCH=${ARCH/i*86/x86} scripts || die | ||
202 | |||
203 | # at least alsa-drivers needs this one ... | ||
204 | touch include/linux/autoconf.h || die | ||
205 | niro | 20887 | |
206 | # compat symlink for 3.7.x new version.h location until everything is fixed | ||
207 | niro | 9311 | ;; |
208 | esac | ||
209 | } | ||
210 | |||
211 | kernel_image_src_install() | ||
212 | { | ||
213 | cd ${SRCDIR} | ||
214 | |||
215 | # needed directories | ||
216 | minstalldir /boot || die | ||
217 | |||
218 | # install modules | ||
219 | niro | 12741 | make ARCH=${ARCH/i*86/x86} INSTALL_MOD_PATH=${BINDIR}/usr modules_install || die |
220 | niro | 9311 | |
221 | # install kernelimage | ||
222 | if [[ -z ${KERNEL_IMAGE_PATH} ]] | ||
223 | then | ||
224 | local my_arch="${ARCH}" | ||
225 | [[ ${my_arch} = i*86 ]] && my_arch=i386 | ||
226 | minstallfile arch/${my_arch}/boot/bzImage \ | ||
227 | /boot/kernel-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION} \ | ||
228 | || die | ||
229 | else | ||
230 | minstallfile ${KERNEL_IMAGE_PATH} \ | ||
231 | /boot/kernel-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION} \ | ||
232 | || die | ||
233 | fi | ||
234 | |||
235 | # install System.map | ||
236 | minstallfile System.map \ | ||
237 | /boot/System.map-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION} \ | ||
238 | || die | ||
239 | |||
240 | # install Module.symvers in boot and /usr/src | ||
241 | minstallfile Module.symvers \ | ||
242 | /boot/Module.symvers-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION} \ | ||
243 | || die | ||
244 | minstalldir /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} || die | ||
245 | minstallfile Module.symvers \ | ||
246 | /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} \ | ||
247 | || die | ||
248 | |||
249 | niro | 18719 | if [[ ${INCLUDE_KERNELVERSION_FILE} = true ]] |
250 | then | ||
251 | MCONFIG=/boot/kernelversion | ||
252 | # install kernel description | ||
253 | mclearconfig || die | ||
254 | maddconfig "KRNVER=${BRANCH}-${PVER}-${ARCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}" || die | ||
255 | maddconfig "KRNLIB=${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}" || die | ||
256 | maddconfig "KRNIMG=kernel-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}" || die | ||
257 | maddconfig "KRNINITRD=" || die | ||
258 | fi | ||
259 | niro | 9311 | |
260 | # install kernel-config from srcdir | ||
261 | minstallfile .config \ | ||
262 | /boot/config-${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION} \ | ||
263 | || die | ||
264 | |||
265 | # fix build symlink | ||
266 | niro | 12741 | if [ -L ${BINDIR}/usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/build ] |
267 | niro | 9311 | then |
268 | echo "fixing build symlink" | ||
269 | niro | 12741 | rm ${BINDIR}/usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/build || die |
270 | niro | 9311 | mlink /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} \ |
271 | niro | 12741 | /usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/build \ |
272 | niro | 9311 | || die |
273 | fi | ||
274 | |||
275 | # and fixing source symlink | ||
276 | niro | 12741 | if [ -L ${BINDIR}/usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/source ] |
277 | niro | 9311 | then |
278 | echo "fixing source symlink" | ||
279 | niro | 12741 | rm ${BINDIR}/usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/source || die |
280 | niro | 9311 | mlink /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} \ |
281 | niro | 12741 | /usr/lib/modules/${PVER}-${BRANCH}-${PBUILD}${KERNEL_ARCH_EXTENSION}/source \ |
282 | niro | 9311 | || die |
283 | fi | ||
284 | niro | 9466 | |
285 | # remove firmware bits if $LINUX_FIRMWARE was set | ||
286 | if [[ ! -z ${LINUX_FIRMWARE} ]] && [[ ${LINUX_FIRMWARE} != internal ]] | ||
287 | then | ||
288 | niro | 12741 | if [[ -d ${BINDIR}/usr/lib/firmware ]] |
289 | niro | 9466 | then |
290 | niro | 12741 | rm -rv ${BINDIR}/usr/lib/firmware |
291 | niro | 9466 | fi |
292 | fi | ||
293 | |||
294 | # compress modules if COMPRESS_MODULES_CMD was set | ||
295 | if [[ ! -z ${COMPRESS_MODULES_CMD} ]] | ||
296 | then | ||
297 | # compress all kernel modules | ||
298 | find ${BINDIR} -name \*.ko | xargs ${COMPRESS_MODULES_CMD} || die | ||
299 | fi | ||
300 | niro | 9311 | } |
301 | |||
302 | kernel_headers_src_install() | ||
303 | { | ||
304 | cd ${SRCDIR} | ||
305 | make ARCH=${ARCH/i*86/x86} INSTALL_HDR_PATH=${BINDIR}/usr headers_install || die | ||
306 | niro | 9746 | |
307 | # clean-up unnecessary files | ||
308 | find ${BINDIR} -name .install -or -name ..install.cmd | xargs --no-run-if-empty rm -f | ||
309 | niro | 9311 | } |
310 | |||
311 | kernel_sources_src_install() | ||
312 | { | ||
313 | cd ${BUILDDIR} | ||
314 | |||
315 | echo "Creating linux-${PVER}-${BRANCH}-${PBUILD} sources tarball ... " | ||
316 | tar cvjf ${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 $(basename ${SRCDIR}) || die | ||
317 | |||
318 | echo "Moving linux-${PVER}-${BRANCH}-${PBUILD} tarball to \${BINDIR}/usr/src ... " | ||
319 | minstalldir /usr/src || die | ||
320 | mv ${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 ${BINDIR}/usr/src || die | ||
321 | } | ||
322 | |||
323 | # installs module-sources path/to/SRCDIR to MODDIR/MODNAME | ||
324 | # kernel_external_modules_install path/to/SRCDIR DESTDIRNAME | ||
325 | kernel_external_modules_install() | ||
326 | { | ||
327 | cd ${BUILDDIR} | ||
328 | |||
329 | local modsrc="$1" | ||
330 | local moddest="$2" | ||
331 | local moddir="${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}" | ||
332 | |||
333 | echo "Installing ${modsrc} to ${moddir}/${moddest} ..." | ||
334 | install -d ${moddir} || die | ||
335 | mv ${modsrc} ${moddir}/${moddest} || die | ||
336 | } | ||
337 | |||
338 | kernel_external_modules_tarball() | ||
339 | { | ||
340 | cd ${BUILDDIR} | ||
341 | |||
342 | echo "Creating kernel-modules-${PVER}-${BRANCH}-${PBUILD} sources tarball ... " | ||
343 | tar cvjf ${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 \ | ||
344 | kernel-modules-${PVER}-${BRANCH}-${PBUILD} || die | ||
345 | |||
346 | echo "Moving kernel-modules-${PVER}-${BRANCH}-${PBUILD} tarball to \${BINDIR}/usr/src ... " | ||
347 | minstalldir /usr/src || die | ||
348 | mv ${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 ${BINDIR}/usr/src || die | ||
349 | } | ||
350 | |||
351 | kernel_src_install() | ||
352 | { | ||
353 | case ${KERNEL_TYPE} in | ||
354 | image) | ||
355 | kernel_image_src_install || die | ||
356 | ;; | ||
357 | |||
358 | headers) | ||
359 | kernel_headers_src_install || die | ||
360 | ;; | ||
361 | |||
362 | sources) | ||
363 | kernel_sources_src_install || die | ||
364 | ;; | ||
365 | esac | ||
366 | } | ||
367 | |||
368 | kernel_major_version() | ||
369 | { | ||
370 | local ksrc="$@" | ||
371 | local kv | ||
372 | |||
373 | if [[ -z ${ksrc} ]] | ||
374 | then | ||
375 | kv="$(uname -r|cut -d. -f1-2)" | ||
376 | else | ||
377 | local version | ||
378 | local patchlevel | ||
379 | |||
380 | # get version from makefile | ||
381 | version=$(grep "^VERSION[[:space:]]*=[[:space:]]*[[:digit:]]" ${ksrc}/Makefile | sed "s/^.*=[[:space:]]*\([[:digit:]]\+\)/\1/g") | ||
382 | # get patchlevel from makefile | ||
383 | patchlevel=$(grep "^PATCHLEVEL[[:space:]]*=[[:space:]]*[[:digit:]]" ${ksrc}/Makefile | sed "s/^.*=[[:space:]]*\([[:digit:]]\+\)/\1/g") | ||
384 | # kernelversion | ||
385 | kv="${version}.${patchlevel}" | ||
386 | fi | ||
387 | |||
388 | echo "${kv}" | ||
389 | } | ||
390 | |||
391 | mod_suffix() | ||
392 | { | ||
393 | local ksrc="$@" | ||
394 | local mod_suffix | ||
395 | local kmv | ||
396 | |||
397 | kmv=$(kernel_major_version ${ksrc}) | ||
398 | if [[ ${kmv//.} -ge 26 ]] | ||
399 | then | ||
400 | mod_suffix="ko" | ||
401 | else | ||
402 | mod_suffix="o" | ||
403 | fi | ||
404 | |||
405 | echo ${mod_suffix} | ||
406 | } | ||
407 | |||
408 | kernel_image_preinstall() | ||
409 | { | ||
410 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] | ||
411 | then | ||
412 | mount /boot &> /dev/null | ||
413 | fi | ||
414 | } | ||
415 | |||
416 | kernel_image_preremove() | ||
417 | { | ||
418 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] | ||
419 | then | ||
420 | mount /boot &> /dev/null | ||
421 | |||
422 | # remove old image entry from grub | ||
423 | niro | 13880 | new-kernel-pkg -v --rminitrd --rmmoddep --remove ${KPVER}-${KBRANCH}-${KPBUILD} |
424 | niro | 9311 | fi |
425 | } | ||
426 | |||
427 | kernel_image_postinstall() | ||
428 | { | ||
429 | [ ! -d ${MROOT}/sys ] && install -d ${MROOT}/sys | ||
430 | |||
431 | # fixes a small glitch in <=mage-0.3.6-r15 with symlinks | ||
432 | [ -f ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD} ] && \ | ||
433 | rm ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD} | ||
434 | |||
435 | [ -x ${MROOT}/sbin/depmod ] && | ||
436 | ${MROOT}/sbin/depmod -ae \ | ||
437 | -F /boot/System.map-${KPVER}-${KBRANCH}-${KPBUILD} \ | ||
438 | ${KPVER}-${KBRANCH}-${KPBUILD} | ||
439 | |||
440 | # do not run this if ${MROOT} is set ! | ||
441 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] | ||
442 | then | ||
443 | new-kernel-pkg -v --mkinitrd --make-default --install ${KPVER}-${KBRANCH}-${KPBUILD} | ||
444 | fi | ||
445 | |||
446 | niro | 18720 | if [[ ${USE_KERNEL_SYMLINKS} = true ]] |
447 | then | ||
448 | # symlink actual kernel to /boot/vmlinuz etc... | ||
449 | ln -snf kernel-${KPVER}-${KBRANCH}-${KPBUILD} ${MROOT}/boot/vmlinuz | ||
450 | ln -snf System.map-${KPVER}-${KBRANCH}-${KPBUILD} ${MROOT}/boot/System.map | ||
451 | ln -snf config-${KPVER}-${KBRANCH}-${KPBUILD} ${MROOT}/boot/config | ||
452 | [[ -f ${MROOT}/boot/initrd-${KPVER}-${KBRANCH}-${KPBUILD}.img ]] && | ||
453 | ln -snf initrd-${KPVER}-${KBRANCH}-${KPBUILD}.img ${MROOT}/boot/initrd | ||
454 | fi | ||
455 | niro | 9311 | } |
456 | |||
457 | kernel_sources_postinstall() | ||
458 | { | ||
459 | # check for linux-VERSION/include as the kernel-image installs | ||
460 | # the file Modules.symver in the linux-VERSION directory | ||
461 | niro | 11362 | if mqueryfeature "kernelsrcunpack" && |
462 | [ ! -d ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD}/include ] | ||
463 | niro | 9311 | then |
464 | echo "Unpacking linux-${KPVER}-${KBRANCH}-${KPBUILD} source tarball ... " | ||
465 | tar xvjf ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 -C ${MROOT}/usr/src | ||
466 | fi | ||
467 | |||
468 | niro | 11362 | if mqueryfeature "kernelsrcunpack" && |
469 | [ ! -d ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} ] && | ||
470 | niro | 9311 | [ -f ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 ] |
471 | then | ||
472 | echo "Unpacking kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} source tarball ... " | ||
473 | tar xvjf ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD}.tar.bz2 -C ${MROOT}/usr/src | ||
474 | fi | ||
475 | |||
476 | niro | 11362 | # create linux symlink |
477 | if mqueryfeature "linuxsymlink" | ||
478 | niro | 9311 | then |
479 | echo "Creating linux -> linux-${KPVER}-${KBRANCH}-${KPBUILD} symlink ... " | ||
480 | [ ! -d ${MROOT}/usr/src ] && install ${MROOT}/usr/src | ||
481 | ln -snf ${MROOT}/usr/src/linux-${KPVER}-${KBRANCH}-${KPBUILD} \ | ||
482 | ${MROOT}/usr/src/linux || die | ||
483 | fi | ||
484 | |||
485 | niro | 11362 | # create kernel-modules symlink |
486 | if mqueryfeature "linuxsymlink" && | ||
487 | niro | 9311 | [ -d ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} ] |
488 | then | ||
489 | echo "Creating kernel-modules -> kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} symlink ... " | ||
490 | [ ! -d ${MROOT}/usr/src ] && install ${MROOT}/usr/src | ||
491 | ln -snf ${MROOT}/usr/src/kernel-modules-${KPVER}-${KBRANCH}-${KPBUILD} \ | ||
492 | ${MROOT}/usr/src/kernel-modules || die | ||
493 | fi | ||
494 | } | ||
495 | |||
496 | export_inherits kernel src_prepare src_compile src_install | ||
497 | |||
498 | # export pre/postinstall functions depending on KERNEL_TYPE | ||
499 | case ${KERNEL_TYPE} in | ||
500 | image) | ||
501 | niro | 18721 | export_inherits kernel_image preinstall preremove postinstall |
502 | SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} kernel_image_preinstall kernel_image_preremove kernel_image_postinstall" | ||
503 | niro | 9311 | ;; |
504 | sources) | ||
505 | export_inherits kernel_sources postinstall | ||
506 | SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} kernel_sources_postinstall" | ||
507 | ;; | ||
508 | esac |