deb-pkg target improvements
cover deb-pkg target improvements
Here's a new patch series with improvements for the deb-pkg target. It's a compromise that includes both the patches from Maximilian Attems and myself, with some changes because of comments, a few fixes, and further improvements.
The (new) second patch simplifies some of the later patches quite a bit.
Maximilian's patch to add a copyright file turned out to be incomplete: the copyright file did not actually get included in the binary packages. This is fixed in this series.
For patches that are essentially unchanged from Maximilian's earlier set I've left his Signed-of-by. In cases where I made real changes (the copyright patch) I've changed that to myself.
The patch series should still be OK for 2.6.30. I've done a fair bit of testing and in the end the actual impact of the changes is relatively minor.
I still plan to write a doc explaining how the deb-pkg target works if this patch series is accepted.
Maximilian:
This *is* a compromise. I don't expect you to be completely happy (e.g. the source package name), but neither am I (I still feel the script is made more complex than needed for its purpose). I've honestly tried to find a solution that's acceptable to us both.
Cheers,
FJP
Diffstat:
scripts/package/builddeb | 149 +++++++++++++++++++++++++++++++-------------- 1 files changed, 102 insertions(+), 47 deletions(-)
PATCH 1/14 deb-pkg: minor general improvements in builddeb script
Minor coding style improvements and typo fix in leading comment.
scripts/package/builddeb +10 -11
@@ -4,7 +4,7 @@ # Copyright 2003 Wichert Akkerman <[email protected]> # # Simple script to generate a deb package for a Linux kernel. All the -# complexity of what to do with a kernel after it is installer or removed +# complexity of what to do with a kernel after it is installed or removed # is left to other scripts and packages: they can install scripts in the # /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on # package install and removal.
@@ -13,13 +13,13 @@ set -e # Some variables and settings used throughout the script version=$KERNELRELEASE -revision=`cat .version` +revision=$(cat .version) tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" packagename=linux-$version fwpackagename=linux-firmware-image -if [ "$ARCH" == "um" ] ; then +if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux-$version fi
@@ -27,12 +27,12 @@ fi rm -rf "$tmpdir" "$fwdir" mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" -if [ "$ARCH" == "um" ] ; then +if [ "$ARCH" = "um" ] ; then mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" fi # Build and install the kernel -if [ "$ARCH" == "um" ] ; then +if [ "$ARCH" = "um" ] ; then $MAKE linux cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" cp .config "$tmpdir/usr/share/doc/$packagename/config"
@@ -46,7 +46,7 @@ fi if grep -q '^CONFIG_MODULES=y' .config ; then INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install - if [ "$ARCH" == "um" ] ; then + if [ "$ARCH" = "um" ] ; then mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" rmdir "$tmpdir/lib/modules/$version" fi
@@ -77,9 +77,8 @@ linux ($version-$revision) unstable; urgency=low EOF # Generate a control file -if [ "$ARCH" == "um" ]; then - -cat <<EOF > debian/control +if [ "$ARCH" = "um" ]; then + cat <<EOF > debian/control Source: linux Section: base Priority: optional
@@ -101,7 +100,7 @@ Description: User Mode Linux kernel, version $version EOF else -cat <<EOF > debian/control + cat <<EOF > debian/control Source: linux Section: base Priority: optional
@@ -116,6 +115,7 @@ Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other files version $version EOF + fi # Fix some ownership and permissions
@@ -143,4 +143,3 @@ dpkg-gencontrol -isp -p$packagename dpkg --build "$tmpdir" .. exit 0 -
PATCH 2/14 deb-pkg: refactor code to reduce duplication
In reply to Frans PopFactor out code to build package into separate function and only write "source" section for the debian/control file once.
---
Because of this patch some things that needed to be done in two places in later patches in the series now only need to be done once.
scripts/package/builddeb +20 -17
@@ -11,6 +11,18 @@ set -e +create_package() { + local pname="$1" pdir="$2" + + # Fix ownership and permissions + chown -R root:root "$pdir" + chmod -R go-w "$pdir" + + # Create the package + dpkg-gencontrol -isp -p$pname -P"$pdir" + dpkg --build "$pdir" .. +} + # Some variables and settings used throughout the script version=$KERNELRELEASE revision=$(cat .version)
@@ -77,13 +89,16 @@ linux ($version-$revision) unstable; urgency=low EOF # Generate a control file -if [ "$ARCH" = "um" ]; then - cat <<EOF > debian/control +cat <<EOF > debian/control Source: linux Section: base Priority: optional Maintainer: $name Standards-Version: 3.6.1 +EOF + +if [ "$ARCH" = "um" ]; then + cat <<EOF >> debian/control Package: $packagename Provides: kernel-image-$version, linux-image-$version
@@ -100,12 +115,7 @@ Description: User Mode Linux kernel, version $version EOF else - cat <<EOF > debian/control -Source: linux -Section: base -Priority: optional -Maintainer: $name -Standards-Version: 3.6.1 + cat <<EOF >> debian/control Package: $packagename Provides: kernel-image-$version, linux-image-$version
@@ -118,10 +128,6 @@ EOF fi -# Fix some ownership and permissions -chown -R root:root "$tmpdir" -chmod -R go-w "$tmpdir" - # Do we have firmware? Move it out of the way and build it into a package. if [ -e "$tmpdir/lib/firmware" ]; then mv "$tmpdir/lib/firmware" "$fwdir/lib/"
@@ -134,12 +140,9 @@ Description: Linux kernel firmware, version $version This package contains firmware from the Linux kernel, version $version EOF - dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir" - dpkg --build "$fwdir" .. + create_package "$fwpackagename" "$fwdir" fi -# Perform the final magic -dpkg-gencontrol -isp -p$packagename -dpkg --build "$tmpdir" .. +create_package "$packagename" "$tmpdir" exit 0
PATCH 3/14 deb-pkg: fix 'file not found' error when building .deb package for arm
In reply to Frans PopNot all architectures prepend the $(boot) path in $(KBUILD_IMAGE). Allow for that fact in the builddeb script. Example is arm.
scripts/package/builddeb +4 -1
@@ -53,7 +53,10 @@ if [ "$ARCH" = "um" ] ; then else cp System.map "$tmpdir/boot/System.map-$version" cp .config "$tmpdir/boot/config-$version" - cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" + # Not all arches include the boot path in KBUILD_IMAGE + if ! cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"; then + cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" + fi fi if grep -q '^CONFIG_MODULES=y' .config ; then
PATCH 4/14 deb-pkg: pass Debian maintainer script parameters to packaging hook scripts
In reply to Frans PopThe Debian packaging scripts created by the deb-pkg target do not pass on the standard Debian maintainer script parameters to hook scripts, which means that those scripts cannot tell whether they are being called during e.g. install vs. upgrade, or removal vs. purge of the package.
As there are several variantions in how hook scripts are called from kernel packages, we pass the parameters in the environment variable DEB_MAINT_PARAMS rather than as extra arguments.
Bump version of builddep script to 1.3.
scripts/package/builddeb +4 -1
@@ -1,6 +1,6 @@ #!/bin/sh # -# builddeb 1.2 +# builddeb 1.3 # Copyright 2003 Wichert Akkerman <[email protected]> # # Simple script to generate a deb package for a Linux kernel. All the
@@ -75,6 +75,9 @@ for script in postinst postrm preinst prerm ; do set -e +# Pass maintainer script parameters to hook scripts +export DEB_MAINT_PARAMS="\$@" + test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d exit 0 EOF
PATCH 5/14 deb-pkg: allow to specify a custom revision for .deb packages
In reply to Frans PopAllow to specify a custom revision for the generated .deb by exporting the environment variable KDEB_PKGVERSION.
scripts/package/builddeb +6 -1
@@ -26,6 +26,11 @@ create_package() { # Some variables and settings used throughout the script version=$KERNELRELEASE revision=$(cat .version) +if [ -n "$KDEB_PKGVERSION" ]; then + packageversion=$KDEB_PKGVERSION +else + packageversion=$version-$revision +fi tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" packagename=linux-$version
@@ -87,7 +92,7 @@ done name="Kernel Compiler <$(id -nu)@$(hostname -f)>" # Generate a simple changelog template cat <<EOF > debian/changelog -linux ($version-$revision) unstable; urgency=low +linux ($packageversion) unstable; urgency=low * A standard release
PATCH 6/14 deb-pkg: allow alternative hook scripts directory in .deb packages
In reply to Frans PopHook scripts in the default directory /etc/kernel are also executed by official Debian kernel packages as well as kernel packages created using make-kpkg. Allow to specify an alternative hook scripts directory by exporting the environment variable KDEB_HOOKDIR.
scripts/package/builddeb +8 -4
@@ -6,8 +6,9 @@ # Simple script to generate a deb package for a Linux kernel. All the # complexity of what to do with a kernel after it is installed or removed # is left to other scripts and packages: they can install scripts in the -# /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on -# package install and removal. +# /etc/kernel/{pre,post}{inst,rm}.d/ directories (or an alternative location +# specified in KDEB_HOOKDIR) that will be called on package install and +# removal. set -e
@@ -73,8 +74,11 @@ if grep -q '^CONFIG_MODULES=y' .config ; then fi # Install the maintainer scripts +# Note: hook scripts under /etc/kernel are also executed by official Debian +# kernel packages, as well as kernel packages built using make-kpkg +debhookdir=${KDEB_HOOKDIR:-/etc/kernel} for script in postinst postrm preinst prerm ; do - mkdir -p "$tmpdir/etc/kernel/$script.d" + mkdir -p "$tmpdir$debhookdir/$script.d" cat <<EOF > "$tmpdir/DEBIAN/$script" #!/bin/sh
@@ -83,7 +87,7 @@ set -e # Pass maintainer script parameters to hook scripts export DEB_MAINT_PARAMS="\$@" -test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d +test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d exit 0 EOF chmod 755 "$tmpdir/DEBIAN/$script"
PATCH 7/14 dep-pkg: improve changelog entry and package descriptions
In reply to Frans Popscripts/package/builddeb +4 -4
@@ -98,7 +98,7 @@ name="Kernel Compiler <$(id -nu)@$(hostname -f)>" cat <<EOF > debian/changelog linux ($packageversion) unstable; urgency=low - * A standard release + * Custom built Linux kernel. -- $name $(date -R) EOF
@@ -126,7 +126,7 @@ Description: User Mode Linux kernel, version $version many other things. . This package contains the Linux kernel, modules and corresponding other - files version $version + files, version: $version. EOF else
@@ -138,7 +138,7 @@ Suggests: $fwpackagename Architecture: any Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other - files version $version + files, version: $version. EOF fi
@@ -152,7 +152,7 @@ if [ -e "$tmpdir/lib/firmware" ]; then Package: $fwpackagename Architecture: all Description: Linux kernel firmware, version $version - This package contains firmware from the Linux kernel, version $version + This package contains firmware from the Linux kernel, version $version. EOF create_package "$fwpackagename" "$fwdir"
PATCH 8/14 deb-pkg: generate debian/copyright file
In reply to Frans PopAdd a basic debian/copyright to the binary packages.
Based on an earlier patch from Maximilian Attems.
---
Original patch did not actually include the copyright file in the binary package. I've also made minor changes in the text of the copyright file.
scripts/package/builddeb +25 -3
@@ -15,6 +15,8 @@ set -e create_package() { local pname="$1" pdir="$2" + cp debian/copyright "$pdir/usr/share/doc/$pname/" + # Fix ownership and permissions chown -R root:root "$pdir" chmod -R go-w "$pdir"
@@ -43,10 +45,10 @@ fi # Setup the directory structure rm -rf "$tmpdir" "$fwdir" -mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" -mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" +mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" +mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" if [ "$ARCH" = "um" ] ; then - mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" + mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" fi # Build and install the kernel
@@ -103,6 +105,26 @@ linux ($packageversion) unstable; urgency=low -- $name $(date -R) EOF +# Generate copyright file +cat <<EOF > debian/copyright +This is a packacked upstream version of the Linux kernel. + +The sources may be found at most Linux ftp sites, including: +ftp://ftp.kernel.org/pub/linux/kernel + +Copyright: 1991 - 2009 Linus Torvalds and others. + +The git repository for mainline kernel development is at: +git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. +EOF + # Generate a control file cat <<EOF > debian/control Source: linux
Re: [PATCH 8/14 v2] deb-pkg: generate debian/copyright file
On Thursday 23 April 2009, Frans Pop wrote:
Add a basic debian/copyright to the binary packages.
Based on an earlier patch from Maximilian Attems.
---
Resending as previous version had a trailing space in one line.
scripts/package/builddeb +25 -3
@@ -15,6 +15,8 @@ set -e create_package() { local pname="$1" pdir="$2" + cp debian/copyright "$pdir/usr/share/doc/$pname/" + # Fix ownership and permissions chown -R root:root "$pdir" chmod -R go-w "$pdir"
@@ -43,10 +45,10 @@ fi # Setup the directory structure rm -rf "$tmpdir" "$fwdir" -mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" -mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" +mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" +mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" if [ "$ARCH" = "um" ] ; then - mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" + mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" fi # Build and install the kernel
@@ -103,6 +105,26 @@ linux ($packageversion) unstable; urgency=low -- $name $(date -R) EOF +# Generate copyright file +cat <<EOF > debian/copyright +This is a packacked upstream version of the Linux kernel. + +The sources may be found at most Linux ftp sites, including: +ftp://ftp.kernel.org/pub/linux/kernel + +Copyright: 1991 - 2009 Linus Torvalds and others. + +The git repository for mainline kernel development is at: +git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. +EOF + # Generate a control file cat <<EOF > debian/control Source: linux
PATCH 9/14 deb-pkg: improve maintainer identification
In reply to Frans PopFrom: maximilian attems <[email protected]>
Subject: 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.
---
I've removed some unnecessary braces. Also, "Anonymous Maintainer" seemed somewhat redundant to me; just "Anonymous" should do.
scripts/package/builddeb +19 -3
@@ -95,14 +95,30 @@ EOF chmod 755 "$tmpdir/DEBIAN/$script" done -name="Kernel Compiler <$(id -nu)@$(hostname -f)>" +# Try to determine maintainer and email values +if [ -n "$DEBEMAIL" ]; then + email=$DEBEMAIL +elif [ -n "$EMAIL" ]; then + email=$EMAIL +else + email=$(id -nu)@$(hostname -f) +fi +if [ -n "$DEBFULLNAME" ]; then + name=$DEBFULLNAME +elif [ -n "$NAME" ]; then + name=$NAME +else + name="Anonymous" +fi +maintainer="$name <$email>" + # Generate a simple changelog template cat <<EOF > debian/changelog linux ($packageversion) unstable; urgency=low * Custom built Linux kernel. - -- $name $(date -R) + -- $maintainer $(date -R) EOF # Generate copyright file
@@ -130,7 +146,7 @@ cat <<EOF > debian/control Source: linux Section: base Priority: optional -Maintainer: $name +Maintainer: $maintainer Standards-Version: 3.6.1 EOF
PATCH 10/14 deb-pkg: improve Source field
In reply to Frans PopThe Source: field is defined as the source package in the package archive from which a binary packages are built. As deb-pkg does not generate a source package, we should avoid to use any existing source packages here.
---
I still have strong objections to "linux-2.6".
IMO "linux-upstream" is a good compromise: it's clear and avoids both Debian's "linux-2.6" and Ubuntu's "linux".
scripts/package/builddeb +2 -2
@@ -114,7 +114,7 @@ maintainer="$name <$email>" # Generate a simple changelog template cat <<EOF > debian/changelog -linux ($packageversion) unstable; urgency=low +linux-upstream ($packageversion) unstable; urgency=low * Custom built Linux kernel.
@@ -143,7 +143,7 @@ EOF # Generate a control file cat <<EOF > debian/control -Source: linux +Source: linux-upstream Section: base Priority: optional Maintainer: $maintainer
PATCH 11/14 deb-pkg: fix generated package name
In reply to Frans PopFrom: maximilian attems <[email protected]>
Subject: deb-pkg: fix generated package name
The binary package that make deb-pkg creates is a linux-image. To be fixed may also be the addition of $DEB_ARCH.
scripts/package/builddeb +1 -1
@@ -36,7 +36,7 @@ else fi tmpdir="$objtree/debian/tmp" fwdir="$objtree/debian/fwtmp" -packagename=linux-$version +packagename=linux-image-$version fwpackagename=linux-firmware-image if [ "$ARCH" = "um" ] ; then
PATCH 12/14 deb-pkg: fix Provides field
In reply to Frans PopFrom: maximilian attems <[email protected]>
Subject: deb-pkg: fix Provides field
kernel-image naming has been dropped for the Lenny release and was only transitional for Etch.
As it builds modules it provides linux-modules-$version.
scripts/package/builddeb +2 -2
@@ -154,7 +154,7 @@ if [ "$ARCH" = "um" ]; then cat <<EOF >> debian/control Package: $packagename -Provides: kernel-image-$version, linux-image-$version +Provides: linux-image, linux-image-2.6, linux-modules-$version Architecture: any Description: User Mode Linux kernel, version $version User-mode Linux is a port of the Linux kernel to its own system call
@@ -171,7 +171,7 @@ else cat <<EOF >> debian/control Package: $packagename -Provides: kernel-image-$version, linux-image-$version +Provides: linux-image, linux-image-2.6, linux-modules-$version Suggests: $fwpackagename Architecture: any Description: Linux kernel, version $version
PATCH 13/14 deb-pkg: fix Section field
In reply to Frans PopFrom: maximilian attems <[email protected]>
Subject: deb-pkg: fix Section field
Section "base" has been removed, the base is defined by Priority field.
For Squeeze the section should be "kernel", but as that's not yet supported for Sarge and Etch we stay with admin for now.
scripts/package/builddeb +1 -1
@@ -144,7 +144,7 @@ EOF # Generate a control file cat <<EOF > debian/control Source: linux-upstream -Section: base +Section: admin Priority: optional Maintainer: $maintainer Standards-Version: 3.6.1
PATCH 14/14 deb-pkg: bump standards version
In reply to Frans PopFrom: maximilian attems <[email protected]>
Subject: deb-pkg: bump standards version
Latest Debian policy is 3.8.1.
Even if we are not yet compliant to it strive for the latest.
scripts/package/builddeb +1 -1
@@ -147,7 +147,7 @@ Source: linux-upstream Section: admin Priority: optional Maintainer: $maintainer -Standards-Version: 3.6.1 +Standards-Version: 3.8.1 EOF if [ "$ARCH" = "um" ]; then
Quoted 5 lines · Frans Pop
Here's a new patch series with improvements for the deb-pkg target. It's a compromise that includes both the patches from Maximilian Attems and myself, with some changes because of comments, a few fixes, and further improvements.
The (new) second patch simplifies some of the later patches quite a bit.
great!
been currently overworked in coorganising this physics workshop [1]. so had no time to respin all of this.
reviewed and the hole patch serie has an
thanks for taking care of it.
Quoted 6 lines · maximilian attems
Quoted 4 lines · Frans Pop
Here's a new patch series with improvements for the deb-pkg target. It's a compromise that includes both the patches from Maximilian Attems and myself, with some changes because of comments, a few fixes, and further improvements.
Quoted 8 lines
Quoted 1 line
The (new) second patch simplifies some of the later patches quite a bit.
great!
been currently overworked in coorganising this physics workshop [1]. so had no time to respin all of this.reviewed and the hole patch serie has an
Applied the full serie with maximilliam's ack.
Thanks for fixing this!
It is applied to kbuild-next so it will show up in .32.
Sam
Quoted 2 lines · Sam Ravnborg
Applied the full serie with maximilliam's ack.
Thanks for fixing this!
thanks for the merge!
Quoted 3 lines
It is applied to kbuild-next so it will show up in .32.
Sam
hmm why .32 and not upcoming .31, seems early enough for that cycle? also you seem to have not pushed out, failed to see the patches in linux-next as of 20090504
Quoted 7 lines · maximilian attems
Quoted 2 lines · Sam Ravnborg
Applied the full serie with maximilliam's ack.
Thanks for fixing this!thanks for the merge!
Quoted 7 lines
Quoted 3 lines
It is applied to kbuild-next so it will show up in .32.
Sam
hmm why .32 and not upcoming .31, seems early enough for that cycle? also you seem to have not pushed out, failed to see the patches in linux-next as of 20090504
I meant .31 - and you are right that I had not pushed out. Done now so soon in -next.
Sam
Quoted 4 lines · Sam Ravnborg
I meant .31 - and you are right that I had not pushed out. Done now so soon in -next.
Sam
cool, landed. thanks :)
Signature · 1 line
maks