Skip to contentSkip to conversation

deb-pkg: fix cross-compile build

PATCH In review Nuno Subtil 4 participants 11 messages May 4, 2011 – May 13, 2011 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 deb-pkg: fix cross-compile build

When generating the header package, scripts/package/builddeb was inferring the target architecture by looking at the output of dpkg --print-architecture. This allows KBUILD_DEBARCH to override that.

---
 scripts/package/builddeb |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
scripts/package/builddeb +6 -1
index f6cbc3d..9372145 100644
@@ -246,7 +246,12 @@ 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)
+
+if [ -n "$KBUILD_DEBARCH" ] ; then
+	arch="$KBUILD_DEBARCH"
+else
+	arch=$(dpkg --print-architecture)
+fi
 
 cat <<EOF >> debian/control
 
Signature · 6 lines
1.7.4.4

Please Cc me on any replies related to this patch.

Thanks,
Nuno
#1 lore raw

Adding Maks to CC.

Quoted 39 lines · Nuno Subtil

When generating the header package, scripts/package/builddeb was inferring the target architecture by looking at the output of dpkg --print-architecture. This allows KBUILD_DEBARCH to override that.

---
 scripts/package/builddeb |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
scripts/package/builddeb +6 -1
index f6cbc3d..9372145 100644
@@ -246,7 +246,12 @@ 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)
+
+if [ -n "$KBUILD_DEBARCH" ] ; then
+	arch="$KBUILD_DEBARCH"
+else
+	arch=$(dpkg --print-architecture)
+fi
 
 cat <<EOF >> debian/control
 
Signature · 11 lines
1.7.4.4

Please Cc me on any replies related to this patch.

Thanks,
Nuno

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 1 line · Michal Marek

Adding Maks to CC.

thanks, this one looks, good please disguard the other patch.

Quoted 6 lines · Nuno Subtil
Quoted 5 lines

When generating the header package, scripts/package/builddeb was inferring the target architecture by looking at the output of dpkg --print-architecture. This allows KBUILD_DEBARCH to override that.

#3 lore raw
Quoted 9 lines · maximilian attems
Quoted 1 line · Michal Marek

Adding Maks to CC.

thanks, this one looks, good please disguard the other patch.

Quoted 5 lines · Nuno Subtil
Quoted 4 lines

When generating the header package, scripts/package/builddeb was inferring the target architecture by looking at the output of dpkg --print-architecture. This allows KBUILD_DEBARCH to override that.

Quoted 6 lines
Quoted 1 line
Quoted 1 line

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Greetings,

Compile breaks when using the following command:
fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

With 'set -x' in scripts/package/builddeb, the relevant output is:
+ '[' -n '' ']'
++ dpkg --print-architecture
+ arch=i386
This indicates that KBUILD_DEBARCH is not set.

The debian/control file is written with the following section:
Package: linux-headers-2.6.39-rc5+
Provides: linux-headers, linux-headers-2.6
Architecture: i386
Description: Linux kernel headers for 2.6.39-rc5+ on i386
This package provides kernel header files for 2.6.39-rc5+ on i386

This produces the following error output:
+ forcearch=-DArchitecture=armel
+ dpkg-gencontrol -isp -DArchitecture=armel
-plinux-headers-2.6.39-rc5+ -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)

Regards,
Robert

#4 lore raw

This patch is not meant to fix that case, only the case where KBUILD_DEBARCH is used.

KBUILD_DEBARCH seems to be meant to be used as an override for what Debian wants to see as the target architecture. Arguably, the right thing to do here might be to do the same arch detection sequence that's done in create_package(), which looks at UTS_MACHINE first and the KBUILD_DEBARCH override after that (though I'm not entirely sure).

This patch only adds the KBUILD_DEBARCH override, but that is still better than the current situation. I can easily get the rest in later if needed.

Nuno

Quoted 45 lines · Robert Gordon
Quoted 9 lines · maximilian attems
Quoted 1 line · Michal Marek

Adding Maks to CC.

thanks, this one looks, good please disguard the other patch.

Quoted 5 lines · Nuno Subtil
Quoted 4 lines

When generating the header package, scripts/package/builddeb was inferring the target architecture by looking at the output of dpkg --print-architecture. This allows KBUILD_DEBARCH to override that.

Quoted 6 lines
Quoted 1 line
Quoted 1 line

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Greetings,

Compile breaks when using the following command:
   fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

With 'set -x' in scripts/package/builddeb, the relevant output is:
   + '[' -n '' ']'
   ++ dpkg --print-architecture
   + arch=i386
This indicates that KBUILD_DEBARCH is not set.

The debian/control file is written with the following section:
   Package: linux-headers-2.6.39-rc5+
   Provides: linux-headers, linux-headers-2.6
   Architecture: i386
   Description: Linux kernel headers for 2.6.39-rc5+ on i386 This package provides kernel header files for 2.6.39-rc5+ on i386

This produces the following error output:
   + forcearch=-DArchitecture=armel
   + dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.39-rc5+ -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)

Regards,
Robert

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 76 lines · Robert Gordon
Quoted 9 lines · Nuno Subtil

This patch is not meant to fix that case, only the case where KBUILD_DEBARCH is used.

KBUILD_DEBARCH seems to be meant to be used as an override for what Debian wants to see as the target architecture. Arguably, the right thing to do here might be to do the same arch detection sequence that's done in create_package(), which looks at UTS_MACHINE first and the KBUILD_DEBARCH override after that (though I'm not entirely sure).

Quoted 56 lines

This patch only adds the KBUILD_DEBARCH override, but that is still better than the current situation. I can easily get the rest in later if needed.

Nuno

Quoted 48 lines · Robert Gordon
Quoted 11 lines · maximilian attems
Quoted 1 line · Michal Marek

Adding Maks to CC.

thanks, this one looks, good please disguard the other patch.

Quoted 7 lines · Nuno Subtil
Quoted 6 lines

When generating the header package, scripts/package/builddeb was inferring the
target architecture by looking at the output of dpkg --print-architecture. This
allows KBUILD_DEBARCH to override that.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Greetings,

Compile breaks when using the following command:
fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

With 'set -x' in scripts/package/builddeb, the relevant output is:
+ '[' -n '' ']'
++ dpkg --print-architecture
+ arch=i386
This indicates that KBUILD_DEBARCH is not set.

The debian/control file is written with the following section:
Package: linux-headers-2.6.39-rc5+
Provides: linux-headers, linux-headers-2.6
Architecture: i386
Description: Linux kernel headers for 2.6.39-rc5+ on i386 This package provides kernel header files for 2.6.39-rc5+ on i386

This produces the following error output:
+ forcearch=-DArchitecture=armel
+ dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.39-rc5+ -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)

Regards,
Robert

Nuno,
Thanks for the response. I am very new at this process, but I am trying to learn. Yesterday, I submitted a patch that was intended to address the same issue that you have addressed. I did what you are suggesting by mimicking what is done in create_package(), but leaving i386/x86_64 untouched. Here is the subject of the patch I sent:

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

Quoted 8 lines

Please advise if I should resend.

Regards,
Robert

-- *
*

Apologies, resending because messages were rejected by the mailing lists (probably due to html) - Robert

#7 lore raw
In reply to a message not in the archive

It looks like your patch duplicates the arch detection logic that's already in create_package, except not completely. I think this is not desirable.

I modified your patch to isolate this logic into a separate function and respect the KBUILD_DEBARCH override (which mostly means I moved the original logic into a separate function). This should make your case work as well, besides respecting the KBUILD_DEBARCH override.

Maks, Michal, can you please take a look at this new patch?

Thanks,
Nuno

Quoted 90 lines · Robert Gordon

On 5/5/11 10:10 AM, Nuno Subtil wrote:

This patch is not meant to fix that case, only the case where KBUILD_DEBARCH is used.

KBUILD_DEBARCH seems to be meant to be used as an override for what Debian wants to see as the target architecture. Arguably, the right thing to do here might be to do the same arch detection sequence that's done in create_package(), which looks at UTS_MACHINE first and the KBUILD_DEBARCH override after that (though I'm not entirely sure).

This patch only adds the KBUILD_DEBARCH override, but that is still better than the current situation. I can easily get the rest in later if needed.

Nuno

On Thu, May 5, 2011 at 08:42, Robert Gordon
<[email protected]> wrote:

On 05/05/2011 02:07 AM, maximilian attems wrote:

On Wed, May 04, 2011 at 10:48:07PM +0200, Michal Marek wrote:

Adding Maks to CC.

thanks, this one looks, good please disguard the other patch.

On Tue, May 03, 2011 at 10:59:10PM -0700, Nuno Subtil wrote:

When generating the header package, scripts/package/builddeb was inferring the
target architecture by looking at the output of dpkg --print-architecture. This
allows KBUILD_DEBARCH to override that.

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Greetings,

Compile breaks when using the following command:
   fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

With 'set -x' in scripts/package/builddeb, the relevant output is:
   + '[' -n '' ']'
   ++ dpkg --print-architecture
   + arch=i386
This indicates that KBUILD_DEBARCH is not set.

The debian/control file is written with the following section:
   Package: linux-headers-2.6.39-rc5+
   Provides: linux-headers, linux-headers-2.6
   Architecture: i386
   Description: Linux kernel headers for 2.6.39-rc5+ on i386 This package provides kernel header files for 2.6.39-rc5+ on i386

This produces the following error output:
   + forcearch=-DArchitecture=armel
   + dpkg-gencontrol -isp -DArchitecture=armel -plinux-headers-2.6.39-rc5+ -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)

Regards,
Robert

Nuno,
     Thanks for the response.  I am very new at this process, but I am trying to learn.  Yesterday, I submitted a patch that was intended to address the same issue that you have addressed.  I did what you are suggesting by mimicking what is done in create_package(), but leaving i386/x86_64 untouched.  Here is the subject of the patch I sent:

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

     Please advise if I should resend.

Regards,
Robert

--

#8 lore raw
Quoted 10 lines · Nuno Subtil

It looks like your patch duplicates the arch detection logic that's already in create_package, except not completely. I think this is not desirable.

I modified your patch to isolate this logic into a separate function and respect the KBUILD_DEBARCH override (which mostly means I moved the original logic into a separate function). This should make your case work as well, besides respecting the KBUILD_DEBARCH override.

Maks, Michal, can you please take a look at this new patch?

thanks doing right now.

Michal please hold off until I have time to give it some runs.

Signature · 1 line
maks
#9 lore raw
Quoted 10 lines · maximilian attems
Quoted 9 lines · Nuno Subtil

It looks like your patch duplicates the arch detection logic that's already in create_package, except not completely. I think this is not desirable.

I modified your patch to isolate this logic into a separate function and respect the KBUILD_DEBARCH override (which mostly means I moved the original logic into a separate function). This should make your case work as well, besides respecting the KBUILD_DEBARCH override.

Quoted 5 lines
Quoted 1 line

Maks, Michal, can you please take a look at this new patch?

thanks doing right now.

Michal please hold off until I have time to give it some runs.

I have tested this patch. It builds fine for arm with the following command:
fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

However x86_64 fails (when using an i386 machine). fakeroot make ARCH=x86_64 deb-pkg

The error occurs in scripts/package/builddeb
+ forcearch=-DArchitecture=amd64
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers-2.6.39-rc7+ -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)

The debian/control file is as follows:
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-rc7+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc7+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc7+
This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc7+.

Package: linux-headers-2.6.39-rc7+
Provides: linux-headers, linux-headers-2.6
Architecture: amd64
Description: Linux kernel headers for 2.6.39-rc7+ on amd64
This package provides kernel header files for 2.6.39-rc7+ on amd64 .
This is useful for people who need to build external modules

The debian/control file for an unpatched scripts/package/builddeb would assign 'i386' instead of 'amd64'.

Regards,
Robert

#10 lore raw
Quoted 2 lines

The debian/control file for an unpatched scripts/package/builddeb would assign 'i386' instead of 'amd64'.

That seems wrong to me. Were the resulting packages actually usable on amd64?

Quoted 64 lines · Robert Gordon
Quoted 10 lines · maximilian attems
Quoted 9 lines · Nuno Subtil

It looks like your patch duplicates the arch detection logic that's already in create_package, except not completely. I think this is not desirable.

I modified your patch to isolate this logic into a separate function and respect the KBUILD_DEBARCH override (which mostly means I moved the original logic into a separate function). This should make your case work as well, besides respecting the KBUILD_DEBARCH override.

Quoted 5 lines
Quoted 1 line

Maks, Michal, can you please take a look at this new patch?

thanks doing right now.

Michal please hold off until I have time to give it some runs.

I have tested this patch.  It builds fine for arm with the following command:
fakeroot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- deb-pkg

However x86_64 fails (when using an i386 machine). fakeroot make ARCH=x86_64 deb-pkg

The error occurs in scripts/package/builddeb
+ forcearch=-DArchitecture=amd64
+ dpkg-gencontrol -isp -DArchitecture=amd64 -plinux-headers-2.6.39-rc7+ -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)

The debian/control file is as follows:
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-rc7+
Provides: linux-image, linux-image-2.6, linux-modules-2.6.39-rc7+
Suggests: linux-firmware-image
Architecture: any
Description: Linux kernel, version 2.6.39-rc7+
 This package contains the Linux kernel, modules and corresponding other files, version: 2.6.39-rc7+.

Package: linux-headers-2.6.39-rc7+
Provides: linux-headers, linux-headers-2.6
Architecture: amd64
Description: Linux kernel headers for 2.6.39-rc7+ on amd64 This package provides kernel header files for 2.6.39-rc7+ on amd64 .
 This is useful for people who need to build external modules

The debian/control file for an unpatched scripts/package/builddeb would assign 'i386' instead of 'amd64'.

Regards,
Robert

#11 lore raw
Quoted 4 lines · Nuno Subtil
Quoted 2 lines

The debian/control file for an unpatched scripts/package/builddeb would assign 'i386' instead of 'amd64'.

That seems wrong to me. Were the resulting packages actually usable on amd64?

I modeled my patch after behavior I saw in the unpatched script. I had also originally set x86_64 to amd64 with the exact results I get with your patch. So, I looked at what the unpatched kernel was doing, which is putting i386 in those fields when building for x86_64 on an i386 machine. I don't know the results would actually run because I don't have an x86_64 myself. It may not run, but it does build.

cheers!

Signature · 1 line
*www.greenroomsoftware.com*