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 revision=`cat .version`
17 tmpdir="$objtree/debian/tmp"
18 packagename=linux-$version
20 if [ "$ARCH" == "um" ] ; then
21 packagename=user-mode-linux-$version
24 # Setup the directory structure
26 mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
27 if [ "$ARCH" == "um" ] ; then
28 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
31 # Build and install the kernel
32 if [ "$ARCH" == "um" ] ; then
34 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
35 cp .config "$tmpdir/usr/share/doc/$packagename/config"
36 gzip "$tmpdir/usr/share/doc/$packagename/config"
37 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
39 cp System.map "$tmpdir/boot/System.map-$version"
40 cp .config "$tmpdir/boot/config-$version"
41 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
44 if grep -q '^CONFIG_MODULES=y' .config ; then
45 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
46 if [ "$ARCH" == "um" ] ; then
47 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
48 rmdir "$tmpdir/lib/modules/$version"
52 # Install the maintainer scripts
53 for script in postinst postrm preinst prerm ; do
54 mkdir -p "$tmpdir/etc/kernel/$script.d"
55 cat <<EOF > "$tmpdir/DEBIAN/$script"
60 test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
63 chmod 755 "$tmpdir/DEBIAN/$script"
66 name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
67 # Generate a simple changelog template
68 cat <<EOF > debian/changelog
69 linux ($version-$revision) unstable; urgency=low
76 # Generate a control file
77 if [ "$ARCH" == "um" ]; then
79 cat <<EOF > debian/control
84 Standards-Version: 3.6.1
87 Provides: kernel-image-$version, linux-image-$version
89 Description: User Mode Linux kernel, version $version
90 User-mode Linux is a port of the Linux kernel to its own system call
91 interface. It provides a kind of virtual machine, which runs Linux
92 as a user process under another Linux kernel. This is useful for
93 kernel development, sandboxes, jails, experimentation, and
96 This package contains the Linux kernel, modules and corresponding other
97 files version $version
101 cat <<EOF > debian/control
106 Standards-Version: 3.6.1
108 Package: $packagename
109 Provides: kernel-image-$version, linux-image-$version
111 Description: Linux kernel, version $version
112 This package contains the Linux kernel, modules and corresponding other
113 files version $version
117 # Fix some ownership and permissions
118 chown -R root:root "$tmpdir"
119 chmod -R go-w "$tmpdir"
121 # Perform the final magic
123 dpkg --build "$tmpdir" ..