Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / scripts / package / builddeb
blobba6bf5d5abf9189ea4dcb71c2af31ce9a9b4dfe5
1 #!/bin/sh
3 # builddeb 1.2
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.
12 set -e
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
25 rm -rf "$tmpdir"
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
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"
38 else
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"
56 #!/bin/sh
58 set -e
60 test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
61 exit 0
62 EOF
63 chmod 755 "$tmpdir/DEBIAN/$script"
64 done
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
71 * A standard release
73 -- $name $(date -R)
74 EOF
76 # Generate a control file
77 if [ "$ARCH" == "um" ]; then
79 cat <<EOF > debian/control
80 Source: linux
81 Section: base
82 Priority: optional
83 Maintainer: $name
84 Standards-Version: 3.6.1
86 Package: $packagename
87 Provides: kernel-image-$version, linux-image-$version
88 Architecture: any
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
94 many other things.
96 This package contains the Linux kernel, modules and corresponding other
97 files version $version
98 EOF
100 else
101 cat <<EOF > debian/control
102 Source: linux
103 Section: base
104 Priority: optional
105 Maintainer: $name
106 Standards-Version: 3.6.1
108 Package: $packagename
109 Provides: kernel-image-$version, linux-image-$version
110 Architecture: any
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
122 dpkg-gencontrol -isp
123 dpkg --build "$tmpdir" ..
125 exit 0