Package: sbuild
Version: 0.65.2-1
Severity: wishlist
Tags: patch

Hi,

it would be great if it were possible to pass a custom configuration
file location to sbuild. Currently, only /etc/sbuild/sbuild.conf as well
as ~/.sbuildrc are used. This means that if one wants to maintain
different profiles to do different kind of builds on the same machine,
then one would either have to create new user or chroot for every sbuild
profile, or copy different configuration files around or switch a
symlink in ~/.sbuildrc to point to the correct file. The latter is also
undesirable because it means that one cannot do several builds with
different configuration options at the same time. And passing
configuration options via the command line instead of the configuration
file is not always an option because either the option can currently
only be set in the configuration file or because the option itself are
many or very long.

A practical example for which it would be useful to maintain more than
one configuration file at a time would be to test the reproducibility of
source packages. In that situation, the user will want to have at least
three configuration files. One to do regular builds (that one would be
in ~/.sbuildrc) and two for reproducible builds. The latter two would
then be responsible for setting environment variables like
DEB_BUILD_OPTIONS, TZ, LANG and LC_ALL as well as run dpkg-buildpackage
in a wrapper of `linux64 --uname-2.6` and `unshare --uts` so that they
differ between the two builds.

With my attached patch and a proper sbuildrc, testing reproducibility in
practice would then be as simple as doing:

$ cd build1 && SBUILD_CONFIG=$HOME/sbuildrc1 sbuild ../package.dsc
$ cd build2 && SBUILD_CONFIG=$HOME/sbuildrc2 sbuild ../package.dsc

Thanks!

cheers, josch
>From 532df8db0bc1b2cd1732623bc167fed1bcb9b7bc Mon Sep 17 00:00:00 2001
From: josch <j.scha...@email.de>
Date: Sun, 28 Jun 2015 13:35:34 +0200
Subject: [PATCH] allow custom configuration file through SBUILD_CONFIG
 environment variable

---
 lib/Sbuild/Conf.pm | 2 ++
 man/sbuild.1.in    | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/lib/Sbuild/Conf.pm b/lib/Sbuild/Conf.pm
index af89f60..23aa9e8 100644
--- a/lib/Sbuild/Conf.pm
+++ b/lib/Sbuild/Conf.pm
@@ -1087,6 +1087,8 @@ sub read ($) {
     my $files = ["$Sbuild::Sysconfig::paths{'SBUILD_CONF'}",
 		 "$HOME/.sbuildrc"];
 
+    push @{$files}, $ENV{'SBUILD_CONFIG'} if defined $ENV{'SBUILD_CONFIG'};
+
     # For compatibility only.  Non-scalars are deprecated.
     my $deprecated_init = <<END;
 my \%mailto;
diff --git a/man/sbuild.1.in b/man/sbuild.1.in
index 431b75d..bf4e611 100644
--- a/man/sbuild.1.in
+++ b/man/sbuild.1.in
@@ -109,6 +109,9 @@ It is also possible to run external commands with sbuild. See the section
 configuration files \fI/etc/sbuild/sbuild.conf\fP and \fI~/.sbuildrc\fP.  An
 example sbuildrc is available in
 \fI/usr/share/doc/sbuild/examples/example.sbuildrc\fP.
+A custom path to a configuration file can also be specified through setting the
+\fBSBUILD_CONFIG\fP environment variable to the path of an additional
+configuration file.
 .PP
 You can build either using a local package with its .dsc file or a
 remote one by specifying an explicit dpkg version.
@@ -617,6 +620,9 @@ The following environment variables are used by \fBsbuild\fR:
 The home directory of the user.
 .IP "LOGNAME"
 Used in lockfiles.
+.IP "SBUILD_CONFIG"
+Path to an additional configuration file on top of the system wide and user
+specific ones.
 .SH FILES
 .TP
 .I /etc/sbuild/sbuild.conf
-- 
2.1.4

Reply via email to