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