+ printdone "build successful\n";
+}
+
+our $version;
+our $sourcechanges;
+our $dscfn;
+
+sub build_source {
+ check_not_dirty();
+ badusage "-p is not allowed with this action" if defined $package;
+ my $clogp = parsechangelog();
+ $package = getfield $clogp, 'Source';
+ my $isuite = getfield $clogp, 'Distribution';
+ $version = getfield $clogp, 'Version';
+ $sourcechanges = "${package}_${version}_source.changes";
+ $dscfn = dscfn($version);
+ if ($cleanmode eq 'dpkg-source') {
+ runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S)), changesopts();
+ } else {
+ if ($cleanmode eq 'git') {
+ runcmd_ordryrun @git, qw(clean -xdf);
+ } elsif ($cleanmode eq 'none') {
+ } else {
+ die "$cleanmode ?";
+ }
+ my $pwd = cmdoutput qw(env - pwd);
+ my $leafdir = basename $pwd;
+ chdir ".." or die $!;
+ runcmd_ordryrun @dpkgsource, qw(-b --), $leafdir;
+ chdir $pwd or die $!;
+ runcmd_ordryrun qw(sh -ec),
+ 'exec >$1; shift; exec "$@"','x',
+ $sourcechanges,
+ @dpkggenchanges, qw(-S), changesopts();
+ }