On Sat, Apr 10, 2010 at 10:00:12PM +0200, Andreas Barth wrote:
> * Roger Leigh ([email protected]) [100410 21:54]:
> > On Sat, Apr 10, 2010 at 09:42:34PM +0200, Andreas Barth wrote:
> > > * Roger Leigh ([email protected]) [100410 21:26]:
> > > > OK.  We could conceivably add a "source-chroot=false" option which would
> > > > force skipping of automatic source chroot creation.  That would be
> > > > pretty simple to add.  Or "source-create"; any suggestions for a better
> > > > name?
> > > 
> > > provide-source-chroot? has-source-chroot?
> > 
> > Currently, all the source-chroot-specific options start with
> > ^source-, so I think I'd like to keep that for consistency.
> 
> Good reason, yes.

The attached patch implements a "source-clone=true|false" option.  Does this
work in the way you want?  Also includes docs and testsuite updates.

If set to false, the -source chroot is no longer created automatically.


Thanks,
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.
diff --git a/man/schroot.conf.5.in b/man/schroot.conf.5.in
index 2bd8b92..40cec0d 100644
--- a/man/schroot.conf.5.in
+++ b/man/schroot.conf.5.in
@@ -214,10 +214,16 @@ path may not be specfied here; they are set automatically by schroot.
 .PP
 Some chroots implement source chroots.  These are chroots which automatically
 create a copy of themselves before use, and are usually session managed.  These
-chroots also provide an additional chroot with a \fI\-source\fP suffix added to
-their name, to allow access to the original data, and to aid in chroot
+chroots additionally provide an extra chroot with a \fI\-source\fP suffix
+added to their name, to allow access to the original data, and to aid in chroot
 maintenance.  These chroots provide the following additional options:
 .TP
+\f[CBI]source\-clone=\fP\f[CI]true\fP|\f[CI]false\fP
+Set whether the source chroot should be automatically cloned (created) for this
+chroot.  The default is \f[CI]true\fP to automatically clone, but if desired
+may be disabled by setting to \f[CI]false\fP.  If disabled, the source chroot
+will be inaccessible.
+.TP
 \f[CBI]source\-users=\fP\f[CI]user1,user2,...\fP
 A comma-separated list of users which are allowed access to the source chroot.
 If empty or omitted, no users will be allowed access.  This will become the
diff --git a/sbuild/sbuild-chroot-config.cc b/sbuild/sbuild-chroot-config.cc
index f153632..bc8a90b 100644
--- a/sbuild/sbuild-chroot-config.cc
+++ b/sbuild/sbuild-chroot-config.cc
@@ -547,7 +547,7 @@ chroot_config::load_keyfile (keyfile& kconfig,
 	chroot_facet_source_clonable::const_ptr psrc
 	  (chroot->get_facet<sbuild::chroot_facet_source_clonable>());
 
-	if (psrc && !chroot->get_active())
+	if (psrc && psrc->get_source_clone() && !chroot->get_active())
 	  {
 	    chroot::ptr source_chroot = chroot->clone_source();
 	    if (source_chroot)
diff --git a/sbuild/sbuild-chroot-facet-source-clonable.cc b/sbuild/sbuild-chroot-facet-source-clonable.cc
index 930ec1e..9e784c7 100644
--- a/sbuild/sbuild-chroot-facet-source-clonable.cc
+++ b/sbuild/sbuild-chroot-facet-source-clonable.cc
@@ -30,6 +30,7 @@ using namespace sbuild;
 
 chroot_facet_source_clonable::chroot_facet_source_clonable ():
   chroot_facet(),
+  source_clone(true),
   source_users(),
   source_groups(),
   source_root_users(),
@@ -84,6 +85,18 @@ chroot_facet_source_clonable::clone_source_setup (chroot::ptr& clone) const
   clone->add_facet(chroot_facet_source::create());
 }
 
+bool
+chroot_facet_source_clonable::get_source_clone () const
+{
+  return this->source_clone;
+}
+
+void
+chroot_facet_source_clonable::set_source_clone (bool source_clone)
+{
+  this->source_clone = source_clone;
+}
+
 string_list const&
 chroot_facet_source_clonable::get_source_users () const
 {
@@ -163,6 +176,10 @@ void
 chroot_facet_source_clonable::get_keyfile (chroot const& chroot,
 					   keyfile&      keyfile) const
 {
+  keyfile::set_object_value(*this, &chroot_facet_source_clonable::get_source_clone,
+			    keyfile, chroot.get_keyfile_name(),
+			    "source-clone");
+
   keyfile::set_object_list_value(*this, &chroot_facet_source_clonable::get_source_users,
 				 keyfile, chroot.get_keyfile_name(),
 				 "source-users");
@@ -185,6 +202,12 @@ chroot_facet_source_clonable::set_keyfile (chroot&        chroot,
 					   keyfile const& keyfile,
 					   string_list&   used_keys)
 {
+  keyfile::get_object_value(*this, &chroot_facet_source_clonable::set_source_clone,
+			    keyfile, chroot.get_keyfile_name(),
+			    "source-clone",
+			    keyfile::PRIORITY_OPTIONAL);
+  used_keys.push_back("source-clone");
+
   keyfile::get_object_list_value(*this, &chroot_facet_source_clonable::set_source_users,
 				 keyfile, chroot.get_keyfile_name(),
 				 "source-users",
diff --git a/sbuild/sbuild-chroot-facet-source-clonable.h b/sbuild/sbuild-chroot-facet-source-clonable.h
index 5d8ae07..a0b1afb 100644
--- a/sbuild/sbuild-chroot-facet-source-clonable.h
+++ b/sbuild/sbuild-chroot-facet-source-clonable.h
@@ -72,6 +72,24 @@ namespace sbuild
     clone_source_setup (chroot::ptr& clone) const;
 
     /**
+     * Is cloning a source chroot automatically permitted?  Note that
+     * this is merely a hint and does not prevent cloning.
+     *
+     * @returns a list of clone.
+     */
+    virtual bool
+    get_source_clone () const;
+
+    /**
+     * Set if cloning a source chroot automatically is permitted.
+     * Note that this is merely a hint and does not prevent cloning.
+     *
+     * @param clone true to automatically clone, otherwise false.
+     */
+    virtual void
+    set_source_clone (bool clone);
+
+    /**
      * Get the users allowed to access the source chroot.
      *
      * @returns a list of users.
@@ -164,6 +182,8 @@ namespace sbuild
 		 string_list&   used_keys);
 
   private:
+    /// Is source chroot cloning permitted?
+    bool          source_clone;
     /// Users allowed to access the source chroot.
     string_list   source_users;
     /// Groups allowed to access the source chroot.
diff --git a/test/test-sbuild-chroot.h b/test/test-sbuild-chroot.h
index 6ab74f1..cd1abd1 100644
--- a/test/test-sbuild-chroot.h
+++ b/test/test-sbuild-chroot.h
@@ -246,6 +246,7 @@ public:
   void setup_keyfile_source (sbuild::keyfile&   keyfile,
 			     std::string const& group)
   {
+    keyfile.set_value(group, "source-clone", "true");
     keyfile.set_value(group, "source-users", "suser1,suser2");
     keyfile.set_value(group, "source-root-users", "suser3,suser4");
     keyfile.set_value(group, "source-groups", "sgroup1,sgroup2");

Attachment: signature.asc
Description: Digital signature

Reply via email to