tag 655215 +patch
thanks

Long ago, on Mon, Jan 09, 2012 at 01:35:09PM +0000, Roger Leigh wrote:
> On Mon, Jan 09, 2012 at 01:37:43PM +0100, Daniel Dehennin wrote:

> > My use case is to automate the building from a VCS (git actually):
> > 
> > - I tag a version to be build
> > - I push the tag
> > - The post-receive hook trigger the build system
> > - The build system pull the git tree
> > - The build system run "git-buildpackage"
> > 
> > The source tree must be clean on the build system, or there is some
> > files under VCS which should not.
> 
> 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).

-- 
Tzafrir Cohen         | tzaf...@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzaf...@cohens.org.il |                    |  best
tzaf...@debian.org    |                    | friend
>From 1e877f828a4e7d793e0c53a872c84fcdaef6f67c Mon Sep 17 00:00:00 2001
From: Tzafrir Cohen <tzaf...@debian.org>
Date: Mon, 31 Aug 2015 19:05:00 +0300
Subject: [PATCH 2/2] Add --no-clean-source

---
 bin/sbuild            | 4 +++-
 lib/Sbuild/Conf.pm    | 7 +++++++
 lib/Sbuild/Options.pm | 6 ++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/bin/sbuild b/bin/sbuild
index ff5fc71..975c93e 100755
--- a/bin/sbuild
+++ b/bin/sbuild
@@ -233,7 +233,9 @@ 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 ($conf->get('CLEAN_SOURCE')) {
+        system($conf->get('FAKEROOT'), 'debian/rules', 'clean');
+    }
     if ($?) {
 	Sbuild::Exception::Build->throw(
 	    error => "Failed to clean source directory $dir ($dsc)",
diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm
index 763ecaa..c8b0109 100644
--- a/lib/Sbuild/Conf.pm
+++ b/lib/Sbuild/Conf.pm
@@ -895,6 +895,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\' and \'aptitude\', which use a built-in resolver module and aptitude to resolve build dependencies, respectively.  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.'
 	},
+	'CLEAN_SOURCE'				=> {
+	    TYPE => 'BOOL',
+	    VARNAME => 'clean_source',
+	    GROUP => 'Build options',
+	    DEFAULT => 1,
+	    HELP => 'Run the \'clean\' target before generating source. 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 587acad..d2db6a4 100644
--- a/lib/Sbuild/Options.pm
+++ b/lib/Sbuild/Options.pm
@@ -241,6 +241,12 @@ sub set_options {
 		       "no-run-lintian" => sub {
 			    $self->set_conf('RUN_LINTIAN', 0);
 		       },
+			"clean-source" => sub {
+			    $self->set_conf('CLEAN_SOURCE', 1);
+		       },
+			"no-clean-source" => sub {
+			    $self->set_conf('CLEAN_SOURCE', 0);
+		       },
 		       "lintian-opts=s" => sub {
 			   push(@{$self->get_conf('LINTIAN_OPTIONS')},
 				split(/\s+/, $_[1]));
-- 
2.5.0

Reply via email to