Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / scripts / package / builddeb
blob8b357b0bd250b0e04012a08815c01cd3f95f22a3
1 #!/bin/sh
3 # builddeb 1.3
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 installed 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 (or an alternative location
10 # specified in KDEB_HOOKDIR) that will be called on package install and
11 # removal.
13 set -e
15 create_package() {
16 local pname="$1" pdir="$2"
18 cp debian/copyright "$pdir/usr/share/doc/$pname/"
19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
22 # Fix ownership and permissions
23 chown -R root:root "$pdir"
24 chmod -R go-w "$pdir"
26 # Create the package
27 dpkg-gencontrol -isp -p$pname -P"$pdir"
28 dpkg --build "$pdir" ..
31 # Some variables and settings used throughout the script
32 version=$KERNELRELEASE
33 revision=$(cat .version)
34 if [ -n "$KDEB_PKGVERSION" ]; then
35 packageversion=$KDEB_PKGVERSION
36 else
37 packageversion=$version-$revision
39 tmpdir="$objtree/debian/tmp"
40 fwdir="$objtree/debian/fwtmp"
41 packagename=linux-image-$version
42 fwpackagename=linux-firmware-image
44 if [ "$ARCH" = "um" ] ; then
45 packagename=user-mode-linux-$version
48 # Setup the directory structure
49 rm -rf "$tmpdir" "$fwdir"
50 mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
51 mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename"
52 if [ "$ARCH" = "um" ] ; then
53 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin"
56 # Build and install the kernel
57 if [ "$ARCH" = "um" ] ; then
58 $MAKE linux
59 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
60 cp .config "$tmpdir/usr/share/doc/$packagename/config"
61 gzip "$tmpdir/usr/share/doc/$packagename/config"
62 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
63 else
64 cp System.map "$tmpdir/boot/System.map-$version"
65 cp .config "$tmpdir/boot/config-$version"
66 # Not all arches include the boot path in KBUILD_IMAGE
67 if ! cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"; then
68 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
72 if grep -q '^CONFIG_MODULES=y' .config ; then
73 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
74 if [ "$ARCH" = "um" ] ; then
75 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
76 rmdir "$tmpdir/lib/modules/$version"
80 # Install the maintainer scripts
81 # Note: hook scripts under /etc/kernel are also executed by official Debian
82 # kernel packages, as well as kernel packages built using make-kpkg
83 debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
84 for script in postinst postrm preinst prerm ; do
85 mkdir -p "$tmpdir$debhookdir/$script.d"
86 cat <<EOF > "$tmpdir/DEBIAN/$script"
87 #!/bin/sh
89 set -e
91 # Pass maintainer script parameters to hook scripts
92 export DEB_MAINT_PARAMS="\$*"
94 test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d
95 exit 0
96 EOF
97 chmod 755 "$tmpdir/DEBIAN/$script"
98 done
100 # Try to determine maintainer and email values
101 if [ -n "$DEBEMAIL" ]; then
102 email=$DEBEMAIL
103 elif [ -n "$EMAIL" ]; then
104 email=$EMAIL
105 else
106 email=$(id -nu)@$(hostname -f)
108 if [ -n "$DEBFULLNAME" ]; then
109 name=$DEBFULLNAME
110 elif [ -n "$NAME" ]; then
111 name=$NAME
112 else
113 name="Anonymous"
115 maintainer="$name <$email>"
117 # Generate a simple changelog template
118 cat <<EOF > debian/changelog
119 linux-upstream ($packageversion) unstable; urgency=low
121 * Custom built Linux kernel.
123 -- $maintainer $(date -R)
126 # Generate copyright file
127 cat <<EOF > debian/copyright
128 This is a packacked upstream version of the Linux kernel.
130 The sources may be found at most Linux ftp sites, including:
131 ftp://ftp.kernel.org/pub/linux/kernel
133 Copyright: 1991 - 2009 Linus Torvalds and others.
135 The git repository for mainline kernel development is at:
136 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
138 This program is free software; you can redistribute it and/or modify
139 it under the terms of the GNU General Public License as published by
140 the Free Software Foundation; version 2 dated June, 1991.
142 On Debian GNU/Linux systems, the complete text of the GNU General Public
143 License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
146 # Generate a control file
147 cat <<EOF > debian/control
148 Source: linux-upstream
149 Section: admin
150 Priority: optional
151 Maintainer: $maintainer
152 Standards-Version: 3.8.1
155 if [ "$ARCH" = "um" ]; then
156 cat <<EOF >> debian/control
158 Package: $packagename
159 Provides: linux-image, linux-image-2.6, linux-modules-$version
160 Architecture: any
161 Description: User Mode Linux kernel, version $version
162 User-mode Linux is a port of the Linux kernel to its own system call
163 interface. It provides a kind of virtual machine, which runs Linux
164 as a user process under another Linux kernel. This is useful for
165 kernel development, sandboxes, jails, experimentation, and
166 many other things.
168 This package contains the Linux kernel, modules and corresponding other
169 files, version: $version.
172 else
173 cat <<EOF >> debian/control
175 Package: $packagename
176 Provides: linux-image, linux-image-2.6, linux-modules-$version
177 Suggests: $fwpackagename
178 Architecture: any
179 Description: Linux kernel, version $version
180 This package contains the Linux kernel, modules and corresponding other
181 files, version: $version.
186 # Do we have firmware? Move it out of the way and build it into a package.
187 if [ -e "$tmpdir/lib/firmware" ]; then
188 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
190 cat <<EOF >> debian/control
192 Package: $fwpackagename
193 Architecture: all
194 Description: Linux kernel firmware, version $version
195 This package contains firmware from the Linux kernel, version $version.
198 create_package "$fwpackagename" "$fwdir"
201 create_package "$packagename" "$tmpdir"
203 exit 0