kbuild, deb-pkg: pass Debian maintainer script parameters to packaging hook scripts
[deliverable/linux.git] / scripts / package / builddeb
... / ...
CommitLineData
1#!/bin/sh
2#
3# builddeb 1.3
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 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 that will be called on
10# package install and removal.
11
12set -e
13
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
26# Some variables and settings used throughout the script
27version=$KERNELRELEASE
28revision=$(cat .version)
29tmpdir="$objtree/debian/tmp"
30fwdir="$objtree/debian/fwtmp"
31packagename=linux-$version
32fwpackagename=linux-firmware-image
33
34if [ "$ARCH" = "um" ] ; then
35 packagename=user-mode-linux-$version
36fi
37
38# Setup the directory structure
39rm -rf "$tmpdir" "$fwdir"
40mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
41mkdir -p "$fwdir/DEBIAN" "$fwdir/lib"
42if [ "$ARCH" = "um" ] ; then
43 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
44fi
45
46# Build and install the kernel
47if [ "$ARCH" = "um" ] ; then
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"
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
60fi
61
62if grep -q '^CONFIG_MODULES=y' .config ; then
63 INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
64 if [ "$ARCH" = "um" ] ; then
65 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
66 rmdir "$tmpdir/lib/modules/$version"
67 fi
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
78# Pass maintainer script parameters to hook scripts
79export DEB_MAINT_PARAMS="\$@"
80
81test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
82exit 0
83EOF
84 chmod 755 "$tmpdir/DEBIAN/$script"
85done
86
87name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
88# Generate a simple changelog template
89cat <<EOF > debian/changelog
90linux ($version-$revision) unstable; urgency=low
91
92 * A standard release
93
94 -- $name $(date -R)
95EOF
96
97# Generate a control file
98cat <<EOF > debian/control
99Source: linux
100Section: base
101Priority: optional
102Maintainer: $name
103Standards-Version: 3.6.1
104EOF
105
106if [ "$ARCH" = "um" ]; then
107 cat <<EOF >> debian/control
108
109Package: $packagename
110Provides: kernel-image-$version, linux-image-$version
111Architecture: any
112Description: User Mode Linux kernel, version $version
113 User-mode Linux is a port of the Linux kernel to its own system call
114 interface. It provides a kind of virtual machine, which runs Linux
115 as a user process under another Linux kernel. This is useful for
116 kernel development, sandboxes, jails, experimentation, and
117 many other things.
118 .
119 This package contains the Linux kernel, modules and corresponding other
120 files version $version
121EOF
122
123else
124 cat <<EOF >> debian/control
125
126Package: $packagename
127Provides: kernel-image-$version, linux-image-$version
128Suggests: $fwpackagename
129Architecture: any
130Description: Linux kernel, version $version
131 This package contains the Linux kernel, modules and corresponding other
132 files version $version
133EOF
134
135fi
136
137# Do we have firmware? Move it out of the way and build it into a package.
138if [ -e "$tmpdir/lib/firmware" ]; then
139 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
140
141 cat <<EOF >> debian/control
142
143Package: $fwpackagename
144Architecture: all
145Description: Linux kernel firmware, version $version
146 This package contains firmware from the Linux kernel, version $version
147EOF
148
149 create_package "$fwpackagename" "$fwdir"
150fi
151
152create_package "$packagename" "$tmpdir"
153
154exit 0
This page took 0.025144 seconds and 5 git commands to generate.