source: trunk/debirf/src/modules/install-kernel @ 1311

Last change on this file since 1311 was 1311, checked in by dkg, 4 years ago

handle choosing a KNAME more cleanly when the metapackage has multiple depends.

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/bash -e
2
3# debirf module: 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# *** REQUIRED MODULE ***
11# WARNING: this module is necessary for proper functioning of debirf.
12#
13# The debirf scripts were written by
14# Jameson Rollins <jrollins@fifthhorseman.net>
15# and
16# Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
17#
18# They are Copyright 2007, and are all released under the GPL,
19# version 3 or later.
20
21# clear out old modules if they exist, to avoid confusion
22rm -rf "$DEBIRF_ROOT/lib/modules"
23
24# download/copy in kernel package
25if [ -z "$DEBIRF_KERNEL_PACKAGE" ] ; then
26    # determine kernel to install. assume arch of build host.
27
28    # determine kernel arch.  need everything after the kernel version
29    # and debian version
30    KARCH=$(uname -r | cut -d- -f3-)
31
32    # determine the full kernel version from the dependency of the
33    # generic 2.6-ARCH package in the debirf root (since it may be
34    # different than what is installed on the build host)
35    KNAME=$(debirf_exec apt-cache show linux-image-"$KARCH" | grep '^Depends: ' | sed 's/^Depends: //' | tr ',' '\n' | tr -d ' ' | grep ^linux-image | sort -r | head -n1)
36
37    # download only the desired kernel package directly into the apt
38    # cache for dpkg extraction
39    debirf_exec sh -c "cd /var/cache/apt/archives/ && aptitude download \"$KNAME\""
40
41else
42    # install kernel deb if given at command line
43    cp "$DEBIRF_KERNEL_PACKAGE" "$DEBIRF_ROOT"/var/cache/apt/archives/
44fi
45
46KPKG=$(basename "$DEBIRF_ROOT"/var/cache/apt/archives/linux-image-2.6.*)
47
48echo "extracting kernel package $KPKG..."
49debirf_exec dpkg --extract /var/cache/apt/archives/"$KPKG" /
50
51# install the module init tools, since they are needed for depmod
52debirf_exec apt-get --assume-yes install module-init-tools
53
54# depmod to create module list
55KVERS=$(ls -1 -t "$DEBIRF_ROOT/lib/modules" | head -n1)
56echo "generating modules.dep..."
57debirf_exec depmod -a "$KVERS"
58
59# extract kernel and debian stock initrd from the build root:
60mv "$DEBIRF_ROOT"/boot/vmlinu* "$DEBIRF_BUILDD"
61
62# remove kernel symlinks
63if [ -L "$DEBIRF_ROOT"/vmlinuz ] ; then
64    rm "$DEBIRF_BUILDD"/vmlinuz
65fi
Note: See TracBrowser for help on using the repository browser.