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