+sub cmd_sbuild {
+ check_not_dirty();
+ badusage "-p is not allowed with dgit sbuild" if defined $package;
+ my $clogp = parsechangelog();
+ $package = getfield $clogp, 'Source';
+ my $isuite = getfield $clogp, 'Distribution';
+ my $version = getfield $clogp, 'Version';
+ runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S));
+ chdir ".." or die $!;
+ my $sourcechanges = "${package}_${version}_source.changes";
+ my $dscfn = dscfn($version);
+ my $pat = "${package}_${version}_*.changes";
+ if (!$dryrun) {
+ stat $dscfn or fail "$dscfn (in parent directory): $!";
+ stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
+ foreach my $cf (glob $pat) {
+ next if $cf eq $sourcechanges;
+ unlink $cf or fail "remove $cf: $!";
+ }
+ }
+ runcmd_ordryrun @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
+ runcmd_ordryrun @mergechanges, glob $pat;
+ my $multichanges = "${package}_${version}_multi.changes";
+ if (!$dryrun) {
+ stat $multichanges or fail "$multichanges: $!";
+ }
+ printdone "build successful, results in $multichanges\n" or die $!;
+}
+