[buildd-tools-devel] [PATCH 10/22] General chroot container member

Jan-Marek Glogowski glogow at fbihome.de
Thu Mar 26 21:13:48 UTC 2009


This drops all chroot specific setters, getters and members
for a general chroot container member. Type, detail name and
keyfile key name data are combined in the get_chroot_strings
function to generalize the container management, but keep
individual keyfile key names.

During the cleanup the mount_device member got dropped, as
most chroot didn't use it and the correct value can be set in
the 10mount script.
---
 bin/schroot/exec/00check             |    2 +-
 bin/schroot/setup/00check            |    2 +-
 bin/schroot/setup/10mount            |    3 +
 sbuild/sbuild-chroot-block-device.cc |   64 +++++++-------------
 sbuild/sbuild-chroot-block-device.h  |   21 ++-----
 sbuild/sbuild-chroot-directory.cc    |   58 +++++-------------
 sbuild/sbuild-chroot-directory.h     |   27 ++-------
 sbuild/sbuild-chroot-file.cc         |   59 ++++++++-----------
 sbuild/sbuild-chroot-file.h          |   18 ++----
 sbuild/sbuild-chroot-loopback.cc     |   61 +++++++------------
 sbuild/sbuild-chroot-loopback.h      |   24 ++------
 sbuild/sbuild-chroot-lvm-snapshot.cc |   36 ++++++------
 sbuild/sbuild-chroot-lvm-snapshot.h  |    9 +--
 sbuild/sbuild-chroot-mountable.h     |    3 -
 sbuild/sbuild-chroot-plain.cc        |   18 ++++--
 sbuild/sbuild-chroot-plain.h         |    6 +-
 sbuild/sbuild-chroot.cc              |  109 +++++++++++++++++++++++-----------
 sbuild/sbuild-chroot.h               |   75 +++++++++++++++--------
 sbuild/sbuild-session.cc             |    2 +-
 test/sbuild-chroot-block-device.cc   |   27 +++++----
 test/sbuild-chroot-directory.cc      |   30 ++++++----
 test/sbuild-chroot-file.cc           |   23 ++++---
 test/sbuild-chroot-lvm-snapshot.cc   |   21 ++++---
 test/sbuild-chroot-plain.cc          |   22 ++++---
 test/sbuild-chroot.cc                |   41 +++++++------
 test/test-sbuild-chroot.h            |    1 -
 26 files changed, 369 insertions(+), 393 deletions(-)

diff --git a/bin/schroot/exec/00check b/bin/schroot/exec/00check
index a5e490c..006fbde 100755
--- a/bin/schroot/exec/00check
+++ b/bin/schroot/exec/00check
@@ -51,7 +51,7 @@ if [ $1 = "exec-start" ]; then
 	echo "CHROOT_MOUNT_LOCATION=$CHROOT_MOUNT_LOCATION"
 	echo "CHROOT_LOCATION=$CHROOT_LOCATION"
 	echo "CHROOT_PATH=$CHROOT_PATH"
-	echo "CHROOT_MOUNT_DEVICE=$CHROOT_MOUNT_DEVICE"
+	echo "CHROOT_CONTAINER=$CHROOT_CONTAINER"
 	if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
 	    :
 	elif [ "$CHROOT_TYPE" = "file" ]; then
diff --git a/bin/schroot/setup/00check b/bin/schroot/setup/00check
index afd3385..136d38a 100755
--- a/bin/schroot/setup/00check
+++ b/bin/schroot/setup/00check
@@ -51,7 +51,7 @@ if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
 	echo "CHROOT_MOUNT_LOCATION=$CHROOT_MOUNT_LOCATION"
 	echo "CHROOT_LOCATION=$CHROOT_LOCATION"
 	echo "CHROOT_PATH=$CHROOT_PATH"
-	echo "CHROOT_MOUNT_DEVICE=$CHROOT_MOUNT_DEVICE"
+	echo "CHROOT_CONTAINER=$CHROOT_CONTAINER"
 	if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
 	    :
 	elif [ "$CHROOT_TYPE" = "file" ]; then
diff --git a/bin/schroot/setup/10mount b/bin/schroot/setup/10mount
index da1248c..e667971 100755
--- a/bin/schroot/setup/10mount
+++ b/bin/schroot/setup/10mount
@@ -84,8 +84,11 @@ if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROO
 	CHROOT_MOUNT_DEVICE="$UNPACK_LOCATION"
     elif [ "$CHROOT_TYPE" = "loopback" ]; then
 	CHROOT_MOUNT_OPTIONS="$CHROOT_MOUNT_OPTIONS -o loop"
+	CHROOT_MOUNT_DEVICE="$CHROOT_FILE"
     elif [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
 	CHROOT_MOUNT_DEVICE="$CHROOT_LVM_SNAPSHOT_DEVICE"
+    elif [ "$CHROOT_TYPE" = "block-device" ]; then
+	CHROOT_MOUNT_DEVICE="$CHROOT_DEVICE"
     fi
 
     if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
diff --git a/sbuild/sbuild-chroot-block-device.cc b/sbuild/sbuild-chroot-block-device.cc
index 5891b67..e704a09 100644
--- a/sbuild/sbuild-chroot-block-device.cc
+++ b/sbuild/sbuild-chroot-block-device.cc
@@ -33,8 +33,7 @@ using namespace sbuild;
 
 chroot_block_device::chroot_block_device ():
   chroot(),
-  chroot_mountable(),
-  device()
+  chroot_mountable()
 {
 }
 
@@ -48,33 +47,13 @@ chroot_block_device::clone () const
   return ptr(new chroot_block_device(*this));
 }
 
-std::string const&
-chroot_block_device::get_device () const
-{
-  return this->device;
-}
-
 void
-chroot_block_device::set_device (std::string const& device)
+chroot_block_device::set_container (std::string const& device)
 {
   if (!is_absname(device))
     throw error(device, DEVICE_ABS);
 
-  this->device = device;
-}
-
-std::string const&
-chroot_block_device::get_mount_device () const
-{
-  return this->device;
-}
-
-std::string const&
-chroot_block_device::get_chroot_type () const
-{
-  static const std::string type("block-device");
-
-  return type;
+  chroot::set_container(device);
 }
 
 void
@@ -82,8 +61,6 @@ chroot_block_device::setup_env (environment& env)
 {
   chroot::setup_env(env);
   chroot_mountable::setup_env(env);
-
-  env.add("CHROOT_DEVICE", get_device());
 }
 
 void
@@ -100,15 +77,17 @@ chroot_block_device::setup_lock (chroot::setup_type type,
       (type == SETUP_STOP && lock == true))
     return;
 
+  std::string device = get_container();
+
   try
     {
-      if (!stat(this->device).is_block())
+      if (!stat(device).is_block())
 	{
-	  throw error(get_device(), DEVICE_NOTBLOCK);
+	  throw error(device, DEVICE_NOTBLOCK);
 	}
       else
 	{
-	  sbuild::device_lock dlock(this->device);
+	  sbuild::device_lock dlock(device);
 	  if (lock)
 	    {
 	      try
@@ -117,7 +96,7 @@ chroot_block_device::setup_lock (chroot::setup_type type,
 		}
 	      catch (sbuild::lock::error const& e)
 		{
-		  throw error(get_device(), DEVICE_LOCK, e);
+		  throw error(device, DEVICE_LOCK, e);
 		}
 	    }
 	  else
@@ -128,7 +107,7 @@ chroot_block_device::setup_lock (chroot::setup_type type,
 		}
 	      catch (sbuild::lock::error const& e)
 		{
-		  throw error(get_device(), DEVICE_UNLOCK, e);
+		  throw error(device, DEVICE_UNLOCK, e);
 		}
 	    }
 	}
@@ -155,9 +134,6 @@ chroot_block_device::get_details (format_detail& detail) const
 {
   this->chroot::get_details(detail);
   this->chroot_mountable::get_details(detail);
-
-  if (!this->device.empty())
-    detail.add(_("Device"), get_device());
 }
 
 void
@@ -165,9 +141,6 @@ chroot_block_device::get_keyfile (keyfile& keyfile) const
 {
   chroot::get_keyfile(keyfile);
   chroot_mountable::get_keyfile(keyfile);
-
-  keyfile::set_object_value(*this, &chroot_block_device::get_device,
-			    keyfile, get_name(), "device");
 }
 
 void
@@ -176,9 +149,18 @@ chroot_block_device::set_keyfile (keyfile const& keyfile,
 {
   chroot::set_keyfile(keyfile, used_keys);
   chroot_mountable::set_keyfile(keyfile, used_keys);
+}
 
-  keyfile::get_object_value(*this, &chroot_block_device::set_device,
-			    keyfile, get_name(), "device",
-			    keyfile::PRIORITY_REQUIRED);
-  used_keys.push_back("device");
+void
+chroot_block_device::get_chroot_strings (std::string *type,
+					 std::string *key_name,
+					 std::string *detail_name) const
+{
+  if (type != NULL)
+    *type = "block-device";
+  if (key_name != NULL)
+    *key_name = "device";
+  if (detail_name != NULL)
+    *detail_name = "Device";
 }
+
diff --git a/sbuild/sbuild-chroot-block-device.h b/sbuild/sbuild-chroot-block-device.h
index abbddca..9b53ec9 100644
--- a/sbuild/sbuild-chroot-block-device.h
+++ b/sbuild/sbuild-chroot-block-device.h
@@ -46,13 +46,6 @@ namespace sbuild
     virtual chroot::ptr
     clone () const;
 
-    /**
-     * Get the block device of the chroot.
-     *
-     * @returns the device.
-     */
-    std::string const&
-    get_device () const;
 
     /**
      * Set the block device of the chroot.  This is the "source" device.
@@ -63,13 +56,12 @@ namespace sbuild
      * @param device the device.
      */
     void
-    set_device (std::string const& device);
+    set_container (std::string const& device);
 
-    virtual std::string const&
-    get_mount_device () const;
-
-    std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
 
     virtual void
     setup_env (environment& env);
@@ -93,9 +85,6 @@ namespace sbuild
     set_keyfile (keyfile const& keyfile,
 		 string_list&   used_keys);
 
-  private:
-    /// The block device to use.
-    std::string device;
   };
 
 }
diff --git a/sbuild/sbuild-chroot-directory.cc b/sbuild/sbuild-chroot-directory.cc
index 978e750..237b616 100644
--- a/sbuild/sbuild-chroot-directory.cc
+++ b/sbuild/sbuild-chroot-directory.cc
@@ -46,21 +46,6 @@ chroot_directory::clone () const
   return ptr(new chroot_directory(*this));
 }
 
-std::string const&
-chroot_directory::get_location () const
-{
-  return chroot::get_location();
-}
-
-void
-chroot_directory::set_location (std::string const& location)
-{
-  if (!is_absname(location))
-    throw error(location, LOCATION_ABS);
-
-  chroot::set_location(location);
-}
-
 std::string
 chroot_directory::get_path () const
 {
@@ -69,15 +54,7 @@ chroot_directory::get_path () const
   if (get_run_setup_scripts() == true)
     return get_mount_location();
   else
-    return get_location();
-}
-
-std::string const&
-chroot_directory::get_chroot_type () const
-{
-  static const std::string type("directory");
-
-  return type;
+    return get_container();
 }
 
 void
@@ -108,28 +85,25 @@ chroot_directory::get_session_flags () const
 }
 
 void
-chroot_directory::get_details (format_detail& detail) const
+chroot_directory::set_container (std::string const& directory)
 {
-  chroot::get_details(detail);
-}
+  if (!directory.empty() && !is_absname(directory))
+    throw error(directory, LOCATION_ABS);
 
-void
-chroot_directory::get_keyfile (keyfile& keyfile) const
-{
-  chroot::get_keyfile(keyfile);
-
-  keyfile::set_object_value(*this, &chroot_directory::get_location,
-			    keyfile, get_name(), "location");
+  chroot::set_container(directory);
+  chroot::set_location(directory);
 }
 
 void
-chroot_directory::set_keyfile (keyfile const& keyfile,
-			       string_list&   used_keys)
+chroot_directory::get_chroot_strings (std::string *type,
+				      std::string *key_name,
+				      std::string *detail_name) const
 {
-  chroot::set_keyfile(keyfile, used_keys);
-
-  keyfile::get_object_value(*this, &chroot_directory::set_location,
-			    keyfile, get_name(), "location",
-			    keyfile::PRIORITY_REQUIRED);
-  used_keys.push_back("location");
+  if (type != NULL)
+    *type = "directory";
+  if (key_name != NULL)
+    *key_name = "location";
+  if (detail_name != NULL)
+    *detail_name = "Location";
 }
+
diff --git a/sbuild/sbuild-chroot-directory.h b/sbuild/sbuild-chroot-directory.h
index fe69e3b..3dedc55 100644
--- a/sbuild/sbuild-chroot-directory.h
+++ b/sbuild/sbuild-chroot-directory.h
@@ -43,26 +43,20 @@ namespace sbuild
     clone () const;
 
     /**
-     * Get the directory location of the chroot.
-     *
-     * @returns the location.
-     */
-    virtual std::string const&
-    get_location () const;
-
-    /**
      * Set the directory location of the chroot.
      *
      * @param location the location.
      */
     virtual void
-    set_location (std::string const& location);
+    set_container (std::string const& directory);
 
     virtual std::string
     get_path () const;
 
-    virtual std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
 
     virtual session_flags
     get_session_flags () const;
@@ -72,17 +66,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);
-
   };
 
 }
diff --git a/sbuild/sbuild-chroot-file.cc b/sbuild/sbuild-chroot-file.cc
index cc730a5..17bd546 100644
--- a/sbuild/sbuild-chroot-file.cc
+++ b/sbuild/sbuild-chroot-file.cc
@@ -33,7 +33,6 @@ using namespace sbuild;
 chroot_file::chroot_file ():
   chroot(),
   chroot_source(),
-  file(),
   repack(false)
 {
   set_run_setup_scripts(true);
@@ -62,19 +61,13 @@ chroot_file::clone_source () const
   return clone;
 }
 
-std::string const&
-chroot_file::get_file () const
-{
-  return this->file;
-}
-
 void
-chroot_file::set_file (std::string const& file)
+chroot_file::set_container (std::string const& file)
 {
   if (!is_absname(file))
     throw error(file, FILE_ABS);
 
-  this->file = file;
+  chroot::set_container(file);
 }
 
 bool
@@ -89,21 +82,12 @@ chroot_file::set_file_repack (bool repack)
   this->repack = repack;
 }
 
-std::string const&
-chroot_file::get_chroot_type () const
-{
-  static const std::string type("file");
-
-  return type;
-}
-
 void
 chroot_file::setup_env (environment& env)
 {
   chroot::setup_env(env);
   chroot_source::setup_env(env);
 
-  env.add("CHROOT_FILE", get_file());
   env.add("CHROOT_FILE_REPACK", this->repack);
 }
 
@@ -115,15 +99,16 @@ chroot_file::setup_lock (chroot::setup_type type,
   // Check ownership and permissions.
   if (type == SETUP_START && lock == true)
     {
-      stat file_status(this->file);
+      std::string file = get_container();
+      stat file_status(file);
 
       // NOTE: taken from chroot_config::check_security.
       if (file_status.uid() != 0)
-	throw error(this->file, FILE_OWNER);
+	throw error(file, FILE_OWNER);
       if (file_status.check_mode(stat::PERM_OTHER_WRITE))
-	throw error(this->file, FILE_PERMS);
+	throw error(file, FILE_PERMS);
       if (!file_status.is_regular())
-	throw error(this->file, FILE_NOTREG);
+	throw error(file, FILE_NOTREG);
     }
 
   /* By default, file chroots do no locking. */
@@ -131,7 +116,6 @@ chroot_file::setup_lock (chroot::setup_type type,
   if ((type == SETUP_START && lock == true) ||
       (type == SETUP_STOP && lock == false && status == 0))
     {
-
       bool start = (type == SETUP_START);
       setup_session_info(start);
     }
@@ -149,9 +133,8 @@ chroot_file::get_details (format_detail& detail) const
   chroot::get_details(detail);
   chroot_source::get_details(detail);
 
-  if (!this->file.empty())
+  if (!get_container().empty())
     detail
-      .add(_("File"), get_file())
       .add(_("File Repack"), this->repack);
 }
 
@@ -161,12 +144,9 @@ chroot_file::get_keyfile (keyfile& keyfile) const
   chroot::get_keyfile(keyfile);
   chroot_source::get_keyfile(keyfile);
 
-  keyfile::set_object_value(*this, &chroot_file::get_file,
-			    keyfile, get_name(), "file");
-
   if (get_active())
-  keyfile::set_object_value(*this, &chroot_file::get_file_repack,
-			    keyfile, get_name(), "file-repack");
+    keyfile::set_object_value(*this, &chroot_file::get_file_repack,
+			      keyfile, get_name(), "file-repack");
 }
 
 void
@@ -176,11 +156,6 @@ chroot_file::set_keyfile (keyfile const& keyfile,
   chroot::set_keyfile(keyfile, used_keys);
   chroot_source::set_keyfile(keyfile, used_keys);
 
-  keyfile::get_object_value(*this, &chroot_file::set_file,
-			    keyfile, get_name(), "file",
-			    keyfile::PRIORITY_REQUIRED);
-  used_keys.push_back("file");
-
   keyfile::get_object_value(*this, &chroot_file::set_file_repack,
 			    keyfile, get_name(), "file-repack",
 			    get_active() ?
@@ -188,3 +163,17 @@ chroot_file::set_keyfile (keyfile const& keyfile,
 			    keyfile::PRIORITY_DISALLOWED);
   used_keys.push_back("file-repack");
 }
+
+void
+chroot_file::get_chroot_strings (std::string *type,
+				 std::string *key_name,
+				 std::string *detail_name) const
+{
+  if (type != NULL)
+    *type = "file";
+  if (key_name != NULL)
+    *key_name = "file";
+  if (detail_name != NULL)
+    *detail_name = "File";
+}
+
diff --git a/sbuild/sbuild-chroot-file.h b/sbuild/sbuild-chroot-file.h
index 0df1b85..24710d4 100644
--- a/sbuild/sbuild-chroot-file.h
+++ b/sbuild/sbuild-chroot-file.h
@@ -49,20 +49,12 @@ namespace sbuild
     clone_source () const;
 
     /**
-     * Get the file used by the chroot.
-     *
-     * @returns the file.
-     */
-    std::string const&
-    get_file () const;
-
-    /**
      * Set the file used by the chroot.
      *
      * @param file the file.
      */
     void
-    set_file (std::string const& file);
+    set_container (std::string const& file);
 
     /**
      * Get the repack status.  This is true if the unpacked archive
@@ -83,8 +75,10 @@ namespace sbuild
     void
     set_file_repack (bool repack);
 
-    virtual std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
 
     virtual void
     setup_env (environment& env);
@@ -109,8 +103,6 @@ namespace sbuild
 		 string_list&   used_keys);
 
   private:
-    /// The file to use.
-    std::string file;
     /// Should the chroot be repacked?
     bool repack;
   };
diff --git a/sbuild/sbuild-chroot-loopback.cc b/sbuild/sbuild-chroot-loopback.cc
index c679107..35fc044 100644
--- a/sbuild/sbuild-chroot-loopback.cc
+++ b/sbuild/sbuild-chroot-loopback.cc
@@ -33,8 +33,7 @@ using namespace sbuild;
 
 chroot_loopback::chroot_loopback ():
   chroot(),
-  chroot_mountable(),
-  file()
+  chroot_mountable()
 {
 }
 
@@ -48,33 +47,13 @@ chroot_loopback::clone () const
   return ptr(new chroot_loopback(*this));
 }
 
-std::string const&
-chroot_loopback::get_file () const
-{
-  return this->file;
-}
-
 void
-chroot_loopback::set_file (std::string const& file)
+chroot_loopback::set_container (std::string const& file)
 {
   if (!is_absname(file))
     throw error(file, FILE_ABS);
 
-  this->file = file;
-}
-
-std::string const&
-chroot_loopback::get_mount_device () const
-{
-  return this->file;
-}
-
-std::string const&
-chroot_loopback::get_chroot_type () const
-{
-  static const std::string type("loopback");
-
-  return type;
+  chroot_mountable::set_container(file);
 }
 
 void
@@ -82,8 +61,6 @@ chroot_loopback::setup_env (environment& env)
 {
   chroot::setup_env(env);
   chroot_mountable::setup_env(env);
-
-  env.add("CHROOT_FILE", get_file());
 }
 
 void
@@ -94,15 +71,16 @@ chroot_loopback::setup_lock (chroot::setup_type type,
   // Check ownership and permissions.
   if (type == SETUP_START && lock == true)
     {
-      stat file_status(this->file);
+      std::string file = get_container();
+      stat file_status(file);
 
       // NOTE: taken from chroot_config::check_security.
       if (file_status.uid() != 0)
-	throw error(this->file, FILE_OWNER);
+	throw error(file, FILE_OWNER);
       if (file_status.check_mode(stat::PERM_OTHER_WRITE))
-	throw error(this->file, FILE_PERMS);
+	throw error(file, FILE_PERMS);
       if (!file_status.is_regular())
-	throw error(this->file, FILE_NOTREG);
+	throw error(file, FILE_NOTREG);
     }
 
   /* By default, loopback chroots do no locking. */
@@ -119,9 +97,6 @@ chroot_loopback::get_details (format_detail& detail) const
 {
   this->chroot::get_details(detail);
   this->chroot_mountable::get_details(detail);
-
-  if (!this->file.empty())
-    detail.add(_("File"), get_file());
 }
 
 void
@@ -129,9 +104,6 @@ chroot_loopback::get_keyfile (keyfile& keyfile) const
 {
   chroot::get_keyfile(keyfile);
   chroot_mountable::get_keyfile(keyfile);
-
-  keyfile::set_object_value(*this, &chroot_loopback::get_file,
-			    keyfile, get_name(), "file");
 }
 
 void
@@ -140,9 +112,18 @@ chroot_loopback::set_keyfile (keyfile const& keyfile,
 {
   chroot::set_keyfile(keyfile, used_keys);
   chroot_mountable::set_keyfile(keyfile, used_keys);
+}
 
-  keyfile::get_object_value(*this, &chroot_loopback::set_file,
-			    keyfile, get_name(), "file",
-			    keyfile::PRIORITY_REQUIRED);
-  used_keys.push_back("file");
+void
+chroot_loopback::get_chroot_strings (std::string *type,
+				     std::string *key_name,
+				     std::string *detail_name) const
+{
+  if (type != NULL)
+    *type = "loopback";
+  if (key_name != NULL)
+    *key_name = "file";
+  if (detail_name != NULL)
+    *detail_name = "File";
 }
+
diff --git a/sbuild/sbuild-chroot-loopback.h b/sbuild/sbuild-chroot-loopback.h
index 9f46080..91ed269 100644
--- a/sbuild/sbuild-chroot-loopback.h
+++ b/sbuild/sbuild-chroot-loopback.h
@@ -47,26 +47,17 @@ namespace sbuild
     clone () const;
 
     /**
-     * Get the file containing the chroot.
-     *
-     * @returns the file.
-     */
-    std::string const&
-    get_file () const;
-
-    /**
      * Set the file containing the chroot.
      *
      * @param file the file.
      */
-    void
-    set_file (std::string const& file);
-
-    virtual std::string const&
-    get_mount_device () const;
+    virtual void
+    set_container (std::string const& file);
 
-    std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
 
     virtual void
     setup_env (environment& env);
@@ -90,9 +81,6 @@ namespace sbuild
     set_keyfile (keyfile const& keyfile,
 		 string_list&   used_keys);
 
-  private:
-    /// The file to use.
-    std::string file;
   };
 
 }
diff --git a/sbuild/sbuild-chroot-lvm-snapshot.cc b/sbuild/sbuild-chroot-lvm-snapshot.cc
index a49f5f7..4423b62 100644
--- a/sbuild/sbuild-chroot-lvm-snapshot.cc
+++ b/sbuild/sbuild-chroot-lvm-snapshot.cc
@@ -77,12 +77,6 @@ chroot_lvm_snapshot::set_snapshot_device (std::string const& snapshot_device)
 }
 
 std::string const&
-chroot_lvm_snapshot::get_mount_device () const
-{
-  return this->snapshot_device;
-}
-
-std::string const&
 chroot_lvm_snapshot::get_snapshot_options () const
 {
   return this->snapshot_options;
@@ -94,14 +88,6 @@ chroot_lvm_snapshot::set_snapshot_options (std::string const& snapshot_options)
   this->snapshot_options = snapshot_options;
 }
 
-std::string const&
-chroot_lvm_snapshot::get_chroot_type () const
-{
-  static const std::string type("lvm-snapshot");
-
-  return type;
-}
-
 void
 chroot_lvm_snapshot::setup_env (environment& env)
 {
@@ -125,7 +111,7 @@ chroot_lvm_snapshot::setup_lock (chroot::setup_type type,
   if (!(type == SETUP_STOP && lock == false))
     {
       if (type == SETUP_START)
-	device = get_device();
+	device = get_container();
       else
 	device = get_snapshot_device();
 
@@ -137,7 +123,7 @@ chroot_lvm_snapshot::setup_lock (chroot::setup_type type,
 	  stat file_status(device);
 	  if (!file_status.is_block())
 	    {
-	      throw error(get_device(), DEVICE_NOTBLOCK);
+	      throw error(device, DEVICE_NOTBLOCK);
 	    }
 	  else
 	    {
@@ -155,7 +141,7 @@ chroot_lvm_snapshot::setup_lock (chroot::setup_type type,
 		    }
 		  catch (sbuild::lock::error const& e)
 		    {
-		      throw error(get_device(), DEVICE_LOCK, e);
+		      throw error(device, DEVICE_LOCK, e);
 		    }
 		}
 	      else
@@ -166,7 +152,7 @@ chroot_lvm_snapshot::setup_lock (chroot::setup_type type,
 		    }
 		  catch (sbuild::lock::error const& e)
 		    {
-		      throw error(get_device(), DEVICE_UNLOCK, e);
+		      throw error(device, DEVICE_UNLOCK, e);
 		    }
 		}
 	    }
@@ -242,3 +228,17 @@ chroot_lvm_snapshot::set_keyfile (keyfile const& keyfile,
 			    keyfile::PRIORITY_REQUIRED);
   used_keys.push_back("lvm-snapshot-options");
 }
+
+void
+chroot_lvm_snapshot::get_chroot_strings (std::string *type,
+					 std::string *key_name,
+					 std::string *detail_name) const
+{
+  if (type != NULL)
+    *type = "lvm-snapshot";
+  if (key_name != NULL)
+    *key_name = "device";
+  if (detail_name != NULL)
+    *detail_name = "LVM Snapshot Device";
+}
+
diff --git a/sbuild/sbuild-chroot-lvm-snapshot.h b/sbuild/sbuild-chroot-lvm-snapshot.h
index d3bf9b2..fe6048a 100644
--- a/sbuild/sbuild-chroot-lvm-snapshot.h
+++ b/sbuild/sbuild-chroot-lvm-snapshot.h
@@ -67,9 +67,6 @@ namespace sbuild
     void
     set_snapshot_device (std::string const& snapshot_device);
 
-    virtual std::string const&
-    get_mount_device () const;
-
     /**
      * Get the logical volume snapshot options.  These are used by
      * lvcreate.
@@ -88,8 +85,10 @@ namespace sbuild
     void
     set_snapshot_options (std::string const& snapshot_options);
 
-    virtual std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
 
     virtual void
     setup_env (environment& env);
diff --git a/sbuild/sbuild-chroot-mountable.h b/sbuild/sbuild-chroot-mountable.h
index 80a55c2..206d6b0 100644
--- a/sbuild/sbuild-chroot-mountable.h
+++ b/sbuild/sbuild-chroot-mountable.h
@@ -41,9 +41,6 @@ namespace sbuild
     /// The destructor.
     virtual ~chroot_mountable ();
 
-    virtual std::string const&
-    get_mount_device () const = 0;
-
     /**
      * Get the filesystem mount_options of the chroot block device.
      *
diff --git a/sbuild/sbuild-chroot-plain.cc b/sbuild/sbuild-chroot-plain.cc
index 3598b5d..437c67e 100644
--- a/sbuild/sbuild-chroot-plain.cc
+++ b/sbuild/sbuild-chroot-plain.cc
@@ -32,7 +32,7 @@
 using namespace sbuild;
 
 chroot_plain::chroot_plain ():
-  chroot()
+  chroot_directory()
 {
 }
 
@@ -46,10 +46,16 @@ chroot_plain::clone () const
   return ptr(new chroot_plain(*this));
 }
 
-std::string const&
-chroot_plain::get_chroot_type () const
+void
+chroot_plain::get_chroot_strings (std::string *type,
+				  std::string *key_name,
+				  std::string *detail_name) const
 {
-  static const std::string type("plain");
-
-  return type;
+  if (type != NULL)
+    *type = "plain";
+  if (key_name != NULL)
+    *key_name = "location";
+  if (detail_name != NULL)
+    *detail_name = "Location";
 }
+
diff --git a/sbuild/sbuild-chroot-plain.h b/sbuild/sbuild-chroot-plain.h
index adcbd22..51115d8 100644
--- a/sbuild/sbuild-chroot-plain.h
+++ b/sbuild/sbuild-chroot-plain.h
@@ -42,8 +42,10 @@ namespace sbuild
     virtual chroot::ptr
     clone () const;
 
-    virtual std::string const&
-    get_chroot_type () const;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const;
   };
 
 }
diff --git a/sbuild/sbuild-chroot.cc b/sbuild/sbuild-chroot.cc
index 05486a7..41a314c 100644
--- a/sbuild/sbuild-chroot.cc
+++ b/sbuild/sbuild-chroot.cc
@@ -57,6 +57,7 @@ namespace
       emap(sbuild::chroot::CHROOT_DEVICE,   N_("Device name not set")),
       // TRANSLATORS: %1% = chroot type name
       emap(sbuild::chroot::CHROOT_TYPE,     N_("Unknown chroot type '%1%'")),
+      emap(sbuild::chroot::CONTAINER_LEN,   N_("Container string is empty")),
       emap(sbuild::chroot::DEVICE_ABS,      N_("Device must have an absolute path")),
       emap(sbuild::chroot::DEVICE_LOCK,     N_("Failed to lock device")),
       emap(sbuild::chroot::DEVICE_NOTBLOCK, N_("File is not a block device")),
@@ -92,8 +93,8 @@ sbuild::chroot::chroot ():
   aliases(),
   environment_filter("^(BASH_ENV|CDPATH|ENV|HOSTALIASES|IFS|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMAIN|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TERMPATH)$"),
   mount_location(),
+  container(),
   location(),
-  mount_device(),
   active(false),
   original(true),
   run_setup_scripts(false),
@@ -179,12 +180,27 @@ sbuild::chroot::set_mount_location (std::string const& location)
 }
 
 std::string const&
+sbuild::chroot::get_container () const
+{
+  return this->container;
+}
+
+std::string const&
 sbuild::chroot::get_location () const
 {
   return this->location;
 }
 
 void
+sbuild::chroot::set_container (std::string const& container)
+{
+  if (container.empty())
+    throw error(container, CONTAINER_LEN);
+
+  this->container = container;
+}
+
+void
 sbuild::chroot::set_location (std::string const& location)
 {
   if (!location.empty() && !is_absname(location))
@@ -199,20 +215,6 @@ sbuild::chroot::get_path () const
   return get_mount_location() + get_location();
 }
 
-std::string const&
-sbuild::chroot::get_mount_device () const
-{
-  return this->mount_device;
-}
-
-void
-sbuild::chroot::set_mount_device (std::string const& device)
-{
-  if (!device.empty() && !is_absname(device))
-    throw error(device, DEVICE_ABS);
-  this->mount_device = device;
-}
-
 unsigned int
 sbuild::chroot::get_priority () const
 {
@@ -384,13 +386,32 @@ sbuild::chroot::set_persona (personality const& persona)
 void
 sbuild::chroot::setup_env (environment& env)
 {
-  env.add("CHROOT_TYPE", get_chroot_type());
+  std::string type, key_name;
+  get_chroot_strings(&type, &key_name, NULL);
+
+  env.add("CHROOT_TYPE", type);
   env.add("CHROOT_NAME", get_name());
   env.add("CHROOT_DESCRIPTION", get_description());
+
+  if (!key_name.empty())
+    {
+      for (std::string::iterator pos = key_name.begin();
+		pos != key_name.end(); ++pos)
+	{
+	  if (*pos == '-')
+	    *pos = '_';
+	  else
+	    *pos = toupper(*pos);
+	}
+
+      key_name.insert(0, "CHROOT_");
+      env.add(key_name, get_container());
+    }
+
+  env.add("CHROOT_CONTAINER", get_container());
   env.add("CHROOT_LOCATION", get_location());
   env.add("CHROOT_MOUNT_LOCATION", get_mount_location());
   env.add("CHROOT_PATH", get_path());
-  env.add("CHROOT_MOUNT_DEVICE", get_mount_device());
   env.add("CHROOT_SCRIPT_CONFIG", normalname(std::string(PACKAGE_SYSCONF_DIR) +  '/' + get_script_config()));
   env.add("CHROOT_SESSION_CREATE",
 	  static_cast<bool>(get_session_flags() & SESSION_CREATE));
@@ -465,16 +486,30 @@ sbuild::chroot::unlock (setup_type type,
 void
 sbuild::chroot::get_details (format_detail& detail) const
 {
+  std::string type, detail_name;
+  get_chroot_strings(&type, NULL, &detail_name);
+
   detail
     .add(_("Name"), get_name())
     .add(_("Description"), get_description())
-    .add(_("Type"), get_chroot_type())
+    .add(_("Type"), type)
     .add(_("Priority"), get_priority())
     .add(_("Users"), get_users())
     .add(_("Groups"), get_groups())
     .add(_("Root Users"), get_root_users())
     .add(_("Root Groups"), get_root_groups())
-    .add(_("Aliases"), get_aliases())
+    .add(_("Aliases"), get_aliases());
+  
+  if (!detail_name.empty())
+    {
+      std::string detail_key = _("Container (%1)");
+      std::string::size_type pos = detail_key.find_first_of("%1", 0, 2);
+      if (pos != std::string::npos)
+	detail_key.replace(pos, 2, detail_name.c_str());
+      detail.add(detail_key, get_container());
+    }
+
+  detail
     .add(_("Environment Filter"), get_environment_filter())
     .add(_("Run Setup Scripts"), get_run_setup_scripts())
     .add(_("Run Execution Scripts"), get_run_exec_scripts())
@@ -500,9 +535,6 @@ sbuild::chroot::get_details (format_detail& detail) const
     detail.add(_("Mount Location"), get_mount_location());
   if (!get_path().empty())
     detail.add(_("Path"), get_path());
-  if (!get_mount_device().empty())
-    // TRANSLATORS: The system device node to mount containing the chroot
-    detail.add(_("Mount Device"), get_mount_device());
 }
 
 void
@@ -521,8 +553,10 @@ sbuild::chroot::get_keyfile (keyfile& keyfile) const
 {
   keyfile.remove_group(get_name());
 
-  keyfile::set_object_value(*this, &chroot::get_chroot_type,
-			    keyfile, get_name(), "type");
+  std::string type, container_key;
+  get_chroot_strings(&type, &container_key, NULL);
+
+  keyfile.set_value(get_name(), "type", type);
 
   keyfile::set_object_value(*this, &chroot::get_active,
 			    keyfile, get_name(), "active");
@@ -542,6 +576,10 @@ sbuild::chroot::get_keyfile (keyfile& keyfile) const
   keyfile::set_object_list_value(*this, &chroot::get_aliases,
 				 keyfile, get_name(), "aliases");
 
+  if (!container_key.empty())
+    keyfile::set_object_value(*this, &chroot::get_container,
+			      keyfile, get_name(), container_key);
+
   keyfile::set_object_value(*this, &chroot::get_environment_filter,
 			    keyfile, get_name(), "environment-filter");
 
@@ -564,10 +602,6 @@ sbuild::chroot::get_keyfile (keyfile& keyfile) const
     keyfile::set_object_value(*this, &chroot::get_mount_location,
 			      keyfile, get_name(), "mount-location");
 
-  if (get_active())
-    keyfile::set_object_value(*this, &chroot::get_mount_device,
-			      keyfile, get_name(), "mount-device");
-
   keyfile::set_object_list_value(*this, &chroot::get_command_prefix,
 				 keyfile, get_name(), "command-prefix");
 
@@ -575,6 +609,7 @@ sbuild::chroot::get_keyfile (keyfile& keyfile) const
 			    keyfile, get_name(), "personality");
 }
 
+
 void
 sbuild::chroot::set_keyfile (keyfile const& keyfile,
 			     string_list&   used_keys)
@@ -665,13 +700,6 @@ sbuild::chroot::set_keyfile (keyfile const& keyfile,
 			    keyfile::PRIORITY_DISALLOWED);
   used_keys.push_back("mount-location");
 
-  keyfile::get_object_value(*this, &chroot::set_mount_device,
-			    keyfile, get_name(), "mount-device",
-			    get_active() ?
-			    keyfile::PRIORITY_OPTIONAL :
-			    keyfile::PRIORITY_DISALLOWED);
-  used_keys.push_back("mount-device");
-
   keyfile::get_object_list_value(*this, &chroot::set_command_prefix,
 				 keyfile, get_name(), "command-prefix",
 				 keyfile::PRIORITY_OPTIONAL);
@@ -681,4 +709,15 @@ sbuild::chroot::set_keyfile (keyfile const& keyfile,
 			    keyfile, get_name(), "personality",
 			    keyfile::PRIORITY_OPTIONAL);
   used_keys.push_back("personality");
+
+  std::string container_key;
+  get_chroot_strings(NULL, &container_key, NULL);
+  if (!container_key.empty())
+    {
+      keyfile::get_object_value(*this, &chroot::set_container,
+				keyfile, get_name(), container_key,
+				keyfile::PRIORITY_REQUIRED);
+      used_keys.push_back(container_key);
+    }
 }
+
diff --git a/sbuild/sbuild-chroot.h b/sbuild/sbuild-chroot.h
index 60af446..6bbbe32 100644
--- a/sbuild/sbuild-chroot.h
+++ b/sbuild/sbuild-chroot.h
@@ -34,11 +34,24 @@ namespace sbuild
 {
 
   /**
-   * Common chroot data.  This class contains all of the metadata
+   * Common chroot data.
+   *
+   * This class contains all of the metadata
    * associated with a single chroot, for all chroot types.  This is
    * the in-core representation of a chroot definition in the
    * configuration file, and may be initialised directly from an open
    * keyfile.
+   *
+   * Except for the base directories the following functions and values 
+   * define the mount directory:
+   * - get_path() returns the absolute path to the constructed chroot.  This
+   *   is most times the concat of get_mount_location() + get_location().
+   * - get_container() returns the container of the chroot.  This is most 
+   *   times directly used as the mount device.
+   * - get_location() returns the absolute path of the chroot inside of the 
+   *   container.  This is user configurable.
+   * - get_mount_location() returns the absolute path to the mount directory.
+   *   This is most times a concat of get_mount_base_directory() + get_name().
    */
   class chroot
   {
@@ -68,6 +81,7 @@ namespace sbuild
 	CHROOT_CREATE,   ///< Chroot creation failed.
 	CHROOT_DEVICE,   ///< Chroot device name not set.
 	CHROOT_TYPE,     ///< Unknown chroot type.
+	CONTAINER_LEN,   ///< An empty string was supplied for the container.
 	DEVICE_ABS,      ///< Device must have an absolute path.
 	DEVICE_LOCK,     ///< Failed to lock device.
 	DEVICE_NOTBLOCK, ///< File is not a block device.
@@ -163,6 +177,18 @@ namespace sbuild
     set_mount_location (std::string const& location);
 
     /**
+     * Get the container of the chroot.
+     *
+     * This is a string, which describes the mount path to the container
+     * of the chroot, which may be most times the same as the device
+     * used by the mount command.
+     *
+     * @returns the path to the chroot container.
+     */
+    virtual std::string const&
+    get_container () const;
+
+    /**
      * Get the location of the chroot.  This is the path to the root
      * of the chroot, and is typically the same as the mount location,
      * but is overridden by the chroot type if required.
@@ -174,6 +200,18 @@ namespace sbuild
 
   protected:
     /**
+     * Set the container of the chroot.
+     *
+     * This is a string, which describes the mount path to the container
+     * of the chroot, which may be most times the same as the device
+     * used by the mount command.
+     *
+     * @param container the path to the chroot container.
+     */
+    virtual void
+    set_container (std::string const& container);
+
+    /**
      * Set the location of the chroot.  This is the path to the root
      * of the chroot, and is typically the same as the mount location,
      * but is overridden by the chroot type if required.
@@ -196,22 +234,6 @@ namespace sbuild
     get_path () const;
 
     /**
-     * Get the mount device of the chroot.
-     *
-     * @returns the device.
-     */
-    virtual std::string const&
-    get_mount_device () const;
-
-    /**
-     * Set the mount device of the chroot.
-     *
-     * @param device the device.
-     */
-    void
-    set_mount_device (std::string const& device);
-
-    /**
      * Get the priority of the chroot.  This is a number indicating
      * whether than a ditribution is older than another.
      *
@@ -369,7 +391,7 @@ namespace sbuild
     /**
      * Set the originality of the chroot.
      *
-     * @param original true if original, false if geneated.
+     * @param original true if original, false if generated.
      */
     void
     set_original (bool original);
@@ -463,12 +485,16 @@ namespace sbuild
     set_persona (personality const& persona);
 
     /**
-     * Get the type of the chroot.
+     * Gets the container config names.
      *
-     * @returns the chroot type.
+     * @param type the chroot type.
+     * @param key_name the name of the key, which stores the container.
+     * @param detail_name the name of the detail for the container.
      */
-    virtual std::string const&
-    get_chroot_type () const = 0;
+    virtual void
+    get_chroot_strings (std::string *type,
+			std::string *key_name,
+			std::string *detail_name) const = 0;
 
     /**
      * Set environment.  Set the environment that the setup scripts
@@ -591,7 +617,6 @@ namespace sbuild
       return keyfile;
     }
 
-
   protected:
     /**
      * Get detailed information about the chroot for output.
@@ -654,10 +679,10 @@ namespace sbuild
     regex         environment_filter;
     /// Location to mount chroot in the filesystem (if any).
     std::string   mount_location;
+    /// Container of the chroot.
+    std::string   container;
     /// Location inside the mount location root.
     std::string   location;
-    /// Block device to mount (if any).
-    std::string   mount_device;
     /// Chroot activity status.
     bool          active;
     /// Was the chroot automatically generated?
diff --git a/sbuild/sbuild-session.cc b/sbuild/sbuild-session.cc
index a497706..fda5507 100644
--- a/sbuild/sbuild-session.cc
+++ b/sbuild/sbuild-session.cc
@@ -658,7 +658,7 @@ session::run_impl ()
 	  chroot_lvm_snapshot *snapshot = 0;
 	  if ((snapshot = dynamic_cast<chroot_lvm_snapshot *>(chroot.get())) != 0)
 	    {
-	      std::string dir(dirname(snapshot->get_device(), '/'));
+	      std::string dir(dirname(snapshot->get_container(), '/'));
 	      std::string device(dir + "/" + this->session_id);
 	      snapshot->set_snapshot_device(device);
 	    }
diff --git a/test/sbuild-chroot-block-device.cc b/test/sbuild-chroot-block-device.cc
index 02fc432..88ed25f 100644
--- a/test/sbuild-chroot-block-device.cc
+++ b/test/sbuild-chroot-block-device.cc
@@ -46,7 +46,7 @@ class test_chroot_block_device : public test_chroot_base<chroot_block_device>
   CPPUNIT_TEST_SUITE(test_chroot_block_device);
   CPPUNIT_TEST(test_device);
   CPPUNIT_TEST(test_mount_options);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_session_flags);
   CPPUNIT_TEST(test_print_details);
@@ -62,7 +62,7 @@ public:
   {
     test_chroot_base<chroot_block_device>::setUp();
     sbuild::chroot_block_device *c = dynamic_cast<sbuild::chroot_block_device *>(chroot.get());
-    c->set_device("/dev/testdev");
+    c->set_container("/dev/testdev");
     c->set_mount_options("-t jfs -o quota,rw");
   }
 
@@ -71,10 +71,8 @@ public:
   {
     sbuild::chroot_block_device *c = dynamic_cast<sbuild::chroot_block_device *>(chroot.get());
     CPPUNIT_ASSERT(c);
-    c->set_device("/dev/some/device");
-    CPPUNIT_ASSERT(c->get_device() == "/dev/some/device");
-    CPPUNIT_ASSERT(chroot->get_mount_device() ==
-		   "/dev/some/device");
+    c->set_container("/dev/some/device");
+    CPPUNIT_ASSERT(c->get_container() == "/dev/some/device");
   }
 
   void
@@ -86,9 +84,14 @@ public:
     CPPUNIT_ASSERT(c->get_mount_options() == "-o opt1,opt2");
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "block-device");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "block-device");
+    CPPUNIT_ASSERT(key_name == "device");
+    CPPUNIT_ASSERT(detail_name == "Device");
   }
 
   void test_setup_env()
@@ -97,15 +100,17 @@ public:
     expected.add("CHROOT_TYPE",           "block-device");
     expected.add("CHROOT_NAME",           "test-name");
     expected.add("CHROOT_DESCRIPTION",    "test-description");
+    expected.add("CHROOT_CONTAINER",      "");
+    expected.add("CHROOT_LOCATION",       "");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_PATH",           "/mnt/mount-location");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/testdev");
     expected.add("CHROOT_DEVICE",         "/dev/testdev");
+    expected.add("CHROOT_CONTAINER",      "/dev/testdev");
     expected.add("CHROOT_MOUNT_OPTIONS",  "-t jfs -o quota,rw");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "false");
+    expected.add("CHROOT_SESSION_CLONE",  "false");
     expected.add("CHROOT_SESSION_CREATE", "false");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<chroot_block_device>::test_setup_env(expected);
   }
diff --git a/test/sbuild-chroot-directory.cc b/test/sbuild-chroot-directory.cc
index d8c0857..2e9f088 100644
--- a/test/sbuild-chroot-directory.cc
+++ b/test/sbuild-chroot-directory.cc
@@ -19,6 +19,7 @@
 #include <config.h>
 
 #include <sbuild/sbuild-chroot-directory.h>
+#include <sbuild/sbuild-chroot-config.h>
 
 #include "test-helpers.h"
 #include "test-sbuild-chroot.h"
@@ -45,7 +46,7 @@ class test_chroot_directory : public test_chroot_base<chroot_directory>
 {
   CPPUNIT_TEST_SUITE(test_chroot_directory);
   CPPUNIT_TEST(test_location);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_setup_env2);
   CPPUNIT_TEST(test_session_flags);
@@ -62,7 +63,7 @@ public:
   {
     test_chroot_base<chroot_directory>::setUp();
     sbuild::chroot_directory *c = dynamic_cast<sbuild::chroot_directory *>(chroot.get());
-    c->set_location("/srv/chroot/example-chroot");
+    c->set_container("/srv/chroot/example-chroot");
   }
 
   void
@@ -73,17 +74,22 @@ public:
     chroot->set_run_setup_scripts(true);
     CPPUNIT_ASSERT(chroot->get_mount_location() == "/mnt/mount-location");
     chroot->set_run_setup_scripts(false);
-    c->set_location("/mnt/mount-location/example");
+    c->set_container("/mnt/mount-location/example");
     chroot->set_mount_location("");
     CPPUNIT_ASSERT(c->get_location() == "/mnt/mount-location/example");
-    CPPUNIT_ASSERT(chroot->get_location() == "/mnt/mount-location/example");
+    CPPUNIT_ASSERT(c->get_container() == "/mnt/mount-location/example");
     CPPUNIT_ASSERT(chroot->get_path() == "/mnt/mount-location/example");
     CPPUNIT_ASSERT(chroot->get_mount_location() == "");
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "directory");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "directory");
+    CPPUNIT_ASSERT(key_name == "location");
+    CPPUNIT_ASSERT(detail_name == "Location");
   }
 
   void test_setup_env()
@@ -93,13 +99,13 @@ public:
     expected.add("CHROOT_NAME",           "test-name");
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
+    expected.add("CHROOT_CONTAINER",      "/srv/chroot/example-chroot");
     expected.add("CHROOT_LOCATION",       "/srv/chroot/example-chroot");
     expected.add("CHROOT_PATH",           "/srv/chroot/example-chroot");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/device-to-mount");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "false");
+    expected.add("CHROOT_SESSION_CLONE",  "false");
     expected.add("CHROOT_SESSION_CREATE", "false");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<chroot_directory>::test_setup_env(expected);
   }
@@ -114,12 +120,12 @@ public:
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_LOCATION",       "/srv/chroot/example-chroot");
+    expected.add("CHROOT_CONTAINER",      "/srv/chroot/example-chroot");
     expected.add("CHROOT_PATH",           "/mnt/mount-location");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/device-to-mount");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "false");
+    expected.add("CHROOT_SESSION_CLONE",  "false");
     expected.add("CHROOT_SESSION_CREATE", "true");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<chroot_directory>::test_setup_env(expected);
   }
diff --git a/test/sbuild-chroot-file.cc b/test/sbuild-chroot-file.cc
index 50a5e01..93c8c4f 100644
--- a/test/sbuild-chroot-file.cc
+++ b/test/sbuild-chroot-file.cc
@@ -45,7 +45,7 @@ class test_chroot_file : public test_chroot_base<chroot_file>
 {
   CPPUNIT_TEST_SUITE(test_chroot_file);
   CPPUNIT_TEST(test_file);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_session_flags);
   CPPUNIT_TEST(test_print_details);
@@ -61,7 +61,7 @@ public:
   {
     test_chroot_base<chroot_file>::setUp();
     sbuild::chroot_file *c = dynamic_cast<sbuild::chroot_file *>(chroot.get());
-    c->set_file("/srv/chroot/example.tar.bz2");
+    c->set_container("/srv/chroot/example.tar.bz2");
   }
 
   void
@@ -69,13 +69,18 @@ public:
   {
     sbuild::chroot_file *c = dynamic_cast<sbuild::chroot_file *>(chroot.get());
     CPPUNIT_ASSERT(c);
-    c->set_file("/srv/chroot-images/unstable.tar.gz");
-    CPPUNIT_ASSERT(c->get_file() == "/srv/chroot-images/unstable.tar.gz");
+    c->set_container("/srv/chroot-images/unstable.tar.gz");
+    CPPUNIT_ASSERT(c->get_container() == "/srv/chroot-images/unstable.tar.gz");
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "file");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "file");
+    CPPUNIT_ASSERT(key_name == "file");
+    CPPUNIT_ASSERT(detail_name == "File");
   }
 
   void test_setup_env()
@@ -84,15 +89,15 @@ public:
     expected.add("CHROOT_TYPE",           "file");
     expected.add("CHROOT_NAME",           "test-name");
     expected.add("CHROOT_DESCRIPTION",    "test-description");
+    expected.add("CHROOT_CONTAINER",      "/srv/chroot/example.tar.bz2");
     expected.add("CHROOT_FILE",           "/srv/chroot/example.tar.bz2");
     expected.add("CHROOT_FILE_REPACK",    "false");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_PATH",           "/mnt/mount-location");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/device-to-mount");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "true");
+    expected.add("CHROOT_SESSION_CLONE",  "true");
     expected.add("CHROOT_SESSION_CREATE", "true");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<chroot_file>::test_setup_env(expected);
   }
diff --git a/test/sbuild-chroot-lvm-snapshot.cc b/test/sbuild-chroot-lvm-snapshot.cc
index 9c459a7..d269abe 100644
--- a/test/sbuild-chroot-lvm-snapshot.cc
+++ b/test/sbuild-chroot-lvm-snapshot.cc
@@ -47,7 +47,7 @@ class test_chroot_lvm_snapshot : public test_chroot_base<chroot_lvm_snapshot>
   CPPUNIT_TEST_SUITE(test_chroot_lvm_snapshot);
   CPPUNIT_TEST(test_snapshot_device);
   CPPUNIT_TEST(test_snapshot_options);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_session_flags);
   CPPUNIT_TEST(test_print_details);
@@ -63,7 +63,7 @@ public:
   {
     test_chroot_base<chroot_lvm_snapshot>::setUp();
     sbuild::chroot_lvm_snapshot *c = dynamic_cast<sbuild::chroot_lvm_snapshot *>(chroot.get());
-    c->set_device("/dev/testdev");
+    c->set_container("/dev/testdev");
     c->set_mount_options("-t jfs -o quota,rw");
     c->set_snapshot_device("/dev/snaptestdev");
     c->set_snapshot_options("--size 1G");
@@ -76,8 +76,6 @@ public:
     CPPUNIT_ASSERT(c);
     c->set_snapshot_device("/dev/some/snapshot/device");
     CPPUNIT_ASSERT(c->get_snapshot_device() == "/dev/some/snapshot/device");
-    CPPUNIT_ASSERT(chroot->get_mount_device() ==
-		   "/dev/some/snapshot/device");
   }
 
   void
@@ -89,9 +87,14 @@ public:
     CPPUNIT_ASSERT(c->get_snapshot_options() == "-o opt1,opt2");
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "lvm-snapshot");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "lvm-snapshot");
+    CPPUNIT_ASSERT(key_name == "device");
+    CPPUNIT_ASSERT(detail_name == "LVM Snapshot Device");
   }
 
   void test_setup_env()
@@ -105,16 +108,16 @@ public:
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_PATH",           "/mnt/mount-location");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/snaptestdev");
     expected.add("CHROOT_DEVICE",         "/dev/testdev");
+    expected.add("CHROOT_CONTAINER",      "/dev/testdev");
     expected.add("CHROOT_MOUNT_OPTIONS",  "-t jfs -o quota,rw");
     expected.add("CHROOT_LVM_SNAPSHOT_NAME", sbuild::basename(c->get_snapshot_device()));
     expected.add("CHROOT_LVM_SNAPSHOT_DEVICE", "/dev/snaptestdev");
     expected.add("CHROOT_LVM_SNAPSHOT_OPTIONS", "--size 1G");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "true");
+    expected.add("CHROOT_SESSION_CLONE",  "true");
     expected.add("CHROOT_SESSION_CREATE", "true");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<chroot_lvm_snapshot>::test_setup_env(expected);
   }
diff --git a/test/sbuild-chroot-plain.cc b/test/sbuild-chroot-plain.cc
index a423fd6..8b2572d 100644
--- a/test/sbuild-chroot-plain.cc
+++ b/test/sbuild-chroot-plain.cc
@@ -45,7 +45,7 @@ class test_chroot_plain : public test_chroot_base<chroot_plain>
 {
   CPPUNIT_TEST_SUITE(test_chroot_plain);
   CPPUNIT_TEST(test_location);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_print_details);
   CPPUNIT_TEST(test_print_config);
@@ -61,7 +61,7 @@ public:
     test_chroot_base<chroot_plain>::setUp();
     sbuild::chroot_plain *c = dynamic_cast<sbuild::chroot_plain *>(chroot.get());
     c->set_mount_location("");
-    c->set_location("/srv/chroot/example-chroot");
+    c->set_container("/srv/chroot/example-chroot");
   }
 
   void
@@ -69,16 +69,20 @@ public:
   {
     sbuild::chroot_plain *c = dynamic_cast<sbuild::chroot_plain *>(chroot.get());
     CPPUNIT_ASSERT(c);
-    c->set_location("/mnt/mount-location/example");
-    CPPUNIT_ASSERT(c->get_location() == "/mnt/mount-location/example");
-    CPPUNIT_ASSERT(chroot->get_location() == "/mnt/mount-location/example");
-    CPPUNIT_ASSERT(chroot->get_path() == "/mnt/mount-location/example");
+    c->set_container("/mnt/mount-directory/example");
+    CPPUNIT_ASSERT(c->get_container() == "/mnt/mount-directory/example");
+    CPPUNIT_ASSERT(c->get_path() == "/mnt/mount-directory/example");
     CPPUNIT_ASSERT(chroot->get_mount_location() == "");
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "plain");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "plain");
+    CPPUNIT_ASSERT(key_name == "location");
+    CPPUNIT_ASSERT(detail_name == "Location");
   }
 
   void test_setup_env()
@@ -88,8 +92,8 @@ public:
     expected.add("CHROOT_NAME",           "test-name");
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     expected.add("CHROOT_LOCATION",       "/srv/chroot/example-chroot");
+    expected.add("CHROOT_CONTAINER",      "/srv/chroot/example-chroot");
     expected.add("CHROOT_PATH",           "/srv/chroot/example-chroot");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/device-to-mount");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
     expected.add("CHROOT_SESSION_CLONE", "false");
     expected.add("CHROOT_SESSION_CREATE", "false");
diff --git a/test/sbuild-chroot.cc b/test/sbuild-chroot.cc
index 51e6998..1c5efba 100644
--- a/test/sbuild-chroot.cc
+++ b/test/sbuild-chroot.cc
@@ -44,9 +44,18 @@ public:
   clone () const
   { return ptr(new basic_chroot(*this)); }
 
-  virtual std::string const&
-  get_chroot_type () const
-  { static const std::string type("test"); return type; }
+  virtual void
+  get_chroot_strings (std::string *type,
+		      std::string *key_name,
+		      std::string *detail_name) const
+  {
+    if (type != NULL)
+      *type = "test-type";
+    if (key_name != NULL)
+      *key_name = "test-key";
+    if (detail_name != NULL)
+      *detail_name = "Test Detail";
+  }
 
   virtual void
   setup_env (sbuild::environment& env)
@@ -73,7 +82,6 @@ class test_chroot : public test_chroot_base<basic_chroot>
   CPPUNIT_TEST_SUITE(test_chroot);
   CPPUNIT_TEST(test_name);
   CPPUNIT_TEST(test_description);
-  CPPUNIT_TEST(test_mount_device);
   CPPUNIT_TEST(test_mount_location);
   CPPUNIT_TEST(test_priority);
   CPPUNIT_TEST(test_groups);
@@ -83,7 +91,7 @@ class test_chroot : public test_chroot_base<basic_chroot>
   CPPUNIT_TEST(test_active);
   CPPUNIT_TEST(test_run_setup_scripts);
   CPPUNIT_TEST(test_run_exec_scripts);
-  CPPUNIT_TEST(test_chroot_type);
+  CPPUNIT_TEST(test_chroot_strings);
   CPPUNIT_TEST(test_setup_env);
   CPPUNIT_TEST(test_session_flags);
   CPPUNIT_TEST(test_print_details);
@@ -114,13 +122,6 @@ public:
 		   "/mnt/mount-location/example");
   }
 
-  void test_mount_device()
-  {
-    chroot->set_mount_device("/dev/device-to-mount/example");
-    CPPUNIT_ASSERT(chroot->get_mount_device() ==
-		   "/dev/device-to-mount/example");
-  }
-
   void test_priority()
   {
     chroot->set_priority(6);
@@ -202,24 +203,28 @@ public:
     CPPUNIT_ASSERT(chroot->get_run_exec_scripts() == false);
   }
 
-  void test_chroot_type()
+  void test_chroot_strings()
   {
-    CPPUNIT_ASSERT(chroot->get_chroot_type() == "test");
+    std::string type, key_name, detail_name;
+    chroot->get_chroot_strings(&type, &key_name, &detail_name);
+    
+    CPPUNIT_ASSERT(type == "test-type");
+    CPPUNIT_ASSERT(key_name == "test-key");
+    CPPUNIT_ASSERT(detail_name == "Test Detail");
   }
 
   void test_setup_env()
   {
     sbuild::environment expected;
-    expected.add("CHROOT_TYPE",           "test");
+    expected.add("CHROOT_TYPE",           "test-type");
     expected.add("CHROOT_NAME",           "test-name");
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_PATH",           "/mnt/mount-location");
-    expected.add("CHROOT_MOUNT_DEVICE",   "/dev/device-to-mount");
     expected.add("CHROOT_SCRIPT_CONFIG",  sbuild::normalname(std::string(PACKAGE_SYSCONF_DIR) + "/script-defaults"));
-    expected.add("CHROOT_SESSION_CLONE", "false");
+    expected.add("CHROOT_SESSION_CLONE",  "false");
     expected.add("CHROOT_SESSION_CREATE", "true");
-    expected.add("CHROOT_SESSION_PURGE", "false");
+    expected.add("CHROOT_SESSION_PURGE",  "false");
 
     test_chroot_base<basic_chroot>::test_setup_env(expected);
   }
diff --git a/test/test-sbuild-chroot.h b/test/test-sbuild-chroot.h
index e627ffa..e7d0c88 100644
--- a/test/test-sbuild-chroot.h
+++ b/test/test-sbuild-chroot.h
@@ -50,7 +50,6 @@ public:
     chroot->set_name("test-name");
     chroot->set_description("test-description");
     chroot->set_mount_location("/mnt/mount-location");
-    chroot->set_mount_device("/dev/device-to-mount");
   }
 
   void tearDown()
-- 
1.6.2.1




More information about the Buildd-tools-devel mailing list