kbuild make deb patch
I originally posted this before 2.6.0 was out and was told to wait until things have stabilized a bit. At least from my point of view that has happened by now so I'm bringing this one up again.
kbuild has had a rpm make target for some time now. Since the concept of kernel packages is quite convenient I added a deb target as well, using the patch below.
Since I'm (still) not familiar with kbuild Makefile bits are quite rough, but they Work For Me(Tm).
Wichert.
scripts/builddeb +82 -0
@@ -0,0 +1,82 @@ +#!/bin/sh +# +# builddeb 1.2 +# Copyright 2003,2004 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 +# 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. + +set -e + +# Some variables and settings used throughout the script +version="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" +tmpdir="$(pwd)/debian/tmp" + +# Setup the directory structure +rm -rf "$tmpdir" +mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" + +# Build and install the kernel +cp System.map "$tmpdir/boot/System.map-$version" +cp .config "$tmpdir/boot/config-$version" +if $(arch | grep -q i.86) ; then + cp arch/i386/boot/bzImage "$tmpdir/boot/vmlinuz-$version" +else + cp vmlinux "$tmpdir/boot/vmlinuz-$version" +fi +if grep -q '^CONFIG_MODULES=y' .config ; then + INSTALL_MOD_PATH="$tmpdir" make modules_install +fi + +# Install the maintainer scripts +for script in postinst postrm preinst prerm ; do + mkdir -p "$tmpdir/etc/kernel/$script.d" + cat <<EOF > "$tmpdir/DEBIAN/$script" +#!/bin/sh + +set -e + +test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d +exit 0 +EOF + chmod 755 "$tmpdir/DEBIAN/$script" +done + +name="Kernel Compiler <$(id -nu)@$(hostname -f)>" +# Generate a simple changelog template +cat <<EOF > debian/changelog +linux ($version) unstable; urgency=low + + * A standard release + + -- $name $(date -R) +EOF + +# Generate a control file +cat <<EOF > debian/control +Source: linux +Section: base +Priority: optional +Maintainer: $name +Standards-Version: 3.6.1 + +Package: linux-$version +Architecture: any +Description: Linux kernel, version $version + This package contains the Linux kernel, modules and corresponding other + files version $version. +EOF + +# Fix some ownership and permissions +chown -R root:root "$tmpdir" +chmod -R go-w "$tmpdir" + +# Perform the final magic +dpkg-gencontrol -isp +dpkg --build "$tmpdir" .. + +exit 0 +
Makefile +85 -18
124 lines not on this page · raw message
Signature · 2 lines
Wichert Akkerman <[email protected]> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
Quoted 3 lines · Wichert Akkerman
kbuild has had a rpm make target for some time now. Since the concept of kernel packages is quite convenient I added a deb target as well,
Why this and not the make-kpkg utility in Debian's kernel-package package?
David Vrabel
Signature · 4 lines
David Vrabel, Design Engineer Arcom, Clifton Road Tel: +44 (0)1223 411200 ext. 3233 Cambridge CB1 7EA, UK Web: http://www.arcom.com/
Quoted 1 line · Previously David Vrabel
Why this and not the make-kpkg utility in Debian's kernel-package package?
Several reasons:
a) it works on non-Debian systems which use dpkg
b) it is a *lot* simpler and faster than make-kpkg
Wichert.
Signature · 2 lines
Wichert Akkerman <[email protected]> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
Quoted 3 lines · Wichert Akkerman
kbuild has had a rpm make target for some time now. Since the concept of kernel packages is quite convenient I added a deb target as well, using the patch below.
I like the idea a lot, but your patch to the makefile touches quite a few things in the clean target that AFAICT are not related to the deb target in any way. Perhaps you are diffing from an older tree?
Signature · 1 line
Ciao, Flavio
Quoted 3 lines · Previously Flavio Stanchina
I like the idea a lot, but your patch to the makefile touches quite a few things in the clean target that AFAICT are not related to the deb target in any way. Perhaps you are diffing from an older tree?
Ah, hmm, good catch. Looks like I dropped a bit of a patch at some point due to a reject and forgot to clean that up. So lets try that again:
scripts/builddeb +82 -0
@@ -0,0 +1,82 @@ +#!/bin/sh +# +# builddeb 1.2 +# Copyright 2003,2004 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 +# 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. + +set -e + +# Some variables and settings used throughout the script +version="$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION" +tmpdir="$(pwd)/debian/tmp" + +# Setup the directory structure +rm -rf "$tmpdir" +mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" + +# Build and install the kernel +cp System.map "$tmpdir/boot/System.map-$version" +cp .config "$tmpdir/boot/config-$version" +if $(arch | grep -q i.86) ; then + cp arch/i386/boot/bzImage "$tmpdir/boot/vmlinuz-$version" +else + cp vmlinux "$tmpdir/boot/vmlinuz-$version" +fi +if grep -q '^CONFIG_MODULES=y' .config ; then + INSTALL_MOD_PATH="$tmpdir" make modules_install +fi + +# Install the maintainer scripts +for script in postinst postrm preinst prerm ; do + mkdir -p "$tmpdir/etc/kernel/$script.d" + cat <<EOF > "$tmpdir/DEBIAN/$script" +#!/bin/sh + +set -e + +test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d +exit 0 +EOF + chmod 755 "$tmpdir/DEBIAN/$script" +done + +name="Kernel Compiler <$(id -nu)@$(hostname -f)>" +# Generate a simple changelog template +cat <<EOF > debian/changelog +linux ($version) unstable; urgency=low + + * A standard release + + -- $name $(date -R) +EOF + +# Generate a control file +cat <<EOF > debian/control +Source: linux +Section: base +Priority: optional +Maintainer: $name +Standards-Version: 3.6.1 + +Package: linux-$version +Architecture: any +Description: Linux kernel, version $version + This package contains the Linux kernel, modules and corresponding other + files version $version. +EOF + +# Fix some ownership and permissions +chown -R root:root "$tmpdir" +chmod -R go-w "$tmpdir" + +# Perform the final magic +dpkg-gencontrol -isp +dpkg --build "$tmpdir" .. + +exit 0 +
Makefile +15 -1
@@ -814,7 +814,7 @@ $(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) -clean: archclean $(clean-dirs) +clean: archclean debclean $(clean-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \
@@ -848,6 +848,20 @@ -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ -type f -print | xargs rm -f +# DEB target +# --------------------------------------------------------------------------- + +.PHONY: deb debclean + +debclean: + rm -rf debian/tmp + rm -f debian/changelog debian/control debian/files + -rmdir debian + +deb: all + @echo ' Creating kernel deb package' + @$(srctree)/scripts/builddeb + # RPM target # ---------------------------------------------------------------------------
Signature · 2 lines
Wichert Akkerman <[email protected]> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
Quoted 10 lines · Wichert Akkerman
I originally posted this before 2.6.0 was out and was told to wait until things have stabilized a bit. At least from my point of view that has happened by now so I'm bringing this one up again.
kbuild has had a rpm make target for some time now. Since the concept of kernel packages is quite convenient I added a deb target as well, using the patch below.
Since I'm (still) not familiar with kbuild
Makefilebits are quite rough, but they Work For Me(Tm).
I'm in progress of doing some infrastructure work to better support building different packages. I have requests for .tar.gz, tar.gz2 as well as deb.
I hope to post a few patches later this week.
I will include your script in the patch-set then.
Sam
On Tue, 2004-06-08 23:08:46 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:
Quoted 4 lines · Wichert Akkerman
I'm in progress of doing some infrastructure work to better support building different packages. I have requests for .tar.gz, tar.gz2 as well as deb.
(Being a Debian user...) I really *love* to see a .tar.{gz,bz2} target. For my in-house use (as well in in the company I work for) we do have a script to basically install modules (+ vmlinuz + vmlinux + .config + System.map), adding some identifier to the filenames (of the last four files mentioned) and preparing a .tar.gz from that.
For my private use, my version of the script also handles some non-ia32 archs :)
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] . +49-172-7608481 "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
Quoted 7 lines · Jan-Benedict Glaw
On Tue, 2004-06-08 23:08:46 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:
Quoted 4 lines · Wichert Akkerman
I'm in progress of doing some infrastructure work to better support building different packages. I have requests for .tar.gz, tar.gz2 as well as deb.
Quoted 5 lines
(Being a Debian user...) I really *love* to see a .tar.{gz,bz2} target. For my in-house use (as well in in the company I work for) we do have a script to basically install modules (+ vmlinuz + vmlinux + .config + System.map), adding some identifier to the filenames (of the last four files mentioned) and preparing a .tar.gz from that.
Could you try to be more specific in what you expect to see in a .tar.gz'ed kernel. A script that creates a .tar.gz from current kernel would be fine :-)
I expect something like:
All files stored in a directory named: kernel-2.6.6-rc4/ Includes all source files
Includes .config
Do you expect to see a fully build kernel?
- With all .o files
- With the output file (bzImage or whatever used by selected architecture)
Anything else?
Sam
On Sun, 2004-06-13 08:19:57 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:
Quoted 8 lines · Jan-Benedict Glaw
Quoted 7 lines
On Tue, 2004-06-08 23:08:46 +0200, Sam Ravnborg <[email protected]> wrote in message <[email protected]>:
Quoted 4 lines · Wichert Akkerman
I'm in progress of doing some infrastructure work to better support building different packages. I have requests for .tar.gz, tar.gz2 as well as deb.
Quoted 8 lines
Quoted 5 lines
(Being a Debian user...) I really *love* to see a .tar.{gz,bz2} target. For my in-house use (as well in in the company I work for) we do have a script to basically install modules (+ vmlinuz + vmlinux + .config + System.map), adding some identifier to the filenames (of the last four files mentioned) and preparing a .tar.gz from that.
Could you try to be more specific in what you expect to see in a .tar.gz'ed kernel. A script that creates a .tar.gz from current kernel would be fine :-)
I'd expect something that you can extract with:
~# cd /
/# tar xzf /path/to/kernel.tar.gz --no-same-owner
That tar file should contain:
./boot/vmlinux-<version> # unstripped vmlinux file for debugging
./boot/vmlinuz-<version> # bootable file - non-i386 archs obviously
# need different files ./boot/System.map-<version> # Map file for 'ps' and for me ./boot/config-<version> # To recreate the kernel ./boot/patch-<version> # Only if it was requested at .tar.gz # build time, containing a -Nurp style # diff to a clean source tree (which # needs to be specified then) ./lib/modules/<kversion>/* # Modules
The tricky part is the <version> and/or <kversion> part. For my personal use, version is like kversion, but extended with whatever the user specified. kversion is Makefile's $(KERNELRELEASE).
As I stated, it's clumsy at ./lib/modules/<kversion>/*, because you'll probably overwrite other modules of the same kernel version with a different(ly compiled) .tar.gz . The tarball's name should exactly contain <version> in it's name so that a script that extracts is can place a proper symlink within ./boot easily.
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] . +49-172-7608481 "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));