| 1 | #!/bin/bash -e |
|---|
| 2 | |
|---|
| 3 | # debirf plugin: install-kernel |
|---|
| 4 | # install a kernel package, indicated by the expected environment |
|---|
| 5 | # variables: |
|---|
| 6 | # DEBIRF_PATH |
|---|
| 7 | # DEBIRF_ROOT |
|---|
| 8 | # DEBIRF_KERNEL_PACKAGE |
|---|
| 9 | # |
|---|
| 10 | # The debirf scripts were written by |
|---|
| 11 | # Jameson Rollins <jrollins@fifthhorseman.net> |
|---|
| 12 | # and |
|---|
| 13 | # Daniel Kahn Gillmor <dkg-debian.org@fifthhorseman.net>. |
|---|
| 14 | # |
|---|
| 15 | # They are Copyright 2007, and are all released under the GPL, |
|---|
| 16 | # version 3 or later. |
|---|
| 17 | |
|---|
| 18 | # clear out old modules if they exist, to avoid confusion |
|---|
| 19 | rm -rf "$DEBIRF_ROOT/lib/modules" |
|---|
| 20 | |
|---|
| 21 | # download/copy in kernel package |
|---|
| 22 | if [ -z "$DEBIRF_KERNEL_PACKAGE" ] ; then |
|---|
| 23 | # otherwise, try to figure out the kernel to install |
|---|
| 24 | # assume arch of build host |
|---|
| 25 | KERNEL_ARCH=$(uname -r | tr '-' '\n' | tail -1) |
|---|
| 26 | debirf_exec apt-get --assume-yes --download-only install linux-image-2.6-"$KERNEL_ARCH" |
|---|
| 27 | else |
|---|
| 28 | # install kernel deb if given at command line |
|---|
| 29 | cp "$DEBIRF_KERNEL_PACKAGE" "$DEBIRF_ROOT"/var/cache/apt/archives/ |
|---|
| 30 | fi |
|---|
| 31 | |
|---|
| 32 | KNAME=$(basename "$DEBIRF_ROOT"/var/cache/apt/archives/linux-image-2.6.*) |
|---|
| 33 | |
|---|
| 34 | echo "extracting kernel package $KNAME..." |
|---|
| 35 | debirf_exec dpkg --extract /var/cache/apt/archives/"$KNAME" / |
|---|
| 36 | |
|---|
| 37 | # install the module init tools, since they are needed for depmod |
|---|
| 38 | debirf_exec apt-get --assume-yes install module-init-tools |
|---|
| 39 | |
|---|
| 40 | # depmod to create module list |
|---|
| 41 | KERNEL_VERS=$(ls -1 "$DEBIRF_ROOT/lib/modules" | head -n1) |
|---|
| 42 | echo "generating modules.dep..." |
|---|
| 43 | debirf_exec depmod -a "$KERNEL_VERS" |
|---|
| 44 | |
|---|
| 45 | # extract kernel and debian stock initrd: |
|---|
| 46 | mv "$DEBIRF_ROOT"/boot/vmlinu* "$DEBIRF_BUILDD" |
|---|
| 47 | |
|---|
| 48 | # remove kernel symlinks |
|---|
| 49 | if [ -L "$DEBIRF_ROOT"/vmlinuz ] ; then |
|---|
| 50 | rm "$DEBIRF_BUILDD"/vmlinuz |
|---|
| 51 | fi |
|---|