+ badusage "dgit build implies --clean=dpkg-source"
+ if $cleanmode ne 'dpkg-source';
+ build_prep();
+ runcmd_ordryrun @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
+ printdone "build successful\n";
+}
+
+sub cmd_git_build {
+ badusage "dgit git-build implies --clean=dpkg-source"
+ if $cleanmode ne 'dpkg-source';
+ build_prep();
+ my @cmd =
+ (qw(git-buildpackage -us -uc --git-no-sign-tags),
+ "--git-builder=@dpkgbuildpackage");
+ unless (grep { m/^--git-debian-branch|^--git-ignore-branch/ } @ARGV) {
+ canonicalise_suite();
+ push @cmd, "--git-debian-branch=".lbranch();
+ }
+ push @cmd, changesopts();
+ runcmd_ordryrun @cmd, @ARGV;
+ printdone "build successful\n";
+}
+
+sub build_source {
+ build_prep();
+ $sourcechanges = "${package}_".(stripepoch $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();
+ }
+}
+
+sub cmd_build_source {
+ badusage "build-source takes no additional arguments" if @ARGV;
+ build_source();
+ printdone "source built, results in $dscfn and $sourcechanges";
+}
+
+sub cmd_sbuild {
+ build_source();
+ chdir ".." or die $!;
+ my $pat = "${package}_".(stripepoch $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}_".(stripepoch $version)."_multi.changes";
+ if (!$dryrun) {
+ stat $multichanges or fail "$multichanges: $!";
+ }
+ printdone "build successful, results in $multichanges\n" or die $!;
+}
+
+sub cmd_quilt_fixup {
+ badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;