diff options
Diffstat (limited to 'scripts/package/builddeb')
-rw-r--r-- | scripts/package/builddeb | 149 |
1 files changed, 102 insertions, 47 deletions
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 1264b8e2829d..01c2d13dd020 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
@@ -1,38 +1,58 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # builddeb 1.2 | 3 | # builddeb 1.3 |
4 | # Copyright 2003 Wichert Akkerman <wichert@wiggy.net> | 4 | # Copyright 2003 Wichert Akkerman <wichert@wiggy.net> |
5 | # | 5 | # |
6 | # Simple script to generate a deb package for a Linux kernel. All the | 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 | 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 | 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 | 9 | # /etc/kernel/{pre,post}{inst,rm}.d/ directories (or an alternative location |
10 | # package install and removal. | 10 | # specified in KDEB_HOOKDIR) that will be called on package install and |
11 | # removal. | ||
11 | 12 | ||
12 | set -e | 13 | set -e |
13 | 14 | ||
15 | create_package() { | ||
16 | local pname="$1" pdir="$2" | ||
17 | |||
18 | cp debian/copyright "$pdir/usr/share/doc/$pname/" | ||
19 | |||
20 | # Fix ownership and permissions | ||
21 | chown -R root:root "$pdir" | ||
22 | chmod -R go-w "$pdir" | ||
23 | |||
24 | # Create the package | ||
25 | dpkg-gencontrol -isp -p$pname -P"$pdir" | ||
26 | dpkg --build "$pdir" .. | ||
27 | } | ||
28 | |||
14 | # Some variables and settings used throughout the script | 29 | # Some variables and settings used throughout the script |
15 | version=$KERNELRELEASE | 30 | version=$KERNELRELEASE |
16 | revision=`cat .version` | 31 | revision=$(cat .version) |
32 | if [ -n "$KDEB_PKGVERSION" ]; then | ||
33 | packageversion=$KDEB_PKGVERSION | ||
34 | else | ||
35 | packageversion=$version-$revision | ||
36 | fi | ||
17 | tmpdir="$objtree/debian/tmp" | 37 | tmpdir="$objtree/debian/tmp" |
18 | fwdir="$objtree/debian/fwtmp" | 38 | fwdir="$objtree/debian/fwtmp" |
19 | packagename=linux-$version | 39 | packagename=linux-image-$version |
20 | fwpackagename=linux-firmware-image | 40 | fwpackagename=linux-firmware-image |
21 | 41 | ||
22 | if [ "$ARCH" == "um" ] ; then | 42 | if [ "$ARCH" = "um" ] ; then |
23 | packagename=user-mode-linux-$version | 43 | packagename=user-mode-linux-$version |
24 | fi | 44 | fi |
25 | 45 | ||
26 | # Setup the directory structure | 46 | # Setup the directory structure |
27 | rm -rf "$tmpdir" "$fwdir" | 47 | rm -rf "$tmpdir" "$fwdir" |
28 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" | 48 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" |
29 | mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" | 49 | mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" |
30 | if [ "$ARCH" == "um" ] ; then | 50 | if [ "$ARCH" = "um" ] ; then |
31 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" | 51 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" |
32 | fi | 52 | fi |
33 | 53 | ||
34 | # Build and install the kernel | 54 | # Build and install the kernel |
35 | if [ "$ARCH" == "um" ] ; then | 55 | if [ "$ARCH" = "um" ] ; then |
36 | $MAKE linux | 56 | $MAKE linux |
37 | cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" | 57 | cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" |
38 | cp .config "$tmpdir/usr/share/doc/$packagename/config" | 58 | cp .config "$tmpdir/usr/share/doc/$packagename/config" |
@@ -41,53 +61,100 @@ if [ "$ARCH" == "um" ] ; then | |||
41 | else | 61 | else |
42 | cp System.map "$tmpdir/boot/System.map-$version" | 62 | cp System.map "$tmpdir/boot/System.map-$version" |
43 | cp .config "$tmpdir/boot/config-$version" | 63 | cp .config "$tmpdir/boot/config-$version" |
44 | cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" | 64 | # Not all arches include the boot path in KBUILD_IMAGE |
65 | if ! cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"; then | ||
66 | cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" | ||
67 | fi | ||
45 | fi | 68 | fi |
46 | 69 | ||
47 | if grep -q '^CONFIG_MODULES=y' .config ; then | 70 | if grep -q '^CONFIG_MODULES=y' .config ; then |
48 | INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install | 71 | INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install |
49 | if [ "$ARCH" == "um" ] ; then | 72 | if [ "$ARCH" = "um" ] ; then |
50 | mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" | 73 | mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" |
51 | rmdir "$tmpdir/lib/modules/$version" | 74 | rmdir "$tmpdir/lib/modules/$version" |
52 | fi | 75 | fi |
53 | fi | 76 | fi |
54 | 77 | ||
55 | # Install the maintainer scripts | 78 | # Install the maintainer scripts |
79 | # Note: hook scripts under /etc/kernel are also executed by official Debian | ||
80 | # kernel packages, as well as kernel packages built using make-kpkg | ||
81 | debhookdir=${KDEB_HOOKDIR:-/etc/kernel} | ||
56 | for script in postinst postrm preinst prerm ; do | 82 | for script in postinst postrm preinst prerm ; do |
57 | mkdir -p "$tmpdir/etc/kernel/$script.d" | 83 | mkdir -p "$tmpdir$debhookdir/$script.d" |
58 | cat <<EOF > "$tmpdir/DEBIAN/$script" | 84 | cat <<EOF > "$tmpdir/DEBIAN/$script" |
59 | #!/bin/sh | 85 | #!/bin/sh |
60 | 86 | ||
61 | set -e | 87 | set -e |
62 | 88 | ||
63 | test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d | 89 | # Pass maintainer script parameters to hook scripts |
90 | export DEB_MAINT_PARAMS="\$@" | ||
91 | |||
92 | test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d | ||
64 | exit 0 | 93 | exit 0 |
65 | EOF | 94 | EOF |
66 | chmod 755 "$tmpdir/DEBIAN/$script" | 95 | chmod 755 "$tmpdir/DEBIAN/$script" |
67 | done | 96 | done |
68 | 97 | ||
69 | name="Kernel Compiler <$(id -nu)@$(hostname -f)>" | 98 | # Try to determine maintainer and email values |
99 | if [ -n "$DEBEMAIL" ]; then | ||
100 | email=$DEBEMAIL | ||
101 | elif [ -n "$EMAIL" ]; then | ||
102 | email=$EMAIL | ||
103 | else | ||
104 | email=$(id -nu)@$(hostname -f) | ||
105 | fi | ||
106 | if [ -n "$DEBFULLNAME" ]; then | ||
107 | name=$DEBFULLNAME | ||
108 | elif [ -n "$NAME" ]; then | ||
109 | name=$NAME | ||
110 | else | ||
111 | name="Anonymous" | ||
112 | fi | ||
113 | maintainer="$name <$email>" | ||
114 | |||
70 | # Generate a simple changelog template | 115 | # Generate a simple changelog template |
71 | cat <<EOF > debian/changelog | 116 | cat <<EOF > debian/changelog |
72 | linux ($version-$revision) unstable; urgency=low | 117 | linux-upstream ($packageversion) unstable; urgency=low |
73 | 118 | ||
74 | * A standard release | 119 | * Custom built Linux kernel. |
75 | 120 | ||
76 | -- $name $(date -R) | 121 | -- $maintainer $(date -R) |
77 | EOF | 122 | EOF |
78 | 123 | ||
79 | # Generate a control file | 124 | # Generate copyright file |
80 | if [ "$ARCH" == "um" ]; then | 125 | cat <<EOF > debian/copyright |
126 | This is a packacked upstream version of the Linux kernel. | ||
127 | |||
128 | The sources may be found at most Linux ftp sites, including: | ||
129 | ftp://ftp.kernel.org/pub/linux/kernel | ||
81 | 130 | ||
131 | Copyright: 1991 - 2009 Linus Torvalds and others. | ||
132 | |||
133 | The git repository for mainline kernel development is at: | ||
134 | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git | ||
135 | |||
136 | This program is free software; you can redistribute it and/or modify | ||
137 | it under the terms of the GNU General Public License as published by | ||
138 | the Free Software Foundation; version 2 dated June, 1991. | ||
139 | |||
140 | On Debian GNU/Linux systems, the complete text of the GNU General Public | ||
141 | License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. | ||
142 | EOF | ||
143 | |||
144 | # Generate a control file | ||
82 | cat <<EOF > debian/control | 145 | cat <<EOF > debian/control |
83 | Source: linux | 146 | Source: linux-upstream |
84 | Section: base | 147 | Section: admin |
85 | Priority: optional | 148 | Priority: optional |
86 | Maintainer: $name | 149 | Maintainer: $maintainer |
87 | Standards-Version: 3.6.1 | 150 | Standards-Version: 3.8.1 |
151 | EOF | ||
152 | |||
153 | if [ "$ARCH" = "um" ]; then | ||
154 | cat <<EOF >> debian/control | ||
88 | 155 | ||
89 | Package: $packagename | 156 | Package: $packagename |
90 | Provides: kernel-image-$version, linux-image-$version | 157 | Provides: linux-image, linux-image-2.6, linux-modules-$version |
91 | Architecture: any | 158 | Architecture: any |
92 | Description: User Mode Linux kernel, version $version | 159 | Description: User Mode Linux kernel, version $version |
93 | User-mode Linux is a port of the Linux kernel to its own system call | 160 | User-mode Linux is a port of the Linux kernel to its own system call |
@@ -97,30 +164,22 @@ Description: User Mode Linux kernel, version $version | |||
97 | many other things. | 164 | many other things. |
98 | . | 165 | . |
99 | This package contains the Linux kernel, modules and corresponding other | 166 | This package contains the Linux kernel, modules and corresponding other |
100 | files version $version | 167 | files, version: $version. |
101 | EOF | 168 | EOF |
102 | 169 | ||
103 | else | 170 | else |
104 | cat <<EOF > debian/control | 171 | cat <<EOF >> debian/control |
105 | Source: linux | ||
106 | Section: base | ||
107 | Priority: optional | ||
108 | Maintainer: $name | ||
109 | Standards-Version: 3.6.1 | ||
110 | 172 | ||
111 | Package: $packagename | 173 | Package: $packagename |
112 | Provides: kernel-image-$version, linux-image-$version | 174 | Provides: linux-image, linux-image-2.6, linux-modules-$version |
113 | Suggests: $fwpackagename | 175 | Suggests: $fwpackagename |
114 | Architecture: any | 176 | Architecture: any |
115 | Description: Linux kernel, version $version | 177 | Description: Linux kernel, version $version |
116 | This package contains the Linux kernel, modules and corresponding other | 178 | This package contains the Linux kernel, modules and corresponding other |
117 | files version $version | 179 | files, version: $version. |
118 | EOF | 180 | EOF |
119 | fi | ||
120 | 181 | ||
121 | # Fix some ownership and permissions | 182 | fi |
122 | chown -R root:root "$tmpdir" | ||
123 | chmod -R go-w "$tmpdir" | ||
124 | 183 | ||
125 | # Do we have firmware? Move it out of the way and build it into a package. | 184 | # Do we have firmware? Move it out of the way and build it into a package. |
126 | if [ -e "$tmpdir/lib/firmware" ]; then | 185 | if [ -e "$tmpdir/lib/firmware" ]; then |
@@ -131,16 +190,12 @@ if [ -e "$tmpdir/lib/firmware" ]; then | |||
131 | Package: $fwpackagename | 190 | Package: $fwpackagename |
132 | Architecture: all | 191 | Architecture: all |
133 | Description: Linux kernel firmware, version $version | 192 | Description: Linux kernel firmware, version $version |
134 | This package contains firmware from the Linux kernel, version $version | 193 | This package contains firmware from the Linux kernel, version $version. |
135 | EOF | 194 | EOF |
136 | 195 | ||
137 | dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir" | 196 | create_package "$fwpackagename" "$fwdir" |
138 | dpkg --build "$fwdir" .. | ||
139 | fi | 197 | fi |
140 | 198 | ||
141 | # Perform the final magic | 199 | create_package "$packagename" "$tmpdir" |
142 | dpkg-gencontrol -isp -p$packagename | ||
143 | dpkg --build "$tmpdir" .. | ||
144 | 200 | ||
145 | exit 0 | 201 | exit 0 |
146 | |||