blob: ba6bf5d5abf9189ea4dcb71c2af31ce9a9b4dfe5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#!/bin/sh
2#
3# builddeb 1.2
4# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
5#
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.
11
12set -e
13
14# Some variables and settings used throughout the script
15version=$KERNELRELEASE
Michal Sojkaed2c9fa2008-02-07 17:18:51 +010016revision=`cat .version`
Linus Torvalds1da177e2005-04-16 15:20:36 -070017tmpdir="$objtree/debian/tmp"
Sam Ravnborg687c3da2005-07-14 20:24:00 +000018packagename=linux-$version
19
20if [ "$ARCH" == "um" ] ; then
21 packagename=user-mode-linux-$version
22fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24# Setup the directory structure
25rm -rf "$tmpdir"
26mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
Sam Ravnborg687c3da2005-07-14 20:24:00 +000027if [ "$ARCH" == "um" ] ; then
28 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
29fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31# Build and install the kernel
Sam Ravnborg687c3da2005-07-14 20:24:00 +000032if [ "$ARCH" == "um" ] ; then
33 $MAKE linux
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"
38else
39 cp System.map "$tmpdir/boot/System.map-$version"
40 cp .config "$tmpdir/boot/config-$version"
41 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
42fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44if grep -q '^CONFIG_MODULES=y' .config ; then
Sam Ravnborga91f98a2005-07-14 20:26:09 +000045 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
Sam Ravnborg687c3da2005-07-14 20:24:00 +000046 if [ "$ARCH" == "um" ] ; then
47 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
48 rmdir "$tmpdir/lib/modules/$version"
49 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070050fi
51
52# Install the maintainer scripts
53for script in postinst postrm preinst prerm ; do
54 mkdir -p "$tmpdir/etc/kernel/$script.d"
55 cat <<EOF > "$tmpdir/DEBIAN/$script"
56#!/bin/sh
57
58set -e
59
60test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
61exit 0
62EOF
63 chmod 755 "$tmpdir/DEBIAN/$script"
64done
65
66name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
67# Generate a simple changelog template
68cat <<EOF > debian/changelog
Michal Sojkaed2c9fa2008-02-07 17:18:51 +010069linux ($version-$revision) unstable; urgency=low
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71 * A standard release
72
73 -- $name $(date -R)
74EOF
75
76# Generate a control file
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000077if [ "$ARCH" == "um" ]; then
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079cat <<EOF > debian/control
80Source: linux
81Section: base
82Priority: optional
83Maintainer: $name
84Standards-Version: 3.6.1
85
Sam Ravnborg687c3da2005-07-14 20:24:00 +000086Package: $packagename
bugme-daemon@bugzilla.kernel.org6f67a002007-08-29 07:57:41 -070087Provides: kernel-image-$version, linux-image-$version
Linus Torvalds1da177e2005-04-16 15:20:36 -070088Architecture: any
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000089Description: 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
94 many other things.
95 .
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 This package contains the Linux kernel, modules and corresponding other
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000097 files version $version
Linus Torvalds1da177e2005-04-16 15:20:36 -070098EOF
99
Sam Ravnborgdc5962f2005-07-14 20:24:56 +0000100else
101cat <<EOF > debian/control
102Source: linux
103Section: base
104Priority: optional
105Maintainer: $name
106Standards-Version: 3.6.1
107
108Package: $packagename
bugme-daemon@bugzilla.kernel.org6f67a002007-08-29 07:57:41 -0700109Provides: kernel-image-$version, linux-image-$version
Sam Ravnborgdc5962f2005-07-14 20:24:56 +0000110Architecture: any
111Description: Linux kernel, version $version
112 This package contains the Linux kernel, modules and corresponding other
113 files version $version
114EOF
115fi
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117# Fix some ownership and permissions
118chown -R root:root "$tmpdir"
119chmod -R go-w "$tmpdir"
120
121# Perform the final magic
122dpkg-gencontrol -isp
123dpkg --build "$tmpdir" ..
124
125exit 0
126