Bug#610689: [buildd-tools-devel] Bug#610689: Bug#610689: sbuild: cross support

2011-01-22 Thread Roger Leigh
On Sat, Jan 22, 2011 at 07:03:48PM +, Roger Leigh wrote:
 On Fri, Jan 21, 2011 at 12:09:55PM +, Hector Oron wrote:
I would love sbuild to gain the ability to handle cross builds.
 […]
 
 Thanks for the informative explanation, it has helped to make the
 problem a bit clearer for me.
 
  It seems that sbuild triggers dpkg --print-architecture to find out chroot 
  architecture, but when doing cross it should try to follow 
  dpkg-architecture's DEB_HOST_ARCH.
  
  Would it be possible to modify Build.pm in some way, either calling 
  dpkg-architecture or autodetecting -a$arch has been passed and it should 
  follow other architecture changes file?
 
 I think we should add two additional options:
   --host   select host arch
   --build  select build arch
 (or whatever are most commonly used in existing Debian tools; these are
 from autoconf configure) and have --arch=foo be equivalent to
 --host=foo --build=foo.

I've attached a patch (against sbuild git master, also on the
cross-build branch of git://git.debian.org/users/rleigh/sbuild.git)
which adds --host and --build options and then uses the correct
host or build arch in the appropriate places.  While I've tested
everything still works fine for normal non-cross builds, this will
need testing for cross builds to make sure I've not got the
host/build arch mixed up in any places (since I will not have
picked any error up when they are both the same).


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
   `-GPG Public Key: 0x25BFB848   Please GPG sign your mail.


signature.asc
Description: Digital signature


Bug#610689: [buildd-tools-devel] Bug#610689: Bug#610689: sbuild: cross support

2011-01-22 Thread Loïc Minier
On Sat, Jan 22, 2011, Roger Leigh wrote:
 I've attached a patch (against sbuild git master, also on the
 cross-build branch of git://git.debian.org/users/rleigh/sbuild.git)
 which adds --host and --build options and then uses the correct
 host or build arch in the appropriate places.  While I've tested
 everything still works fine for normal non-cross builds, this will
 need testing for cross builds to make sure I've not got the
 host/build arch mixed up in any places (since I will not have
 picked any error up when they are both the same).

 I think the patches got lost somewhere; I've extracted them from git
 and am attaching them here for others; thanks!

 I confirm that the first patch seems to mix build and host arch: you
 want to search for a chroot named after the build architecture rather
 than the host architecture (at least that's how I name mine  ;-)  this
 affects bin/sbuild-createchroot and the man page changes at least.  I
 also saw you're testing for build_arch in the .dsc, but the build arch
 is always irrelevant when looking at debian/* ATM -- they only speak of
 host architectures:
for my $a (split(/\s+/, $dscarchs)) {
-   if (Dpkg::Arch::debarch_is($arch, $a)) {
+   if (Dpkg::Arch::debarch_is($build_arch, $a)) {

 The second patch has a typo, it tests BUILD_ARCH != BUILD_ARCH.


 If you're looking for test cases, hello/hello-debhelper should be
 fairly easy to cross-compile, or u-boot (only latest version is fixed).

-- 
Loïc Minier
From 942d6778da6367b0b2215117f418e15a1d88dd71 Mon Sep 17 00:00:00 2001
From: Roger Leigh rle...@debian.org
Date: Sat, 22 Jan 2011 21:32:34 +
Subject: [PATCH 1/2] Add initial host/build arch separation for cross building

---
 bin/sbuild |6 ++-
 bin/sbuild-createchroot|   18 ++-
 bin/sbuild-update  |2 +
 lib/Sbuild/Build.pm|   61 +---
 lib/Sbuild/Conf.pm |9 +-
 lib/Sbuild/ConfBase.pm |   10 --
 lib/Sbuild/InternalResolver.pm |8 ++--
 lib/Sbuild/Options.pm  |9 +-
 lib/Sbuild/ResolverBase.pm |   10 +++---
 lib/Sbuild/Utility.pm  |2 +-
 man/sbuild.1.in|   15 +-
 11 files changed, 101 insertions(+), 49 deletions(-)

diff --git a/bin/sbuild b/bin/sbuild
index cafbf1b..21e2911 100755
--- a/bin/sbuild
+++ b/bin/sbuild
@@ -69,8 +69,10 @@ sub main () {
 	if $conf-get('DEBUG');
 print Selected chroot  . $conf-get('CHROOT') . \n
 	if $conf-get('DEBUG') and defined $conf-get('CHROOT');
-print Selected architecture  . $conf-get('ARCH') . \n
-	if $conf-get('DEBUG'  defined($conf-get('ARCH')));
+print Selected host architecture  . $conf-get('HOST_ARCH') . \n
+	if $conf-get('DEBUG'  defined($conf-get('HOST_ARCH')));
+print Selected build architecture  . $conf-get('BUILD_ARCH') . \n
+	if $conf-get('DEBUG'  defined($conf-get('BUILD_ARCH')));
 
 open_log($conf);
 
diff --git a/bin/sbuild-createchroot b/bin/sbuild-createchroot
index 722d9b4..4c23320 100755
--- a/bin/sbuild-createchroot
+++ b/bin/sbuild-createchroot
@@ -90,7 +90,9 @@ sub set_options {
 
 $self-add_options(
 	arch=s = sub {
-	$self-set_conf('ARCH', $_[1]);
+	# We use HOST_ARCH to store the bootstrap arch, and ARCH
+	# as the native arch
+	$self-set_conf('HOST_ARCH', $_[1]);
 	},
 	foreign = sub {
 	$self-set_conf('FOREIGN', 0);
@@ -177,7 +179,7 @@ if ($conf-get('VERBOSE')) {
 print I: SCRIPT: $script\n if (defined($script));
 }
 
-my @args = (--arch= . $conf-get('ARCH'),
+my @args = (--arch= . $conf-get('HOST_ARCH'),
 	--variant=buildd);
 push @args, --verbose if $conf-get('VERBOSE');
 push @args, --foreign if $conf-get('FOREIGN');
@@ -250,11 +252,11 @@ dump_file(${target}/etc/apt/sources.list);
 print I: Please add any additional APT sources to ${target}/etc/apt/sources.list\n;
 
 # Write out schroot chroot configuration.
-my $chrootname = ${suite}- . $conf-get('ARCH') . -sbuild;
+my $chrootname = ${suite}- . $conf-get('HOST_ARCH') . -sbuild;
 
 # Determine the schroot chroot configuration to use.
 my $config_entry;
-my $arch = $conf-get('ARCH');
+my $arch = $conf-get('HOST_ARCH');
 if ($conf-get('MAKE_SBUILD_TARBALL')) {
 my $tarball = $conf-get('MAKE_SBUILD_TARBALL');
 
@@ -300,8 +302,8 @@ if (-d /etc/schroot/chroot.d) {
 # Detect whether personality might be needed.
 if ($conf-get('ARCH') ne $conf-get('HOST_ARCH')) {
 	# Take care of the known case(s).
-	if ($conf-get('ARCH') eq 'i386' 
-	$conf-get('HOST_ARCH') eq 'amd64') {
+	if ($conf-get('HOST_ARCH') eq 'i386' 
+	$conf-get('ARCH') eq 'amd64') {
 	$personality='linux32';
 	$personality_message =
 		I: Added personality=$personality automatically (i386 on amd64).\n;
@@ -309,7 +311,7 @@ if (-d /etc/schroot/chroot.d) {
 	else {
 	$personality_message =
 		W: The selected architecture and the current architecture do not match\n .
-		W: ( . $conf-get('ARCH') .  

Bug#610689: [buildd-tools-devel] Bug#610689: Bug#610689: sbuild: cross support

2011-01-22 Thread Hector Oron
Hi,

2011/1/22 Roger Leigh rle...@codelibre.net:

 I've attached a patch (against sbuild git master, also on the
 cross-build branch of git://git.debian.org/users/rleigh/sbuild.git)
 which adds --host and --build options and then uses the correct
 host or build arch in the appropriate places.  While I've tested
 everything still works fine for normal non-cross builds, this will
 need testing for cross builds to make sure I've not got the
 host/build arch mixed up in any places (since I will not have
 picked any error up when they are both the same).

Thanks, that was quick...

From a quick glance, the package is missing automake (and autotools-dev)
build dependency. It also fails to run bootstrap code...

make: *** No rule to make target `configure', needed by
`debian/build/config.status'.  Stop.
dpkg-buildpackage: error: debian/rules build gave error exit status 2

Maybe a
configure:
   ./bootstrap
was forgotten on the debian/rules file?

Once it is built and installed,

zumbi@cat:~$ sudo sbuild -d sid_amd64 hello_2.6-1
Argument amd64 isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
sbuild (Debian sbuild) 0.60.9 (22 Jan 2011) on cat.emdebian.org
Argument amd64 isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
sbuild (Debian sbuild) 0.60.9 (22 Jan 2011) on cat.emdebian.org


â hello 2.6-1 (amd64)22 Jan 2011 23:11 â


Package: hello
Version: 2.6-1
Source Version: 2.6-1
Architecture: amd64
Host Architecture: amd64
Build Architecture: amd64
[...]
Checking correctness of dependencies...

Cannot open /srv/chroot/sid_amd64/etc/lsb-release: No such file or directory

â Install hello build dependencies (internal resolver) â


Cannot open /srv/chroot/sid_amd64/etc/lsb-release: No such file or directory
Build-Depends: base-files, base-passwd, bash, coreutils, dash,
debianutils, diffutils, dpkg, e2fsprogs, findutils, grep, gzip,
hostname, ncurses-base, ncurses-bin, perl-base, sed, login,
sysvinit-utils, sysvinit, tar, bsdutils, mount, util-linux,
libc6.1-dev | libc-dev, libc6-dev-sparc64, gcc (= 4:4.4.3), g++ (=
4:4.4.3), make, dpkg-dev (= 1.13.5)
Checking for already installed dependencies...
Use of uninitialized value $ver in hash element at
/usr/share/perl5/Sbuild/InternalResolver.pm line 558, $pipe line 7.
Use of uninitialized value $ver in hash element at
/usr/share/perl5/Sbuild/InternalResolver.pm line 560, $pipe line 7.
Use of uninitialized value $ver in hash element at
/usr/share/perl5/Sbuild/InternalResolver.pm line 558, $pipe line 8.
Use of uninitialized value $ver in hash element at
/usr/share/perl5/Sbuild/InternalResolver.pm line 558, $pipe line 8.
Can't use an undefined value as an ARRAY reference at
/usr/share/perl5/Sbuild/InternalResolver.pm line 571.

When trying --host and --build options I get:
zumbi@cat:~$ sudo sbuild -d sid_amd64 --host=armel --build=amd64 hello_2.6-1
Argument amd64 isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
Argument amd64 isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
sbuild (Debian sbuild) 0.60.9 (22 Jan 2011) on cat.emdebian.org


â hello 2.6-1 (amd64)22 Jan 2011 23:12 â


age: hello
Version: 2.6-1
Source Version: 2.6-1
Architecture: amd64
Host Architecture: armel
Build Architecture: amd64
Requested host architecture (armel) and chroot architecture (amd64) do
not match.  Skipping build.

-

zumbi@cat:~$ sudo sbuild -d sid_amd64 --host=amd64 --build=armel hello_2.6-1
Argument armel isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
Argument armel isn't numeric in numeric ne (!=) at
/usr/share/perl5/Sbuild/Build.pm line 1809.
sbuild (Debian sbuild) 0.60.9 (22 Jan 2011) on cat.emdebian.org


â hello 2.6-1 (armel)22 Jan 2011 23:13 â


Package: hello
Version: 2.6-1
Source Version: 2.6-1
Architecture: armel
Host Architecture: amd64
Build Architecture: armel
[...]
Checking correctness of dependencies...
Cannot open /srv/chroot/sid_amd64/etc/lsb-release: No such file or directory


â Install hello build dependencies (internal resolver)   

Bug#610689: [buildd-tools-devel] Bug#610689: Bug#610689: sbuild: cross support

2011-01-22 Thread Roger Leigh
On Sat, Jan 22, 2011 at 11:16:44PM +, Hector Oron wrote:
 Hi,
 
 2011/1/22 Roger Leigh rle...@codelibre.net:
 
  I've attached a patch (against sbuild git master, also on the
  cross-build branch of git://git.debian.org/users/rleigh/sbuild.git)
  which adds --host and --build options and then uses the correct
  host or build arch in the appropriate places.  While I've tested
  everything still works fine for normal non-cross builds, this will
  need testing for cross builds to make sure I've not got the
  host/build arch mixed up in any places (since I will not have
  picked any error up when they are both the same).
 
 Thanks, that was quick...
 
 From a quick glance, the package is missing automake (and autotools-dev)
 build dependency. It also fails to run bootstrap code...
 
 make: *** No rule to make target `configure', needed by
 `debian/build/config.status'.  Stop.
 dpkg-buildpackage: error: debian/rules build gave error exit status 2
 
 Maybe a
 configure:
./bootstrap
 was forgotten on the debian/rules file?

No, this is intended.  The debian packaging builds from the release
tarball, not the plain git repo, which needs make dist running to
generate the release tarball (as for most upstream projects--it's not
Debian native).
If you run the top-level ./bootstrap from the git repository, it will
set things up and then autoreconf (it gets the version from NEWS and
the release metadata out of git).

 zumbi@cat:~$ sudo sbuild -d sid_amd64 hello_2.6-1
 Argument amd64 isn't numeric in numeric ne (!=) at
 /usr/share/perl5/Sbuild/Build.pm line 1809.

Fixed in git on cross-build.

 Use of uninitialized value $ver in hash element at
 /usr/share/perl5/Sbuild/InternalResolver.pm line 558, $pipe line 7.

This one I'm not sure about yet; I'll take a better look tomorrow.
I didn't test with internal because it most likely can't be made
to work to install cross-build dependencies.

 When trying --host and --build options I get:
 zumbi@cat:~$ sudo sbuild -d sid_amd64 --host=armel --build=amd64 hello_2.6-1

As I mentioned to Loïc, I messed up and confused the host/build.
I'll fix up that and the other issues and then hopefully have a
better place to start testing!

The internal resolver errors look the same as without cross-building.


Many thanks for testing!  I'll get back to you with something better
as soon as I can.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
   `-GPG Public Key: 0x25BFB848   Please GPG sign your mail.


signature.asc
Description: Digital signature