Skip to contentSkip to conversation

PATCH: ARCH in builddeb

PATCH Wei Chong Tan 2 participants 11 messages Sep 14, 2009 – Sep 22, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello,

I was using "make ARCH=i386 deb-pkg" in the kernel on a 64bit machine and found out that the .deb package created was _amd64.deb. Consequently, I modify the builddeb script to take into account the ARCH environment variable.

Thanks,
Tan Wei Chong.

Quoted 1 line

From 477c02443f0fb5a8e39d607197720fec21cecc8b Mon Sep 17 00:00:00 2001

From: Tan, Wei Chong <[email protected]>
Date: Mon, 14 Sep 2009 12:56:55 +0800
Subject: [PATCH] update builddeb script to allow ARCH customization

---
 scripts/package/builddeb |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
scripts/package/builddeb +5 -1
index 8b357b0..cdb017f 100644
@@ -24,7 +24,11 @@ create_package() {
 	chmod -R go-w "$pdir"
 
 	# Create the package
-	dpkg-gencontrol -isp -p$pname -P"$pdir"
+	if [ "$ARCH" = "" ] ; then
+		dpkg-gencontrol -isp -p$pname -P"$pdir"
+	else
+		dpkg-gencontrol -DArchitecture=$ARCH -isp -p$pname -P"$pdir"
+	fi
 	dpkg --build "$pdir" ..
 }
 
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 4 lines · Wei Chong Tan

I was using "make ARCH=i386 deb-pkg" in the kernel on a 64bit machine and found out that the .deb package created was _amd64.deb. Consequently, I modify the builddeb script to take into account the ARCH environment variable.

Thanks for the patch. I'd like to give it some testing though as I fear it may break one other use case that currently somehow does work correctly.

If I cross-compile for arm with EABI set in the config, the script currently correctly generates an armel package (probably through dpkg-cross).

Possibly your change would override that and change it to arm. I don't know for sure it will go wrong, but it does need testing. I'll let you know.

Cheers,
FJP

#2 lore raw
Quoted 10 lines · Frans Pop
Quoted 4 lines · Wei Chong Tan

I was using "make ARCH=i386 deb-pkg" in the kernel on a 64bit machine and found out that the .deb package created was _amd64.deb. Consequently, I modify the builddeb script to take into account the ARCH environment variable.

Thanks for the patch. I'd like to give it some testing though as I fear it may break one other use case that currently somehow does work correctly.

Quoted 7 lines

If I cross-compile for arm with EABI set in the config, the script currently correctly generates an armel package (probably through dpkg-cross).

Possibly your change would override that and change it to arm. I don't know for sure it will go wrong, but it does need testing. I'll let you know.

Yes, it is as I feared. Your patch results in an "arm" package when I do a cross-build for "armel" (for which I must of course set ARCH to "arm" as armel is not a valid Linux architecture).

I agree that being able to build i386 on amd64 is a valuable option and I have actually run into that issue myself (and solved it by building in an i386 chroot).

A possible solution could be to check that CROSS_COMPILE is *not* set, but I'm not sure if that would be the correct solution. Input from others on this would be welcome.

Cheers,
FJP

#3 lore raw
Quoted 6 lines

Yes, it is as I feared. Your patch results in an "arm" package when I do a cross-build for "armel" (for which I must of course set ARCH to "arm" as armel is not a valid Linux architecture).
A possible solution could be to check that CROSS_COMPILE is *not* set, but I'm not sure if that would be the correct solution. Input from others on this would be welcome.

Thanks Frans for the help,
I will try to check CROSS_COMPILE and see in addition to other alternatives.

Regards,
Wei Chong.

#4 lore raw

Hi Frans,

How about this? Hopefully this would work for all arch supported.

Regards,
Tan, Wei Chong.

Subject: [PATCH] update builddeb script to allow ARCH customization

scripts/package/builddeb +6 -1
index 8b357b0..96c3ae9 100644
@@ -24,7 +24,12 @@ create_package() {
 	chmod -R go-w "$pdir"
 
 	# Create the package
-	dpkg-gencontrol -isp -p$pname -P"$pdir"
+	if [ -n $ARCH ]
+	then
+		dpkg-architecture -a$ARCH -c "dpkg-gencontrol -isp -p$pname -P\"$pdir\""
+	else
+		dpkg-gencontrol -isp -p$pname -P"$pdir"
+	fi
 	dpkg --build "$pdir" ..
 }
#5 lore raw
Quoted 1 line · Wei Chong Tan

How about this? Hopefully this would work for all arch supported.

That still given me an arm instead of an armel package.

I get the following from the deb-pkg target:
dpkg-architecture: warning: Specified GNU system type arm-linux-gnu does
not match gcc system type arm-linux-gnueabi.
dpkg-deb: building package linux-image-2.6.31' in ../linux-image-2.6.31_6481.gc7572df_arm.deb'.

So, somehow dpkg is able to do the right thing based on what is set for gcc (I expect from the CROSS_COMPILE option), but not if that gets overruled as both your patches seem to be doing.

Cheers,
FJP

#6 lore raw
Quoted 3 lines · Frans Pop

So, somehow dpkg is able to do the right thing based on what is set for gcc (I expect from the CROSS_COMPILE option), but not if that gets overruled as both your patches seem to be doing.

Actually, I think the correct way to build a linux kernel for i386 on an amd64 [1] system is to use 'linux32 make deb-pkg' [2]. With that no changes to the kernel build system should be needed at all, and I think with that you even should not need to set the ARCH variable.

It should also be possible to build a 64-bit kernel for i386 on amd64 that way using 'linux32 make ARCH=x86_64 deb-pkg'.

Untested, but AFAIK that should work. Sorry for not mentioning it earlier, but it's a command I've never really used myself and I keep forgetting about it :-/

Cheers,
FJP

[1] amd64 as in the Debian architecture, which also covers Intel 64-bit
[2] linux32 is in until-linux package and thus guaranteed to be available

#7 lore raw
Quoted 9 lines · Frans Pop
Quoted 3 lines · Frans Pop

So, somehow dpkg is able to do the right thing based on what is set for gcc (I expect from the CROSS_COMPILE option), but not if that gets overruled as both your patches seem to be doing.

Actually, I think the correct way to build a linux kernel for i386 on an amd64 [1] system is to use 'linux32 make deb-pkg' [2]. With that no changes to the kernel build system should be needed at all, and I think with that you even should not need to set the ARCH variable.

I've tried it now and unfortunately this does not work either. It works perfectly for the kernel build itself, but has no effect on the package that is created, so you still get an amd64 package.

:-(

#8 lore raw
In reply to Frans Pop

Hi Frans,

Quoted 7 lines

That still given me an arm instead of an armel package.

I get the following from the deb-pkg target:
dpkg-architecture: warning: Specified GNU system type arm-linux-gnu does
not match gcc system type arm-linux-gnueabi.
dpkg-deb: building package linux-image-2.6.31' in ../linux-image-2.6.31_6481.gc7572df_arm.deb'.

dpkg-architecture seems to set a bunch of build-time environment variable, could it be there one is not set by default for arm vs armel?

Regards,
Wei Chong.

#9 lore raw
Quoted 5 lines · Wei Chong Tan
Quoted 1 line

That still given me an arm instead of an armel package.

dpkg-architecture seems to set a bunch of build-time environment variable, could it be there one is not set by default for arm vs armel?

dpkg-gencontrol, if left alone, seems to understand about cross-compiling *and* understand the difference between compiling for arm and armel, while dpkg-architecture seems to ignore that. But I really don't know enough about either to be able to say what the exact problem is or what the correct solution is here.

All I can tell you is that when I cross-compile for armel (on a Debian amd64/Lenny host system) with very simply the following set in the environment, it all magically works correctly:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-

I don't think we should lose correct automatic detection for the sake of fixing your use case.

I would suggest asking for advice on the debian-devel mailing list or, maybe even better, from the dpkg maintainers.

Cheers,
FJP

#10 lore raw

Hi Frans,

Quoted 3 lines

I don't think we should lose correct automatic detection for the sake of fixing your use case.

I agree, it is actually not such a big deal for my case. I just thought that if it can be fix once and for all, correctly for all architecture and build, then it would make others (including myself) less confused when first attempt it.

Quoted 3 lines

I would suggest asking for advice on the debian-devel mailing list or, maybe even better, from the dpkg maintainers.

Let me try to ask around debian-devel then.

Regards,
Wei Chong.