3 # debirf module: install-kernel
4 # install a kernel package, indicated by the expected environment
8 # DEBIRF_KERNEL_PACKAGE
10 # *** REQUIRED MODULE ***
11 # WARNING: this module is necessary for proper functioning of debirf.
13 # The debirf scripts were written by
14 # Jameson Rollins <jrollins@fifthhorseman.net>
16 # Daniel Kahn Gillmor <dkg-debian.org@fifthhorseman.net>.
18 # They are Copyright 2007, and are all released under the GPL,
21 # clear out old modules if they exist, to avoid confusion
22 rm -rf "$DEBIRF_ROOT/lib/modules"
24 # download/copy in kernel package
25 if [ -z "$DEBIRF_KERNEL_PACKAGE" ] ; then
26 # determine kernel to install. assume arch of build host.
28 # determine kernel arch. need everything after the kernel version
30 if [ -z "$DEBIRF_KERNEL_ARCH" ]; then
31 KARCH=$(uname -r | cut -d- -f3-)
33 KARCH="$DEBIRF_KERNEL_ARCH"
36 # determine the full kernel version from the dependency of the
37 # generic 2.6-ARCH package in the debirf root (since it may be
38 # different than what is installed on the build host)
39 KNAME=$(debirf_exec apt-cache show linux-image-2.6-"$KARCH" | grep '^Depends: ' | sed 's/^Depends: //')
41 # download only the desired kernel package directly into the apt
42 # cache for dpkg extraction
43 debirf_exec sh -c "cd /var/cache/apt/archives/ && aptitude download \"$KNAME\""
45 # install kernel deb if given at command line
46 debirf_exec sh -c "cd /var/cache/apt/archives/ && aptitude download \"$DEBIRF_KERNEL_PACKAGE\""
49 KPKG=$(basename "$DEBIRF_ROOT"/var/cache/apt/archives/linux-image-2.6.*)
51 echo "extracting kernel package $KPKG..."
52 debirf_exec dpkg --extract /var/cache/apt/archives/"$KPKG" /
54 # install the module init tools, since they are needed for depmod
55 debirf_exec apt-get --assume-yes install module-init-tools
57 # depmod to create module list
58 KVERS=$(ls -1 -t "$DEBIRF_ROOT/lib/modules" | head -n1)
59 echo "generating modules.dep..."
60 debirf_exec depmod -a "$KVERS"
62 # extract kernel and debian stock initrd from the build root:
63 mv "$DEBIRF_ROOT"/boot/vmlinu* "$DEBIRF_BUILDD"
65 # remove kernel symlinks
66 if [ -L "$DEBIRF_ROOT"/vmlinuz ] ; then
67 rm "$DEBIRF_BUILDD"/vmlinuz