[buildd-tools-devel] [PATCH 1/3] Drop mount_device member

Jan-Marek Glogowski glogow at fbihome.de
Sun Mar 29 19:38:00 UTC 2009


The current usage can be handled much easier in the 10mount setup
script.
---
 bin/schroot/exec/00check             |    1 -
 bin/schroot/setup/00check            |    1 -
 bin/schroot/setup/10mount            |    3 +++
 sbuild/sbuild-chroot-block-device.cc |    6 ------
 sbuild/sbuild-chroot-block-device.h  |    3 ---
 sbuild/sbuild-chroot-loopback.cc     |    6 ------
 sbuild/sbuild-chroot-loopback.h      |    2 --
 sbuild/sbuild-chroot-lvm-snapshot.cc |    6 ------
 sbuild/sbuild-chroot-lvm-snapshot.h  |    3 ---
 sbuild/sbuild-chroot-mountable.h     |    3 ---
 sbuild/sbuild-chroot.cc              |   31 +------------------------------
 sbuild/sbuild-chroot.h               |   21 +--------------------
 test/sbuild-chroot-block-device.cc   |    7 ++-----
 test/sbuild-chroot-directory.cc      |   10 ++++------
 test/sbuild-chroot-file.cc           |    5 ++---
 test/sbuild-chroot-lvm-snapshot.cc   |    7 ++-----
 test/sbuild-chroot-plain.cc          |    1 -
 test/sbuild-chroot.cc                |   13 ++-----------
 test/test-sbuild-chroot.h            |    1 -
 19 files changed, 17 insertions(+), 113 deletions(-)

diff --git a/bin/schroot/exec/00check b/bin/schroot/exec/00check
index a5e490c..0caa1be 100755
--- a/bin/schroot/exec/00check
+++ b/bin/schroot/exec/00check
@@ -51,7 +51,6 @@ 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"
 	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..4188c74 100755
--- a/bin/schroot/setup/00check
+++ b/bin/schroot/setup/00check
@@ -51,7 +51,6 @@ 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"
 	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..d06e170 100644
--- a/sbuild/sbuild-chroot-block-device.cc
+++ b/sbuild/sbuild-chroot-block-device.cc
@@ -64,12 +64,6 @@ chroot_block_device::set_device (std::string const& 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");
diff --git a/sbuild/sbuild-chroot-block-device.h b/sbuild/sbuild-chroot-block-device.h
index abbddca..4ae8aff 100644
--- a/sbuild/sbuild-chroot-block-device.h
+++ b/sbuild/sbuild-chroot-block-device.h
@@ -65,9 +65,6 @@ namespace sbuild
     void
     set_device (std::string const& device);
 
-    virtual std::string const&
-    get_mount_device () const;
-
     std::string const&
     get_chroot_type () const;
 
diff --git a/sbuild/sbuild-chroot-loopback.cc b/sbuild/sbuild-chroot-loopback.cc
index c679107..dc1d0df 100644
--- a/sbuild/sbuild-chroot-loopback.cc
+++ b/sbuild/sbuild-chroot-loopback.cc
@@ -64,12 +64,6 @@ chroot_loopback::set_file (std::string const& 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");
diff --git a/sbuild/sbuild-chroot-loopback.h b/sbuild/sbuild-chroot-loopback.h
index 9f46080..e4322db 100644
--- a/sbuild/sbuild-chroot-loopback.h
+++ b/sbuild/sbuild-chroot-loopback.h
@@ -62,8 +62,6 @@ namespace sbuild
     void
     set_file (std::string const& file);
 
-    virtual std::string const&
-    get_mount_device () const;
 
     std::string const&
     get_chroot_type () const;
diff --git a/sbuild/sbuild-chroot-lvm-snapshot.cc b/sbuild/sbuild-chroot-lvm-snapshot.cc
index a49f5f7..552d128 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;
diff --git a/sbuild/sbuild-chroot-lvm-snapshot.h b/sbuild/sbuild-chroot-lvm-snapshot.h
index d3bf9b2..1e9984a 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.
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.cc b/sbuild/sbuild-chroot.cc
index 05486a7..c22bfcd 100644
--- a/sbuild/sbuild-chroot.cc
+++ b/sbuild/sbuild-chroot.cc
@@ -93,7 +93,6 @@ sbuild::chroot::chroot ():
   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(),
   location(),
-  mount_device(),
   active(false),
   original(true),
   run_setup_scripts(false),
@@ -199,20 +198,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
 {
@@ -390,7 +375,6 @@ sbuild::chroot::setup_env (environment& env)
   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));
@@ -500,9 +484,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
@@ -564,10 +545,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 +552,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 +643,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);
diff --git a/sbuild/sbuild-chroot.h b/sbuild/sbuild-chroot.h
index 60af446..73fa685 100644
--- a/sbuild/sbuild-chroot.h
+++ b/sbuild/sbuild-chroot.h
@@ -196,22 +196,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 +353,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);
@@ -591,7 +575,6 @@ namespace sbuild
       return keyfile;
     }
 
-
   protected:
     /**
      * Get detailed information about the chroot for output.
@@ -656,8 +639,6 @@ namespace sbuild
     std::string   mount_location;
     /// 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/test/sbuild-chroot-block-device.cc b/test/sbuild-chroot-block-device.cc
index 02fc432..bb8e721 100644
--- a/test/sbuild-chroot-block-device.cc
+++ b/test/sbuild-chroot-block-device.cc
@@ -73,8 +73,6 @@ public:
     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");
   }
 
   void
@@ -99,13 +97,12 @@ 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/testdev");
     expected.add("CHROOT_DEVICE",         "/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..9bbc2cd 100644
--- a/test/sbuild-chroot-directory.cc
+++ b/test/sbuild-chroot-directory.cc
@@ -95,11 +95,10 @@ public:
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     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);
   }
@@ -115,11 +114,10 @@ public:
     expected.add("CHROOT_MOUNT_LOCATION", "/mnt/mount-location");
     expected.add("CHROOT_LOCATION",       "/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..d153f92 100644
--- a/test/sbuild-chroot-file.cc
+++ b/test/sbuild-chroot-file.cc
@@ -88,11 +88,10 @@ public:
     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..7da7bdb 100644
--- a/test/sbuild-chroot-lvm-snapshot.cc
+++ b/test/sbuild-chroot-lvm-snapshot.cc
@@ -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
@@ -105,16 +103,15 @@ 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_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..ca2a572 100644
--- a/test/sbuild-chroot-plain.cc
+++ b/test/sbuild-chroot-plain.cc
@@ -89,7 +89,6 @@ public:
     expected.add("CHROOT_DESCRIPTION",    "test-description");
     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_CREATE", "false");
diff --git a/test/sbuild-chroot.cc b/test/sbuild-chroot.cc
index 51e6998..dd8d709 100644
--- a/test/sbuild-chroot.cc
+++ b/test/sbuild-chroot.cc
@@ -73,7 +73,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);
@@ -114,13 +113,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);
@@ -215,11 +207,10 @@ 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/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