2010-11-01 23:45:24

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

If the environment variable CROSS_COMPILE is set, override
the Architecture control field, based on the value of the
ARCH environment variable.

With this patch the following make command:

make CROSS_COMPILE='' ARCH=i386 deb-pkg

will output an i386 Debian package instead of an amd64 one,
when run on amd64 machine.

Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 49b74e1..e5b7b9b 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,20 @@ create_package() {
chown -R root:root "$pdir"
chmod -R go-w "$pdir"

+ # Check for cross compilation
+ local forcearch=""
+ env | grep -q CROSS_COMPILE
+ if [ $? -eq 0 ] ; then
+ local debarch=""
+ case "$ARCH" in
+ x86_64) debarch="amd64" ;;
+ *) debarch="$ARCH" ;;
+ esac
+ forcearch="-DArchitecture=$debarch"
+ fi
+
# Create the package
- dpkg-gencontrol -isp -p$pname -P"$pdir"
+ dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
dpkg --build "$pdir" ..
}

--
1.7.2.3


2010-11-03 22:57:10

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 2.11.2010 00:31, Asbjoern Sloth Toennesen wrote:
> If the environment variable CROSS_COMPILE is set, override
> the Architecture control field, based on the value of the
> ARCH environment variable.
>
> With this patch the following make command:
>
> make CROSS_COMPILE='' ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on amd64 machine.

I know very little about debian packaging, but shouldn't this be done in
all cases, regardless of CROSS_COMPILE being set or not? You even show
in the above example that in some cases you don't need CROSS_COMPILE to
build a kernel for a different architecture. make rpm-pkg seems to
suffer from the same problem, btw.

Michal

2010-11-03 23:25:48

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 3.11.2010 23:57, Michal Marek wrote:
> build a kernel for a different architecture. make rpm-pkg seems to
> suffer from the same problem, btw.

rpm-pkg actually handles this properly, it runs rpmbuild --target
$(UTS_MACHINE).

Michal

2010-11-04 01:50:25

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 11/03/2010 10:57 PM, Michal Marek wrote:
> I know very little about debian packaging, but shouldn't this be done in
> all cases, regardless of CROSS_COMPILE being set or not? You even show
> in the above example that in some cases you don't need CROSS_COMPILE to
> build a kernel for a different architecture.

I had a problem earlier with Kbuild ignoring ARCH if CROSS_COMPILE
wasn't set, but can't reproduce with the current kernel, but I also
started out with upgrading it from .26, since squeezes .32 doesn't work
on Soekris net4501. So this is no longer an issue.

The other reason for make it dependent on CROSS_COMPILE at least to
begin with is that the ARCH -> debarch translation table doesn't have to
be as complete since it doesn't break anything in the currently working
non-cross compile senario. If this doesn't matter then I will send a new
patch, that doesn't depend on CROSS_COMPILE being set.

I have CC'ed the debian-kernel list, for people not on LKML:
https://patchwork.kernel.org/patch/296182/

2010-11-04 02:47:12

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

Attempt to guess the correct value of the Architecture control
field, based on the ARCH environment variable. Fallback to letting
deb-gencontrol use the host platform's architecture.

With this patch the following make command:

make ARCH=i386 deb-pkg

will output an i386 Debian package instead of an amd64 one,
when run on amd64 machine.

Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5f1e2fc..02fd63f 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,24 @@ create_package() {
chown -R root:root "$pdir"
chmod -R go-w "$pdir"

+ # Attempt to find correct debian architecture
+ local forcearch="" debarch=""
+ case "$ARCH" in
+ x86_64) debarch="amd64" ;;
+ i386|ia64) debarch="$ARCH" ;;
+ *)
+ case "$SUBARCH" in
+ arm) debarch=$(grep -q CONFIG_AEABI=y .config \
+ && echo armel || echo arm) ;;
+ esac
+ ;;
+ esac
+ if [ -n "$debarch" ] ; then
+ forcearch="-DArchitecture=$debarch"
+ fi
+
# Create the package
- dpkg-gencontrol -isp -p$pname -P"$pdir"
+ dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
dpkg --build "$pdir" ..
}

--
1.7.2.3

2010-11-04 03:39:03

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 11/04/2010 02:42 AM, Asbjoern Sloth Toennesen wrote:
> + case "$SUBARCH" in
> + arm) debarch=$(grep -q CONFIG_AEABI=y .config \
> + && echo armel || echo arm) ;;
> + esac

Hmm, didn't test the ARM part of that patch properly SUBARCH isn't
available to builddeb. Will reply to this mail with fixed patch.

2010-11-04 03:44:35

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

Attempt to guess the correct value of the Architecture control
field, based on the ARCH environment variable. Fallback to letting
deb-gencontrol use the host platform's architecture.

With this patch the following make command:

make ARCH=i386 deb-pkg

will output an i386 Debian package instead of an amd64 one,
when run on amd64 machine.

Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5f1e2fc..43b8826 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,23 @@ create_package() {
chown -R root:root "$pdir"
chmod -R go-w "$pdir"

+ # Attempt to find the correct Debian architecture
+ local forcearch="" debarch=""
+ case "$ARCH" in
+ i386|ia64)
+ debarch="$ARCH" ;;
+ x86_64)
+ debarch="amd64" ;;
+ *)
+ grep -q CONFIG_ARM=y .config &&
+ debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el)
+ esac
+ if [ -n "$debarch" ] ; then
+ forcearch="-DArchitecture=$debarch"
+ fi
+
# Create the package
- dpkg-gencontrol -isp -p$pname -P"$pdir"
+ dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
dpkg --build "$pdir" ..
}

--
1.7.2.3

2010-11-04 05:58:05

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On Thu, Nov 04, 2010 at 03:44:04AM +0000, Asbjoern Sloth Toennesen wrote:
> Attempt to guess the correct value of the Architecture control
> field, based on the ARCH environment variable. Fallback to letting
> deb-gencontrol use the host platform's architecture.
>
> With this patch the following make command:
>
> make ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on amd64 machine.
>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
> ---
> scripts/package/builddeb | 17 ++++++++++++++++-
> 1 files changed, 16 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 5f1e2fc..43b8826 100644
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -25,8 +25,23 @@ create_package() {
> chown -R root:root "$pdir"
> chmod -R go-w "$pdir"
>
> + # Attempt to find the correct Debian architecture
> + local forcearch="" debarch=""
> + case "$ARCH" in
> + i386|ia64)
> + debarch="$ARCH" ;;
> + x86_64)
> + debarch="amd64" ;;

On the commandline I can say ARCH=x86 - will it do the right thing then?

> + *)
> + grep -q CONFIG_ARM=y .config &&
> + debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el)
> + esac

sparc may be know as sparc32, sparc64 and sparc these days.
I recall that at least in the past debian supported sparc.

Sam

2010-11-04 12:29:28

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 11/04/2010 05:58 AM, Sam Ravnborg wrote:
> On Thu, Nov 04, 2010 at 03:44:04AM +0000, Asbjoern Sloth Toennesen wrote:
>> [...]
>> + # Attempt to find the correct Debian architecture
>> + local forcearch="" debarch=""
>> + case "$ARCH" in
>> + i386|ia64)
>> + debarch="$ARCH" ;;
>> + x86_64)
>> + debarch="amd64" ;;
>
> On the commandline I can say ARCH=x86 - will it do the right thing then?

No, not if you are cross compiling since ARCH=x86 isn't specific to
either, we would have to look at the config. In that case it is better
to do something like:

x86|i386|x86_64)
debarch=$(grep -q CONFIG_64BIT=y .config &&
echo amd64 || echo i386) ;;

>> + *)
>> + grep -q CONFIG_ARM=y .config &&
>> + debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el)
>> + esac
>
> sparc may be know as sparc32, sparc64 and sparc these days.
> I recall that at least in the past debian supported sparc.

I only included the major Debian architectures in my patch since, I
don't know enough about all the smaller architectures and there config
dependencies. I have however added mips as it seemed straight forward.

AFAICT there are some problems surrounding sparc, since sparc in debian
uses 64-bit kernels, 32-bit userland, and the new sparc64 port uses
64-kernels and 64-bit userland, so we have no way of knowing if the
64-bit sparc kernel should have the Architecture field set to sparc or
sparc64.

For now I will just set it to sparc, as that is a release candidate for
squeeze, where sparc64 isn't nearly that far along.

sparc*)
debarch=sparc ;;
mips)
debarch=mips$(grep -q CPU_LITTLE_ENDIAN && echo el) ;;


I will sum these up in a new revision of the patch, when I get an ack
from Michal or a Debian kernel team member.

2010-11-04 12:36:16

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 4.11.2010 13:29, Asbj?rn Sloth T?nnesen wrote:
> No, not if you are cross compiling since ARCH=x86 isn't specific to
> either, we would have to look at the config. In that case it is better
> to do something like:
>
> x86|i386|x86_64)
> debarch=$(grep -q CONFIG_64BIT=y .config &&

No, you should use $UTS_MACHINE (`uname -m` in the resulting kernel),
like make rpm-pkg does, and only translate x86_64 to amd64.

Michal

2010-11-04 13:34:02

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: fix Architecture field when cross compiling

On 11/04/2010 12:36 PM, Michal Marek wrote:
> On 4.11.2010 13:29, Asbj?rn Sloth T?nnesen wrote:
>> No, not if you are cross compiling since ARCH=x86 isn't specific to
>> either, we would have to look at the config. In that case it is better
>> to do something like:
>>
>> x86|i386|x86_64)
>> debarch=$(grep -q CONFIG_64BIT=y .config &&
>
> No, you should use $UTS_MACHINE (`uname -m` in the resulting kernel),
> like make rpm-pkg does, and only translate x86_64 to amd64.

Ok, sorry, hadn't caught that it was on the resulting kernel.

So that solves the x86 architectures, but according to a quick git grep,
.config analysis is still needed for arm(el) and mips(el).

2010-11-05 12:33:09

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: select userland architectire based on UTS_MACHINE

Instead of creating the debian package for the compiling userland,
create it for a userland matching the kernel thats being compiled.

This patch supports all Lenny release architectures,
and Linux-based architecture candidates for Squeeze.

If it can't find a proper Debian userspace it displays a warning,
and fallback to let deb-gencontrol use the host's userspace arch.

Eg. with this patch the following make command:

make ARCH=i386 deb-pkg

will output an i386 Debian package instead of an amd64 one,
when run on an amd64 machine.

Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5f1e2fc..1df1cc0 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,39 @@ 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|hppa)
+ debarch="$UTS_MACHINE" ;;
+ x86_64)
+ debarch=amd64 ;;
+ sparc*)
+ debarch=sparc ;;
+ s390*)
+ debarch=s390 ;;
+ ppc*)
+ debarch=powerpc ;;
+ 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 "$debarch" ] ; then
+ forcearch="-DArchitecture=$debarch"
+ fi
+
# Create the package
- dpkg-gencontrol -isp -p$pname -P"$pdir"
+ dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
dpkg --build "$pdir" ..
}

--
1.7.2.3

2010-11-05 12:41:38

by maximilian attems

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architectire based on UTS_MACHINE

On Fri, Nov 05, 2010 at 12:32:41PM +0000, Asbjoern Sloth Toennesen wrote:
> Instead of creating the debian package for the compiling userland,
> create it for a userland matching the kernel thats being compiled.
>
> This patch supports all Lenny release architectures,
> and Linux-based architecture candidates for Squeeze.
>
> If it can't find a proper Debian userspace it displays a warning,
> and fallback to let deb-gencontrol use the host's userspace arch.
>
> Eg. with this patch the following make command:
>
> make ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on an amd64 machine.
>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>

thank you, indeed very cool.

Acked-by: maximilian attems <[email protected]>
> ---
> scripts/package/builddeb | 33 ++++++++++++++++++++++++++++++++-
> 1 files changed, 32 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 5f1e2fc..1df1cc0 100644
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -25,8 +25,39 @@ 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|hppa)
> + debarch="$UTS_MACHINE" ;;

small nitpick parisc* != hppa


> + x86_64)
> + debarch=amd64 ;;
> + sparc*)
> + debarch=sparc ;;
> + s390*)
> + debarch=s390 ;;
> + ppc*)
> + debarch=powerpc ;;
> + 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 "$debarch" ] ; then
> + forcearch="-DArchitecture=$debarch"
> + fi
> +
> # Create the package
> - dpkg-gencontrol -isp -p$pname -P"$pdir"
> + dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
> dpkg --build "$pdir" ..
> }
>
> --
> 1.7.2.3
>
> --
> 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

2010-11-05 12:44:48

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architectire based on UTS_MACHINE

On 11/05/2010 12:32 PM, Asbjoern Sloth Toennesen wrote:
> kbuild, deb-pkg: select userland architectire based on UTS_MACHINE

s/architectire/architecture/g

2010-11-05 13:29:47

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architectire based on UTS_MACHINE

On 11/05/2010 12:41 PM, maximilian attems wrote:
> On Fri, Nov 05, 2010 at 12:32:41PM +0000, Asbjoern Sloth Toennesen wrote:
>> Instead of creating the debian package for the compiling userland,
>> create it for a userland matching the kernel thats being compiled.
>>
>> This patch supports all Lenny release architectures,
>> and Linux-based architecture candidates for Squeeze.
>>
>> If it can't find a proper Debian userspace it displays a warning,
>> and fallback to let deb-gencontrol use the host's userspace arch.
>>
>> Eg. with this patch the following make command:
>>
>> make ARCH=i386 deb-pkg
>>
>> will output an i386 Debian package instead of an amd64 one,
>> when run on an amd64 machine.
>>
>> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
>
> thank you, indeed very cool.

Thanks.

>> [...]
>> + case "$UTS_MACHINE" in
>> + i386|ia64|alpha|hppa)
>> + debarch="$UTS_MACHINE" ;;
>
> small nitpick parisc* != hppa

Right, hppa should be by it self.

2010-11-05 13:30:23

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: select userland architecture based on UTS_MACHINE

Instead of creating the debian package for the compiling userland,
create it for a userland matching the kernel thats being compiled.

This patch supports all Lenny release architectures,
and Linux-based architecture candidates for Squeeze.

If it can't find a proper Debian userspace it displays a warning,
and fallback to let deb-gencontrol use the host's userspace arch.

Eg. with this patch the following make command:

make ARCH=i386 deb-pkg

will output an i386 Debian package instead of an amd64 one,
when run on an amd64 machine.

Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5f1e2fc..0043ccd 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,41 @@ 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 "$debarch" ] ; then
+ forcearch="-DArchitecture=$debarch"
+ fi
+
# Create the package
- dpkg-gencontrol -isp -p$pname -P"$pdir"
+ dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
dpkg --build "$pdir" ..
}

--
1.7.2.3

2010-11-05 13:36:47

by maximilian attems

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architecture based on UTS_MACHINE

On Fri, Nov 05, 2010 at 01:30:08PM +0000, Asbjoern Sloth Toennesen wrote:
> Instead of creating the debian package for the compiling userland,
> create it for a userland matching the kernel thats being compiled.
>
> This patch supports all Lenny release architectures,
> and Linux-based architecture candidates for Squeeze.
>
> If it can't find a proper Debian userspace it displays a warning,
> and fallback to let deb-gencontrol use the host's userspace arch.
>
> Eg. with this patch the following make command:
>
> make ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on an amd64 machine.
>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>

please add my ack as Debian linux-2.6 maintainer.

Acked-by: maximilian attems <[email protected]>
> ---
> scripts/package/builddeb | 35 ++++++++++++++++++++++++++++++++++-
> 1 files changed, 34 insertions(+), 1 deletions(-)
>

2010-11-05 13:43:55

by Sven-Haegar Koch

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architecture based on UTS_MACHINE

On Fri, 5 Nov 2010, Asbjoern Sloth Toennesen wrote:

> Instead of creating the debian package for the compiling userland,
> create it for a userland matching the kernel thats being compiled.

> Eg. with this patch the following make command:
>
> make ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on an amd64 machine.

How do I either select a differnet package-arch or reverse to the
current way?

I am right now using 'make ARCH=x86_64 deb-pkg' on a 32bit userspace
environment running with a 64bit kernel, wanting to create packages to
be installed in this i386 arch.

(As I want 64bit support where possible (mostly for AES-NI support in
dm-crypt), but don't have the time available to do a complete userspace
reinstall and reconfiguration)

c'ya
sven-haegar

--
Three may keep a secret, if two of them are dead.
- Ben F.

2010-11-06 19:04:45

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architecture based on UTS_MACHINE

On 11/05/2010 01:42 PM, Sven-Haegar Koch wrote:
> On Fri, 5 Nov 2010, Asbjoern Sloth Toennesen wrote:
>
>> Instead of creating the debian package for the compiling userland,
>> create it for a userland matching the kernel thats being compiled.
>
>> Eg. with this patch the following make command:
>>
>> make ARCH=i386 deb-pkg
>>
>> will output an i386 Debian package instead of an amd64 one,
>> when run on an amd64 machine.
>
> How do I either select a differnet package-arch or reverse to the
> current way?
>
> I am right now using 'make ARCH=x86_64 deb-pkg' on a 32bit userspace
> environment running with a 64bit kernel, wanting to create packages to
> be installed in this i386 arch.
>
> (As I want 64bit support where possible (mostly for AES-NI support in
> dm-crypt), but don't have the time available to do a complete userspace
> reinstall and reconfiguration)

Sounds like an one off thing, so in your case forcing the installation
should work:

dpkg --force-architecture linux-image-*.deb

The problem with that approach is that it doesn't work with APT, but I
doubt that there are any private APT repositories with this environment.

The issue with one kernel and 2 userspaces will also arise in sparc,
when the sparc64 userland gets going. So it will need to be dealt with
at some point, so I create a 3 lines additional patch for it.

2010-11-06 19:05:33

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH] kbuild, deb-pkg: support overriding userland architecture

Usefull if building for sparc64 userland, because the
sparc and sparc64 userlands use the same 64-bit kernel,
making it impossible to always select the correct userland
architecture for the resulting debian package.

Might also be usefull, if you want a i386 userland with a amd64 kernel.

Example usage:
make DEBARCH=i386 deb-pkg

This patch is based on my 'kbuild, deb-pkg: select
userland architecture based on UTS_MACHINE' patch.

LKML-reference: <[email protected]>
Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
---
scripts/package/builddeb | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 0043ccd..4772a73 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -54,6 +54,9 @@ create_package() {
echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
echo "" >&2
esac
+ if [ -n "$DEBARCH" ] ; then
+ debarch="$DEBARCH"
+ fi
if [ -n "$debarch" ] ; then
forcearch="-DArchitecture=$debarch"
fi
--
1.7.2.3

2010-11-07 08:22:52

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: support overriding userland architecture

On Sat, Nov 06, 2010 at 07:05:20PM +0000, Asbjoern Sloth Toennesen wrote:
>Usefull if building for sparc64 userland, because the
>sparc and sparc64 userlands use the same 64-bit kernel,
>making it impossible to always select the correct userland
>architecture for the resulting debian package.
>
>Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
>Example usage:
> make DEBARCH=i386 deb-pkg
>
>This patch is based on my 'kbuild, deb-pkg: select
>userland architecture based on UTS_MACHINE' patch.
>

This is a good idea. :)

Reviewed-by: WANG Cong <[email protected]>

Thanks.

--
Live like a child, think like the god.

2010-11-25 14:35:56

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: select userland architecture based on UTS_MACHINE

On Fri, Nov 05, 2010 at 01:30:08PM +0000, Asbjoern Sloth Toennesen wrote:
> Instead of creating the debian package for the compiling userland,
> create it for a userland matching the kernel thats being compiled.
>
> This patch supports all Lenny release architectures,
> and Linux-based architecture candidates for Squeeze.
>
> If it can't find a proper Debian userspace it displays a warning,
> and fallback to let deb-gencontrol use the host's userspace arch.
>
> Eg. with this patch the following make command:
>
> make ARCH=i386 deb-pkg
>
> will output an i386 Debian package instead of an amd64 one,
> when run on an amd64 machine.
>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
> ---
> scripts/package/builddeb | 35 ++++++++++++++++++++++++++++++++++-
> 1 files changed, 34 insertions(+), 1 deletions(-)

Applied to kbuild-2.6.git#packaging, thanks.

Michal

2010-11-25 14:37:43

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: support overriding userland architecture

On Sat, Nov 06, 2010 at 07:05:20PM +0000, Asbjoern Sloth Toennesen wrote:
> Usefull if building for sparc64 userland, because the
> sparc and sparc64 userlands use the same 64-bit kernel,
> making it impossible to always select the correct userland
> architecture for the resulting debian package.
>
> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
> Example usage:
> make DEBARCH=i386 deb-pkg

This variable deserves a mention in Documentation/kbuild/kbuild.txt not
just in the commit log. Otherwise the patch is OK with me.

Michal

2010-11-25 19:10:38

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: support overriding userland architecture

On Thu, Nov 25, 2010 at 03:37:39PM +0100, Michal Marek wrote:
> On Sat, Nov 06, 2010 at 07:05:20PM +0000, Asbjoern Sloth Toennesen wrote:
> > Usefull if building for sparc64 userland, because the
> > sparc and sparc64 userlands use the same 64-bit kernel,
> > making it impossible to always select the correct userland
> > architecture for the resulting debian package.
> >
> > Might also be usefull, if you want a i386 userland with a amd64 kernel.
> >
> > Example usage:
> > make DEBARCH=i386 deb-pkg
>
> This variable deserves a mention in Documentation/kbuild/kbuild.txt not
> just in the commit log. Otherwise the patch is OK with me.
kbuild related variables is usually named KBUILD_* - but not all of them.

Sam

2010-12-03 17:48:05

by maximilian attems

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: support overriding userland architecture

hello Asbjoern,

On Sat, 06 Nov 2010, Asbjoern Sloth Toennesen wrote:

> Usefull if building for sparc64 userland, because the
> sparc and sparc64 userlands use the same 64-bit kernel,
> making it impossible to always select the correct userland
> architecture for the resulting debian package.
>
> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
> Example usage:
> make DEBARCH=i386 deb-pkg
>
> This patch is based on my 'kbuild, deb-pkg: select
> userland architecture based on UTS_MACHINE' patch.

care to repost with KBUILD_ prefix, to keep namespace sane and mention
in Documentation/kbuild/kbuild.txt together with the relevant acks.
It be really cool to have that in next 2.6.38.

thanks

> LKML-reference: <[email protected]>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>

Acked-by: maximilian attems <[email protected]>

2010-12-03 19:37:30

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH] kbuild, deb-pkg: support overriding userland architecture

Hi Max,

On 12/03/2010 05:48 PM, maximilian attems wrote:
> On Sat, 06 Nov 2010, Asbjoern Sloth Toennesen wrote:
>> Usefull if building for sparc64 userland, because the
>> sparc and sparc64 userlands use the same 64-bit kernel,
>> making it impossible to always select the correct userland
>> architecture for the resulting debian package.
>>
>> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>>
>> Example usage:
>> make DEBARCH=i386 deb-pkg
>>
>> This patch is based on my 'kbuild, deb-pkg: select
>> userland architecture based on UTS_MACHINE' patch.
>
> care to repost with KBUILD_ prefix, to keep namespace sane and mention
> in Documentation/kbuild/kbuild.txt together with the relevant acks.
> It be really cool to have that in next 2.6.38.

Sure its on my todo for the weekend, have just had an insane week.

I just noticed the armhf port effort yesterday, that would also need
this patch, I will add your Ack-by when sending the updated patch.

I also have a bunch of e1000e cleanups scheduled for 2.6.38, will submit
to netdev this weekend as well.

Thanks, for the reminding effort.

--
Best regards
Asbjørn Sloth Tønnesen
asbjorn.biz

2010-12-08 21:36:06

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH v2] kbuild, deb-pkg: support overriding userland architecture

Usefull if building for sparc64 userland, because the
sparc and sparc64 userlands use the same 64-bit kernel,
making it impossible to always select the correct userland
architecture for the resulting debian package.

Might also be usefull, if you want a i386 userland with a amd64 kernel.

Example usage:
make DEBARCH=i386 deb-pkg

LKML-reference: <[email protected]>
Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
Acked-by: maximilian attems <[email protected]>
---
Documentation/kbuild/kbuild.txt | 8 ++++++++
scripts/package/builddeb | 3 +++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 634c625..2940df0 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -60,6 +60,14 @@ But some architectures such as x86 and sparc have aliases.
x86: i386 for 32 bit, x86_64 for 64 bit
sparc: sparc for 32 bit, sparc64 for 64 bit

+DEBARCH
+--------------------------------------------------
+For the deb-pkg target, allows overriding the normal heuristics deployed by
+deb-deb. Normally deb-pkg attempts to guess the right architecture based on
+the UTS_MACHINE variable, and on some architectures also the kernel config.
+The value of DEBARCH is assumed (not checked) to be a valid Debian
+architecture.
+
CROSS_COMPILE
--------------------------------------------------
Specify an optional fixed part of the binutils filename.
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5d6be3f..22b6995 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -54,6 +54,9 @@ create_package() {
echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
echo "" >&2
esac
+ if [ -n "$DEBARCH" ] ; then
+ debarch="$DEBARCH"
+ fi
if [ -n "$debarch" ] ; then
forcearch="-DArchitecture=$debarch"
fi
--
1.7.2.3

2010-12-09 14:24:50

by maximilian attems

[permalink] [raw]
Subject: Re: [PATCH v2] kbuild, deb-pkg: support overriding userland architecture

On Wed, Dec 08, 2010 at 09:35:50PM +0000, Asbjoern Sloth Toennesen wrote:
> Usefull if building for sparc64 userland, because the
> sparc and sparc64 userlands use the same 64-bit kernel,
> making it impossible to always select the correct userland
> architecture for the resulting debian package.
>
> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
> Example usage:
> make DEBARCH=i386 deb-pkg

hmm the conclusion was to prepend a KBUILD_ prefix for a kbuild variable?
Any reason why that was overlooked?

I checked man devscripts and saw yet no definition of DEBARCH, but in order
not to have any potential conflicts and to keep namespase sane I think
it is very much preferred to use KBUILD_DEBARCH.

thanks

--
maks

2010-12-09 15:23:34

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH v2] kbuild, deb-pkg: support overriding userland architecture

On 12/09/2010 02:24 PM, maximilian attems wrote:
> On Wed, Dec 08, 2010 at 09:35:50PM +0000, Asbjoern Sloth Toennesen wrote:
>> Usefull if building for sparc64 userland, because the
>> sparc and sparc64 userlands use the same 64-bit kernel,
>> making it impossible to always select the correct userland
>> architecture for the resulting debian package.
>>
>> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>>
>> Example usage:
>> make DEBARCH=i386 deb-pkg
>
> hmm the conclusion was to prepend a KBUILD_ prefix for a kbuild variable?
> Any reason why that was overlooked?
>
> I checked man devscripts and saw yet no definition of DEBARCH, but in order
> not to have any potential conflicts and to keep namespase sane I think
> it is very much preferred to use KBUILD_DEBARCH.

Sorry, I forgot it, patch comming up.

2010-12-09 15:31:56

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH v3] kbuild, deb-pkg: support overriding userland architecture

Usefull if building for sparc64 userland, because the
sparc and sparc64 userlands use the same 64-bit kernel,
making it impossible to always select the correct userland
architecture for the resulting debian package.

Might also be usefull, if you want a i386 userland with a amd64 kernel.

Example usage:
make KBUILD_DEBARCH=i386 deb-pkg

LKML-reference: <[email protected]>
Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
Acked-by: maximilian attems <[email protected]>
---
Documentation/kbuild/kbuild.txt | 8 ++++++++
scripts/package/builddeb | 3 +++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 634c625..9cf3bf0 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -60,6 +60,14 @@ But some architectures such as x86 and sparc have aliases.
x86: i386 for 32 bit, x86_64 for 64 bit
sparc: sparc for 32 bit, sparc64 for 64 bit

+KBUILD_DEBARCH
+--------------------------------------------------
+For the deb-pkg target, allows overriding the normal heuristics deployed by
+deb-deb. Normally deb-pkg attempts to guess the right architecture based on
+the UTS_MACHINE variable, and on some architectures also the kernel config.
+The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
+architecture.
+
CROSS_COMPILE
--------------------------------------------------
Specify an optional fixed part of the binutils filename.
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5d6be3f..ffe2419 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -54,6 +54,9 @@ create_package() {
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
--
1.7.2.3

2010-12-09 15:34:36

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH v3] kbuild, deb-pkg: support overriding userland architecture

On 9.12.2010 16:24, Asbjoern Sloth Toennesen wrote:
> Usefull if building for sparc64 userland, because the
> sparc and sparc64 userlands use the same 64-bit kernel,
> making it impossible to always select the correct userland
> architecture for the resulting debian package.
>
> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
> Example usage:
> make KBUILD_DEBARCH=i386 deb-pkg
>
> LKML-reference: <[email protected]>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
> Reviewed-by: WANG Cong <[email protected]>
> Acked-by: maximilian attems <[email protected]>
> ---
> Documentation/kbuild/kbuild.txt | 8 ++++++++
> scripts/package/builddeb | 3 +++
> 2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
> index 634c625..9cf3bf0 100644
> --- a/Documentation/kbuild/kbuild.txt
> +++ b/Documentation/kbuild/kbuild.txt
> @@ -60,6 +60,14 @@ But some architectures such as x86 and sparc have aliases.
> x86: i386 for 32 bit, x86_64 for 64 bit
> sparc: sparc for 32 bit, sparc64 for 64 bit
>
> +KBUILD_DEBARCH
> +--------------------------------------------------
> +For the deb-pkg target, allows overriding the normal heuristics deployed by
> +deb-deb. Normally deb-pkg attempts to guess the right architecture based on
^^^^^^^

deb-pkg?

Michal

2010-12-09 15:42:11

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: Re: [PATCH v3] kbuild, deb-pkg: support overriding userland architecture

On 12/09/2010 03:34 PM, Michal Marek wrote:
> On 9.12.2010 16:24, Asbjoern Sloth Toennesen wrote:
>> Usefull if building for sparc64 userland, because the
>> sparc and sparc64 userlands use the same 64-bit kernel,
>> making it impossible to always select the correct userland
>> architecture for the resulting debian package.
>>
>> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>>
>> Example usage:
>> make KBUILD_DEBARCH=i386 deb-pkg
>>
>> LKML-reference: <[email protected]>
>> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
>> Reviewed-by: WANG Cong <[email protected]>
>> Acked-by: maximilian attems <[email protected]>
>> ---
>> Documentation/kbuild/kbuild.txt | 8 ++++++++
>> scripts/package/builddeb | 3 +++
>> 2 files changed, 11 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
>> index 634c625..9cf3bf0 100644
>> --- a/Documentation/kbuild/kbuild.txt
>> +++ b/Documentation/kbuild/kbuild.txt
>> @@ -60,6 +60,14 @@ But some architectures such as x86 and sparc have aliases.
>> x86: i386 for 32 bit, x86_64 for 64 bit
>> sparc: sparc for 32 bit, sparc64 for 64 bit
>>
>> +KBUILD_DEBARCH
>> +--------------------------------------------------
>> +For the deb-pkg target, allows overriding the normal heuristics deployed by
>> +deb-deb. Normally deb-pkg attempts to guess the right architecture based on
> ^^^^^^^
>
> deb-pkg?

Sure. Anything else before I make a v4?

2010-12-12 17:48:07

by Asbjoern Sloth Toennesen

[permalink] [raw]
Subject: [PATCH v4] kbuild, deb-pkg: support overriding userland architecture

Usefull if building for sparc64 userland, because the
sparc and sparc64 userlands use the same 64-bit kernel,
making it impossible to always select the correct userland
architecture for the resulting debian package.

Might also be usefull, if you want a i386 userland with a amd64 kernel.

Example usage:
make KBUILD_DEBARCH=i386 deb-pkg

LKML-reference: <[email protected]>
Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
Acked-by: maximilian attems <[email protected]>
---
Documentation/kbuild/kbuild.txt | 8 ++++++++
scripts/package/builddeb | 3 +++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 634c625..b146eb8 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -51,6 +51,14 @@ Specify the output directory when building the kernel.
The output directory can also be specificed using "O=...".
Setting "O=..." takes precedence over KBUILD_OUTPUT.

+KBUILD_DEBARCH
+--------------------------------------------------
+For the deb-pkg target, allows overriding the normal heuristics deployed by
+deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
+the UTS_MACHINE variable, and on some architectures also the kernel config.
+The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
+architecture.
+
ARCH
--------------------------------------------------
Set ARCH to the architecture to be built.
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5d6be3f..ffe2419 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -54,6 +54,9 @@ create_package() {
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
--
1.7.2.3

2010-12-20 15:53:59

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH v4] kbuild, deb-pkg: support overriding userland architecture

On Sun, Dec 12, 2010 at 05:39:40PM +0000, Asbjoern Sloth Toennesen wrote:
> Usefull if building for sparc64 userland, because the
> sparc and sparc64 userlands use the same 64-bit kernel,
> making it impossible to always select the correct userland
> architecture for the resulting debian package.
>
> Might also be usefull, if you want a i386 userland with a amd64 kernel.
>
> Example usage:
> make KBUILD_DEBARCH=i386 deb-pkg
>
> LKML-reference: <[email protected]>
> Signed-off-by: Asbjoern Sloth Toennesen <[email protected]>
> Reviewed-by: WANG Cong <[email protected]>
> Acked-by: maximilian attems <[email protected]>

Applied to kbuild-2.6.git#packaging, thanks.

Michal