chiark / gitweb /
dgit: new 'pbuilder' and 'cowbuilder' subcommands
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 27 Jul 2018 04:35:12 +0000 (12:35 +0800)
committerSean Whitton <spwhitton@spwhitton.name>
Sat, 28 Jul 2018 10:18:11 +0000 (18:18 +0800)
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
debian/changelog
dgit

index e6ff923aefad58cdcc4b164f6ff7065b86fd9d92..3370e6e23cb3e6a55ffe616ce02007a1f0627136 100644 (file)
@@ -1,5 +1,8 @@
 dgit (6.1~) unstable; urgency=medium
 
+  New feature [Sean Whitton]:
+  * 'pbuilder' and 'cowbuilder' subcommands.
+
   Minor fixes:
   * Fix an error message to refer to the build products dir instead of
     just the parent directory [Sean Whitton].
diff --git a/dgit b/dgit
index c1723aaa9d86bfff154f9addd9aa3c2a6fe8288a..dfe0d155d4d1e6401d63bad0291b61934834f810 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -129,6 +129,8 @@ our (@mergechanges) = qw(mergechanges -f);
 our (@gbp_build) = ('');
 our (@gbp_pq) = ('gbp pq');
 our (@changesopts) = ('');
+our (@pbuilder) = ("sudo -E pbuilder");
+our (@cowbuilder) = ("sudo -E cowbuilder");
 
 our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
                     'curl' => \@curl,
@@ -148,7 +150,9 @@ our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
                      'gbp-build' => \@gbp_build,
                      'gbp-pq' => \@gbp_pq,
                      'ch' => \@changesopts,
-                     'mergechanges' => \@mergechanges);
+                     'mergechanges' => \@mergechanges,
+                     'pbuilder' => \@pbuilder,
+                     'cowbuilder' => \@cowbuilder);
 
 our %opts_opt_cmdonly = ('gpg' => 1, 'git' => 1);
 our %opts_cfg_insertpos = map {
@@ -571,6 +575,7 @@ main usages:
   dgit [dgit-opts] fetch|pull [dgit-opts] [suite]
   dgit [dgit-opts] build [dpkg-buildpackage-opts]
   dgit [dgit-opts] sbuild [sbuild-opts]
+  dgit [dgit-opts] pbuilder|cowbuilder [debbuildopts]
   dgit [dgit-opts] push [dgit-opts] [suite]
   dgit [dgit-opts] push-source [dgit-opts] [suite]
   dgit [dgit-opts] rpush build-host:build-dir ...
@@ -6475,13 +6480,13 @@ sub cmd_push_source {
 
 sub cmd_sbuild {
     build_prep_early();
-    build_with_binary_builder(\@sbuild, <<END, qw(-d), $isuite, @ARGV, $dscfn);
+    binary_builder(\@sbuild, <<END, qw(-d), $isuite, @ARGV, $dscfn);
 perhaps you need to pass -A ?  (sbuild's default is to build only
 arch-specific binaries; dgit 1.4 used to override that.)
 END
 }
 
-sub build_with_binary_builder ($$$) {
+sub binary_builder {
     my ($bbuilder, $pbmc_msg, @args) = @_;
     build_prep(WANTSRC_SOURCE);
     build_source();
@@ -6500,6 +6505,37 @@ sub build_with_binary_builder ($$$) {
     };
 }
 
+sub pbuilder ($) {
+    my ($pbuilder) = @_;
+    build_prep_early();
+    # @ARGV is allowed to contain only things that should be passed to
+    # pbuilder under debbuildopts; just massage those
+    my $wantsrc = massage_dbp_args \@ARGV;
+    fail "you asked for a builder but your debbuildopts didn't ask for".
+      " any binaries -- is this really what you meant?"
+      unless $wantsrc & WANTSRC_BUILDER;
+    fail "we must build a .dsc to pass to the builder but your debbuiltopts".
+      " forbids the building of a source package; cannot continue"
+      unless $wantsrc & WANTSRC_SOURCE;
+    # We do not want to include the verb "build" in @pbuilder because
+    # the user can customise @pbuilder and they shouldn't be required
+    # to include "build" in their customised value.  However, if the
+    # user passes any additional args to pbuilder using the dgit
+    # option --pbuilder:foo, such args need to come after the "build"
+    # verb.  opts_opt_multi_cmd does all of that.
+    binary_builder([opts_opt_multi_cmd ["build"], @$pbuilder], undef,
+                   qw(--debbuildopts), "@ARGV", qw(--distribution), $isuite,
+                   $dscfn);
+}
+
+sub cmd_pbuilder {
+    pbuilder(\@pbuilder);
+}
+
+sub cmd_cowbuilder {
+    pbuilder(\@cowbuilder);
+}
+
 sub cmd_quilt_fixup {
     badusage "incorrect arguments to dgit quilt-fixup" if @ARGV;
     build_prep_early();