Bug#655215: [buildd-tools-devel] Bug#655215: Bug#655215: sbuild: Do not do run "fakeroot ./debian/rules clean" before building source

2015-12-24 Thread Johannes Schauer
Control: tag -1 + pending

Hi,

On Sun, 13 Sep 2015 15:28:13 +0200 Johannes Schauer  wrote:
> On Mon, 31 Aug 2015 18:43:36 +0200 Tzafrir Cohen 
> wrote:
> > Long ago, on Mon, Jan 09, 2012 at 01:35:09PM +, 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 
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
 

Bug#655215: [buildd-tools-devel] Bug#655215: Bug#655215: sbuild: Do not do run "fakeroot ./debian/rules clean" before building source

2015-09-13 Thread Johannes Schauer
Hi,

On Mon, 31 Aug 2015 18:43:36 +0200 Tzafrir Cohen  wrote:
> Long ago, on Mon, Jan 09, 2012 at 01:35:09PM +, 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.

cheers, josch


signature.asc
Description: signature


Bug#655215: [buildd-tools-devel] Bug#655215: Bug#655215: sbuild: Do not do run "fakeroot ./debian/rules clean" before building source

2015-08-31 Thread Tzafrir Cohen
tag 655215 +patch
thanks

Long ago, on Mon, Jan 09, 2012 at 01:35:09PM +, 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 
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



Bug#655215: [buildd-tools-devel] Bug#655215: Bug#655215: sbuild: Do not do run fakeroot ./debian/rules clean before building source

2012-01-09 Thread Roger Leigh
On Mon, Jan 09, 2012 at 01:37:43PM +0100, Daniel Dehennin wrote:
 Roger Leigh rle...@codelibre.net writes:
 
  When you run dpkg-buildpackage, it also runs debian/rules clean
  prior to running dpkg-source -b to pack up the source package.  sbuild
  is simply copying the behaviour of dpkg-buildpackage here.  From what
  I understand, if we omit the clean, we would potentially pack up a
  dirty source tree.  We don't build the source tree directly--it's a
  requirement that we pack it up prior to building.
 
  I think it's important to point out that sbuild itself /does not
  build source trees/.  It builds Debian packages from a .dsc.  I.e.
  from a Debian source package.  If you run sbuild with a .dsc or
  package_version rather than a directory, it will do all its work
  inside the chroot.  Part of the job of sbuild is doing clean builds
  of packages; you can't do a clean build starting from a dirty tree.
 
 I'm ok with doing dpkg-source -b on a clean tree.
 
 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).


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
   `-GPG Public Key: 0x25BFB848   Please GPG sign your mail.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org