[buildd-tools-devel] Bug#775539: sbuild: overwrites DEB_BUILD_OPTIONS environment variable when cross-building

Johannes Schauer josch at debian.org
Thu Dec 24 00:08:39 UTC 2015


Hi,

On Fri, 16 Jan 2015 16:09:25 -0800 Vagrant Cascadian <vagrant at debian.org> wrote:
> I tried to build u-boot for armhf in an amd64 cross-build environment using:
> 
>   DEB_BUILD_OPTIONS=parallel=5 sbuild -d UNRELEASED -c sid-armhf-cross-ccache --arch=amd64 --host=armhf --build-dep-resolver=aptitude --no-source
> 
> 
> Which seems to overwrite DEB_BUILD_OPTIONS rather than append nocheck
> to DEB_BUILD_OPTIONS:
> 
>   User Environment
>   ────────────────
>   
>   CONFIG_SITE=/etc/dpkg-cross/cross-config.armhf
>   DEB_BUILD_OPTIONS=nocheck
> 
> 
> Specifying in ~/.sbuildrc works fine:
> 
>   $build_environment = {
>     'DEB_BUILD_OPTIONS' => 'parallel=5'
>   };
> 
> User Environment
> ────────────────
> 
> CONFIG_SITE=/etc/dpkg-cross/cross-config.armhf
> DEB_BUILD_OPTIONS=parallel=5 nocheck
> 
> 
> I think sbuild is somehow invoking the else statement in the following code:
> 
>   $ git grep -A 2 -B 4 nocheck
>   lib/Sbuild/Build.pm-    # Add cross environment config
>   lib/Sbuild/Build.pm-    if ($host_arch ne $build_arch) {
>   lib/Sbuild/Build.pm-            $buildenv{'CONFIG_SITE'} = "/etc/dpkg-cross/cross-config." . $host_arch;
>   lib/Sbuild/Build.pm-            if (defined($buildenv{'DEB_BUILD_OPTIONS'})) {
>   lib/Sbuild/Build.pm:                    $buildenv{'DEB_BUILD_OPTIONS'} .= " nocheck";
>   lib/Sbuild/Build.pm-            } else {
>   lib/Sbuild/Build.pm:                    $buildenv{'DEB_BUILD_OPTIONS'} = "nocheck";
>   lib/Sbuild/Build.pm-            }
>   lib/Sbuild/Build.pm-    }


indeed, this happens because at that point $buildenv{'DEB_BUILD_OPTIONS'} is
indeed undefined because %buildenv is set to
%{$self->get_conf('BUILD_ENVIRONMENT')} which in turn is by default an empty
%hash.

Then later in the function exec_command() in Chroot.pm, the actual environment
variables are considered via %ENV but any environment variable that was earlier
set through %buildenv will completely replace any environment variable from
%ENV. This makes sense because the exec_command() function has no clue about
%the meaning of each environment variable.

So I guess a sensible default would be either put this in ~/.sbuildrc:

$build_environment = %ENV;

Or to be more conservative and say:

$build_environment = {
    'DEB_BUILD_OPTIONS' => $ENV{'DEB_BUILD_OPTIONS'}
};

Or to change the default of the BUILD_ENVIRONMENT config variable in Conf.pm
from the empty hash to %ENV.

Or lastly, to change the check that you quoted above to also check
$ENV{'DEB_BUILD_OPTIONS'} and concatenate accordingly.

Can you test if the first two options work for you?

cheers, josch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20151224/32e679a4/attachment-0001.sig>


More information about the Buildd-tools-devel mailing list