4 # Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
6 # Simple script to generate a deb package for a Linux kernel. All the
7 # complexity of what to do with a kernel after it is installer or removed
8 # is left to other scripts and packages: they can install scripts in the
9 # /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on
10 # package install and removal.
14 # Some variables and settings used throughout the script
15 version
=$KERNELRELEASE
16 tmpdir
="$objtree/debian/tmp"
18 # Setup the directory structure
20 mkdir
-p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
22 # Build and install the kernel
23 cp System.map
"$tmpdir/boot/System.map-$version"
24 cp .config
"$tmpdir/boot/config-$version"
25 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
27 if grep -q '^CONFIG_MODULES=y' .config
; then
28 INSTALL_MOD_PATH
="$tmpdir" make modules_install
31 # Install the maintainer scripts
32 for script in postinst postrm preinst prerm
; do
33 mkdir
-p "$tmpdir/etc/kernel/$script.d"
34 cat <<EOF > "$tmpdir/DEBIAN/$script"
39 test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
42 chmod 755 "$tmpdir/DEBIAN/$script"
45 name
="Kernel Compiler <$(id -nu)@$(hostname -f)>"
46 # Generate a simple changelog template
47 cat <<EOF > debian/changelog
48 linux ($version) unstable; urgency=low
55 # Generate a control file
56 cat <<EOF > debian/control
61 Standards-Version: 3.6.1
63 Package: linux-$version
65 Description: Linux kernel, version $version
66 This package contains the Linux kernel, modules and corresponding other
67 files version $version.
70 # Fix some ownership and permissions
71 chown
-R root
:root
"$tmpdir"
72 chmod -R go-w
"$tmpdir"
74 # Perform the final magic
76 dpkg
--build "$tmpdir" ..