From fc213e4c6faad2032a7b918b2256f335b764ffdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Fri, 22 Jul 2016 02:52:07 +0200 Subject: [PATCH 1/8] =?UTF-8?q?Updated=20L=C3=A9o's=20patch=20for=20the=20?= =?UTF-8?q?--use-schroot-session=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debian/support-for-schroot-sessions.patch | 1298 +---------------- 1 file changed, 23 insertions(+), 1275 deletions(-) diff --git a/contrib/debian/support-for-schroot-sessions.patch b/contrib/debian/support-for-schroot-sessions.patch index 29aea1f..7fbf6c2 100644 --- a/contrib/debian/support-for-schroot-sessions.patch +++ b/contrib/debian/support-for-schroot-sessions.patch @@ -2,115 +2,14 @@ Description: Allow reusing existing session. The user can, with the --use-schroot-session, provide an existing schroot session ID and the sbuild will run using this same session not creating a new one. -Author: -Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch +This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but +rebased on sbuild 0.69.0: +http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch ---- sbuild-0.64.1.orig/Makefile.in -+++ sbuild-0.64.1/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. -@@ -656,9 +656,10 @@ distcheck: dist - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ -- && ../configure --srcdir=.. --prefix="$$dc_install_base" \ -+ && ../configure \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ - $(DISTCHECK_CONFIGURE_FLAGS) \ -+ --srcdir=.. --prefix="$$dc_install_base" \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ ---- sbuild-0.64.1.orig/aclocal.m4 -+++ sbuild-0.64.1/aclocal.m4 -@@ -1,4 +1,4 @@ --# generated automatically by aclocal 1.14 -*- Autoconf -*- -+# generated automatically by aclocal 1.14.1 -*- Autoconf -*- - - # Copyright (C) 1996-2013 Free Software Foundation, Inc. - -@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], - [am__api_version='1.14' - dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to - dnl require some minimum version. Point them to the right macro. --m4_if([$1], [1.14], [], -+m4_if([$1], [1.14.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl - ]) - -@@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) - # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. - # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. - AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], --[AM_AUTOMAKE_VERSION([1.14])dnl -+[AM_AUTOMAKE_VERSION([1.14.1])dnl - m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl - _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -@@ -573,7 +573,8 @@ to "yes", and re-run configure. - END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi --fi]) -+fi -+]) - - dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not - dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further ---- sbuild-0.64.1.orig/bin/Makefile.in -+++ sbuild-0.64.1/bin/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/configs/Makefile.in -+++ sbuild-0.64.1/configs/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/db/Makefile.in -+++ sbuild-0.64.1/db/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/etc/Makefile.in -+++ sbuild-0.64.1/etc/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/lib/Buildd/Makefile.in -+++ sbuild-0.64.1/lib/Buildd/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/lib/Makefile.in -+++ sbuild-0.64.1/lib/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/lib/Sbuild/ChrootInfoSchroot.pm -+++ sbuild-0.64.1/lib/Sbuild/ChrootInfoSchroot.pm +Author: Marko Dimjašević + +--- sbuild-0.69.0.orig/lib/Sbuild/ChrootInfoSchroot.pm ++++ sbuild-0.69.0/lib/Sbuild/ChrootInfoSchroot.pm @@ -22,6 +22,7 @@ package Sbuild::ChrootInfoSchroot; use Sbuild::ChrootInfo; @@ -119,7 +18,7 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo use strict; use warnings; -@@ -184,7 +185,11 @@ sub _create { +@@ -177,7 +178,11 @@ sub _create { my $chroot = undef; @@ -132,14 +31,14 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo $chroot = Sbuild::ChrootSchroot->new($self->get('Config'), $chroot_id); } ---- sbuild-0.64.1.orig/lib/Sbuild/Conf.pm -+++ sbuild-0.64.1/lib/Sbuild/Conf.pm -@@ -130,7 +130,24 @@ sub setup ($) { - VARNAME => 'chroot', - GROUP => 'Chroot options', - DEFAULT => undef, -- HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])' -+ HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', +--- sbuild-0.69.0.orig/lib/Sbuild/Conf.pm ++++ sbuild-0.69.0/lib/Sbuild/Conf.pm +@@ -131,7 +131,24 @@ sub setup ($) { + GROUP => 'Chroot options', + DEFAULT => undef, + HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', +- CLI_OPTIONS => ['-c', '--chroot'] ++ CLI_OPTIONS => ['-c', '--chroot'], + CHECK => sub { + if (defined $conf->get('USE_SCHROOT_SESSION')){ + warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; @@ -160,1129 +59,8 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo }, 'BUILD_ARCH_ALL' => { TYPE => 'BOOL', ---- /dev/null -+++ sbuild-0.64.1/lib/Sbuild/Conf.pm.orig -@@ -0,0 +1,1118 @@ -+# -+# Conf.pm: configuration library for sbuild -+# Copyright © 2005 Ryan Murray -+# Copyright © 2006-2010 Roger Leigh -+# -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see -+# . -+# -+####################################################################### -+ -+package Sbuild::Conf; -+ -+use strict; -+use warnings; -+ -+use Cwd qw(cwd); -+use File::Spec; -+use POSIX qw(getgroups getgid); -+use Sbuild qw(isin); -+use Sbuild::ConfBase; -+use Sbuild::Sysconfig; -+ -+BEGIN { -+ use Exporter (); -+ our (@ISA, @EXPORT); -+ -+ @ISA = qw(Exporter); -+ -+ @EXPORT = qw(new setup read); -+} -+ -+sub setup ($); -+sub read ($); -+ -+sub new { -+ my $conf = Sbuild::ConfBase->new(@_); -+ Sbuild::Conf::setup($conf); -+ Sbuild::Conf::read($conf); -+ -+ return $conf; -+} -+ -+sub setup ($) { -+ my $conf = shift; -+ -+ my $validate_program = sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ my $program = $conf->get($key); -+ -+ die "$key binary is not defined" -+ if !defined($program) || !$program; -+ -+ # Emulate execvp behaviour by searching the binary in the PATH. -+ my @paths = split(/:/, $conf->get('PATH')); -+ # Also consider the empty path for absolute locations. -+ push (@paths, ''); -+ my $found = 0; -+ foreach my $path (@paths) { -+ $found = 1 if (-x File::Spec->catfile($path, $program)); -+ } -+ -+ die "$key binary '$program' does not exist or is not executable" -+ if !$found; -+ }; -+ -+ my $validate_directory = sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ my $directory = $conf->get($key); -+ -+ die "$key directory is not defined" -+ if !defined($directory) || !$directory; -+ -+ die "$key directory '$directory' does not exist" -+ if !-d $directory; -+ }; -+ -+ my $validate_append_version = sub { -+ my $conf = shift; -+ my $entry = shift; -+ -+ if (defined($conf->get('APPEND_TO_VERSION')) && -+ $conf->get('APPEND_TO_VERSION') && -+ $conf->get('BUILD_SOURCE') != 0) { -+ # See for details -+ die "The --append-to-version option is incompatible with a source upload\n"; -+ } -+ -+ if ($conf->get('BUILD_SOURCE') && -+ $conf->get('BIN_NMU')) { -+ print STDERR "Not building source package for binNMU\n"; -+ $conf->_set_value('BUILD_SOURCE', 0); -+ } -+ }; -+ -+ my $set_signing_option = sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $value = shift; -+ my $key = $entry->{'NAME'}; -+ $conf->_set_value($key, $value); -+ -+ my @signing_options = (); -+ push @signing_options, "-m".$conf->get('MAINTAINER_NAME') -+ if defined $conf->get('MAINTAINER_NAME'); -+ push @signing_options, "-e".$conf->get('UPLOADER_NAME') -+ if defined $conf->get('UPLOADER_NAME'); -+ $conf->set('SIGNING_OPTIONS', \@signing_options); -+ }; -+ -+ our $HOME = $conf->get('HOME'); -+ -+ my %sbuild_keys = ( -+ 'CHROOT' => { -+ TYPE => 'STRING', -+ VARNAME => 'chroot', -+ GROUP => 'Chroot options', -+ DEFAULT => undef, -+ HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])' -+ }, -+ 'BUILD_ARCH_ALL' => { -+ TYPE => 'BOOL', -+ VARNAME => 'build_arch_all', -+ GROUP => 'Build options', -+ DEFAULT => 0, -+ HELP => 'Build architecture: all packages by default' -+ }, -+ 'BUILD_ARCH_ANY' => { -+ TYPE => 'BOOL', -+ VARNAME => 'build_arch_any', -+ GROUP => 'Build options', -+ DEFAULT => 1, -+ HELP => 'Build architecture: any packages by default' -+ }, -+ 'NOLOG' => { -+ TYPE => 'BOOL', -+ GROUP => '__INTERNAL', -+ DEFAULT => 0, -+ HELP => 'Disable use of log file' -+ }, -+ 'SUDO' => { -+ TYPE => 'STRING', -+ VARNAME => 'sudo', -+ GROUP => 'Programs', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('CHROOT_MODE') eq 'split' || -+ ($conf->get('CHROOT_MODE') eq 'schroot' && -+ $conf->get('CHROOT_SPLIT'))) { -+ $validate_program->($conf, $entry); -+ -+ local (%ENV) = %ENV; # make local environment -+ $ENV{'DEBIAN_FRONTEND'} = "noninteractive"; -+ $ENV{'APT_CONFIG'} = "test_apt_config"; -+ $ENV{'SHELL'} = '/bin/sh'; -+ -+ my $sudo = $conf->get('SUDO'); -+ chomp( my $test_df = `$sudo sh -c 'echo \$DEBIAN_FRONTEND'` ); -+ chomp( my $test_ac = `$sudo sh -c 'echo \$APT_CONFIG'` ); -+ chomp( my $test_sh = `$sudo sh -c 'echo \$SHELL'` ); -+ -+ if ($test_df ne "noninteractive" || -+ $test_ac ne "test_apt_config" || -+ $test_sh ne '/bin/sh') { -+ print STDERR "$sudo is stripping APT_CONFIG, DEBIAN_FRONTEND and/or SHELL from the environment\n"; -+ print STDERR "'Defaults:" . $conf->get('USERNAME') . " env_keep+=\"APT_CONFIG DEBIAN_FRONTEND SHELL\"' is not set in /etc/sudoers\n"; -+ die "$sudo is incorrectly configured" -+ } -+ } -+ }, -+ DEFAULT => 'sudo', -+ HELP => 'Path to sudo binary' -+ }, -+ 'SU' => { -+ TYPE => 'STRING', -+ VARNAME => 'su', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'su', -+ HELP => 'Path to su binary' -+ }, -+ 'SCHROOT' => { -+ TYPE => 'STRING', -+ GROUP => '__INTERNAL', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('CHROOT_MODE') eq 'schroot') { -+ $validate_program->($conf, $entry); -+ } -+ }, -+ DEFAULT => 'schroot', -+ HELP => 'Path to schroot binary' -+ }, -+ 'SCHROOT_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'schroot_options', -+ GROUP => 'Programs', -+ DEFAULT => ['-q'], -+ HELP => 'Additional command-line options for schroot' -+ }, -+ 'FAKEROOT' => { -+ TYPE => 'STRING', -+ VARNAME => 'fakeroot', -+ GROUP => 'Programs', -+ DEFAULT => 'fakeroot', -+ HELP => 'Path to fakeroot binary' -+ }, -+ 'APT_GET' => { -+ TYPE => 'STRING', -+ VARNAME => 'apt_get', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'apt-get', -+ HELP => 'Path to apt-get binary' -+ }, -+ 'APT_CACHE' => { -+ TYPE => 'STRING', -+ VARNAME => 'apt_cache', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'apt-cache', -+ HELP => 'Path to apt-cache binary' -+ }, -+ 'APTITUDE' => { -+ TYPE => 'STRING', -+ VARNAME => 'aptitude', -+ GROUP => 'Programs', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('BUILD_DEP_RESOLVER') eq 'aptitude') { -+ $validate_program->($conf, $entry); -+ } -+ }, -+ DEFAULT => 'aptitude', -+ HELP => 'Path to aptitude binary' -+ }, -+ 'XAPT' => { -+ TYPE => 'STRING', -+ VARNAME => 'xapt', -+ GROUP => 'Programs', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('BUILD_DEP_RESOLVER') eq 'xapt') { -+ $validate_program->($conf, $entry); -+ } -+ }, -+ DEFAULT => 'xapt' -+ }, -+ 'DPKG_BUILDPACKAGE_USER_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional command-line options for dpkg-buildpackage. Not settable in config.' -+ }, -+ 'DPKG_SOURCE' => { -+ TYPE => 'STRING', -+ VARNAME => 'dpkg_source', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'dpkg-source', -+ HELP => 'Path to dpkg-source binary' -+ }, -+ 'DPKG_SOURCE_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'dpkg_source_opts', -+ GROUP => 'Programs', -+ DEFAULT => [], -+ HELP => 'Additional command-line options for dpkg-source' -+ }, -+ 'DCMD' => { -+ TYPE => 'STRING', -+ VARNAME => 'dcmd', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'dcmd', -+ HELP => 'Path to dcmd binary' -+ }, -+ 'MD5SUM' => { -+ TYPE => 'STRING', -+ VARNAME => 'md5sum', -+ GROUP => 'Programs', -+ CHECK => $validate_program, -+ DEFAULT => 'md5sum', -+ HELP => 'Path to md5sum binary' -+ }, -+ 'STATS_DIR' => { -+ TYPE => 'STRING', -+ VARNAME => 'stats_dir', -+ GROUP => 'Statistics', -+ DEFAULT => "$HOME/stats", -+ HELP => 'Directory for writing build statistics to' -+ }, -+ 'PACKAGE_CHECKLIST' => { -+ TYPE => 'STRING', -+ VARNAME => 'package_checklist', -+ GROUP => 'Chroot options', -+ DEFAULT => "$Sbuild::Sysconfig::paths{'SBUILD_LOCALSTATE_DIR'}/package-checklist", -+ HELP => 'Where to store list currently installed packages inside chroot' -+ }, -+ 'BUILD_ENV_CMND' => { -+ TYPE => 'STRING', -+ VARNAME => 'build_env_cmnd', -+ GROUP => 'Build options', -+ DEFAULT => "", -+ HELP => 'This command is run with the dpkg-buildpackage command line passed to it (in the chroot, if doing a chrooted build). It is used by the sparc buildd (which is sparc64) to call the wrapper script that sets the environment to sparc (32-bit). It could be used for other build environment setup scripts. Note that this is superceded by schroot\'s \'command-prefix\' option' -+ }, -+ 'PGP_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'pgp_options', -+ GROUP => 'Build options', -+ DEFAULT => ['-us', '-uc'], -+ HELP => 'Additional signing options for dpkg-buildpackage' -+ }, -+ 'LOG_DIR' => { -+ TYPE => 'STRING', -+ VARNAME => 'log_dir', -+ GROUP => 'Logging options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ my $directory = $conf->get($key); -+ }, -+ GET => sub { -+ my $conf = shift; -+ my $entry = shift; -+ -+ my $retval = $conf->_get($entry->{'NAME'}); -+ -+ # user mode defaults to the build directory, while buildd mode -+ # defaults to $HOME/logs. -+ if (!defined($retval)) { -+ $retval = $conf->get('BUILD_DIR'); -+ if ($conf->get('SBUILD_MODE') eq 'buildd') { -+ $retval = "$HOME/logs"; -+ } -+ } -+ -+ return $retval; -+ }, -+ HELP => 'Directory for storing build logs. This defaults to \'.\' when SBUILD_MODE is set to \'user\' (the default), and to \'$HOME/logs\' when SBUILD_MODE is set to \'buildd\'.' -+ }, -+ 'LOG_COLOUR' => { -+ TYPE => 'BOOL', -+ VARNAME => 'log_colour', -+ GROUP => 'Logging options', -+ DEFAULT => 1, -+ HELP => 'Add colour highlighting to interactive log messages (informational, warning and error messages). Log files will not be coloured.' -+ }, -+ 'LOG_FILTER' => { -+ TYPE => 'BOOL', -+ VARNAME => 'log_filter', -+ GROUP => 'Logging options', -+ DEFAULT => 1, -+ HELP => 'Filter variable strings from log messages such as the chroot name and build directory' -+ }, -+ 'LOG_COLOUR' => { -+ TYPE => 'BOOL', -+ VARNAME => 'log_colour', -+ GROUP => 'Logging options', -+ DEFAULT => 1, -+ HELP => 'Colour log messages such as critical failures, warnings and success' -+ }, -+ 'LOG_DIR_AVAILABLE' => { -+ TYPE => 'BOOL', -+ GROUP => '__INTERNAL', -+ GET => sub { -+ my $conf = shift; -+ my $entry = shift; -+ -+ my $nolog = $conf->get('NOLOG'); -+ my $directory = $conf->get('LOG_DIR'); -+ my $log_dir_available = 1; -+ -+ if ($nolog) { -+ $log_dir_available = 0; -+ } elsif ($conf->get('SBUILD_MODE') ne "buildd") { -+ if ($directory && ! -d $directory) { -+ $log_dir_available = 0; -+ } -+ } elsif ($directory && ! -d $directory && -+ !mkdir $directory) { -+ # Only create the log dir in buildd mode -+ warn "Could not create '$directory': $!\n"; -+ $log_dir_available = 0; -+ } -+ -+ return $log_dir_available; -+ } -+ }, -+ 'MAILTO' => { -+ TYPE => 'STRING', -+ VARNAME => 'mailto', -+ GROUP => 'Logging options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ die "mailto not set\n" -+ if !$conf->get('MAILTO') && -+ $conf->get('SBUILD_MODE') eq "buildd"; -+ }, -+ GET => sub { -+ my $conf = shift; -+ my $entry = shift; -+ -+ my $retval = $conf->_get($entry->{'NAME'}); -+ -+ # Now, we might need to adjust the MAILTO based on the -+ # config data. We shouldn't do this if it was already -+ # explicitly set by the command line option: -+ if (defined($conf->get('MAILTO_FORCED_BY_CLI')) && -+ !$conf->get('MAILTO_FORCED_BY_CLI') -+ && defined($conf->get('DISTRIBUTION')) -+ && $conf->get('DISTRIBUTION') -+ && defined($conf->get('MAILTO_HASH')) -+ && $conf->get('MAILTO_HASH')->{$conf->get('DISTRIBUTION')}) { -+ $retval = $conf->get('MAILTO_HASH')->{$conf->get('DISTRIBUTION')}; -+ } -+ -+ return $retval; -+ }, -+ DEFAULT => "", -+ HELP => 'email address to mail build logs to' -+ }, -+ 'MAILTO_FORCED_BY_CLI' => { -+ TYPE => 'BOOL', -+ GROUP => '__INTERNAL', -+ DEFAULT => 0 -+ }, -+ 'MAILTO_HASH' => { -+ TYPE => 'HASH:STRING', -+ VARNAME => 'mailto_hash', -+ GROUP => 'Logging options', -+ DEFAULT => {}, -+ HELP => 'Like MAILTO, but per-distribution. This is a hashref mapping distribution name to MAILTO. Note that for backward compatibility, this is also settable using the hash %mailto (deprecated), rather than a hash reference.' -+ }, -+ 'MAILFROM' => { -+ TYPE => 'STRING', -+ VARNAME => 'mailfrom', -+ GROUP => 'Logging options', -+ DEFAULT => "Source Builder ", -+ HELP => 'email address set in the From line of build logs' -+ }, -+ 'COMPRESS_BUILD_LOG_MAILS' => { -+ TYPE => 'BOOL', -+ VARNAME => 'compress_build_log_mails', -+ GROUP => 'Logging options', -+ DEFAULT => 1, -+ HELP => 'Should build log mails be compressed?' -+ }, -+ 'MIME_BUILD_LOG_MAILS' => { -+ TYPE => 'BOOL', -+ VARNAME => 'mime_build_log_mails', -+ GROUP => 'Logging options', -+ DEFAULT => 1, -+ HELP => 'Should build log mails be MIME encoded?' -+ }, -+ 'PURGE_BUILD_DEPS' => { -+ TYPE => 'STRING', -+ VARNAME => 'purge_build_deps', -+ GROUP => 'Chroot options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ die "Bad purge mode \'" . -+ $conf->get('PURGE_BUILD_DEPS') . "\'" -+ if !isin($conf->get('PURGE_BUILD_DEPS'), -+ qw(always successful never)); -+ }, -+ DEFAULT => 'always', -+ HELP => 'When to purge the build dependencies after a build; possible values are "never", "successful", and "always"' -+ }, -+ 'PURGE_BUILD_DIRECTORY' => { -+ TYPE => 'STRING', -+ VARNAME => 'purge_build_directory', -+ GROUP => 'Chroot options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ die "Bad purge mode \'" . -+ $conf->get('PURGE_BUILD_DIRECTORY') . "\'" -+ if !isin($conf->get('PURGE_BUILD_DIRECTORY'), -+ qw(always successful never)); -+ }, -+ DEFAULT => 'always', -+ HELP => 'When to purge the build directory after a build; possible values are "never", "successful", and "always"' -+ }, -+ 'PURGE_SESSION' => { -+ TYPE => 'STRING', -+ VARNAME => 'purge_session', -+ GROUP => 'Chroot options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ die "Bad purge mode \'" . -+ $conf->get('PURGE_SESSION') . "\'" -+ if !isin($conf->get('PURGE_SESSION'), -+ qw(always successful never)); -+ }, -+ DEFAULT => 'always', -+ HELP => 'Purge the schroot session following a build. This is useful in conjunction with the --purge and --purge-deps options when using snapshot chroots, since by default the snapshot will be deleted. Possible values are "always" (default), "never", and "successful"' -+ }, -+ 'TOOLCHAIN_REGEX' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'toolchain_regex', -+ GROUP => 'Build options', -+ DEFAULT => ['binutils$', -+ 'dpkg-dev$', -+ 'gcc-[\d.]+$', -+ 'g\+\+-[\d.]+$', -+ 'libstdc\+\+', -+ 'libc[\d.]+-dev$', -+ 'linux-kernel-headers$', -+ 'linux-libc-dev$', -+ 'gnumach-dev$', -+ 'hurd-dev$', -+ 'kfreebsd-kernel-headers$' -+ ], -+ HELP => 'Regular expressions identifying toolchain packages. Note that for backward compatibility, this is also settable using the array @toolchain_regex (deprecated), rather than an array reference.' -+ }, -+ 'STALLED_PKG_TIMEOUT' => { -+ TYPE => 'NUMERIC', -+ VARNAME => 'stalled_pkg_timeout', -+ GROUP => 'Build timeouts', -+ DEFAULT => 150, # minutes -+ HELP => 'Time (in minutes) of inactivity after which a build is terminated. Activity is measured by output to the log file.' -+ }, -+ 'MAX_LOCK_TRYS' => { -+ TYPE => 'NUMERIC', -+ VARNAME => 'max_lock_trys', -+ GROUP => 'Build timeouts', -+ DEFAULT => 120, -+ HELP => 'Number of times to try waiting for a lock.' -+ }, -+ 'LOCK_INTERVAL' => { -+ TYPE => 'NUMERIC', -+ VARNAME => 'lock_interval', -+ GROUP => 'Build timeouts', -+ DEFAULT => 5, -+ HELP => 'Lock wait interval (seconds). Maximum wait time is (max_lock_trys × lock_interval).' -+ }, -+ 'CHROOT_MODE' => { -+ TYPE => 'STRING', -+ VARNAME => 'chroot_mode', -+ GROUP => 'Chroot options', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ die "Bad chroot mode \'" . $conf->get('CHROOT_MODE') . "\'" -+ if !isin($conf->get('CHROOT_MODE'), -+ qw(schroot sudo)); -+ }, -+ DEFAULT => 'schroot', -+ HELP => 'Mechanism to use for chroot virtualisation. Possible value are "schroot" (default) and "sudo".' -+ }, -+ 'CHROOT_SPLIT' => { -+ TYPE => 'BOOL', -+ VARNAME => 'chroot_split', -+ GROUP => 'Chroot options', -+ DEFAULT => 0, -+ HELP => 'Run in split mode? In split mode, apt-get and dpkg are run on the host system, rather than inside the chroot.' -+ }, -+ 'CHECK_SPACE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'check_space', -+ GROUP => 'Build options', -+ DEFAULT => 1, -+ HELP => 'Check free disk space prior to starting a build. sbuild requires the free space to be at least twice the size of the unpacked sources to allow a build to proceed. Can be disabled to allow building if space is very limited, but the threshold to abort a build has been exceeded despite there being sufficient space for the build to complete.' -+ }, -+ 'BUILD_DIR' => { -+ TYPE => 'STRING', -+ VARNAME => 'build_dir', -+ GROUP => 'Core options', -+ DEFAULT => cwd(), -+ IGNORE_DEFAULT => 1, # Don't dump class to config -+ EXAMPLE => '$build_dir = \'/home/pete/build\';', -+ CHECK => $validate_directory, -+ HELP => 'This option is deprecated. Directory for chroot symlinks and sbuild logs. Defaults to the current directory if unspecified. It is used as the location of chroot symlinks (obsolete) and for current build log symlinks and some build logs. There is no default; if unset, it defaults to the current working directory. $HOME/build is another common configuration.' -+ }, -+ 'SBUILD_MODE' => { -+ TYPE => 'STRING', -+ VARNAME => 'sbuild_mode', -+ GROUP => 'Core options', -+ DEFAULT => 'user', -+ HELP => 'sbuild behaviour; possible values are "user" (exit status reports build failures) and "buildd" (exit status does not report build failures) for use in a buildd setup. "buildd" also currently implies enabling of "legacy features" such as chroot symlinks in the build directory and the creation of current symlinks in the build directory.' -+ }, -+ 'CHROOT_SETUP_SCRIPT' => { -+ TYPE => 'STRING', -+ VARNAME => 'chroot_setup_script', -+ GROUP => 'Chroot options', -+ DEFAULT => undef, -+ HELP => 'Script to run to perform custom setup tasks in the chroot.' -+ }, -+ 'FORCE_ORIG_SOURCE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'force_orig_source', -+ GROUP => 'Build options', -+ DEFAULT => 0, -+ HELP => 'By default, the -s option only includes the .orig.tar.gz when needed (i.e. when the Debian revision is 0 or 1). By setting this option to 1, the .orig.tar.gz will always be included when -s is used. This is equivalent to --force-orig-source.' -+ }, -+ 'INDIVIDUAL_STALLED_PKG_TIMEOUT' => { -+ TYPE => 'HASH:NUMERIC', -+ VARNAME => 'individual_stalled_pkg_timeout', -+ GROUP => 'Build timeouts', -+ DEFAULT => {}, -+ HELP => 'Some packages may exceed the general timeout (e.g. redirecting output to a file) and need a different timeout. This has is a mapping between source package name and timeout. Note that for backward compatibility, this is also settable using the hash %individual_stalled_pkg_timeout (deprecated) , rather than a hash reference.', -+ EXAMPLE => -+'%individual_stalled_pkg_timeout = (smalleiffel => 300, -+ jade => 300, -+ atlas => 300, -+ glibc => 1000, -+ \'gcc-3.3\' => 300, -+ kwave => 600);' -+ }, -+ 'ENVIRONMENT_FILTER' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'environment_filter', -+ GROUP => 'Core options', -+ DEFAULT => ['^PATH$', -+ '^DEB(IAN|SIGN)?_[A-Z_]+$', -+ '^(C(PP|XX)?|LD|F)FLAGS(_APPEND)?$', -+ '^USER(NAME)?$', -+ '^LOGNAME$', -+ '^HOME$', -+ '^TERM$', -+ '^SHELL$'], -+ HELP => 'Only environment variables matching one of the regular expressions in this arrayref will be passed to dpkg-buildpackage and other programs run by sbuild.' -+ }, -+ 'BUILD_ENVIRONMENT' => { -+ TYPE => 'HASH:STRING', -+ VARNAME => 'build_environment', -+ GROUP => 'Core options', -+ DEFAULT => {}, -+ HELP => 'Environment to set during the build. Defaults to setting PATH and LD_LIBRARY_PATH only. Note that these environment variables are not subject to filtering with ENVIRONMENT_FILTER. Example:', -+ EXAMPLE => -+'$build_environment = { -+ \'CCACHE_DIR\' => \'/build/cache\' -+};' -+ }, -+ 'LD_LIBRARY_PATH' => { -+ TYPE => 'STRING', -+ VARNAME => 'ld_library_path', -+ GROUP => 'Build environment', -+ DEFAULT => undef, -+ HELP => 'Library search path to use inside the chroot.' -+ }, -+ 'MAINTAINER_NAME' => { -+ TYPE => 'STRING', -+ VARNAME => 'maintainer_name', -+ GROUP => 'Maintainer options', -+ DEFAULT => undef, -+ SET => $set_signing_option, -+ HELP => 'Name to use as override in .changes files for the Maintainer field. The Maintainer field will not be overridden unless set here.' -+ }, -+ 'UPLOADER_NAME' => { -+ VARNAME => 'uploader_name', -+ TYPE => 'STRING', -+ GROUP => 'Maintainer options', -+ DEFAULT => undef, -+ SET => $set_signing_option, -+ HELP => 'Name to use as override in .changes file for the Changed-By: field.' -+ }, -+ 'KEY_ID' => { -+ TYPE => 'STRING', -+ VARNAME => 'key_id', -+ GROUP => 'Maintainer options', -+ DEFAULT => undef, -+ HELP => 'Key ID to use in .changes for the current upload. It overrides both $maintainer_name and $uploader_name.' -+ }, -+ 'SIGNING_OPTIONS' => { -+ TYPE => 'STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => "", -+ HELP => 'PGP-related identity options to pass to dpkg-buildpackage. Usually neither .dsc nor .changes files are not signed automatically.' -+ }, -+ 'APT_CLEAN' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_clean', -+ GROUP => 'Chroot options', -+ DEFAULT => 0, -+ HELP => 'APT clean. 1 to enable running "apt-get clean" at the start of each build, or 0 to disable.' -+ }, -+ 'APT_UPDATE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_update', -+ GROUP => 'Chroot options', -+ DEFAULT => 1, -+ HELP => 'APT update. 1 to enable running "apt-get update" at the start of each build, or 0 to disable.' -+ }, -+ 'APT_UPDATE_ARCHIVE_ONLY' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_update_archive_only', -+ GROUP => 'Chroot options', -+ DEFAULT => 1, -+ HELP => 'Update local temporary APT archive directly (1, the default) or set to 0 to disable and do a full apt update (not recommended in case the mirror content has changed since the build started).' -+ }, -+ 'APT_UPGRADE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_upgrade', -+ GROUP => 'Chroot options', -+ DEFAULT => 0, -+ HELP => 'APT upgrade. 1 to enable running "apt-get upgrade" at the start of each build, or 0 to disable.' -+ }, -+ 'APT_DISTUPGRADE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_distupgrade', -+ GROUP => 'Chroot options', -+ DEFAULT => 1, -+ HELP => 'APT distupgrade. 1 to enable running "apt-get dist-upgrade" at the start of each build, or 0 to disable.' -+ }, -+ 'APT_ALLOW_UNAUTHENTICATED' => { -+ TYPE => 'BOOL', -+ VARNAME => 'apt_allow_unauthenticated', -+ GROUP => 'Chroot options', -+ DEFAULT => 0, -+ HELP => 'Force APT to accept unauthenticated packages. By default, unauthenticated packages are not allowed. This is to keep the build environment secure, using apt-secure(8). By setting this to 1, APT::Get::AllowUnauthenticated is set to "true" when running apt-get. This is disabled by default: only enable it if you know what you are doing.' -+ }, -+ 'BATCH_MODE' => { -+ TYPE => 'BOOL', -+ GROUP => '__INTERNAL', -+ DEFAULT => 0, -+ HELP => 'Enable batch mode?' -+ }, -+ 'CORE_DEPENDS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'core_depends', -+ GROUP => 'Core options', -+ DEFAULT => ['build-essential', 'fakeroot'], -+ HELP => 'Packages which must be installed in the chroot for all builds.' -+ }, -+ 'MANUAL_DEPENDS' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'MANUAL_CONFLICTS' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'MANUAL_DEPENDS_ARCH' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'MANUAL_CONFLICTS_ARCH' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'MANUAL_DEPENDS_INDEP' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'MANUAL_CONFLICTS_INDEP' => { -+ TYPE => 'ARRAY:STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => [], -+ HELP => 'Additional per-build dependencies. Do not set by hand.' -+ }, -+ 'CROSSBUILD_CORE_DEPENDS' => { -+ TYPE => 'HASH:ARRAY:STRING', -+ VARNAME => 'crossbuild_core_depends', -+ GROUP => 'Multiarch support (transitional)', -+ DEFAULT => { arm64 => ['crossbuild-essential-arm64'], -+ armel => ['crossbuild-essential-armel'], -+ armhf => ['crossbuild-essential-armhf'], -+ ia64 => ['crossbuild-essential-ia64'], -+ mips => ['crossbuild-essential-mips'], -+ mipsel => ['crossbuild-essential-mipsel'], -+ powerpc => ['crossbuild-essential-powerpc'], -+ sparc => ['crossbuild-essential-sparc'] -+ }, -+ HELP => 'Per-architecture dependencies required for cross-building.' -+ }, 'BUILD_SOURCE' => { -+ TYPE => 'BOOL', -+ VARNAME => 'build_source', -+ GROUP => 'Build options', -+ DEFAULT => 0, -+ CHECK => $validate_append_version, -+ HELP => 'By default, do not build a source package (binary only build). Set to 1 to force creation of a source package, but note that this is inappropriate for binary NMUs, where the option will always be disabled.' -+ }, -+ 'ARCHIVE' => { -+ TYPE => 'STRING', -+ VARNAME => 'archive', -+ GROUP => 'Core options', -+ DEFAULT => undef, -+ HELP => 'Archive being built. Only set in build log. This might be useful for derivative distributions.' -+ }, -+ 'BIN_NMU' => { -+ TYPE => 'STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => undef, -+ CHECK => $validate_append_version, -+ HELP => 'Binary NMU changelog entry. Do not set by hand.' -+ }, -+ 'BIN_NMU_VERSION' => { -+ TYPE => 'STRING', -+ GROUP => '__INTERNAL', -+ DEFAULT => undef, -+ HELP => 'Binary NMU version number. Do not set by hand.' -+ }, -+ 'APPEND_TO_VERSION' => { -+ TYPE => 'STRING', -+ VARNAME => 'append_to_version', -+ GROUP => 'Build options', -+ DEFAULT => undef, -+ CHECK => $validate_append_version, -+ HELP => 'Suffix to append to version number. May be useful for derivative distributions.' -+ }, -+ 'GCC_SNAPSHOT' => { -+ TYPE => 'BOOL', -+ VARNAME => 'gcc_snapshot', -+ GROUP => 'Build options', -+ DEFAULT => 0, -+ HELP => 'Build using current GCC snapshot?' -+ }, -+ 'JOB_FILE' => { -+ TYPE => 'STRING', -+ VARNAME => 'job_file', -+ GROUP => 'Core options', -+ DEFAULT => 'build-progress', -+ HELP => 'Job status file (only used in batch mode)' -+ }, -+ 'BUILD_DEP_RESOLVER' => { -+ TYPE => 'STRING', -+ VARNAME => 'build_dep_resolver', -+ GROUP => 'Dependency resolution', -+ DEFAULT => 'apt', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ if ($conf->get($key) eq 'internal') { -+ warn "W: Build dependency resolver 'internal' has been removed; defaulting to 'apt'. Please update your configuration.\n"; -+ $conf->set('BUILD_DEP_RESOLVER', 'apt'); -+ } -+ -+ die '$key: Invalid build-dependency resolver \'' . -+ $conf->get($key) . -+ "'\nValid algorithms are 'apt', 'aptitude' and 'xapt'\n" -+ if !isin($conf->get($key), -+ qw(apt aptitude xapt)); -+ }, -+ 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.' -+ }, -+ 'LINTIAN' => { -+ TYPE => 'STRING', -+ VARNAME => 'lintian', -+ GROUP => 'Build validation', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('RUN_LINTIAN')) { -+ $validate_program->($conf, $entry); -+ } -+ }, -+ DEFAULT => 'lintian', -+ HELP => 'Path to lintian binary' -+ }, -+ 'RUN_LINTIAN' => { -+ TYPE => 'BOOL', -+ VARNAME => 'run_lintian', -+ GROUP => 'Build validation', -+ CHECK => sub { -+ my $conf = shift; -+ $conf->check('LINTIAN'); -+ }, -+ DEFAULT => 0, -+ HELP => 'Run lintian?' -+ }, -+ 'LINTIAN_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'lintian_opts', -+ GROUP => 'Build validation', -+ DEFAULT => [], -+ HELP => 'Options to pass to lintian. Each option is a separate arrayref element. For example, [\'-i\', \'-v\'] to add -i and -v.' -+ }, -+ 'PIUPARTS' => { -+ TYPE => 'STRING', -+ VARNAME => 'piuparts', -+ GROUP => 'Build validation', -+ CHECK => sub { -+ my $conf = shift; -+ my $entry = shift; -+ my $key = $entry->{'NAME'}; -+ -+ # Only validate if needed. -+ if ($conf->get('RUN_PIUPARTS')) { -+ $validate_program->($conf, $entry); -+ } -+ }, -+ DEFAULT => 'piuparts', -+ HELP => 'Path to piuparts binary' -+ }, -+ 'RUN_PIUPARTS' => { -+ TYPE => 'BOOL', -+ VARNAME => 'run_piuparts', -+ GROUP => 'Build validation', -+ CHECK => sub { -+ my $conf = shift; -+ $conf->check('PIUPARTS'); -+ }, -+ DEFAULT => 0, -+ HELP => 'Run piuparts' -+ }, -+ 'PIUPARTS_OPTIONS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'piuparts_opts', -+ GROUP => 'Build validation', -+ DEFAULT => [], -+ HELP => 'Options to pass to piuparts. Each option is a separate arrayref element. For example, [\'-b\', \'\'] to add -b and .' -+ }, -+ 'PIUPARTS_ROOT_ARGS' => { -+ TYPE => 'ARRAY:STRING', -+ VARNAME => 'piuparts_root_args', -+ GROUP => 'Build validation', -+ DEFAULT => [], -+ HELP => 'Preceding arguments to launch piuparts as root. If no arguments are specified, piuparts will be launched via sudo.' -+ }, -+ 'EXTERNAL_COMMANDS' => { -+ TYPE => 'HASH:ARRAY:ARRAY:STRING', -+ VARNAME => 'external_commands', -+ GROUP => 'Chroot options', -+ DEFAULT => { -+ "pre-build-commands" => [], -+ "chroot-system-setup-commands" => [], -+ "chroot-user-setup-commands" => [], -+ "chroot-cleanup-commands" => [], -+ "post-build-commands" => [], -+ }, -+ HELP => 'External commands to run at various stages of a build. Commands are held in a hash of arrays of arrays data structure.', -+ EXAMPLE => -+'$external_commands = { -+ "pre-build-commands" => [ -+ [\'foo\', \'arg1\', \'arg2\'], -+ [\'bar\', \'arg1\', \'arg2\', \'arg3\'], -+ ], -+ "chroot-system-setup-commands" => [ -+ [\'foo\', \'arg1\', \'arg2\'], -+ [\'bar\', \'arg1\', \'arg2\', \'arg3\'], -+ ], -+ "chroot-user-setup-commands" => [ -+ [\'foo\', \'arg1\', \'arg2\'], -+ [\'bar\', \'arg1\', \'arg2\', \'arg3\'], -+ ], -+ "chroot-cleanup-commands" => [ -+ [\'foo\', \'arg1\', \'arg2\'], -+ [\'bar\', \'arg1\', \'arg2\', \'arg3\'], -+ ], -+ "post-build-commands" => [ -+ [\'foo\', \'arg1\', \'arg2\'], -+ [\'bar\', \'arg1\', \'arg2\', \'arg3\'], -+ ], -+};' -+ }, -+ 'LOG_EXTERNAL_COMMAND_OUTPUT' => { -+ TYPE => 'BOOL', -+ VARNAME => 'log_external_command_output', -+ GROUP => 'Chroot options', -+ DEFAULT => 1, -+ HELP => 'Log standard output of commands run by sbuild?' -+ }, -+ 'LOG_EXTERNAL_COMMAND_ERROR' => { -+ TYPE => 'BOOL', -+ VARNAME => 'log_external_command_error', -+ GROUP => 'Chroot options', -+ DEFAULT => 1, -+ HELP => 'Log standard error of commands run by sbuild?' -+ }, -+ 'RESOLVE_ALTERNATIVES' => { -+ TYPE => 'BOOL', -+ VARNAME => 'resolve_alternatives', -+ GROUP => 'Dependency resolution', -+ DEFAULT => undef, -+ GET => sub { -+ my $conf = shift; -+ my $entry = shift; -+ -+ my $retval = $conf->_get($entry->{'NAME'}); -+ -+ if (!defined($retval)) { -+ $retval = 0; -+ $retval = 1 -+ if ($conf->get('BUILD_DEP_RESOLVER') eq 'aptitude'); -+ } -+ -+ return $retval; -+ }, -+ EXAMPLE => '$resolve_alternatives = 0;', -+ HELP => 'Should the dependency resolver use alternatives in Build-Depends, Build-Depends-Arch and Build-Depends-Indep? By default, using \'apt\' resolver, only the first alternative will be used; all other alternatives will be removed. When using the \'aptitude\' resolver, it will default to using all alternatives. Note that this does not include architecture-specific alternatives, which are reduced to the build architecture prior to alternatives removal. This should be left disabled when building for unstable; it may be useful when building for experimental or backports. Set to undef to use the default, 1 to enable, or 0 to disable.' -+ }, -+ 'SBUILD_BUILD_DEPENDS_SECRET_KEY' => { -+ TYPE => 'STRING', -+ VARNAME => 'sbuild_build_depends_secret_key', -+ GROUP => 'Dependency resolution', -+ DEFAULT => '/var/lib/sbuild/apt-keys/sbuild-key.sec', -+ HELP => 'GPG secret key for temporary local apt archive.' -+ }, -+ 'SBUILD_BUILD_DEPENDS_PUBLIC_KEY' => { -+ TYPE => 'STRING', -+ VARNAME => 'sbuild_build_depends_public_key', -+ GROUP => 'Dependency resolution', -+ DEFAULT => '/var/lib/sbuild/apt-keys/sbuild-key.pub', -+ HELP => 'GPG public key for temporary local apt archive.' -+ }, -+ ); -+ -+ $conf->set_allowed_keys(\%sbuild_keys); -+} -+ -+sub read ($) { -+ my $conf = shift; -+ -+ # Set here to allow user to override. -+ if (-t STDIN && -t STDOUT) { -+ $conf->_set_default('VERBOSE', 1); -+ } else { -+ $conf->_set_default('VERBOSE', 0); -+ } -+ -+ my $HOME = $conf->get('HOME'); -+ -+ my $files = ["$Sbuild::Sysconfig::paths{'SBUILD_CONF'}", -+ "$HOME/.sbuildrc"]; -+ -+ # For compatibility only. Non-scalars are deprecated. -+ my $deprecated_init = <set('MAILTO_HASH', \\\%mailto); -+} -+if (\@toolchain_regex) { -+ warn 'W: \@toolchain_regex is deprecated; please use the array reference \$toolchain_regexp[]\n'; -+ \$conf->set('TOOLCHAIN_REGEX', \\\@toolchain_regex); -+} -+if (\%individual_stalled_pkg_timeout) { -+ warn 'W: \%individual_stalled_pkg_timeout is deprecated; please use the hash reference \$individual_stalled_pkg_timeout{}\n'; -+ \$conf->set('INDIVIDUAL_STALLED_PKG_TIMEOUT', -+ \\\%individual_stalled_pkg_timeout); -+} -+END -+ -+ my $custom_setup = <get('EXTERNAL_COMMANDS')}{"chroot-user-setup-commands"}}, -+\$chroot_setup_script) if (\$chroot_setup_script); -+ -+ # Trigger log directory creation if needed -+ \$conf->get('LOG_DIR_AVAILABLE'); -+ -+END -+ -+ -+ $conf->read($files, $deprecated_init, $deprecated_setup, -+ $custom_setup); -+} -+ -+1; ---- sbuild-0.64.1.orig/lib/Sbuild/Makefile.am -+++ sbuild-0.64.1/lib/Sbuild/Makefile.am +--- sbuild-0.69.0.orig/lib/Sbuild/Makefile.am ++++ sbuild-0.69.0/lib/Sbuild/Makefile.am @@ -30,6 +30,7 @@ MODULES = \ ChrootPlain.pm \ ChrootRoot.pm \ @@ -1291,14 +69,8 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo ChrootSudo.pm \ ChrootSetup.pm \ ChrootInfo.pm \ ---- sbuild-0.64.1.orig/lib/Sbuild/Makefile.in -+++ sbuild-0.64.1/lib/Sbuild/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. +--- sbuild-0.69.0.orig/lib/Sbuild/Makefile.in ++++ sbuild-0.69.0/lib/Sbuild/Makefile.in @@ -297,6 +297,7 @@ MODULES = \ ChrootPlain.pm \ ChrootRoot.pm \ @@ -1307,8 +79,8 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo ChrootSudo.pm \ ChrootSetup.pm \ ChrootInfo.pm \ ---- sbuild-0.64.1.orig/lib/Sbuild/Options.pm -+++ sbuild-0.64.1/lib/Sbuild/Options.pm +--- sbuild-0.69.0.orig/lib/Sbuild/Options.pm ++++ sbuild-0.69.0/lib/Sbuild/Options.pm @@ -90,6 +90,9 @@ sub set_options { "c|chroot=s" => sub { $self->set_conf('CHROOT', $_[1]); @@ -1320,7 +92,7 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo $self->set_conf('APT_CLEAN', 1); }, --- /dev/null -+++ sbuild-0.64.1/lib/Sbuild/SessionSchroot.pm ++++ sbuild-0.69.0/lib/Sbuild/SessionSchroot.pm @@ -0,0 +1,123 @@ +# +# SessionChroot.pm: chroot library for sbuild, using an existing @@ -1445,27 +217,3 @@ Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-fo +} + +1; ---- sbuild-0.64.1.orig/man/Makefile.in -+++ sbuild-0.64.1/man/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/test/Makefile.in -+++ sbuild-0.64.1/test/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. ---- sbuild-0.64.1.orig/tools/Makefile.in -+++ sbuild-0.64.1/tools/Makefile.in -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.14 from Makefile.am. -+# Makefile.in generated by automake 1.14.1 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994-2013 Free Software Foundation, Inc. From 5b47e12d5e58e1c61e9a0c18cbee279d3fc718bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Mon, 25 Jul 2016 05:19:49 +0200 Subject: [PATCH 2/8] Aligned the use-schroot-session patch with the DEP3 meta-info format --- contrib/debian/support-for-schroot-sessions.patch | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contrib/debian/support-for-schroot-sessions.patch b/contrib/debian/support-for-schroot-sessions.patch index 7fbf6c2..c6f4974 100644 --- a/contrib/debian/support-for-schroot-sessions.patch +++ b/contrib/debian/support-for-schroot-sessions.patch @@ -1,11 +1,10 @@ -Description: Allow reusing existing session. -The user can, with the --use-schroot-session, provide an existing -schroot session ID and the sbuild will run using this same session -not creating a new one. -This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but -rebased on sbuild 0.69.0: -http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch - +Description: Allow reusing existing schroot session + The user can, with the --use-schroot-session, provide an existing + schroot session ID and sbuild will run using this same session not + creating a new one. + This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but + rebased on sbuild 0.69.0. +Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch Author: Marko Dimjašević --- sbuild-0.69.0.orig/lib/Sbuild/ChrootInfoSchroot.pm From aec5803fb723d86fc8d0239f4f2d747a932f4948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Mon, 25 Jul 2016 06:25:25 +0200 Subject: [PATCH 3/8] =?UTF-8?q?Fixed=20clemux/docker-slave=20to=20use=20L?= =?UTF-8?q?=C3=A9o's=20patch=20for=20sbuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/clemux/docker/debile-slave/Dockerfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/clemux/docker/debile-slave/Dockerfile b/contrib/clemux/docker/debile-slave/Dockerfile index 167cb62..52710f9 100644 --- a/contrib/clemux/docker/debile-slave/Dockerfile +++ b/contrib/clemux/docker/debile-slave/Dockerfile @@ -15,7 +15,16 @@ COPY *.deb /tmp/ WORKDIR /tmp -RUN apt-get update && apt-get install -y python python-dput dput-ng python-firehose adduser python-debian python-requests python-yaml sbuild python-schroot +RUN apt-get update && apt-get install -y python python-dput dput-ng python-firehose adduser python-debian python-requests python-yaml python-schroot wget + +# Use a custom version of sbuild written by Léo Cavaillé that adds an +# option --use-schroot-session, which enables starting sbuild with an +# existing schroot session. +RUN wget https://dimjasevic.net/marko/debile/libsbuild-perl_0.69.0-2_all.deb +RUN wget https://dimjasevic.net/marko/debile/sbuild_0.69.0-2_all.deb +RUN (dpkg --install libsbuild-perl_0.69.0-2_all.deb || true) +RUN (dpkg --install sbuild_0.69.0-2_all.deb || true) +RUN apt-get --assume-yes --fix-broken install RUN dpkg -i python-debile*.deb debile-slave*.deb From bf69ceea9c90c9846152ec4b7c89280b3011a893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Mon, 25 Jul 2016 17:49:54 +0200 Subject: [PATCH 4/8] =?UTF-8?q?Added=20L=C3=A9o=20in=20the=20Author=20meta?= =?UTF-8?q?-info=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/debian/support-for-schroot-sessions.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/debian/support-for-schroot-sessions.patch b/contrib/debian/support-for-schroot-sessions.patch index c6f4974..433bfd9 100644 --- a/contrib/debian/support-for-schroot-sessions.patch +++ b/contrib/debian/support-for-schroot-sessions.patch @@ -5,7 +5,7 @@ Description: Allow reusing existing schroot session This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but rebased on sbuild 0.69.0. Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch -Author: Marko Dimjašević +Author: Marko Dimjašević , Léo Cavaillé --- sbuild-0.69.0.orig/lib/Sbuild/ChrootInfoSchroot.pm +++ sbuild-0.69.0/lib/Sbuild/ChrootInfoSchroot.pm From a21461ed12da42f9a3469a6a5b538e600044968c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Wed, 27 Jul 2016 23:26:21 +0200 Subject: [PATCH 5/8] Reworked installing a patched sbuild from source --- contrib/clemux/docker/debile-slave/Dockerfile | 13 +- .../clemux/docker/debile-slave/sources.list | 1 + .../support-for-schroot-sessions.patch | 218 ++++++++++++++++++ 3 files changed, 227 insertions(+), 5 deletions(-) create mode 100644 contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch diff --git a/contrib/clemux/docker/debile-slave/Dockerfile b/contrib/clemux/docker/debile-slave/Dockerfile index 52710f9..dc73f38 100644 --- a/contrib/clemux/docker/debile-slave/Dockerfile +++ b/contrib/clemux/docker/debile-slave/Dockerfile @@ -15,15 +15,18 @@ COPY *.deb /tmp/ WORKDIR /tmp -RUN apt-get update && apt-get install -y python python-dput dput-ng python-firehose adduser python-debian python-requests python-yaml python-schroot wget +RUN apt-get update && apt-get install -y python python-dput dput-ng python-firehose adduser python-debian python-requests python-yaml python-schroot # Use a custom version of sbuild written by Léo Cavaillé that adds an # option --use-schroot-session, which enables starting sbuild with an # existing schroot session. -RUN wget https://dimjasevic.net/marko/debile/libsbuild-perl_0.69.0-2_all.deb -RUN wget https://dimjasevic.net/marko/debile/sbuild_0.69.0-2_all.deb -RUN (dpkg --install libsbuild-perl_0.69.0-2_all.deb || true) -RUN (dpkg --install sbuild_0.69.0-2_all.deb || true) +RUN apt-get build-dep --assume-yes sbuild +RUN apt-get source sbuild +COPY support-for-schroot-sessions.patch /tmp/ +RUN cd sbuild-* && cp ../support-for-schroot-sessions.patch . && \ + patch -p1 < ../support-for-schroot-sessions.patch && \ + dpkg-buildpackage -us -uc -nc +RUN (dpkg --install *sbuild*.deb || true) RUN apt-get --assume-yes --fix-broken install RUN dpkg -i python-debile*.deb debile-slave*.deb diff --git a/contrib/clemux/docker/debile-slave/sources.list b/contrib/clemux/docker/debile-slave/sources.list index 2d4128f..e5f360b 100644 --- a/contrib/clemux/docker/debile-slave/sources.list +++ b/contrib/clemux/docker/debile-slave/sources.list @@ -1,4 +1,5 @@ deb http://172.17.42.1:3142/debian/ sid main contrib non-free +deb-src http://172.17.42.1:3142/debian/ sid main contrib non-free deb http://172.17.42.1:3142/debian/ experimental main contrib non-free diff --git a/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch b/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch new file mode 100644 index 0000000..c6f4974 --- /dev/null +++ b/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch @@ -0,0 +1,218 @@ +Description: Allow reusing existing schroot session + The user can, with the --use-schroot-session, provide an existing + schroot session ID and sbuild will run using this same session not + creating a new one. + This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but + rebased on sbuild 0.69.0. +Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch +Author: Marko Dimjašević + +--- sbuild-0.69.0.orig/lib/Sbuild/ChrootInfoSchroot.pm ++++ sbuild-0.69.0/lib/Sbuild/ChrootInfoSchroot.pm +@@ -22,6 +22,7 @@ package Sbuild::ChrootInfoSchroot; + + use Sbuild::ChrootInfo; + use Sbuild::ChrootSchroot; ++use Sbuild::SessionSchroot; + + use strict; + use warnings; +@@ -177,7 +178,11 @@ sub _create { + + my $chroot = undef; + +- if (defined($chroot_id)) { ++ if ($self->get_conf('USE_SCHROOT_SESSION')) { ++ $chroot = Sbuild::SessionSchroot->new($self->get('Config')); ++ } ++ ++ if (defined($chroot_id) && ! defined($chroot)) { + $chroot = Sbuild::ChrootSchroot->new($self->get('Config'), $chroot_id); + } + +--- sbuild-0.69.0.orig/lib/Sbuild/Conf.pm ++++ sbuild-0.69.0/lib/Sbuild/Conf.pm +@@ -131,7 +131,24 @@ sub setup ($) { + GROUP => 'Chroot options', + DEFAULT => undef, + HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', +- CLI_OPTIONS => ['-c', '--chroot'] ++ CLI_OPTIONS => ['-c', '--chroot'], ++ CHECK => sub { ++ if (defined $conf->get('USE_SCHROOT_SESSION')){ ++ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; ++ } ++ } ++ }, ++ 'USE_SCHROOT_SESSION' => { ++ TYPE => 'STRING', ++ VARNAME => 'use_schroot_session', ++ GROUP => 'Chroot options', ++ DEFAULT => undef, ++ HELP => 'Rather than creating a session internally, use a given session', ++ CHECK => sub { ++ if (defined $conf->get('CHROOT')){ ++ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; ++ } ++ } + }, + 'BUILD_ARCH_ALL' => { + TYPE => 'BOOL', +--- sbuild-0.69.0.orig/lib/Sbuild/Makefile.am ++++ sbuild-0.69.0/lib/Sbuild/Makefile.am +@@ -30,6 +30,7 @@ MODULES = \ + ChrootPlain.pm \ + ChrootRoot.pm \ + ChrootSchroot.pm \ ++ SessionSchroot.pm \ + ChrootSudo.pm \ + ChrootSetup.pm \ + ChrootInfo.pm \ +--- sbuild-0.69.0.orig/lib/Sbuild/Makefile.in ++++ sbuild-0.69.0/lib/Sbuild/Makefile.in +@@ -297,6 +297,7 @@ MODULES = \ + ChrootPlain.pm \ + ChrootRoot.pm \ + ChrootSchroot.pm \ ++ SessionSchroot.pm \ + ChrootSudo.pm \ + ChrootSetup.pm \ + ChrootInfo.pm \ +--- sbuild-0.69.0.orig/lib/Sbuild/Options.pm ++++ sbuild-0.69.0/lib/Sbuild/Options.pm +@@ -90,6 +90,9 @@ sub set_options { + "c|chroot=s" => sub { + $self->set_conf('CHROOT', $_[1]); + }, ++ "use-schroot-session=s" => sub { ++ $self->set_conf('USE_SCHROOT_SESSION', $_[1]); ++ }, + "apt-clean" => sub { + $self->set_conf('APT_CLEAN', 1); + }, +--- /dev/null ++++ sbuild-0.69.0/lib/Sbuild/SessionSchroot.pm +@@ -0,0 +1,123 @@ ++# ++# SessionChroot.pm: chroot library for sbuild, using an existing ++# schroot sessopn. ++# Copyright © 2005 Ryan Murray ++# Copyright © 2005-2008 Roger Leigh ++# Copyright © 2008 Simon McVittie ++# Copyright © 2013 Léo Cavaillé ++# ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see ++# . ++# ++####################################################################### ++ ++package Sbuild::SessionSchroot; ++ ++use strict; ++use warnings; ++ ++BEGIN { ++ use Exporter (); ++ use Sbuild::Chroot; ++ our (@ISA, @EXPORT); ++ ++ @ISA = qw(Exporter Sbuild::Chroot); ++ ++ @EXPORT = qw(); ++} ++ ++sub new { ++ my $class = shift; ++ my $conf = shift; ++ ++ # If not defined SUPER::new will return undef ++ my $chroot_id = "fake-chroot-id";; ++ ++ my $self = $class->SUPER::new($conf, $chroot_id); ++ bless($self, $class); ++ $self->set('Session ID', $self->get_conf('USE_SCHROOT_SESSION')); ++ ++ return $self; ++} ++ ++# When a session is given, no need to begin the session anymore ++# This sub is just the check that the given session ID is usable ++sub begin_session { ++ my $self = shift; ++ my $schroot_session = $self->get('Session ID'); ++ print STDERR "Using session id $schroot_session\n" ++ if $self->get_conf('DEBUG'); ++ ++ my $info = $self->get('Chroots')->get_info($schroot_session); ++ if (defined($info) && ++ defined($info->{'Location'}) && -d $info->{'Location'}) { ++ $self->set('Priority', $info->{'Priority'}); ++ $self->set('Location', $info->{'Location'}); ++ $self->set('Session Purged', $info->{'Session Purged'}); ++ } else { ++ die $self->get('Session ID') . " this session does not exist\n"; ++ } ++ ++ return 0 if !$self->_setup_options(); ++ ++ return 1; ++} ++ ++sub end_session { ++ my $self = shift; ++ ++ print STDERR "By design, session is not ended by sbuild (session id " . $self->get('Session ID') . ")\n" ++ if $self->get_conf('DEBUG'); ++ ++ return 1; ++} ++ ++sub get_command_internal { ++ my $self = shift; ++ my $options = shift; ++ ++ my $command = $options->{'INTCOMMAND'}; # Command to run ++ my $user = $options->{'USER'}; # User to run command under ++ my $dir; # Directory to use (optional) ++ $dir = $self->get('Defaults')->{'DIR'} if ++ (defined($self->get('Defaults')) && ++ defined($self->get('Defaults')->{'DIR'})); ++ $dir = $options->{'DIR'} if ++ defined($options->{'DIR'}) && $options->{'DIR'}; ++ ++ if (!defined $user || $user eq "") { ++ $user = $self->get_conf('USERNAME'); ++ } ++ ++ my @cmdline = (); ++ ++ if (!defined($dir)) { ++ $dir = '/'; ++ } ++ @cmdline = ($self->get_conf('SCHROOT'), ++ '-d', $dir, ++ '-c', $self->get('Session ID'), ++ '--run-session', ++ @{$self->get_conf('SCHROOT_OPTIONS')}, ++ '-u', "$user", '-p', '--', ++ @$command); ++ ++ $options->{'USER'} = $user; ++ $options->{'COMMAND'} = $command; ++ $options->{'EXPCOMMAND'} = \@cmdline; ++ $options->{'CHDIR'} = undef; ++ $options->{'DIR'} = $dir; ++} ++ ++1; From 3f6731f084109f2473c90d95393d3058d643955e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Sat, 30 Jul 2016 05:52:56 +0200 Subject: [PATCH 6/8] Fixed the patch as its earlier version didn't work as expected. --- .../debian/support-for-schroot-sessions.patch | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/contrib/debian/support-for-schroot-sessions.patch b/contrib/debian/support-for-schroot-sessions.patch index 433bfd9..1329af8 100644 --- a/contrib/debian/support-for-schroot-sessions.patch +++ b/contrib/debian/support-for-schroot-sessions.patch @@ -32,17 +32,17 @@ Author: Marko Dimjašević , Léo Cavaillé 'Chroot options', - DEFAULT => undef, - HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', +@@ -131,7 +131,25 @@ sub setup ($) { + GROUP => 'Chroot options', + DEFAULT => undef, + HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', - CLI_OPTIONS => ['-c', '--chroot'] + CLI_OPTIONS => ['-c', '--chroot'], -+ CHECK => sub { -+ if (defined $conf->get('USE_SCHROOT_SESSION')){ -+ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; -+ } -+ } ++ CHECK => sub { ++ if (defined $conf->get('USE_SCHROOT_SESSION')){ ++ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; ++ } ++ } + }, + 'USE_SCHROOT_SESSION' => { + TYPE => 'STRING', @@ -50,11 +50,12 @@ Author: Marko Dimjašević , Léo Cavaillé 'Chroot options', + DEFAULT => undef, + HELP => 'Rather than creating a session internally, use a given session', -+ CHECK => sub { -+ if (defined $conf->get('CHROOT')){ -+ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; -+ } -+ } ++ CLI_OPTIONS => ['--use-schroot-session'], ++ CHECK => sub { ++ if (defined $conf->get('CHROOT')){ ++ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; ++ } ++ } }, 'BUILD_ARCH_ALL' => { TYPE => 'BOOL', From d4b6d77c3cce15ef43aef58c76a8a5c48d755348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Mon, 1 Aug 2016 01:10:48 +0200 Subject: [PATCH 7/8] Removed schroot patch from contrib/clemux --- contrib/clemux/docker/debile-slave/Dockerfile | 2 +- .../support-for-schroot-sessions.patch | 218 ------------------ 2 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch diff --git a/contrib/clemux/docker/debile-slave/Dockerfile b/contrib/clemux/docker/debile-slave/Dockerfile index dc73f38..0d44dbf 100644 --- a/contrib/clemux/docker/debile-slave/Dockerfile +++ b/contrib/clemux/docker/debile-slave/Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update && apt-get install -y python python-dput dput-ng python-fireh RUN apt-get build-dep --assume-yes sbuild RUN apt-get source sbuild COPY support-for-schroot-sessions.patch /tmp/ -RUN cd sbuild-* && cp ../support-for-schroot-sessions.patch . && \ +RUN cd sbuild-* && \ patch -p1 < ../support-for-schroot-sessions.patch && \ dpkg-buildpackage -us -uc -nc RUN (dpkg --install *sbuild*.deb || true) diff --git a/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch b/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch deleted file mode 100644 index c6f4974..0000000 --- a/contrib/clemux/docker/debile-slave/support-for-schroot-sessions.patch +++ /dev/null @@ -1,218 +0,0 @@ -Description: Allow reusing existing schroot session - The user can, with the --use-schroot-session, provide an existing - schroot session ID and sbuild will run using this same session not - creating a new one. - This is based on Léo Cavaillé's earlier patch for sbuild 0.64.1, but - rebased on sbuild 0.69.0. -Origin: http://leo.cavaille.net/public/gsoc/sbuild-patches/0001-Added-support-for-schroot-sessions.patch -Author: Marko Dimjašević - ---- sbuild-0.69.0.orig/lib/Sbuild/ChrootInfoSchroot.pm -+++ sbuild-0.69.0/lib/Sbuild/ChrootInfoSchroot.pm -@@ -22,6 +22,7 @@ package Sbuild::ChrootInfoSchroot; - - use Sbuild::ChrootInfo; - use Sbuild::ChrootSchroot; -+use Sbuild::SessionSchroot; - - use strict; - use warnings; -@@ -177,7 +178,11 @@ sub _create { - - my $chroot = undef; - -- if (defined($chroot_id)) { -+ if ($self->get_conf('USE_SCHROOT_SESSION')) { -+ $chroot = Sbuild::SessionSchroot->new($self->get('Config')); -+ } -+ -+ if (defined($chroot_id) && ! defined($chroot)) { - $chroot = Sbuild::ChrootSchroot->new($self->get('Config'), $chroot_id); - } - ---- sbuild-0.69.0.orig/lib/Sbuild/Conf.pm -+++ sbuild-0.69.0/lib/Sbuild/Conf.pm -@@ -131,7 +131,24 @@ sub setup ($) { - GROUP => 'Chroot options', - DEFAULT => undef, - HELP => 'Default chroot (defaults to distribution[-arch][-sbuild])', -- CLI_OPTIONS => ['-c', '--chroot'] -+ CLI_OPTIONS => ['-c', '--chroot'], -+ CHECK => sub { -+ if (defined $conf->get('USE_SCHROOT_SESSION')){ -+ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; -+ } -+ } -+ }, -+ 'USE_SCHROOT_SESSION' => { -+ TYPE => 'STRING', -+ VARNAME => 'use_schroot_session', -+ GROUP => 'Chroot options', -+ DEFAULT => undef, -+ HELP => 'Rather than creating a session internally, use a given session', -+ CHECK => sub { -+ if (defined $conf->get('CHROOT')){ -+ warn "W: Option -c/--chroot will be ignored with --use-schroot-session"; -+ } -+ } - }, - 'BUILD_ARCH_ALL' => { - TYPE => 'BOOL', ---- sbuild-0.69.0.orig/lib/Sbuild/Makefile.am -+++ sbuild-0.69.0/lib/Sbuild/Makefile.am -@@ -30,6 +30,7 @@ MODULES = \ - ChrootPlain.pm \ - ChrootRoot.pm \ - ChrootSchroot.pm \ -+ SessionSchroot.pm \ - ChrootSudo.pm \ - ChrootSetup.pm \ - ChrootInfo.pm \ ---- sbuild-0.69.0.orig/lib/Sbuild/Makefile.in -+++ sbuild-0.69.0/lib/Sbuild/Makefile.in -@@ -297,6 +297,7 @@ MODULES = \ - ChrootPlain.pm \ - ChrootRoot.pm \ - ChrootSchroot.pm \ -+ SessionSchroot.pm \ - ChrootSudo.pm \ - ChrootSetup.pm \ - ChrootInfo.pm \ ---- sbuild-0.69.0.orig/lib/Sbuild/Options.pm -+++ sbuild-0.69.0/lib/Sbuild/Options.pm -@@ -90,6 +90,9 @@ sub set_options { - "c|chroot=s" => sub { - $self->set_conf('CHROOT', $_[1]); - }, -+ "use-schroot-session=s" => sub { -+ $self->set_conf('USE_SCHROOT_SESSION', $_[1]); -+ }, - "apt-clean" => sub { - $self->set_conf('APT_CLEAN', 1); - }, ---- /dev/null -+++ sbuild-0.69.0/lib/Sbuild/SessionSchroot.pm -@@ -0,0 +1,123 @@ -+# -+# SessionChroot.pm: chroot library for sbuild, using an existing -+# schroot sessopn. -+# Copyright © 2005 Ryan Murray -+# Copyright © 2005-2008 Roger Leigh -+# Copyright © 2008 Simon McVittie -+# Copyright © 2013 Léo Cavaillé -+# -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see -+# . -+# -+####################################################################### -+ -+package Sbuild::SessionSchroot; -+ -+use strict; -+use warnings; -+ -+BEGIN { -+ use Exporter (); -+ use Sbuild::Chroot; -+ our (@ISA, @EXPORT); -+ -+ @ISA = qw(Exporter Sbuild::Chroot); -+ -+ @EXPORT = qw(); -+} -+ -+sub new { -+ my $class = shift; -+ my $conf = shift; -+ -+ # If not defined SUPER::new will return undef -+ my $chroot_id = "fake-chroot-id";; -+ -+ my $self = $class->SUPER::new($conf, $chroot_id); -+ bless($self, $class); -+ $self->set('Session ID', $self->get_conf('USE_SCHROOT_SESSION')); -+ -+ return $self; -+} -+ -+# When a session is given, no need to begin the session anymore -+# This sub is just the check that the given session ID is usable -+sub begin_session { -+ my $self = shift; -+ my $schroot_session = $self->get('Session ID'); -+ print STDERR "Using session id $schroot_session\n" -+ if $self->get_conf('DEBUG'); -+ -+ my $info = $self->get('Chroots')->get_info($schroot_session); -+ if (defined($info) && -+ defined($info->{'Location'}) && -d $info->{'Location'}) { -+ $self->set('Priority', $info->{'Priority'}); -+ $self->set('Location', $info->{'Location'}); -+ $self->set('Session Purged', $info->{'Session Purged'}); -+ } else { -+ die $self->get('Session ID') . " this session does not exist\n"; -+ } -+ -+ return 0 if !$self->_setup_options(); -+ -+ return 1; -+} -+ -+sub end_session { -+ my $self = shift; -+ -+ print STDERR "By design, session is not ended by sbuild (session id " . $self->get('Session ID') . ")\n" -+ if $self->get_conf('DEBUG'); -+ -+ return 1; -+} -+ -+sub get_command_internal { -+ my $self = shift; -+ my $options = shift; -+ -+ my $command = $options->{'INTCOMMAND'}; # Command to run -+ my $user = $options->{'USER'}; # User to run command under -+ my $dir; # Directory to use (optional) -+ $dir = $self->get('Defaults')->{'DIR'} if -+ (defined($self->get('Defaults')) && -+ defined($self->get('Defaults')->{'DIR'})); -+ $dir = $options->{'DIR'} if -+ defined($options->{'DIR'}) && $options->{'DIR'}; -+ -+ if (!defined $user || $user eq "") { -+ $user = $self->get_conf('USERNAME'); -+ } -+ -+ my @cmdline = (); -+ -+ if (!defined($dir)) { -+ $dir = '/'; -+ } -+ @cmdline = ($self->get_conf('SCHROOT'), -+ '-d', $dir, -+ '-c', $self->get('Session ID'), -+ '--run-session', -+ @{$self->get_conf('SCHROOT_OPTIONS')}, -+ '-u', "$user", '-p', '--', -+ @$command); -+ -+ $options->{'USER'} = $user; -+ $options->{'COMMAND'} = $command; -+ $options->{'EXPCOMMAND'} = \@cmdline; -+ $options->{'CHDIR'} = undef; -+ $options->{'DIR'} = $dir; -+} -+ -+1; From 15f9941f1691abb8239da7fe2da1bda722f6db93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Mon, 1 Aug 2016 01:16:24 +0200 Subject: [PATCH 8/8] Updated a README for Docker --- contrib/clemux/docker/README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/clemux/docker/README.rst b/contrib/clemux/docker/README.rst index dc3a80e..7c48fdf 100644 --- a/contrib/clemux/docker/README.rst +++ b/contrib/clemux/docker/README.rst @@ -21,6 +21,13 @@ already setup to use apt-cacher. Otherwise, you'll need to edit the ``sources.list`` files to use the mirror of your choosing. +Copy a patch for sbuild from +``contrib/debian/support-for-schroot-sessions.patch`` to enable using an +schroot session in sbuild. When in the root of the Debile repository, +run: + +$ cp contrib/debian/support-for-schroot-sessions.patch contrib/clemux/docker/debile-slave/ + Docker runs as root, and the ``docker`` CLI program will need access to docker's unix socket. If you don't want to run ``docker`` as root, you can add your user to the group ``docker``: