Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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" |
Sam Ravnborg | 687c3da | 2005-07-14 20:24:00 +0000 | [diff] [blame] | 17 | packagename=linux-$version |
| 18 | |
| 19 | if [ "$ARCH" == "um" ] ; then |
| 20 | packagename=user-mode-linux-$version |
| 21 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | # Setup the directory structure |
| 24 | rm -rf "$tmpdir" |
| 25 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" |
Sam Ravnborg | 687c3da | 2005-07-14 20:24:00 +0000 | [diff] [blame] | 26 | if [ "$ARCH" == "um" ] ; then |
| 27 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" |
| 28 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | # Build and install the kernel |
Sam Ravnborg | 687c3da | 2005-07-14 20:24:00 +0000 | [diff] [blame] | 31 | if [ "$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" |
| 37 | else |
| 38 | cp System.map "$tmpdir/boot/System.map-$version" |
| 39 | cp .config "$tmpdir/boot/config-$version" |
| 40 | cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" |
| 41 | fi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | if grep -q '^CONFIG_MODULES=y' .config ; then |
Sam Ravnborg | a91f98a | 2005-07-14 20:26:09 +0000 | [diff] [blame] | 44 | INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install |
Sam Ravnborg | 687c3da | 2005-07-14 20:24:00 +0000 | [diff] [blame] | 45 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | fi |
| 50 | |
| 51 | # Install the maintainer scripts |
| 52 | for 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 | |
| 57 | set -e |
| 58 | |
| 59 | test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d |
| 60 | exit 0 |
| 61 | EOF |
| 62 | chmod 755 "$tmpdir/DEBIAN/$script" |
| 63 | done |
| 64 | |
| 65 | name="Kernel Compiler <$(id -nu)@$(hostname -f)>" |
| 66 | # Generate a simple changelog template |
| 67 | cat <<EOF > debian/changelog |
| 68 | linux ($version) unstable; urgency=low |
| 69 | |
| 70 | * A standard release |
| 71 | |
| 72 | -- $name $(date -R) |
| 73 | EOF |
| 74 | |
| 75 | # Generate a control file |
Sam Ravnborg | dc5962f | 2005-07-14 20:24:56 +0000 | [diff] [blame] | 76 | if [ "$ARCH" == "um" ]; then |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | cat <<EOF > debian/control |
| 79 | Source: linux |
| 80 | Section: base |
| 81 | Priority: optional |
| 82 | Maintainer: $name |
| 83 | Standards-Version: 3.6.1 |
| 84 | |
Sam Ravnborg | 687c3da | 2005-07-14 20:24:00 +0000 | [diff] [blame] | 85 | Package: $packagename |
bugme-daemon@bugzilla.kernel.org | 6f67a00 | 2007-08-29 07:57:41 -0700 | [diff] [blame^] | 86 | Provides: kernel-image-$version, linux-image-$version |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | Architecture: any |
Sam Ravnborg | dc5962f | 2005-07-14 20:24:56 +0000 | [diff] [blame] | 88 | Description: User Mode Linux kernel, version $version |
| 89 | User-mode Linux is a port of the Linux kernel to its own system call |
| 90 | interface. It provides a kind of virtual machine, which runs Linux |
| 91 | as a user process under another Linux kernel. This is useful for |
| 92 | kernel development, sandboxes, jails, experimentation, and |
| 93 | many other things. |
| 94 | . |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | This package contains the Linux kernel, modules and corresponding other |
Sam Ravnborg | dc5962f | 2005-07-14 20:24:56 +0000 | [diff] [blame] | 96 | files version $version |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | EOF |
| 98 | |
Sam Ravnborg | dc5962f | 2005-07-14 20:24:56 +0000 | [diff] [blame] | 99 | else |
| 100 | cat <<EOF > debian/control |
| 101 | Source: linux |
| 102 | Section: base |
| 103 | Priority: optional |
| 104 | Maintainer: $name |
| 105 | Standards-Version: 3.6.1 |
| 106 | |
| 107 | Package: $packagename |
bugme-daemon@bugzilla.kernel.org | 6f67a00 | 2007-08-29 07:57:41 -0700 | [diff] [blame^] | 108 | Provides: kernel-image-$version, linux-image-$version |
Sam Ravnborg | dc5962f | 2005-07-14 20:24:56 +0000 | [diff] [blame] | 109 | Architecture: any |
| 110 | Description: Linux kernel, version $version |
| 111 | This package contains the Linux kernel, modules and corresponding other |
| 112 | files version $version |
| 113 | EOF |
| 114 | fi |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | # Fix some ownership and permissions |
| 117 | chown -R root:root "$tmpdir" |
| 118 | chmod -R go-w "$tmpdir" |
| 119 | |
| 120 | # Perform the final magic |
| 121 | dpkg-gencontrol -isp |
| 122 | dpkg --build "$tmpdir" .. |
| 123 | |
| 124 | exit 0 |
| 125 | |