Skip to contentSkip to conversation

kbuild: create linux-headers package in deb-pkg

PATCH In review Theodore Ts'o 4 participants 7 messages Dec 25, 2010 – Jan 18, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: create linux-headers package in deb-pkg

Create a linux-headers-$KVER.deb package which can be used to build external modules without having the source tree around.

---
 scripts/package/builddeb |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
scripts/package/builddeb +27 -1
index 49b74e1..cb5b29d 100644
@@ -40,15 +40,17 @@ else
 fi
 tmpdir="$objtree/debian/tmp"
 fwdir="$objtree/debian/fwtmp"
+hdrdir="$objtree/debian/hdrtmp"
 packagename=linux-image-$version
 fwpackagename=linux-firmware-image
+hdrpackagename=linux-headers-$version
 
 if [ "$ARCH" = "um" ] ; then
 	packagename=user-mode-linux-$version
 fi
 
 # Setup the directory structure
-rm -rf "$tmpdir" "$fwdir"
+rm -rf "$tmpdir" "$fwdir" "$hdrdir"
 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
@@ -188,6 +190,30 @@ EOF
 
 fi
 
+# Build header package
+find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$
+find arch/x86/include include scripts -type f >> /tmp/files$$
+(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$)
+destdir=$hdrdir/usr/src/linux-headers-$version
+mkdir -p "$destdir" "$hdrdir/DEBIAN" "$hdrdir/usr/share/doc/$hdrpackagename"
+tar -c -f - -T /tmp/files$$ | (cd $destdir; tar -xf -)
+(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
+rm -f /tmp/files$$ /tmp/objfiles$$
+arch=$(dpkg --print-architecture)
+
+cat <<EOF >> debian/control
+
+Package: $hdrpackagename
+Provides: linux-headers, linux-headers-2.6
+Architecture: $arch
+Description: Linux kernel headers for $KERNELRELEASE on $arch
+ This package provides kernel header files for $KERNELRELEASE on $arch
+ .
+ This is useful for people who need to build external modules
+EOF
+
+create_package "$hdrpackagename" "$hdrdir"
+
 # 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/"
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 2 lines · Theodore Ts'o

Create a linux-headers-$KVER.deb package which can be used to build external modules without having the source tree around.

thanks that's great.

fjp had back a year ago asked for a bindeb-pkg once we add more things to deb-pkg. I had submitted linux-libc-dev built out of deb-pkg
http://marc.info/?l=linux-kbuild&m=125737390700914&w=2

It's an orthogonal issue, but just to clear it up.

Signature · 1 line
maks
Quoted 30 lines
---
 scripts/package/builddeb |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
scripts/package/builddeb +3 -1
index 49b74e1..cb5b29d 100644
@@ -40,15 +40,17 @@ else
 fi
 tmpdir="$objtree/debian/tmp"
 fwdir="$objtree/debian/fwtmp"
+hdrdir="$objtree/debian/hdrtmp"
 packagename=linux-image-$version
 fwpackagename=linux-firmware-image
+hdrpackagename=linux-headers-$version
 
 if [ "$ARCH" = "um" ] ; then
 	packagename=user-mode-linux-$version
 fi
 
 # Setup the directory structure
-rm -rf "$tmpdir" "$fwdir"
+rm -rf "$tmpdir" "$fwdir" "$hdrdir"
 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

scripts/package/builddeb EOF · line 195

Quoted 6 lines
scripts/package/builddeb +3 -0
@@ -188,6 +190,30 @@ EOF
 
 fi
 
+# Build header package
+find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$
+find arch/x86/include include scripts -type f >> /tmp/files$$

x86 centric?

scripts/package/builddeb EOF · line 198

Quoted 3 lines
scripts/package/builddeb +3 -0
+(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$)
+destdir=$hdrdir/usr/src/linux-headers-$version
+mkdir -p "$destdir" "$hdrdir/DEBIAN" "$hdrdir/usr/share/doc/$hdrpackagename"

could move up to the other mkdir calls.

scripts/package/builddeb EOF · line 208

Quoted 10 lines
scripts/package/builddeb +10 -0
+tar -c -f - -T /tmp/files$$ | (cd $destdir; tar -xf -)
+(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
+rm -f /tmp/files$$ /tmp/objfiles$$
+arch=$(dpkg --print-architecture)
+
+cat <<EOF >> debian/control
+
+Package: $hdrpackagename
+Provides: linux-headers, linux-headers-2.6
+Architecture: $arch

not sure if that will interfere with the new crosscompile feature of deb-pkg in linux-next.

Quoted 11 lines
scripts/package/builddeb +8 -0
+Description: Linux kernel headers for $KERNELRELEASE on $arch
+ This package provides kernel header files for $KERNELRELEASE on $arch
+ .
+ This is useful for people who need to build external modules
+EOF
+
+create_package "$hdrpackagename" "$hdrdir"
+
 # 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/"
#2 lore raw
Quoted 3 lines · maximilian attems
Quoted 2 lines · Theodore Ts'o

Create a linux-headers-$KVER.deb package which can be used to build external modules without having the source tree around.

Thanks, applied to kbuild-2.6.git#packaging.

Quoted 5 lines

fjp had back a year ago asked for a bindeb-pkg once we add more things to deb-pkg. I had submitted linux-libc-dev built out of deb-pkg
http://marc.info/?l=linux-kbuild&m=125737390700914&w=2

It's an orthogonal issue, but just to clear it up.

Can you repost it? It seems I missed it when I was taking over kbuild from Sam last year.

Michal

#3 lore raw
In reply to maximilian attems

Seems review went unnoticed, due to using signature.

Quoted 4 lines · maximilian attems

scripts/package/builddeb EOF · line 195

Quoted 3 lines
scripts/package/builddeb +3 -0
+# Build header package
+find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$
+find arch/x86/include include scripts -type f >> /tmp/files$$

x86 centric?

this will break on any non x86 arch, what is the correct variable for $ARCH?

Quoted 4 lines

scripts/package/builddeb EOF · line 198

Quoted 3 lines
scripts/package/builddeb +3 -0
+(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$)
+destdir=$hdrdir/usr/src/linux-headers-$version
+mkdir -p "$destdir" "$hdrdir/DEBIAN" "$hdrdir/usr/share/doc/$hdrpackagename"

could move up to the other mkdir calls.

we did that already.

Quoted 4 lines
Quoted 4 lines
scripts/package/builddeb +4 -0
+tar -c -f - -T /tmp/files$$ | (cd $destdir; tar -xf -)
+(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
+rm -f /tmp/files$$ /tmp/objfiles$$
+arch=$(dpkg --print-architecture)
Quoted 8 lines

scripts/package/builddeb EOF · line 208

Quoted 6 lines
scripts/package/builddeb +6 -0
+
+cat <<EOF >> debian/control
+
+Package: $hdrpackagename
+Provides: linux-headers, linux-headers-2.6
+Architecture: $arch

not sure if that will interfere with the new crosscompile feature of deb-pkg in linux-next.

aboves arch call seems redundant with what we already have.

Quoted 11 lines
Quoted 11 lines
scripts/package/builddeb +8 -0
+Description: Linux kernel headers for $KERNELRELEASE on $arch
+ This package provides kernel header files for $KERNELRELEASE on $arch
+ .
+ This is useful for people who need to build external modules
+EOF
+
+create_package "$hdrpackagename" "$hdrdir"
+
 # 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/"
Signature · 1 line
maks
#4 lore raw
Quoted 1 line · maximilian attems

Seems review went unnoticed, due to using signature.

Oh, indeed, I thought that was just full-quote in your email, sorry.

Quoted 8 lines · maximilian attems
Quoted 4 lines

scripts/package/builddeb EOF · line 195

Quoted 3 lines
scripts/package/builddeb +3 -0
+# Build header package
+find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$
+find arch/x86/include include scripts -type f >> /tmp/files$$

x86 centric?

this will break on any non x86 arch, what is the correct variable for $ARCH?

This should be changed to arch/$SRCARCH/include.

Quoted 20 lines
Quoted 4 lines

scripts/package/builddeb EOF · line 198

Quoted 3 lines
scripts/package/builddeb +3 -0
+(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$)
+destdir=$hdrdir/usr/src/linux-headers-$version
+mkdir -p "$destdir" "$hdrdir/DEBIAN" "$hdrdir/usr/share/doc/$hdrpackagename"

could move up to the other mkdir calls.

we did that already.

Quoted 4 lines
Quoted 4 lines
scripts/package/builddeb +4 -0
+tar -c -f - -T /tmp/files$$ | (cd $destdir; tar -xf -)
+(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
+rm -f /tmp/files$$ /tmp/objfiles$$
+arch=$(dpkg --print-architecture)
Quoted 8 lines

scripts/package/builddeb EOF · line 208

Quoted 6 lines
scripts/package/builddeb +6 -0
+
+cat <<EOF >> debian/control
+
+Package: $hdrpackagename
+Provides: linux-headers, linux-headers-2.6
+Architecture: $arch

not sure if that will interfere with the new crosscompile feature of deb-pkg in linux-next.

Quoted 1 line

aboves arch call seems redundant with what we already have.

Yes, please remove it. BTW, here is a bugreport I got privately about the very same issue:
On 12.1.2011 10:02, Ralf Rösch wrote:

| [...]
| Attached you will find a patch to complete the build successfully for my
| mipsel target.
| The dpkg --print-architecture shows i386 which results in error:
| dpkg-gencontrol: Fehler: aktuelle Host-Architektur »mipsel« erscheint
| nicht in der Architekturliste (i386) des Pakets
| (current host architecture 'mipsel' does not appear in package's list
i386)
| so I changed "arch" temporary to "any".
|
| It would be nice if it would be possible to make the kernel-headers
| installable on any host.
| They are needed very frequently for cross-compiling. (I already possible
| with dpkg force).

Michal

#5 lore raw
Quoted 9 lines · Michal Marek
Quoted 6 lines · maximilian attems
Quoted 3 lines

scripts/package/builddeb EOF · line 195

Quoted 2 lines
scripts/package/builddeb +2 -0
+find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$
+find arch/x86/include include scripts -type f >> /tmp/files$$

x86 centric?

this will break on any non x86 arch, what is the correct variable for $ARCH?

This should be changed to arch/$SRCARCH/include.

thanks for the pointer, sent patch, that was the easy part.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

scripts/package/builddeb EOF · line 208

Quoted 10 lines
scripts/package/builddeb +10 -0
+tar -c -f - -T /tmp/files$$ | (cd $destdir; tar -xf -)
+(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
+rm -f /tmp/files$$ /tmp/objfiles$$
+arch=$(dpkg --print-architecture)
+
+cat <<EOF >> debian/control
+
+Package: $hdrpackagename
+Provides: linux-headers, linux-headers-2.6
+Architecture: $arch

not sure if that will interfere with the new crosscompile feature of deb-pkg in linux-next.

Quoted 3 lines
Quoted 1 line

aboves arch call seems redundant with what we already have.

Yes, please remove it.

will look at it again in a calmer moment.

Quoted 17 lines

BTW, here is a bugreport I got privately about
the very same issue:
On 12.1.2011 10:02, Ralf Rösch wrote:

| [...]
| Attached you will find a patch to complete the build successfully for my
| mipsel target.
| The dpkg --print-architecture shows i386 which results in error:
| dpkg-gencontrol: Fehler: aktuelle Host-Architektur »mipsel« erscheint
| nicht in der Architekturliste (i386) des Pakets
| (current host architecture 'mipsel' does not appear in package's list
i386)
| so I changed "arch" temporary to "any".
|
| It would be nice if it would be possible to make the kernel-headers
| installable on any host.
| They are needed very frequently for cross-compiling. (I already possible
| with dpkg force).

Added Ben Hutchings and d-kernel on Cc. I do not use OOT modules, so I don't have a strong word on that, but from what I see in Debian they are arch specific.

Signature · 1 line
maks
#6 lore raw
Quoted 1 line · maximilian attems

On Thu, Jan 13, 2011 at 02:55:26PM +0100, Michal Marek wrote:

[...]

Quoted 18 lines
Quoted 17 lines

BTW, here is a bugreport I got privately about
the very same issue:
On 12.1.2011 10:02, Ralf Rösch wrote:

| [...]
| Attached you will find a patch to complete the build successfully for my
| mipsel target.
| The dpkg --print-architecture shows i386 which results in error:
| dpkg-gencontrol: Fehler: aktuelle Host-Architektur »mipsel« erscheint
| nicht in der Architekturliste (i386) des Pakets
| (current host architecture 'mipsel' does not appear in package's list
i386)
| so I changed "arch" temporary to "any".
|
| It would be nice if it would be possible to make the kernel-headers
| installable on any host.
| They are needed very frequently for cross-compiling. (I already possible
| with dpkg force).
Quoted 3 lines

Added Ben Hutchings and d-kernel on Cc. I do not use OOT modules, so I don't have a strong word on that, but from what I see in Debian they are arch specific.

Kernel header packages should be labelled with the target architecture. This is because the headers include some generated files that are both architecture- and configuration-specific.

Any package of libraries or headers for some architecture is in theory useful for cross-development on any other architecture, yet we do not label them as architecture: all. If we did that, we would then have to use a different name and installation path for each target so that they are co-installable; this would also bloat the package list files. You should normally be able to convert a package for use in cross- development using dpkg-cross, which changes its name and paths accordingly. However I don't know how well this will work for kernel headers.

Ben.

Signature · 3 lines
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus