blob: 6edb29f2b4a6c8aa056a748168a70583897a9d3c [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
16tmpdir="$objtree/debian/tmp"
Sam Ravnborg687c3da2005-07-14 20:24:00 +000017packagename=linux-$version
18
19if [ "$ARCH" == "um" ] ; then
20 packagename=user-mode-linux-$version
21fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23# Setup the directory structure
24rm -rf "$tmpdir"
25mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
Sam Ravnborg687c3da2005-07-14 20:24:00 +000026if [ "$ARCH" == "um" ] ; then
27 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
28fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30# Build and install the kernel
Sam Ravnborg687c3da2005-07-14 20:24:00 +000031if [ "$ARCH" == "um" ] ; then
32 $MAKE linux
33 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
34 cp .config "$tmpdir/usr/share/doc/$packagename/config"
35 gzip "$tmpdir/usr/share/doc/$packagename/config"
36 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
37else
38 cp System.map "$tmpdir/boot/System.map-$version"
39 cp .config "$tmpdir/boot/config-$version"
40 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
41fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43if grep -q '^CONFIG_MODULES=y' .config ; then
Sam Ravnborga91f98a2005-07-14 20:26:09 +000044 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
Sam Ravnborg687c3da2005-07-14 20:24:00 +000045 if [ "$ARCH" == "um" ] ; then
46 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
47 rmdir "$tmpdir/lib/modules/$version"
48 fi
Linus Torvalds1da177e2005-04-16 15:20:36 -070049fi
50
51# Install the maintainer scripts
52for script in postinst postrm preinst prerm ; do
53 mkdir -p "$tmpdir/etc/kernel/$script.d"
54 cat <<EOF > "$tmpdir/DEBIAN/$script"
55#!/bin/sh
56
57set -e
58
59test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
60exit 0
61EOF
62 chmod 755 "$tmpdir/DEBIAN/$script"
63done
64
65name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
66# Generate a simple changelog template
67cat <<EOF > debian/changelog
68linux ($version) unstable; urgency=low
69
70 * A standard release
71
72 -- $name $(date -R)
73EOF
74
75# Generate a control file
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000076if [ "$ARCH" == "um" ]; then
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078cat <<EOF > debian/control
79Source: linux
80Section: base
81Priority: optional
82Maintainer: $name
83Standards-Version: 3.6.1
84
Sam Ravnborg687c3da2005-07-14 20:24:00 +000085Package: $packagename
Linus Torvalds1da177e2005-04-16 15:20:36 -070086Architecture: any
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000087Description: User Mode Linux kernel, version $version
88 User-mode Linux is a port of the Linux kernel to its own system call
89 interface. It provides a kind of virtual machine, which runs Linux
90 as a user process under another Linux kernel. This is useful for
91 kernel development, sandboxes, jails, experimentation, and
92 many other things.
93 .
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 This package contains the Linux kernel, modules and corresponding other
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000095 files version $version
Linus Torvalds1da177e2005-04-16 15:20:36 -070096EOF
97
Sam Ravnborgdc5962f2005-07-14 20:24:56 +000098else
99cat <<EOF > debian/control
100Source: linux
101Section: base
102Priority: optional
103Maintainer: $name
104Standards-Version: 3.6.1
105
106Package: $packagename
107Architecture: any
108Description: Linux kernel, version $version
109 This package contains the Linux kernel, modules and corresponding other
110 files version $version
111EOF
112fi
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114# Fix some ownership and permissions
115chown -R root:root "$tmpdir"
116chmod -R go-w "$tmpdir"
117
118# Perform the final magic
119dpkg-gencontrol -isp
120dpkg --build "$tmpdir" ..
121
122exit 0
123