Control: tag -1 + pending

Hi,

On Sun, 13 Sep 2015 15:28:13 +0200 Johannes Schauer <[email protected]> wrote:
> On Mon, 31 Aug 2015 18:43:36 +0200 Tzafrir Cohen <[email protected]>
> wrote:
> > Long ago, on Mon, Jan 09, 2012 at 01:35:09PM +0000, Roger Leigh wrote:
> > > In this situation, I guess there are two possibilities:
> > > 
> > > 1) You run "dpkg-source -b" yourself, then run sbuild with the
> > >    resulting .dsc.  This won't require any changes to sbuild directly.
> > > 
> > > 2) We add an option to sbuild to permit cleaning of the tree to be
> > >    skipped.  I guess we can add -nc like for dpkg-buildpackage.
> > > 
> > > It depends on whether (1) is too much of an inconvenience.  But it's
> > > certainly possible to do (2).
> > 
> > (1) is indeed of indeed of inconvenience for me. Attached a simple
> > patch for (2).
> 
> thanks for the patch!
> 
> I did not try it out yet but have two comments:
> 
>  1. Your if statement in bin/sbuild only wraps the system() call but not the
>     check whether system() was successful
> 
>  2. You are adding two new command line options but did not update the man
>     page.

attached patch should fix this issue.

Thanks!

cheers, josch
From fa5835af3ebe2e2b52cc5aa230035c0159432fa4 Mon Sep 17 00:00:00 2001
From: Johannes 'josch' Schauer <[email protected]>
Date: Thu, 24 Dec 2015 12:50:42 +0100
Subject: [PATCH] bin/sbuild: add --clean-source and --no-clean-source to allow
 building a package from an unpacked directory without calling debian/rules
 clean (closes: #655215)

---
 bin/sbuild            | 12 +++++++-----
 lib/Sbuild/Conf.pm    |  7 +++++++
 lib/Sbuild/Options.pm |  6 ++++++
 man/sbuild.1.in       | 10 ++++++++++
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/bin/sbuild b/bin/sbuild
index ff5fc71..5870f1b 100755
--- a/bin/sbuild
+++ b/bin/sbuild
@@ -233,11 +233,13 @@ sub create_source_package ($) {
     chdir($dir) or Sbuild::Exception::Build->throw(
 	error => "Failed to change directory",
 	failstage => "pack-source");
-    system($conf->get('FAKEROOT'), 'debian/rules', 'clean');
-    if ($?) {
-	Sbuild::Exception::Build->throw(
-	    error => "Failed to clean source directory $dir ($dsc)",
-	    failstage => "pack-source");
+    if ($conf->get('CLEAN_SOURCE')) {
+	system($conf->get('FAKEROOT'), 'debian/rules', 'clean');
+	if ($?) {
+	    Sbuild::Exception::Build->throw(
+		error => "Failed to clean source directory $dir ($dsc)",
+		failstage => "pack-source");
+	}
     }
     my @dpkg_source_command = ($conf->get('DPKG_SOURCE'), '-b');
     push @dpkg_source_command, @{$conf->get('DPKG_SOURCE_OPTIONS')}
diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm
index 54e70e2..b3a4605 100644
--- a/lib/Sbuild/Conf.pm
+++ b/lib/Sbuild/Conf.pm
@@ -894,6 +894,13 @@ sub setup ($) {
 	    },
 	    HELP => 'Build dependency resolver.  The \'apt\' resolver is currently the default, and recommended for most users.  This resolver uses apt-get to resolve dependencies.  Alternative resolvers are \'apt\', \'aptitude\' and \'aspcud\'. The \'apt\' resolver uses a built-in resolver module while the \'aptitude\' resolver uses aptitude to resolve build dependencies.  The aptitude resolver is similar to apt, but is useful in more complex situations, such as where multiple distributions are required, for example when building from experimental, where packages are needed from both unstable and experimental, but defaulting to unstable. If the dependency situation is too complex for either apt or aptitude to solve it, you can use the \'aspcud\' resolver which is a real SAT solver and will thus alwyas find a solution if a solution exists.'
 	},
+	'CLEAN_SOURCE'				=> {
+	    TYPE => 'BOOL',
+	    VARNAME => 'clean_source',
+	    GROUP => 'Build options',
+	    DEFAULT => 1,
+	    HELP => 'When running sbuild from within an unpacked source tree, run the \'clean\' target before generating the source package. This might require some of the build dependencies necessary for running the \'clean\' target to be installed on the host machine. Only disable if you start from a clean checkout and you know what you are doing.'
+	},
 	'LINTIAN'				=> {
 	    TYPE => 'STRING',
 	    VARNAME => 'lintian',
diff --git a/lib/Sbuild/Options.pm b/lib/Sbuild/Options.pm
index 73b3fb9..6215684 100644
--- a/lib/Sbuild/Options.pm
+++ b/lib/Sbuild/Options.pm
@@ -234,6 +234,12 @@ sub set_options {
 		       "no-resolve-alternatives" => sub {
 			   $self->set_conf('RESOLVE_ALTERNATIVES', 0);
 		       },
+			"clean-source" => sub {
+			    $self->set_conf('CLEAN_SOURCE', 1);
+		       },
+			"no-clean-source" => sub {
+			    $self->set_conf('CLEAN_SOURCE', 0);
+		       },
 			"run-lintian" => sub {
 			    $self->set_conf('RUN_LINTIAN', 1);
 		       },
diff --git a/man/sbuild.1.in b/man/sbuild.1.in
index ff40639..646bf0d 100644
--- a/man/sbuild.1.in
+++ b/man/sbuild.1.in
@@ -351,6 +351,16 @@ This option is similar to \-\-make\-binNMU except that it allows the user to
 specify an arbitrary string to be appended to the version number (immediately
 before the '+' in the Debian revision if \-\-make\-binNMU is also provided).
 .TP
+.BR \-\-clean\-source
+When executing sbuild from within an unpacked source tree, execute the
+debian/rules clean target. This is the default and might require some of the
+build dependencies installed on the host.
+.TP
+.BR \-\-no\-clean\-source
+When executing sbuild from within an unpacked source tree, do not run the
+debian/rules clean target before building the source package. Only set this if
+you start from a clean checkout and you know what you are doing.
+.TP
 .BR \-\-run\-lintian
 Run lintian after a successful build.
 .TP
-- 
2.5.1

Attachment: signature.asc
Description: signature

Reply via email to