]> bbs.cooldavid.org Git - net-next-2.6.git/blame - scripts/package/builddeb
Merge branch 'for-linus' of git://git.infradead.org/users/eparis/notify
[net-next-2.6.git] / scripts / package / builddeb
CommitLineData
1da177e4
LT
1#!/bin/sh
2#
4964451a 3# builddeb 1.3
1da177e4
LT
4# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
5#
6# Simple script to generate a deb package for a Linux kernel. All the
4f66199b 7# complexity of what to do with a kernel after it is installed or removed
1da177e4 8# is left to other scripts and packages: they can install scripts in the
fe233cb6
FP
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.
1da177e4
LT
12
13set -e
14
3e2ab256
FP
15create_package() {
16 local pname="$1" pdir="$2"
17
9461f666 18 cp debian/copyright "$pdir/usr/share/doc/$pname/"
1ab18486 19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
b59a1225
FJ
21 sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \
22 | xargs -r0 md5sum > DEBIAN/md5sums"
9461f666 23
3e2ab256
FP
24 # Fix ownership and permissions
25 chown -R root:root "$pdir"
26 chmod -R go-w "$pdir"
27
28 # Create the package
29 dpkg-gencontrol -isp -p$pname -P"$pdir"
30 dpkg --build "$pdir" ..
31}
32
1da177e4
LT
33# Some variables and settings used throughout the script
34version=$KERNELRELEASE
4f66199b 35revision=$(cat .version)
c72c75db
FP
36if [ -n "$KDEB_PKGVERSION" ]; then
37 packageversion=$KDEB_PKGVERSION
38else
39 packageversion=$version-$revision
40fi
1da177e4 41tmpdir="$objtree/debian/tmp"
bf1b3644 42fwdir="$objtree/debian/fwtmp"
f7a2c31f 43packagename=linux-image-$version
bf1b3644 44fwpackagename=linux-firmware-image
687c3dac 45
4f66199b 46if [ "$ARCH" = "um" ] ; then
687c3dac
SR
47 packagename=user-mode-linux-$version
48fi
1da177e4
LT
49
50# Setup the directory structure
bf1b3644 51rm -rf "$tmpdir" "$fwdir"
9461f666
FP
52mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
53mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename"
4f66199b 54if [ "$ARCH" = "um" ] ; then
9461f666 55 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin"
687c3dac 56fi
1da177e4
LT
57
58# Build and install the kernel
4f66199b 59if [ "$ARCH" = "um" ] ; then
687c3dac
SR
60 $MAKE linux
61 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
62 cp .config "$tmpdir/usr/share/doc/$packagename/config"
63 gzip "$tmpdir/usr/share/doc/$packagename/config"
64 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
65else
66 cp System.map "$tmpdir/boot/System.map-$version"
67 cp .config "$tmpdir/boot/config-$version"
a89b433b 68 # Not all arches include the boot path in KBUILD_IMAGE
242c5ab0
GJ
69 if [ -e $KBUILD_IMAGE ]; then
70 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
71 else
a89b433b
FP
72 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
73 fi
687c3dac 74fi
1da177e4
LT
75
76if grep -q '^CONFIG_MODULES=y' .config ; then
a91f98a2 77 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
4f66199b 78 if [ "$ARCH" = "um" ] ; then
687c3dac
SR
79 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
80 rmdir "$tmpdir/lib/modules/$version"
81 fi
1da177e4
LT
82fi
83
84# Install the maintainer scripts
fe233cb6
FP
85# Note: hook scripts under /etc/kernel are also executed by official Debian
86# kernel packages, as well as kernel packages built using make-kpkg
87debhookdir=${KDEB_HOOKDIR:-/etc/kernel}
1da177e4 88for script in postinst postrm preinst prerm ; do
fe233cb6 89 mkdir -p "$tmpdir$debhookdir/$script.d"
1da177e4
LT
90 cat <<EOF > "$tmpdir/DEBIAN/$script"
91#!/bin/sh
92
93set -e
94
4964451a 95# Pass maintainer script parameters to hook scripts
241ad11f 96export DEB_MAINT_PARAMS="\$*"
4964451a 97
fe233cb6 98test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d
1da177e4
LT
99exit 0
100EOF
101 chmod 755 "$tmpdir/DEBIAN/$script"
102done
103
edec611d 104# Try to determine maintainer and email values
105if [ -n "$DEBEMAIL" ]; then
106 email=$DEBEMAIL
107elif [ -n "$EMAIL" ]; then
108 email=$EMAIL
109else
110 email=$(id -nu)@$(hostname -f)
111fi
112if [ -n "$DEBFULLNAME" ]; then
113 name=$DEBFULLNAME
114elif [ -n "$NAME" ]; then
115 name=$NAME
116else
117 name="Anonymous"
118fi
119maintainer="$name <$email>"
120
1da177e4
LT
121# Generate a simple changelog template
122cat <<EOF > debian/changelog
4bf4cd49 123linux-upstream ($packageversion) unstable; urgency=low
1da177e4 124
a83ca277 125 * Custom built Linux kernel.
1da177e4 126
edec611d 127 -- $maintainer $(date -R)
1da177e4
LT
128EOF
129
9461f666
FP
130# Generate copyright file
131cat <<EOF > debian/copyright
132This is a packacked upstream version of the Linux kernel.
133
134The sources may be found at most Linux ftp sites, including:
135ftp://ftp.kernel.org/pub/linux/kernel
136
137Copyright: 1991 - 2009 Linus Torvalds and others.
138
139The git repository for mainline kernel development is at:
140git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
141
142 This program is free software; you can redistribute it and/or modify
143 it under the terms of the GNU General Public License as published by
144 the Free Software Foundation; version 2 dated June, 1991.
145
146On Debian GNU/Linux systems, the complete text of the GNU General Public
147License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
148EOF
149
1da177e4 150# Generate a control file
3e2ab256 151cat <<EOF > debian/control
4bf4cd49 152Source: linux-upstream
aa42abed 153Section: kernel
dc5962fd 154Priority: optional
edec611d 155Maintainer: $maintainer
2d7204ac 156Standards-Version: 3.8.4
ee6eed80 157Homepage: http://www.kernel.org/
3e2ab256
FP
158EOF
159
160if [ "$ARCH" = "um" ]; then
161 cat <<EOF >> debian/control
dc5962fd
SR
162
163Package: $packagename
8ebc2fe9 164Provides: linux-image, linux-image-2.6, linux-modules-$version
dc5962fd
SR
165Architecture: any
166Description: User Mode Linux kernel, version $version
167 User-mode Linux is a port of the Linux kernel to its own system call
168 interface. It provides a kind of virtual machine, which runs Linux
169 as a user process under another Linux kernel. This is useful for
170 kernel development, sandboxes, jails, experimentation, and
171 many other things.
172 .
173 This package contains the Linux kernel, modules and corresponding other
a83ca277 174 files, version: $version.
dc5962fd
SR
175EOF
176
177else
3e2ab256 178 cat <<EOF >> debian/control
1da177e4 179
687c3dac 180Package: $packagename
8ebc2fe9 181Provides: linux-image, linux-image-2.6, linux-modules-$version
bf1b3644 182Suggests: $fwpackagename
1da177e4 183Architecture: any
dc5962fd 184Description: Linux kernel, version $version
1da177e4 185 This package contains the Linux kernel, modules and corresponding other
a83ca277 186 files, version: $version.
1da177e4 187EOF
4f66199b 188
dc5962fd 189fi
1da177e4 190
bf1b3644
JM
191# Do we have firmware? Move it out of the way and build it into a package.
192if [ -e "$tmpdir/lib/firmware" ]; then
193 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
194
195 cat <<EOF >> debian/control
196
197Package: $fwpackagename
198Architecture: all
199Description: Linux kernel firmware, version $version
a83ca277 200 This package contains firmware from the Linux kernel, version $version.
bf1b3644
JM
201EOF
202
3e2ab256 203 create_package "$fwpackagename" "$fwdir"
bf1b3644
JM
204fi
205
3e2ab256 206create_package "$packagename" "$tmpdir"
1da177e4
LT
207
208exit 0