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``: 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;