From patchwork Wed Dec 14 17:54:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wookey X-Patchwork-Id: 5704 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C4B9223E0E for ; Wed, 14 Dec 2011 17:54:57 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id B2D20A18832 for ; Wed, 14 Dec 2011 17:54:57 +0000 (UTC) Received: by eaak10 with SMTP id k10so972414eaa.11 for ; Wed, 14 Dec 2011 09:54:57 -0800 (PST) Received: by 10.204.133.213 with SMTP id g21mr1717328bkt.126.1323885296756; Wed, 14 Dec 2011 09:54:56 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs15383bkc; Wed, 14 Dec 2011 09:54:56 -0800 (PST) Received: by 10.204.7.81 with SMTP id c17mr1688569bkc.63.1323885295226; Wed, 14 Dec 2011 09:54:55 -0800 (PST) Received: from stoneboat.aleph1.co.uk (stoneboat.aleph1.co.uk. [80.68.88.63]) by mx.google.com with ESMTPS id eo3si1985435wbb.50.2011.12.14.09.54.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Dec 2011 09:54:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of wookey@aleph1.co.uk designates 80.68.88.63 as permitted sender) client-ip=80.68.88.63; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of wookey@aleph1.co.uk designates 80.68.88.63 as permitted sender) smtp.mail=wookey@aleph1.co.uk Received: from host-78-151-164-206.static.as13285.net ([78.151.164.206] helo=dream.aleph1.co.uk) by stoneboat.aleph1.co.uk with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1Rat2Z-00059Q-Ol; Wed, 14 Dec 2011 17:54:54 +0000 Received: from wookey by dream.aleph1.co.uk with local (Exim 4.72) (envelope-from ) id 1Rat2T-00067b-MX; Wed, 14 Dec 2011 17:54:45 +0000 From: wookey@linaro.org To: patches@linaro.org Cc: Wookey Date: Wed, 14 Dec 2011 17:54:17 +0000 Message-Id: <1323885273-23505-1-git-send-email-wookey@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-SA-Exim-Connect-IP: 78.151.164.206 X-SA-Exim-Mail-From: wookey@aleph1.co.uk X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on stoneboat.aleph1.co.uk X-Spam-Level: X-Spam-Status: No, score=-1.9 required=4.5 tests=BAYES_00 autolearn=no version=3.3.1 Subject: [PATCH 01/17] Add BUILD_ARCH and HOST_ARCH throughout X-SA-Exim-Version: 4.2.1 (built Mon, 22 Mar 2010 06:51:10 +0000) X-SA-Exim-Scanned: Yes (on stoneboat.aleph1.co.uk) From: Wookey --- bin/sbuild | 6 ++++-- bin/sbuild-update | 2 ++ lib/Sbuild/Build.pm | 27 +++++++++++++++++---------- lib/Sbuild/ConfBase.pm | 20 ++++++++++++++------ lib/Sbuild/InternalResolver.pm | 8 ++++---- lib/Sbuild/Options.pm | 9 ++++++++- lib/Sbuild/ResolverBase.pm | 10 +++++----- man/sbuild.1.in | 15 ++++++++++++++- 8 files changed, 68 insertions(+), 29 deletions(-) diff --git a/bin/sbuild b/bin/sbuild index 9aabbe5..2c56f32 100755 --- a/bin/sbuild +++ b/bin/sbuild @@ -97,8 +97,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'))); $job = Sbuild::Build->new($jobname, $conf); $job->set('Pkg Status Trigger', \&status_trigger); diff --git a/bin/sbuild-update b/bin/sbuild-update index fa2d3bc..cb0bd48 100755 --- a/bin/sbuild-update +++ b/bin/sbuild-update @@ -80,6 +80,8 @@ sub set_options { $self->add_options( "arch=s" => sub { $self->set_conf('ARCH', $_[1]); + $self->set_conf('HOST_ARCH', $_[1]); + $self->set_conf('BUILD_ARCH', $_[1]); }, "update|u" => sub { $self->set_conf('UPDATE', 1); diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm index 6b1930e..4b1a017 100644 --- a/lib/Sbuild/Build.pm +++ b/lib/Sbuild/Build.pm @@ -74,7 +74,6 @@ sub new { $self->set('ABORT', undef); $self->set('Job', $dsc); - $self->set('Arch', undef); $self->set('Chroot Dir', ''); $self->set('Chroot Build Dir', ''); $self->set('Build Dir', ''); @@ -401,7 +400,9 @@ sub run_chroot_session { # TODO: Don't hack the build location in; add a means to customise # the chroot directly. i.e. allow changing of /build location. $self->set('Chroot Build Dir', - tempdir($self->get('Package') . '-XXXXXX', + tempdir($self->get_conf('USERNAME') . '-' . + $self->get('Package_SVersion') . '-' . + $self->get('BUILD_ARCH') . '-XXXXXX', DIR => $session->get('Location') . "/build")); $self->set('Build Dir', $session->strip_chroot_path($self->get('Chroot Build Dir'))); @@ -466,7 +467,9 @@ sub run_chroot_session { my $resolver = get_resolver($self->get('Config'), $session, $host); $resolver->set('Log Stream', $self->get('Log Stream')); - $resolver->set('Arch', $self->get('Arch')); + $resolver->set('Arch', $self->get_conf('ARCH')); + $resolver->set('Host Arch', $self->get_conf('HOST_ARCH')); + $resolver->set('Build Arch', $self->get_conf('BUILD_ARCH')); $resolver->set('Chroot Build Dir', $self->get('Chroot Build Dir')); $self->set('Dependency Resolver', $resolver); @@ -793,7 +796,8 @@ sub fetch_source_files { my $build_dir = $self->get('Chroot Build Dir'); my $pkg = $self->get('Package'); my $ver = $self->get('OVersion'); - my $arch = $self->get('Arch'); + my $host_arch = $self->get_conf('HOST_ARCH'); + my $build_arch = $self->get_conf('BUILD_ARCH'); my ($dscarchs, $dscpkg, $dscver, @fetched); @@ -979,7 +983,7 @@ sub fetch_source_files { !($dscarchs eq "all" && $self->get_conf('BUILD_ARCH_ALL')) ) { my $msg = "$dsc: $arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping\n"; $self->log($msg); - Sbuild::Exception::Build->throw(error => "$dsc: $arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping", + Sbuild::Exception::Build->throw(error => "$dsc: $host_arch not in arch list or does not match any arch wildcards: $dscarchs -- skipping", status => "skipped", failstage => "arch-check"); return 0; @@ -1190,7 +1194,8 @@ sub build { my $dscdir = $self->get('DSC Dir'); my $pkg = $self->get('Package'); my $build_dir = $self->get('Chroot Build Dir'); - my $arch = $self->get('Arch'); + my $host_arch = $self->get_conf('HOST_ARCH'); + my $build_arch = $self->get_conf('BUILD_ARCH'); my( $rv, $changes ); local( *PIPE, *F, *F2 ); @@ -1573,7 +1578,6 @@ sub build { } } - # Restore write access to build tree now build is complete. $self->get('Session')->run_command( { COMMAND => ['chmod', '-R', 'g+w', $self->get('Build Dir')], @@ -1902,7 +1906,8 @@ sub generate_stats { $self->add_stat('Package', $self->get('Package')); $self->add_stat('Version', $self->get('Version')); $self->add_stat('Source-Version', $self->get('OVersion')); - $self->add_stat('Architecture', $self->get('Arch')); + $self->add_stat('Architecture', $self->get_conf('HOST_ARCH')); + $self->add_stat('Build Architecture', $self->get_conf('BUILD_ARCH')); $self->add_stat('Distribution', $self->get_conf('DISTRIBUTION')); $self->add_stat('Space', $self->get('This Space')); $self->add_stat('Build-Time', @@ -2154,7 +2159,7 @@ sub open_build_log { $self->log("sbuild (Debian sbuild) $version ($release_date) on $hostname\n"); my $head1 = $self->get('Package') . ' ' . $self->get('Version') . - ' (' . $self->get('Arch') . ') '; + ' (' . $arch_string . ') '; my $head2 = strftime("%d %b %Y %H:%M", localtime($self->get('Pkg Start Time'))); my $head = $head1 . ' ' x (80 - 4 - length($head1) - length($head2)) . @@ -2165,7 +2170,9 @@ sub open_build_log { $self->log("Version: " . $self->get('Version') . "\n"); $self->log("Source Version: " . $self->get('OVersion') . "\n"); $self->log("Distribution: " . $self->get_conf('DISTRIBUTION') . "\n"); - $self->log("Architecture: " . $self->get('Arch') . "\n"); + $self->log("Architecture: " . $self->get_conf('BUILD_ARCH') . "\n"); + $self->log("Host Architecture: " . $self->get_conf('HOST_ARCH') . "\n"); + $self->log("Build Architecture: " . $self->get_conf('BUILD_ARCH') . "\n"); $self->log("\n"); } diff --git a/lib/Sbuild/ConfBase.pm b/lib/Sbuild/ConfBase.pm index 8c17ce3..769f56d 100644 --- a/lib/Sbuild/ConfBase.pm +++ b/lib/Sbuild/ConfBase.pm @@ -102,7 +102,7 @@ sub init_allowed_keys { chomp(my $hostname = `hostname -f`); # Not user-settable. - chomp(my $host_arch = + chomp(my $native_arch = readpipe("dpkg --print-architecture")); my %common_keys = ( @@ -148,19 +148,27 @@ sub init_allowed_keys { HELP => 'Program to use to send mail' }, # TODO: Check if defaulted in code assuming undef + # ARCH is the native (system) architecture. Not used for host/build. 'ARCH' => { TYPE => 'STRING', - VARNAME => 'arch', - GROUP => 'Build options', - DEFAULT => $host_arch, + GROUP => '__INTERNAL', + DEFAULT => $native_arch HELP => 'Build architecture.' }, 'HOST_ARCH' => { TYPE => 'STRING', - GROUP => '__INTERNAL', - DEFAULT => $host_arch, + VARNAME => 'host_arch', + GROUP => 'Build options', + DEFAULT => $native_arch HELP => 'Host architecture' }, + 'BUILD_ARCH' => { + TYPE => 'STRING', + VARNAME => 'build_arch', + GROUP => 'Build options', + DEFAULT => $native_arch + HELP => 'Build architecture.' + }, 'HOSTNAME' => { TYPE => 'STRING', GROUP => '__INTERNAL', diff --git a/lib/Sbuild/InternalResolver.pm b/lib/Sbuild/InternalResolver.pm index dbe91ee..56af6e5 100644 --- a/lib/Sbuild/InternalResolver.pm +++ b/lib/Sbuild/InternalResolver.pm @@ -84,10 +84,10 @@ sub install_deps { my $positive = deps_parse(join(", ", @apt_positive), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); my $negative = deps_parse(join(", ", @apt_negative), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); my $build_depends = $positive; my $build_conflicts = $negative; @@ -207,10 +207,10 @@ sub parse_one_srcdep { my ($use_it, $ignore_it, $include) = (0, 0, 0); foreach (@archs) { if (/^!/) { - $ignore_it = 1 if Dpkg::Arch::debarch_is($self->get('Arch'), substr($_, 1)); + $ignore_it = 1 if Dpkg::Arch::debarch_is($self->get('Host Arch'), substr($_, 1)); } else { - $use_it = 1 if Dpkg::Arch::debarch_is($self->get('Arch'), $_); + $use_it = 1 if Dpkg::Arch::debarch_is($self->get('Host Arch'), $_); $include = 1; } } diff --git a/lib/Sbuild/Options.pm b/lib/Sbuild/Options.pm index f80030a..2d86f63 100644 --- a/lib/Sbuild/Options.pm +++ b/lib/Sbuild/Options.pm @@ -40,7 +40,14 @@ sub set_options { my $self = shift; $self->add_options("arch=s" => sub { - $self->set_conf('ARCH', $_[1]); + $self->set_conf('HOST_ARCH', $_[1]); + $self->set_conf('BUILD_ARCH', $_[1]); + }, + "build=s" => sub { + $self->set_conf('BUILD_ARCH', $_[1]); + }, + "host=s" => sub { + $self->set_conf('HOST_ARCH', $_[1]); }, "A|arch-all" => sub { $self->set_conf('BUILD_ARCH_ALL', 1); diff --git a/lib/Sbuild/ResolverBase.pm b/lib/Sbuild/ResolverBase.pm index 4ed99f5..3f003c8 100644 --- a/lib/Sbuild/ResolverBase.pm +++ b/lib/Sbuild/ResolverBase.pm @@ -585,7 +585,7 @@ sub setup_apt_archive { return 0; } - my $arch = $self->get('Arch'); + my $arch = $self->get('Host Arch'); print DUMMY_CONTROL <<"EOF"; Package: $dummy_pkg_name Version: 0.invalid.0 @@ -618,17 +618,17 @@ EOF if ($self->get_conf('BUILD_ARCH_ALL')) { $positive = deps_parse(join(", ", @positive, @positive_indep), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); $negative = deps_parse(join(", ", @negative, @negative_indep), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); } else { $positive = deps_parse(join(", ", @positive), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); $negative = deps_parse(join(", ", @negative), reduce_arch => 1, - host_arch => $self->get('Arch')); + host_arch => $self->get('Host Arch')); } $self->log("Merged Build-Depends: $positive\n") if $positive; diff --git a/man/sbuild.1.in b/man/sbuild.1.in index c06ad6a..a027fdc 100644 --- a/man/sbuild.1.in +++ b/man/sbuild.1.in @@ -29,6 +29,8 @@ sbuild \- build debian packages from source .RB [ \-d \[or] \-\-dist=\fIdistribution\fP ] .RB [ \-c \[or] \-\-chroot=\fIchroot\fP ] .RB [ \-\-arch=\fIarchitecture\fP ] +.RB [ \-\-build=\fIarchitecture\fP ] +.RB [ \-\-host=\fIarchitecture\fP ] .RB [ \-s \[or] \-\-source ] .RB [ \-\-force\-orig\-source ] .RB [ \-\-make\-binNMU=\fIchangelog-entry\fP ] @@ -138,7 +140,18 @@ Build using the architecture specified. A chroot named \fI$distribution\-$arch-sbuild\fP or \fI$distribution\-arch\fP is searched for, in that order of preference. The chroot must be installed and configured appropriately to build as that architecture, e.g. using -\fIpersonality=linux32\fP to build i386 packages on an amd64 system. +\fIpersonality=linux32\fP to build i386 packages on an amd64 system. Note that +this option is equivalent to "\-\-host=architecture \-\-build=architecture". +.TP +.BR "\-\-host=\fIarchitecture\fP" +Build using the host architecture specified. A chroot named +\fI$distribution\-$arch-sbuild\fP or \fI$distribution\-arch\fP is searched for, +in that order of preference. This option is only useful for cross-building +when used together with \-\-build. +.TP +.BR "\-\-build=\fIarchitecture\fP" +Build using the build architecture specified. This option is only useful for +cross-building when used together with \-\-host. .TP .BR \-A ", " "\-\-arch\-all" Also build Architecture: all packages, i.e. use dpkg\-buildpackage \-b