diff options
author | Roger Leigh <rleigh@debian.org> | 2009-07-11 21:24:45 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2009-07-11 21:24:45 +0100 |
commit | 3206495531a5580b572cb91681069de0649f08a8 (patch) | |
tree | 31f763ebe4a5869b721bd30eaf641842b6b1c9a2 | |
parent | 98e38238674878dd665a05f819c0bcb616905970 (diff) | |
download | schroot-3206495531a5580b572cb91681069de0649f08a8.tar.gz |
[sbuild::chroot_source] Replace is_source with source_clonable
This fits the use-case for is_source rather better, and allows
it to be overridden by chroot_union (since source options aren't
available when union is not enabled).
-rw-r--r-- | sbuild/sbuild-chroot-source.cc | 20 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-source.h | 10 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-union.cc | 10 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-union.h | 3 |
4 files changed, 28 insertions, 15 deletions
diff --git a/sbuild/sbuild-chroot-source.cc b/sbuild/sbuild-chroot-source.cc index 81eb65aa..47205a0c 100644 --- a/sbuild/sbuild-chroot-source.cc +++ b/sbuild/sbuild-chroot-source.cc @@ -29,7 +29,7 @@ using boost::format; using namespace sbuild; chroot_source::chroot_source (): - is_source(false), + source_clonable(true), source_users(), source_groups(), source_root_users(), @@ -62,7 +62,7 @@ chroot_source::clone_source_setup (chroot::ptr& clone) const std::tr1::shared_ptr<chroot_source> source(std::tr1::dynamic_pointer_cast<chroot_source>(clone)); if (source) - source->set_source(true); + source->set_source_clonable(false); } string_list const& @@ -114,15 +114,15 @@ chroot_source::set_source_root_groups (string_list const& groups) } bool -chroot_source::get_source () const +chroot_source::get_source_clonable () const { - return this->is_source; + return this->source_clonable; } void -chroot_source::set_source (bool source) +chroot_source::set_source_clonable (bool clonable) { - this->is_source = source; + this->source_clonable = clonable; } void @@ -138,7 +138,7 @@ chroot_source::get_session_flags () const assert(base != 0); // Cloning is only possible for non-source and inactive chroots. - if (this->get_source() || base->get_active()) + if (!this->get_source_clonable() || base->get_active()) return chroot::SESSION_NOFLAGS; else return chroot::SESSION_CLONE; @@ -147,7 +147,7 @@ chroot_source::get_session_flags () const void chroot_source::get_details (format_detail& detail) const { - if (!this->get_source()) + if (this->get_source_clonable()) detail .add(_("Source Users"), get_source_users()) .add(_("Source Groups"), get_source_groups()) @@ -162,7 +162,7 @@ chroot_source::get_keyfile (keyfile& keyfile) const const chroot *base = dynamic_cast<const chroot *>(this); assert(base != 0); - if (!this->get_source()) + if (this->get_source_clonable()) { keyfile::set_object_list_value(*this, &chroot_source::get_source_users, keyfile, base->get_keyfile_name(), "source-users"); @@ -186,7 +186,7 @@ chroot_source::set_keyfile (keyfile const& keyfile, const chroot *base = dynamic_cast<const chroot *>(this); assert(base != 0); - if (!this->get_source()) + if (this->get_source_clonable()) { keyfile::get_object_list_value(*this, &chroot_source::set_source_users, keyfile, base->get_keyfile_name(), "source-users", diff --git a/sbuild/sbuild-chroot-source.h b/sbuild/sbuild-chroot-source.h index d171f30f..ce1145b7 100644 --- a/sbuild/sbuild-chroot-source.h +++ b/sbuild/sbuild-chroot-source.h @@ -142,20 +142,20 @@ namespace sbuild set_source_root_groups (string_list const& groups); /** - * Get if the chroot is a source chroot or not. + * Get if the chroot is a clonable source chroot or not. * * @returns true if the chroot is a source chroot, otherwise false. */ virtual bool - get_source () const; + get_source_clonable () const; /** - * Set if the chroot is a source chroot or not. + * Set if the chroot is a clonable source chroot or not. * * @param source true if a source chroot, or false if not. */ virtual void - set_source (bool source); + set_source_clonable (bool clonable); void setup_env (environment& env); @@ -176,7 +176,7 @@ namespace sbuild private: /// Is the chroot source or clone? - bool is_source; + bool source_clonable; /// Users allowed to access the source chroot. string_list source_users; /// Groups allowed to access the source chroot. diff --git a/sbuild/sbuild-chroot-union.cc b/sbuild/sbuild-chroot-union.cc index fc467eb1..8f54b0a9 100644 --- a/sbuild/sbuild-chroot-union.cc +++ b/sbuild/sbuild-chroot-union.cc @@ -75,6 +75,13 @@ chroot_union::clone_source_setup (chroot::ptr& clone) const } bool +chroot_union::get_source_clonable () const +{ + return chroot_source::get_source_clonable() && + get_union_configured(); +} + +bool chroot_union::get_union_configured () const { return get_union_type() != "none"; @@ -127,6 +134,9 @@ chroot_union::set_union_type (std::string const& type) this->union_type = type; else throw error(type, UNION_TYPE_UNKNOWN); + + // If union not enabled, don't implement source interface. + set_source_clonable(this->union_type != "none"); } std::string const& diff --git a/sbuild/sbuild-chroot-union.h b/sbuild/sbuild-chroot-union.h index 90bf9555..8ca2fc35 100644 --- a/sbuild/sbuild-chroot-union.h +++ b/sbuild/sbuild-chroot-union.h @@ -59,6 +59,9 @@ namespace sbuild clone_source_setup (chroot::ptr& clone) const; public: + bool + get_source_clonable () const; + /** * Get fs union configured state. * |