From 2fe542fd271fe4000035f846c5a89815c94d0194 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Wed, 27 Feb 2013 11:04:17 -0600
Subject: [PATCH] builddeb: now generates armhf debs on x86 hosts

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 patch.sh                                      |   7 +-
 ...-architecture-matching-for-cross-bui.patch | 139 ++++++++++++++++++
 ...et-host-machine-after-dpkg-gencontro.patch | 114 --------------
 ...definition-of-strstr-to-decompress.c.patch |  40 -----
 version.sh                                    |   2 +-
 5 files changed, 141 insertions(+), 161 deletions(-)
 create mode 100644 patches/arm/0001-deb-pkg-Simplify-architecture-matching-for-cross-bui.patch
 delete mode 100644 patches/arm/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch
 delete mode 100644 patches/arm/0002-arm-add-definition-of-strstr-to-decompress.c.patch

diff --git a/patch.sh b/patch.sh
index 8d866efba..60be5e66f 100644
--- a/patch.sh
+++ b/patch.sh
@@ -47,12 +47,7 @@ cleanup () {
 
 arm () {
 	echo "dir: arm"
-	${git} "${DIR}/patches/arm/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch"
-
-	#Status: v2 Review:
-	#http://lists.infradead.org/pipermail/linux-arm-kernel/2012-August/112440.html
-#	${git} "${DIR}/patches/arm/0002-arm-add-definition-of-strstr-to-decompress.c.patch"
-#	${git} "${DIR}/patches/arm/0003-Without-MACH_-option-Early-printk-DEBUG_LL.patch"
+	${git} "${DIR}/patches/arm/0001-deb-pkg-Simplify-architecture-matching-for-cross-bui.patch"
 }
 
 imx () {
diff --git a/patches/arm/0001-deb-pkg-Simplify-architecture-matching-for-cross-bui.patch b/patches/arm/0001-deb-pkg-Simplify-architecture-matching-for-cross-bui.patch
new file mode 100644
index 000000000..8822384db
--- /dev/null
+++ b/patches/arm/0001-deb-pkg-Simplify-architecture-matching-for-cross-bui.patch
@@ -0,0 +1,139 @@
+From 1b4c2bc7af46a8d7cba2bc1d4aa8fd814dc1c3cc Mon Sep 17 00:00:00 2001
+From: maximilian attems <max@xxxxxxx>
+Date: Thu, 6 Sep 2012 15:22:02 +0200
+Subject: [PATCH] deb-pkg: Simplify architecture matching for cross building
+
+No point in invoking dpkg to get the archticture of the host
+we build on. Instead directly use the logic implemented
+in create_package(). No need anymore to override arch.
+
+While at it fix the linux images to be for the specific
+built arch.
+
+Signed-off-by: maximilian attems <max@xxxxxxx>
+---
+ scripts/package/builddeb |   81 ++++++++++++++++++++++------------------------
+ 1 file changed, 38 insertions(+), 43 deletions(-)
+
+diff --git a/scripts/package/builddeb b/scripts/package/builddeb
+index acb8650..a5f197b 100644
+--- a/scripts/package/builddeb
++++ b/scripts/package/builddeb
+@@ -25,44 +25,8 @@ 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
+-	if [ -n "$debarch" ] ; then
+-		forcearch="-DArchitecture=$debarch"
+-	fi
+-
+ 	# Create the package
+-	dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
++	dpkg-gencontrol -p$pname -P"$pdir"
+ 	dpkg --build "$pdir" ..
+ }
+ 
+@@ -83,6 +47,38 @@ fwpackagename=linux-firmware-image
+ kernel_headers_packagename=linux-headers-$version
+ libc_headers_packagename=linux-libc-dev
+ 
++# 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
++
+ if [ "$ARCH" = "um" ] ; then
+ 	packagename=user-mode-linux-$version
+ fi
+@@ -234,8 +230,8 @@ else
+ Package: $packagename
+ Provides: linux-image, linux-image-2.6, linux-modules-$version
+ Suggests: $fwpackagename
+-Architecture: any
+-Description: Linux kernel, version $version
++Architecture: $debarch
++Description: Linux kernel, version $version on $debarch
+  This package contains the Linux kernel, modules and corresponding other
+  files, version: $version.
+ EOF
+@@ -252,15 +248,14 @@ mkdir -p "$destdir"
+ (cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -)
+ ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
+ rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
+-arch=$(dpkg --print-architecture)
+ 
+ cat <<EOF >> debian/control
+ 
+ Package: $kernel_headers_packagename
++Architecture: $debarch
+ 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
++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
+-- 
+1.7.10.4
+
diff --git a/patches/arm/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch b/patches/arm/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch
deleted file mode 100644
index f8053aed5..000000000
--- a/patches/arm/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 870f216398ba1ba913c6c3ff22386c35f3a283ed Mon Sep 17 00:00:00 2001
-From: Robert Gordon <robert@greenroomsoftware.com>
-Date: Wed, 13 Apr 2011 11:32:29 -0500
-Subject: [PATCH 1/2] kbuild, deb-pkg: set host machine after dpkg-gencontrol
-
-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.
-
-Signed-off-by: Robert Gordon <robert@greenroomsoftware.com>
-Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
----
- scripts/package/builddeb |   70 +++++++++++++++++++++++----------------------
- 1 files changed, 36 insertions(+), 34 deletions(-)
-
-diff --git a/scripts/package/builddeb b/scripts/package/builddeb
-index acb8650..72d6255 100644
---- a/scripts/package/builddeb
-+++ b/scripts/package/builddeb
-@@ -26,37 +26,7 @@ create_package() {
- 	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 +36,38 @@ create_package() {
- 	dpkg --build "$pdir" ..
- }
- 
-+#Set the correct debian arch
-+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)
-@@ -258,9 +260,9 @@ 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
--- 
-1.7.7.6
-
diff --git a/patches/arm/0002-arm-add-definition-of-strstr-to-decompress.c.patch b/patches/arm/0002-arm-add-definition-of-strstr-to-decompress.c.patch
deleted file mode 100644
index 593095349..000000000
--- a/patches/arm/0002-arm-add-definition-of-strstr-to-decompress.c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From df5dd27751e257a4445a6cd930c5db233955d033 Mon Sep 17 00:00:00 2001
-From: Shawn Landden <shawnlandden@gmail.com>
-Date: Wed, 30 May 2012 13:45:08 -0700
-Subject: [PATCH 2/2] arm: add definition of strstr() to decompress.c
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-include/linux/dynamic_debug.h uses strstr from <linux/string.h>
-and is included via <linux/kernel.h> from lib/xz/xz_private.h
-when CONFIG_KERNEL_XZ=y.
-
-However arch/arm/boot/compressed/decompress.c defines _LINUX_STRING_H
-preventing the load of <linux/string.h> resulting in:
-
-include/linux/dynamic_debug.h:111:2: error: implicit declaration of function ‘strstr’
-
-Define strstr in arch/arm/boot/compressed/decompress.c, providing the needed
-subset of <linux/string.h>.
-
-Signed-off-by: Shawn Landden <shawnlandden@gmail.com>
----
- arch/arm/boot/compressed/decompress.c |    1 +
- 1 files changed, 1 insertions(+), 0 deletions(-)
-
-diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
-index 9deb56a..0f96125 100644
---- a/arch/arm/boot/compressed/decompress.c
-+++ b/arch/arm/boot/compressed/decompress.c
-@@ -50,6 +50,7 @@ extern char * strstr(const char * s1, const char *s2);
- #ifdef CONFIG_KERNEL_XZ
- #define memmove memmove
- #define memcpy memcpy
-+extern char * strstr(const char *, const char *);
- #include "../../../../lib/decompress_unxz.c"
- #endif
- 
--- 
-1.7.7.6
-
diff --git a/version.sh b/version.sh
index 148038150..5be7a159b 100644
--- a/version.sh
+++ b/version.sh
@@ -24,7 +24,7 @@ config="omap2plus_defconfig"
 #Kernel/Build
 KERNEL_REL=3.8
 KERNEL_TAG=${KERNEL_REL}
-BUILD=d0.13
+BUILD=d0.14
 
 #v3.X-rcX + upto SHA
 KERNEL_SHA="d895cb1af15c04c522a25c79cc429076987c089b"
-- 
GitLab