kbuild, deb-pkg: fix 'file not found' error when building .deb package for arm
[deliverable/linux.git] / scripts / package / builddeb
CommitLineData
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
4f66199b 7# complexity of what to do with a kernel after it is installed or removed
1da177e4
LT
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
3e2ab256
FP
14create_package() {
15 local pname="$1" pdir="$2"
16
17 # Fix ownership and permissions
18 chown -R root:root "$pdir"
19 chmod -R go-w "$pdir"
20
21 # Create the package
22 dpkg-gencontrol -isp -p$pname -P"$pdir"
23 dpkg --build "$pdir" ..
24}
25
1da177e4
LT
26# Some variables and settings used throughout the script
27version=$KERNELRELEASE
4f66199b 28revision=$(cat .version)
1da177e4 29tmpdir="$objtree/debian/tmp"
bf1b3644 30fwdir="$objtree/debian/fwtmp"
687c3dac 31packagename=linux-$version
bf1b3644 32fwpackagename=linux-firmware-image
687c3dac 33
4f66199b 34if [ "$ARCH" = "um" ] ; then
687c3dac
SR
35 packagename=user-mode-linux-$version
36fi
1da177e4
LT
37
38# Setup the directory structure
bf1b3644 39rm -rf "$tmpdir" "$fwdir"
1da177e4 40mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
bf1b3644 41mkdir -p "$fwdir/DEBIAN" "$fwdir/lib"
4f66199b 42if [ "$ARCH" = "um" ] ; then
687c3dac
SR
43 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
44fi
1da177e4
LT
45
46# Build and install the kernel
4f66199b 47if [ "$ARCH" = "um" ] ; then
687c3dac
SR
48 $MAKE linux
49 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
50 cp .config "$tmpdir/usr/share/doc/$packagename/config"
51 gzip "$tmpdir/usr/share/doc/$packagename/config"
52 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
53else
54 cp System.map "$tmpdir/boot/System.map-$version"
55 cp .config "$tmpdir/boot/config-$version"
a89b433b
FP
56 # Not all arches include the boot path in KBUILD_IMAGE
57 if ! cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"; then
58 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
59 fi
687c3dac 60fi
1da177e4
LT
61
62if grep -q '^CONFIG_MODULES=y' .config ; then
a91f98a2 63 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
4f66199b 64 if [ "$ARCH" = "um" ] ; then
687c3dac
SR
65 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
66 rmdir "$tmpdir/lib/modules/$version"
67 fi
1da177e4
LT
68fi
69
70# Install the maintainer scripts
71for script in postinst postrm preinst prerm ; do
72 mkdir -p "$tmpdir/etc/kernel/$script.d"
73 cat <<EOF > "$tmpdir/DEBIAN/$script"
74#!/bin/sh
75
76set -e
77
78test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
79exit 0
80EOF
81 chmod 755 "$tmpdir/DEBIAN/$script"
82done
83
84name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
85# Generate a simple changelog template
86cat <<EOF > debian/changelog
ed2c9fa5 87linux ($version-$revision) unstable; urgency=low
1da177e4
LT
88
89 * A standard release
90
91 -- $name $(date -R)
92EOF
93
94# Generate a control file
3e2ab256 95cat <<EOF > debian/control
dc5962fd
SR
96Source: linux
97Section: base
98Priority: optional
99Maintainer: $name
100Standards-Version: 3.6.1
3e2ab256
FP
101EOF
102
103if [ "$ARCH" = "um" ]; then
104 cat <<EOF >> debian/control
dc5962fd
SR
105
106Package: $packagename
6f67a004 107Provides: kernel-image-$version, linux-image-$version
dc5962fd
SR
108Architecture: any
109Description: User Mode Linux kernel, version $version
110 User-mode Linux is a port of the Linux kernel to its own system call
111 interface. It provides a kind of virtual machine, which runs Linux
112 as a user process under another Linux kernel. This is useful for
113 kernel development, sandboxes, jails, experimentation, and
114 many other things.
115 .
116 This package contains the Linux kernel, modules and corresponding other
117 files version $version
118EOF
119
120else
3e2ab256 121 cat <<EOF >> debian/control
1da177e4 122
687c3dac 123Package: $packagename
6f67a004 124Provides: kernel-image-$version, linux-image-$version
bf1b3644 125Suggests: $fwpackagename
1da177e4 126Architecture: any
dc5962fd 127Description: Linux kernel, version $version
1da177e4 128 This package contains the Linux kernel, modules and corresponding other
dc5962fd 129 files version $version
1da177e4 130EOF
4f66199b 131
dc5962fd 132fi
1da177e4 133
bf1b3644
JM
134# Do we have firmware? Move it out of the way and build it into a package.
135if [ -e "$tmpdir/lib/firmware" ]; then
136 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
137
138 cat <<EOF >> debian/control
139
140Package: $fwpackagename
141Architecture: all
142Description: Linux kernel firmware, version $version
143 This package contains firmware from the Linux kernel, version $version
144EOF
145
3e2ab256 146 create_package "$fwpackagename" "$fwdir"
bf1b3644
JM
147fi
148
3e2ab256 149create_package "$packagename" "$tmpdir"
1da177e4
LT
150
151exit 0
This page took 0.388483 seconds and 5 git commands to generate.