kbuild, deb-pkg: set host machine after dpkg-gencontrol
This patch was prepared using git format-patch and git send-email. Details follow. Regards,
Robert Gordon
scripts/package/builddeb script was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.
--- scripts/package/builddeb | 73 +++++++++++++++++++++++---------------------- 1 files changed, 37 insertions(+), 36 deletions(-)
scripts/package/builddeb +37 -36
@@ -25,38 +25,7 @@ create_package() { chown -R root:root "$pdir" chmod -R go-w "$pdir" - # Attempt to find the correct Debian architecture - local forcearch="" debarch="" - case "$UTS_MACHINE" in - i386|ia64|alpha) - debarch="$UTS_MACHINE" ;; - x86_64) - debarch=amd64 ;; - sparc*) - debarch=sparc ;; - s390*) - debarch=s390 ;; - ppc*) - debarch=powerpc ;; - parisc*) - debarch=hppa ;; - mips*) - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; - arm*) - debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; - *) - echo "" >&2 - echo "** ** ** WARNING ** ** **" >&2 - echo "" >&2 - echo "Your architecture doesn't have it's equivalent" >&2 - echo "Debian userspace architecture defined!" >&2 - echo "Falling back to using your current userspace instead!" >&2 - echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 - echo "" >&2 - esac - if [ -n "$KBUILD_DEBARCH" ] ; then - debarch="$KBUILD_DEBARCH" - fi + local forcearch="" if [ -n "$debarch" ] ; then forcearch="-DArchitecture=$debarch" fi
@@ -66,6 +35,39 @@ create_package() { dpkg --build "$pdir" .. } +# Attempt to find the correct Debian architecture +case "$UTS_MACHINE" in +i386|ia64|alpha) + debarch="$UTS_MACHINE" ;; +x86_64) + debarch=amd64 ;; +sparc*) + debarch=sparc ;; +s390*) + debarch=s390 ;; +ppc*) + debarch=powerpc ;; +parisc*) + debarch=hppa ;; +mips*) + debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; +arm*) + debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; +*) + echo "" >&2 + echo "** ** ** WARNING ** ** **" >&2 + echo "" >&2 + echo "Your architecture doesn't have it's equivalent" >&2 + echo "Debian userspace architecture defined!" >&2 + echo "Falling back to using your current userspace instead!" >&2 + echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 + echo "" >&2 +esac +if [ -n "$KBUILD_DEBARCH" ] ; then + debarch="$KBUILD_DEBARCH" +fi + + # Some variables and settings used throughout the script version=$KERNELRELEASE revision=$(cat .version)
@@ -246,15 +248,14 @@ mkdir -p "$destdir" (cd $srctree; 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: $kernel_headers_packagename 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 +Architecture: $debarch +Description: Linux kernel headers for $KERNELRELEASE on $debarch + This package provides kernel header files for $KERNELRELEASE on $debarch . This is useful for people who need to build external modules EOF
Signature · 1 line
1.7.1
Quoted 3 lines · Robert Gordon
This patch was prepared using git format-patch and git send-email. Details follow. Regards,
Robert Gordon
thanks so the patch was now applyable and so testable. (:
Quoted 1 line
scripts/package/builddebscript was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.
hmm don't be shy to use line-breaks in the desc for next times..
Quoted 1 line
Signed-off-by Robert Gordon <[email protected]>
rudimentary testing showed, that make deb-pkg works,
but make ARCH=i386 deb-pkg on an amd64 Debian box seems borked:
+ dpkg-gencontrol -isp -DArchitecture=i386 -plinux-headers-2.6.39-rc3+ -P/media/data/mattems/src/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'amd64' does not appear in package's architecture list (i386)
had no time to investigate yet, hope you will do.
greetings
Signature · 1 line
maks
Quoted 12 lines · maximilian attems
Quoted 3 lines · Robert Gordon
This patch was prepared using git format-patch and git send-email. Details follow. Regards,
Robert Gordonthanks so the patch was now applyable and so testable. (:
Quoted 1 line
scripts/package/builddebscript was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.hmm don't be shy to use line-breaks in the desc for next times..
Quoted 7 lines
Quoted 1 line
Signed-off-by Robert Gordon <[email protected]>rudimentary testing showed, that
make deb-pkgworks,
butmake ARCH=i386 deb-pkgon an amd64 Debian box seems borked:
+ dpkg-gencontrol -isp -DArchitecture=i386 -plinux-headers-2.6.39-rc3+ -P/media/data/mattems/src/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'amd64' does not appear in package's architecture list (i386)
Weird, as without the patch we get the same error just with (i386) swapped for (armel)..
make ARCH=armel deb-pkg (on amd64)
Note, with cross building we always have CROSS_COMPILE=something too..
Regards,
Signature · 2 lines
Robert Nelson http://www.rcn-ee.com/
Quoted 21 lines · Robert Nelson
Quoted 12 lines · maximilian attems
Quoted 3 lines · Robert Gordon
This patch was prepared using git format-patch and git send-email. Details follow. Regards,
Robert Gordonthanks so the patch was now applyable and so testable. (:
Quoted 1 line
scripts/package/builddebscript was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.hmm don't be shy to use line-breaks in the desc for next times..
Quoted 7 lines
Quoted 1 line
Signed-off-by Robert Gordon<[email protected]>rudimentary testing showed, that
make deb-pkgworks,
butmake ARCH=i386 deb-pkgon an amd64 Debian box seems borked:
+ dpkg-gencontrol -isp -DArchitecture=i386 -plinux-headers-2.6.39-rc3+ -P/media/data/mattems/src/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'amd64' does not appear in package's architecture list (i386)
Quoted 6 lines
Weird, as without the patch we get the same error just with (i386) swapped for (armel)..
make ARCH=armel deb-pkg (on amd64)
Note, with cross building we always have CROSS_COMPILE=something too..
x86_64 and i386 are just two flavors of x86 in the kernel build and two switches in gcc, so unlike genuine cross builds, you don't need CROSS_COMPILE=something to build for one if you are running another. I didn't follow the thread closely (relying on Maximilian to review anything deb-pkg related), I just wanted to point out a potential difference that might confuse you when comparing builds for arm and for i386.
Michal
Quoted 12 lines · maximilian attems
Quoted 3 lines · Robert Gordon
This patch was prepared using git format-patch and git send-email. Details follow. Regards,
Robert Gordonthanks so the patch was now applyable and so testable. (:
Quoted 1 line
scripts/package/builddebscript was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.hmm don't be shy to use line-breaks in the desc for next times..
Quoted 7 lines
Quoted 1 line
Signed-off-by Robert Gordon <[email protected]>rudimentary testing showed, that
make deb-pkgworks,
butmake ARCH=i386 deb-pkgon an amd64 Debian box seems borked:
+ dpkg-gencontrol -isp -DArchitecture=i386 -plinux-headers-2.6.39-rc3+ -P/media/data/mattems/src/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'amd64' does not appear in package's architecture list (i386)
at a second look your patch is just wrong the arch overriding is currently correctly done in create_package(), with the debian/control file having the host arch written to it.
so please post what exactly you were trying to build in the first place?
Signature · 1 line
maks
Quoted 28 lines · maximilian attems
Quoted 21 lines · maximilian attems
Quoted 1 line · Robert Gordon
This patch was prepared using git format-patch and git send-email.
Details follow.
Quoted 2 lines
Regards,
Robert Gordonthanks so the patch was now applyable and so testable. (:
Quoted 1 line
scripts/package/builddebscript was setting the host machine $archin the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The patch modifies the script to guarantee the correct debian arch for the target is written to the control file instead. The issue originally arose in the 2.6.38 series.
hmm don't be shy to use line-breaks in the desc for next times..
Quoted 1 line
Signed-off-by Robert Gordon <[email protected]>rudimentary testing showed, that
make deb-pkgworks, butmake ARCH=i386 deb-pkgon an amd64 Debian box seems borked:
+ dpkg-gencontrol -isp -DArchitecture=i386(quoted diff) +0
-2-plinux-headers-2.6.39-rc3+ -P/media/data/mattems/src/linux-2.6/debian/hdrtmpQuoted 1 line
dpkg-gencontrol: error: current host architecture 'amd64' does not appear in package's architecture list (i386)
at a second look your patch is just wrong the arch overriding is currently correctly done in
create_package(), with the debian/control file having the host arch written to it.
Quoted 1 line
so please post what exactly you were trying to build in the first place?
When cross compiling for an arm on an i386 machine, dpkg-gencontrol fails. I am currently on the road and my internet connection is not allowing me to pull Linus's kernel onto my laptop. If you will permit, I'll use the latest kernel from Ubunutu for the (ARM) Beagleboard (2.6.38), since I have it with me already. I worked with the latest kernel at home this past weekend and the /scripts/packages/buildeb file was the same in both versions (i.e. I can apply the patch to the 2.6.38 or 2.6.39 versions).
Here is the original 'make' command:
make ARCH=arm LOCALVERSION=-x1 CROSS_COMPILE=arm-linux-gnueabi- KDEB_PKGVERSION=1.0cross deb-pkg
Here is how it fails:
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386) make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
Immediately after the failure, the debian/control file contains the following section:
Package: linux-headers-2.6.38.2-x1
Provides: linux-headers, linux-headers-2.6
Architecture: i386
Description: Linux kernel headers for 2.6.38.2-x1 on i386
This package provides kernel header files for 2.6.38.2-x1 on i386
Since I am cross-compiling for an ARM machine, I don't think I want kernel headers for i386. After my patch is applied, the relevant fields say 'armel' and the deb-pkg process executes to successful completion.
I will pull Linus's kernel at my first opportunity, but I hope this answer helps.
Regards,
Robert Gordon
Quoted 10 lines · On Mon, Apr 18, 2011 at 03:28:28PM -0400, [email protected] wrote:
Here is the original 'make' command:
make ARCH=arm LOCALVERSION=-x1 CROSS_COMPILE=arm-linux-gnueabi- KDEB_PKGVERSION=1.0cross deb-pkgHere is how it fails:
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
did you check how it dpkg-gencontrol is called?
just put an set -x on the top of builddeb.
Signature · 1 line
maks
Quoted 5 lines · maximilian attems
Quoted 4 lines · On Mon, Apr 18, 2011 at 03:28:28PM -0400, [email protected] wrote:
Here is the original 'make' command:
make ARCH=arm LOCALVERSION=-x1 CROSS_COMPILE=arm-linux-gnueabi- KDEB_PKGVERSION=1.0cross deb-pkg
Quoted 9 lines
Quoted 6 lines
Here is how it fails:
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2did you check how it dpkg-gencontrol is called?
just put an set -x on the top of builddeb.
Here is the output:
dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.38.2-x1 -P/opt/kernel_new/2.6-stable/KERNEL/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
[2]+ Done gedit KERNEL/scripts/package/builddeb
The information in the debian/control file remains the same, i.e. it seems to contain instructions to build headers for an i386.
Regards,
Robert
Quoted 25 lines · Robert Gordon
Quoted 5 lines · maximilian attems
Quoted 4 lines · On Mon, Apr 18, 2011 at 03:28:28PM -0400, [email protected] wrote:
Here is the original 'make' command:
make ARCH=arm LOCALVERSION=-x1 CROSS_COMPILE=arm-linux-gnueabi- KDEB_PKGVERSION=1.0cross deb-pkgQuoted 9 lines
Quoted 6 lines
Here is how it fails:
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2did you check how it dpkg-gencontrol is called?
just put an set -x on the top of builddeb.Here is the output:
dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.38.2-x1 -P/opt/kernel_new/2.6-stable/KERNEL/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
[2]+ Done gedit KERNEL/scripts/package/builddeb
Quoted 5 lines
The information in the debian/control file remains the same, i.e. it seems to contain instructions to build headers for an i386.
Regards,
Robert
I have used the 2.6.39-rc4+ kernel to sort out the difficulties with building .deb packages for a non-x86 architecture. I repeated the same steps four times:
fakeroot make ARCH=[x86_64,arm] [CROSS_COMPILE=] deb-pkg
cat debian/control
The four steps proceeded in this order:
1) ARCH=x86_64, the patch I submitted was not applied - succeeded
2) ARCH=x86_64, the patch I submitted was applied - failed
3) ARCH=arm, the patched I submitted was applied - succeeded
4) ARH=arm, the patched I submitted was removed - failed
The problem appears to be in lines 43 & 44 of the latest patch I sent:x86_64)
debarch=amd64 ;;
The debian arch for x86_64 is being set to amd64, which is getting written into the debian/control file prior to invocation of dpkg-gencontrol. If my patch is not applied, i386 gets written into the debian/control file instead, and the x86_64 cross compile succeeds. However, when my patch is not applied i386 is written into the debian/control file when cross compiling for arm, which leads to the script failing. When my patch is applied, arm is written into the debian/control file, when cross compiling for arm, and this succeeds.
I will attempt to modify the debarch for x86_64 to remain x86_64 and see if that works. If so, I'll submit a new patch. The notes from what I have described so far are included below.
Regards,
Robert Gordon
**********Using original /scripts/package/builddeb - succeeded ************ fakeroot make ARCH=x86_64 deb-pkg
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/hdrtmp
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-firmware-image -P/opt/kernel-linus/linux-2.6/debian/fwtmp
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-libc-dev -P/opt/kernel-linus/linux-2.6/debian/headertmp
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-image-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/tmp
cat debian/control
Source: linux-upstream
Section: kernel
Priority: optional
Maintainer: Anonymous <root@robert-VGN-Z690Y>
Standards-Version: 3.8.4
Homepage: http://www.kernel.org/
Package: linux-image-2.6.39-rc4+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc4+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc4+
This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc4+.
Package: linux-headers-2.6.39-rc4+
Provides: linux-headers, linux-headers-2.6
Architecture: i386
Description: Linux kernel headers for 2.6.39-rc4+ on i386
This package provides kernel header files for 2.6.39-rc4+ on i386 .
This is useful for people who need to build external modules
Package: linux-firmware-image
Architecture: all
Description: Linux kernel firmware, version 2.6.39-rc4+
This package contains firmware from the Linux kernel, version 2.6.39-rc4+.
Package: linux-libc-dev
Section: devel
Provides: linux-kernel-headers
Architecture: any
Description: Linux support headers for userspace development
This package provides userspaces headers from the Linux kernel. These
headers
are used by the installed headers for GNU glibc and other system libraries.
**********Using patched /scripts/package/builddeb - failed ************ patch -p1 < builddeb.patch
fakeroot make ARCH=x86_64 deb-pkg
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'i386' does not appear in package's architecture list (amd64)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
cat debian/control
Source: linux-upstream
Section: kernel
Priority: optional
Maintainer: Anonymous <root@robert-VGN-Z690Y>
Standards-Version: 3.8.4
Homepage: http://www.kernel.org/
Package: linux-image-2.6.39-rc4+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc4+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc4+
This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc4+.
Package: linux-headers-2.6.39-rc4+
Provides: linux-headers, linux-headers-2.6
Architecture: amd64
Description: Linux kernel headers for 2.6.39-rc4+ on amd64
This package provides kernel header files for 2.6.39-rc4+ on amd64 .
This is useful for people who need to build external modules
**********Using patched /scripts/package/builddeb - succeeded ************ fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/hdrtmp
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-firmware-image -P/opt/kernel-linus/linux-2.6/debian/fwtmp
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-libc-dev -P/opt/kernel-linus/linux-2.6/debian/headertmp
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-image-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/tmp
cat debian/control
Source: linux-upstream
Section: kernel
Priority: optional
Maintainer: Anonymous <root@robert-VGN-Z690Y>
Standards-Version: 3.8.4
Homepage: http://www.kernel.org/
Package: linux-image-2.6.39-rc4+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc4+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc4+
This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc4+.
Package: linux-headers-2.6.39-rc4+
Provides: linux-headers, linux-headers-2.6
Architecture: armel
Description: Linux kernel headers for 2.6.39-rc4+ on armel
This package provides kernel header files for 2.6.39-rc4+ on armel .
This is useful for people who need to build external modules
Package: linux-firmware-image
Architecture: all
Description: Linux kernel firmware, version 2.6.39-rc4+
This package contains firmware from the Linux kernel, version 2.6.39-rc4+.
Package: linux-libc-dev
Section: devel
Provides: linux-kernel-headers
Architecture: any
Description: Linux support headers for userspace development
This package provides userspaces headers from the Linux kernel. These
headers
are used by the installed headers for GNU glibc and other system libraries.
**********Using original /scripts/package/builddeb - failed ************ fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.39-rc4+ -P/opt/kernel-linus/linux-2.6/debian/hdrtmp
dpkg-gencontrol: error: current host architecture 'armel' does not appear in package's architecture list (i386)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2
cat debian/control
Source: linux-upstream
Section: kernel
Priority: optional
Maintainer: Anonymous <root@robert-VGN-Z690Y>
Standards-Version: 3.8.4
Homepage: http://www.kernel.org/
Package: linux-image-2.6.39-rc4+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc4+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc4+
This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc4+.
Package: linux-headers-2.6.39-rc4+
Provides: linux-headers, linux-headers-2.6
Architecture: i386
Description: Linux kernel headers for 2.6.39-rc4+ on i386
This package provides kernel header files for 2.6.39-rc4+ on i386 .
This is useful for people who need to build external modules