buildpackage: implement --[no-]build cmdline option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 26 Apr 2013 08:20:11 +0000 (11:20 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:22:10 +0000 (14:22 +0200)
For enabling/disabling the builder script. The option is a bit
asymmetric: --git-no-build automatically disables the 'postbuild' hook
whereas --git-build does not enable it (e.g. if --git-no-hooks is
given).

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
docs/manpages/gbp-buildpackage.sgml
gbp/config.py
gbp/scripts/buildpackage.py

index 0e5561e..4b4930b 100644 (file)
@@ -43,6 +43,7 @@
       <arg><option>--git-postbuild=</option><replaceable>COMMAND</replaceable></arg>
       <arg><option>--git-postexport=</option><replaceable>COMMAND</replaceable></arg>
       <arg><option>--git-prebuild=</option><replaceable>COMMAND</replaceable></arg>
+      <arg><option>--git-[no-]build</option></arg>
       <arg><option>--git-[no-]hooks</option></arg>
       <arg><option>--git-debian-tag=</option><replaceable>tag-format</replaceable></arg>
       <arg><option>--git-upstream-tag=</option><replaceable>tag-format</replaceable></arg>
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>--git-[no-]build</option>
+        </term>
+        <listitem>
+          <para>
+          Enable builder. Note: <option>--git-no-build</option> causes the
+          postbuild hook to be disabled, too.
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>--git-[no-]hooks</option>
         </term>
         <listitem>
index 81000ae..228c67c 100644 (file)
@@ -108,6 +108,7 @@ class GbpOptionParser(OptionParser):
                  'prebuild'        : '',
                  'postexport'      : '',
                  'postimport'      : '',
+                 'build'           : 'True',
                  'hooks'           : 'True',
                  'debian-tag'      : 'debian/%(version)s',
                  'debian-tag-msg'  : '%(pkg)s Debian release %(version)s',
@@ -275,6 +276,8 @@ class GbpOptionParser(OptionParser):
              'postimport':
                   ("hook run after a successful import, "
                    "default is '%(postimport)s'"),
+             'build':
+                  ("Enable running builder, default is %(build)s"),
              'hooks':
                   ("Enable running all hooks, default is %(hooks)s"),
              'time-machine':
index c0dfe02..415ba03 100755 (executable)
@@ -346,6 +346,15 @@ def setup_pbuilder(options):
             os.environ['GIT_PBUILDER_OPTIONS'] = options.pbuilder_options
 
 
+def disable_builder(options):
+    """Disable builder (and postbuild hook)"""
+    gbp.log.info("Disabling builder and postbuild hook")
+    options.builder = ''
+    options.postbuild = ''
+    options.pbuilder = None
+    options.qemubuilder = None
+
+
 def disable_hooks(options):
     """Disable all hooks (except for builder)"""
     for hook in ['cleaner', 'postexport', 'prebuild', 'postbuild', 'posttag']:
@@ -443,6 +452,7 @@ def build_parser(name, prefix=None):
     cmd_group.add_config_file_option(option_name="arch", dest="pbuilder_arch")
     cmd_group.add_boolean_config_file_option(option_name = "pbuilder-autoconf", dest="pbuilder_autoconf")
     cmd_group.add_config_file_option(option_name="pbuilder-options", dest="pbuilder_options")
+    cmd_group.add_boolean_config_file_option(option_name="build", dest="build")
     cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
     export_group.add_config_file_option(option_name="export-dir", dest="export_dir", type="path",
                       help="before building the package export the source into EXPORT_DIR, default is '%(export-dir)s'")
@@ -470,6 +480,9 @@ def parse_args(argv, prefix):
     options, args = parser.parse_args(args)
 
     gbp.log.setup(options.color, options.verbose, options.color_scheme)
+    if not options.build:
+        disable_builder(options)
+        dpkg_args = []
     if not options.hooks:
         disable_hooks(options)
     if options.retag: