Commit edec611db0474e90503d46428e4f196d5e30c091

Authored by maximilian attems
Committed by Sam Ravnborg
1 parent 9461f666e4

kbuild, deb-pkg: improve maintainer identification

Try harder to find email and maintainer name.
Debian's own devscripts all use DEBEMAIL or DEBFULLNAME prior to an
eventual EMAIL or NAME environment variable. Match their logic.

"Anonymous" sounds nicer then "Kernel Compiler" if no name is found.

Signed-off-by: maximilian attems <max@stro.at>
Signed-off-by: Frans Pop <elendil@planet.nl>
Cc: Andres Salomon <dilinger@debian.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 1 changed file with 19 additions and 3 deletions Inline Diff

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