Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #!/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 | ||
12 | set -e | |
13 | ||
14 | # Some variables and settings used throughout the script | |
15 | version=$KERNELRELEASE | |
16 | tmpdir="$objtree/debian/tmp" | |
17 | ||
18 | # Setup the directory structure | |
19 | rm -rf "$tmpdir" | |
20 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" | |
21 | ||
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" | |
26 | ||
27 | if grep -q '^CONFIG_MODULES=y' .config ; then | |
28 | INSTALL_MOD_PATH="$tmpdir" make modules_install | |
29 | fi | |
30 | ||
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" | |
35 | #!/bin/sh | |
36 | ||
37 | set -e | |
38 | ||
39 | test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d | |
40 | exit 0 | |
41 | EOF | |
42 | chmod 755 "$tmpdir/DEBIAN/$script" | |
43 | done | |
44 | ||
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 | |
49 | ||
50 | * A standard release | |
51 | ||
52 | -- $name $(date -R) | |
53 | EOF | |
54 | ||
55 | # Generate a control file | |
56 | cat <<EOF > debian/control | |
57 | Source: linux | |
58 | Section: base | |
59 | Priority: optional | |
60 | Maintainer: $name | |
61 | Standards-Version: 3.6.1 | |
62 | ||
63 | Package: linux-$version | |
64 | Architecture: any | |
65 | Description: Linux kernel, version $version | |
66 | This package contains the Linux kernel, modules and corresponding other | |
67 | files version $version. | |
68 | EOF | |
69 | ||
70 | # Fix some ownership and permissions | |
71 | chown -R root:root "$tmpdir" | |
72 | chmod -R go-w "$tmpdir" | |
73 | ||
74 | # Perform the final magic | |
75 | dpkg-gencontrol -isp | |
76 | dpkg --build "$tmpdir" .. | |
77 | ||
78 | exit 0 | |
79 |