[buildd-tools-devel] [PATCH 2/8] [chroot_directory] Inherit from chroot_plain

Jan-Marek Glogowski glogow at fbihome.de
Wed May 20 17:55:52 UTC 2009


---
 sbuild/sbuild-chroot-directory.cc |   81 +------------------------------------
 sbuild/sbuild-chroot-directory.h  |   35 +---------------
 sbuild/sbuild-session.cc          |    4 +-
 3 files changed, 5 insertions(+), 115 deletions(-)

diff --git a/sbuild/sbuild-chroot-directory.cc b/sbuild/sbuild-chroot-directory.cc
index 273bb76..96780c8 100644
--- a/sbuild/sbuild-chroot-directory.cc
+++ b/sbuild/sbuild-chroot-directory.cc
@@ -32,9 +32,9 @@
 using namespace sbuild;
 
 chroot_directory::chroot_directory ():
-  chroot(),
-  directory()
+  chroot_plain()
 {
+  set_run_setup_scripts(true);
 }
 
 chroot_directory::~chroot_directory ()
@@ -47,21 +47,6 @@ chroot_directory::clone () const
   return ptr(new chroot_directory(*this));
 }
 
-std::string const&
-chroot_directory::get_directory () const
-{
-  return this->directory;
-}
-
-void
-chroot_directory::set_directory (std::string const& directory)
-{
-  if (!is_absname(directory))
-    throw error(directory, DIRECTORY_ABS);
-
-  this->directory = directory;
-}
-
 std::string
 chroot_directory::get_path () const
 {
@@ -77,14 +62,6 @@ chroot_directory::get_chroot_type () const
 }
 
 void
-chroot_directory::setup_env (environment& env)
-{
-  chroot::setup_env(env);
-
-  env.add("CHROOT_DIRECTORY", get_directory());
-}
-
-void
 chroot_directory::setup_lock (chroot::setup_type type,
 			      bool               lock,
 			      int                status)
@@ -103,57 +80,3 @@ chroot_directory::get_session_flags () const
 {
   return SESSION_CREATE;
 }
-
-void
-chroot_directory::get_details (format_detail& detail) const
-{
-  chroot::get_details(detail);
-
-  detail.add(_("Directory"), get_directory());
-}
-
-void
-chroot_directory::get_keyfile (keyfile& keyfile) const
-{
-  chroot::get_keyfile(keyfile);
-
-  keyfile::set_object_value(*this, &chroot_directory::get_directory,
-			    keyfile, get_name(), "directory");
-}
-
-void
-chroot_directory::set_keyfile (keyfile const& keyfile,
-			       string_list&   used_keys)
-{
-  chroot::set_keyfile(keyfile, used_keys);
-
-  // "directory" should be required, but we also accept "location" as
-  // an alternative (but deprecated) variant.  Therefore, ensure by
-  // hand that one of them is defined, but not both.
-
-  bool directory_key = keyfile.has_key(get_name(), "directory");
-  bool location_key = keyfile.has_key(get_name(), "location");
-
-  keyfile::priority directory_priority = keyfile::PRIORITY_OPTIONAL;
-  keyfile::priority location_priority = keyfile::PRIORITY_DEPRECATED;
-
-  if (!directory_key && !location_key)
-    throw keyfile::error(get_name(), keyfile::MISSING_KEY_NL, "directory");
-
-  // Using both keys is not allowed (which one is the correct one?),
-  // so force an exception to be thrown when reading the old location
-  // key.
-  if (directory_key && location_key)
-    location_priority = keyfile::PRIORITY_DISALLOWED;
-
-
-  keyfile::get_object_value(*this, &chroot_directory::set_directory,
-			    keyfile, get_name(), "directory",
-			    directory_priority);
-  used_keys.push_back("directory");
-
-  keyfile::get_object_value(*this, &chroot_directory::set_directory,
-			    keyfile, get_name(), "location",
-			    location_priority);
-  used_keys.push_back("location");
-}
diff --git a/sbuild/sbuild-chroot-directory.h b/sbuild/sbuild-chroot-directory.h
index fda21f5..c0eb9c4 100644
--- a/sbuild/sbuild-chroot-directory.h
+++ b/sbuild/sbuild-chroot-directory.h
@@ -27,7 +27,7 @@ namespace sbuild
   /**
    * A chroot located in the filesystem.
    */
-  class chroot_directory : virtual public chroot
+  class chroot_directory : virtual public chroot_plain
   {
   protected:
     /// The constructor.
@@ -42,31 +42,12 @@ namespace sbuild
     virtual chroot::ptr
     clone () const;
 
-    /**
-     * Get the directory containing the chroot.
-     *
-     * @returns the location.
-     */
-    std::string const&
-    get_directory () const;
-
-    /**
-     * Set the directory containing the chroot.
-     *
-     * @param directory the directory.
-     */
-    void
-    set_directory (std::string const& directory);
-
     virtual std::string
     get_path () const;
 
     virtual std::string const&
     get_chroot_type () const;
 
-    virtual void
-    setup_env (environment& env);
-
     virtual session_flags
     get_session_flags () const;
 
@@ -75,20 +56,6 @@ namespace sbuild
     setup_lock (chroot::setup_type type,
 		bool               lock,
 		int                status);
-
-    virtual void
-    get_details (format_detail& detail) const;
-
-    virtual void
-    get_keyfile (keyfile& keyfile) const;
-
-    virtual void
-    set_keyfile (keyfile const& keyfile,
-		 string_list&   used_keys);
-
-  private:
-    /// The directory to use.
-    std::string directory;
   };
 
 }
diff --git a/sbuild/sbuild-session.cc b/sbuild/sbuild-session.cc
index 60bcd97..d9d3a88 100644
--- a/sbuild/sbuild-session.cc
+++ b/sbuild/sbuild-session.cc
@@ -637,8 +637,8 @@ session::run_impl ()
 	     session id.  Only set for non-plain chroots which run
 	     setup scripts. */
 	  {
-	    chroot_plain *plain = dynamic_cast<chroot_plain *>(chroot.get());
-	    if (chroot->get_mount_location().empty() && plain == 0)
+	    if (chroot->get_mount_location().empty() 
+                && (chroot->get_chroot_type() != "plain"))
 	      {
 		std::string location(std::string(SCHROOT_MOUNT_DIR) + "/" +
 				     this->session_id);
-- 
1.6.3.1




More information about the Buildd-tools-devel mailing list