Skip to contentSkip to conversation

kbuild, deb-pkg: set host machine $arch correctly when cross-compiling or not

PATCH New Robert Gordon 1 participant 1 message May 4, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild, deb-pkg: set host machine $arch correctly when cross-compiling or not

scripts/package/builddeb script was setting the host machine $arch in the KERNEL/debian/control prior to an invocation of dpkg-gencontrol. The existing method is appropriate for i386/x86_64 but fails when cross-compiling for non-intel. The patch modifies the script to guarantee the correct $arch for the target is written to the control file. This patch has been tested building x86_64 on an i386 machine and also when cross-compiling for ARM on an i386 machine. The issue first arose in the 2.6.38 release.

---
 scripts/package/builddeb |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
scripts/package/builddeb +17 -1
index f6cbc3d..91ced36 100644
@@ -246,7 +246,23 @@ 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)
+
+case "$UTS_MACHINE" in
+sparc*)
+	arch=sparc ;;
+s390*)
+	arch=s390 ;;
+ppc*)
+	arch=powerpc ;;
+parisc*)
+	arch=hppa ;;
+mips*)
+	arch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;;
+arm*)
+	arch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;;
+i386|ia64|alpha|x86_64|*)
+	arch=$(dpkg --print-architecture) ;;
+esac
 
 cat <<EOF >> debian/control
 
Signature · 1 line
1.7.1