summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-04-30 23:04:27 +0100
committerRoger Leigh <rleigh@debian.org>2013-05-04 17:17:17 +0100
commitda63989e1cb406e88a0e3f55ecbcc57e35297a0a (patch)
treecdd368a2bd6fc5956d6b5148452af6d1bd6e5f3c /lib
parent1e8ae2956633ef9e00a2420a708c1692571fc9ec (diff)
downloadschroot-da63989e1cb406e88a0e3f55ecbcc57e35297a0a.tar.gz
sbuild::chroot: Remove unused virtual methods
These methods are now completely delegating to chroot facets.
Diffstat (limited to 'lib')
-rw-r--r--lib/sbuild/chroot/chroot.cc294
-rw-r--r--lib/sbuild/chroot/chroot.h77
2 files changed, 130 insertions, 241 deletions
diff --git a/lib/sbuild/chroot/chroot.cc b/lib/sbuild/chroot/chroot.cc
index 2582cf16..d16507fd 100644
--- a/lib/sbuild/chroot/chroot.cc
+++ b/lib/sbuild/chroot/chroot.cc
@@ -522,35 +522,28 @@ namespace sbuild
void
chroot::setup_env (environment& env) const
{
- setup_env(*this, env);
-
- for (const auto& facet : facets)
- facet->setup_env(*this, env);
- }
-
- void
- chroot::setup_env (chroot const& chroot,
- environment& env) const
- {
- env.add("CHROOT_TYPE", chroot.get_chroot_type());
- env.add("CHROOT_NAME", chroot.get_name());
- env.add("SESSION_ID", chroot.get_name());
- env.add("CHROOT_DESCRIPTION", chroot.get_description());
- env.add("CHROOT_MOUNT_LOCATION", chroot.get_mount_location());
- env.add("CHROOT_PATH", chroot.get_path());
- if (!chroot.get_script_config().empty())
- env.add("CHROOT_SCRIPT_CONFIG", normalname(std::string(SCHROOT_SYSCONF_DIR) + '/' + chroot.get_script_config()));
- if (!chroot.get_profile().empty())
+ env.add("CHROOT_TYPE", get_chroot_type());
+ env.add("CHROOT_NAME", get_name());
+ env.add("SESSION_ID", get_name());
+ env.add("CHROOT_DESCRIPTION", get_description());
+ env.add("CHROOT_MOUNT_LOCATION", get_mount_location());
+ env.add("CHROOT_PATH", get_path());
+ if (!get_script_config().empty())
+ env.add("CHROOT_SCRIPT_CONFIG", normalname(std::string(SCHROOT_SYSCONF_DIR) + '/' + get_script_config()));
+ if (!get_profile().empty())
{
- env.add("CHROOT_PROFILE", chroot.get_profile());
- env.add("CHROOT_PROFILE_DIR", normalname(std::string(SCHROOT_SYSCONF_DIR) + '/' + chroot.get_profile()));
+ env.add("CHROOT_PROFILE", get_profile());
+ env.add("CHROOT_PROFILE_DIR", normalname(std::string(SCHROOT_SYSCONF_DIR) + '/' + get_profile()));
}
env.add("CHROOT_SESSION_CREATE",
- static_cast<bool>(chroot.get_session_flags() & SESSION_CREATE));
+ static_cast<bool>(get_session_flags() & SESSION_CREATE));
env.add("CHROOT_SESSION_CLONE",
- static_cast<bool>(chroot.get_session_flags() & SESSION_CLONE));
+ static_cast<bool>(get_session_flags() & SESSION_CLONE));
env.add("CHROOT_SESSION_PURGE",
- static_cast<bool>(chroot.get_session_flags() & SESSION_PURGE));
+ static_cast<bool>(get_session_flags() & SESSION_PURGE));
+
+ for (const auto& facet : facets)
+ facet->setup_env(*this, env);
}
void
@@ -577,7 +570,7 @@ namespace sbuild
chroot::session_flags
chroot::get_session_flags () const
{
- session_flags flags = get_session_flags(*this);
+ session_flags flags = SESSION_NOFLAGS;
for (const auto& facet : facets)
flags = flags | facet->get_session_flags(*this);
@@ -585,57 +578,44 @@ namespace sbuild
return flags;
}
- chroot::session_flags
- chroot::get_session_flags (chroot const& chroot) const
- {
- return SESSION_NOFLAGS;
- }
-
void
chroot::get_details (format_detail& detail) const
{
- get_details(*this, detail);
-
- for (const auto& facet : facets)
- facet->get_details(*this, detail);
- }
-
- void
- chroot::get_details (chroot const& chroot,
- format_detail& detail) const
- {
- detail.add(_("Name"), chroot.get_name());
+ detail.add(_("Name"), get_name());
detail
- .add(_("Description"), chroot.get_description())
- .add(_("Type"), chroot.get_chroot_type())
- .add(_("Message Verbosity"), chroot.get_verbosity_string())
- .add(_("Users"), chroot.get_users())
- .add(_("Groups"), chroot.get_groups())
- .add(_("Root Users"), chroot.get_root_users())
- .add(_("Root Groups"), chroot.get_root_groups())
- .add(_("Aliases"), chroot.get_aliases())
- .add(_("Preserve Environment"), chroot.get_preserve_environment())
- .add(_("Default Shell"), chroot.get_default_shell())
- .add(_("Environment Filter"), chroot.get_environment_filter())
- .add(_("Run Setup Scripts"), chroot.get_run_setup_scripts())
- .add(_("Configuration Profile"), chroot.get_profile())
- .add(_("Script Configuration"), chroot.get_script_config())
+ .add(_("Description"), get_description())
+ .add(_("Type"), get_chroot_type())
+ .add(_("Message Verbosity"), get_verbosity_string())
+ .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(_("Preserve Environment"), get_preserve_environment())
+ .add(_("Default Shell"), get_default_shell())
+ .add(_("Environment Filter"), get_environment_filter())
+ .add(_("Run Setup Scripts"), get_run_setup_scripts())
+ .add(_("Configuration Profile"), get_profile())
+ .add(_("Script Configuration"), get_script_config())
.add(_("Session Managed"),
- static_cast<bool>(chroot.get_session_flags() & chroot::SESSION_CREATE))
+ static_cast<bool>(get_session_flags() & chroot::SESSION_CREATE))
.add(_("Session Cloned"),
- static_cast<bool>(chroot.get_session_flags() & chroot::SESSION_CLONE))
+ static_cast<bool>(get_session_flags() & chroot::SESSION_CLONE))
.add(_("Session Purged"),
- static_cast<bool>(chroot.get_session_flags() & chroot::SESSION_PURGE));
+ static_cast<bool>(get_session_flags() & chroot::SESSION_PURGE));
- if (!chroot.get_command_prefix().empty())
- detail.add(_("Command Prefix"), chroot.get_command_prefix());
+ if (!get_command_prefix().empty())
+ detail.add(_("Command Prefix"), get_command_prefix());
/* Non user-settable properties are listed last. */
- if (!chroot.get_mount_location().empty())
- detail.add(_("Mount Location"), chroot.get_mount_location());
- if (!chroot.get_path().empty())
- detail.add(_("Path"), chroot.get_path());
+ if (!get_mount_location().empty())
+ detail.add(_("Mount Location"), get_mount_location());
+ if (!get_path().empty())
+ detail.add(_("Path"), get_path());
+
+ for (const auto& facet : facets)
+ facet->get_details(*this, detail);
}
void
@@ -660,17 +640,6 @@ namespace sbuild
{
string_list used_keys;
- get_used_keys(used_keys);
-
- for (const auto& facet : facets)
- facet->get_used_keys(used_keys);
-
- return used_keys;
- }
-
- void
- chroot::get_used_keys (string_list& used_keys) const
- {
// Keys which are used elsewhere, but should be counted as "used".
used_keys.push_back("type");
@@ -694,222 +663,213 @@ namespace sbuild
used_keys.push_back("message-verbosity");
used_keys.push_back("preserve-environment");
used_keys.push_back("shell");
- }
-
- void
- chroot::get_keyfile (keyfile& keyfile) const
- {
- get_keyfile(*this, keyfile);
for (const auto& facet : facets)
- facet->get_keyfile(*this, keyfile);
+ facet->get_used_keys(used_keys);
+
+ return used_keys;
}
void
- chroot::get_keyfile (chroot const& chroot,
- keyfile& keyfile) const
+ chroot::get_keyfile (keyfile& keyfile) const
{
- keyfile.remove_group(chroot.get_name());
+ keyfile.remove_group(get_name());
bool session = static_cast<bool>(get_facet<facet::session>());
if (session)
- keyfile::set_object_value(chroot, &chroot::get_name,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_name,
+ keyfile, get_name(),
"name");
- keyfile::set_object_value(chroot, &chroot::get_chroot_type,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_chroot_type,
+ keyfile, get_name(),
"type");
- keyfile::set_object_value(chroot, &chroot::get_profile,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_profile,
+ keyfile, get_name(),
"profile");
if (!get_script_config().empty())
- keyfile::set_object_value(chroot, &chroot::get_script_config,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_script_config,
+ keyfile, get_name(),
"script-config");
- keyfile::set_object_list_value(chroot, &chroot::get_aliases,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_aliases,
+ keyfile, get_name(),
"aliases");
- keyfile::set_object_value(chroot, &chroot::get_environment_filter,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_environment_filter,
+ keyfile, get_name(),
"environment-filter");
- keyfile::set_object_value(chroot, &chroot::get_description,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_description,
+ keyfile, get_name(),
"description");
- keyfile::set_object_list_value(chroot, &chroot::get_users,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_users,
+ keyfile, get_name(),
"users");
- keyfile::set_object_list_value(chroot, &chroot::get_groups,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_groups,
+ keyfile, get_name(),
"groups");
- keyfile::set_object_list_value(chroot, &chroot::get_root_users,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_root_users,
+ keyfile, get_name(),
"root-users");
- keyfile::set_object_list_value(chroot, &chroot::get_root_groups,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_root_groups,
+ keyfile, get_name(),
"root-groups");
if (session)
- keyfile::set_object_value(chroot, &chroot::get_mount_location,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_mount_location,
+ keyfile, get_name(),
"mount-location");
- keyfile::set_object_list_value(chroot, &chroot::get_command_prefix,
- keyfile, chroot.get_name(),
+ keyfile::set_object_list_value(*this, &chroot::get_command_prefix,
+ keyfile, get_name(),
"command-prefix");
- keyfile::set_object_value(chroot, &chroot::get_verbosity_string,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_verbosity_string,
+ keyfile, get_name(),
"message-verbosity");
- keyfile::set_object_value(chroot, &chroot::get_preserve_environment,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_preserve_environment,
+ keyfile, get_name(),
"preserve-environment");
- keyfile::set_object_value(chroot, &chroot::get_default_shell,
- keyfile, chroot.get_name(),
+ keyfile::set_object_value(*this, &chroot::get_default_shell,
+ keyfile, get_name(),
"shell");
- }
-
- void
- chroot::set_keyfile (keyfile const& keyfile)
- {
- set_keyfile(*this, keyfile);
for (const auto& facet : facets)
- facet->set_keyfile(*this, keyfile);
+ facet->get_keyfile(*this, keyfile);
}
void
- chroot::set_keyfile (chroot& chroot,
- keyfile const& keyfile)
+ chroot::set_keyfile (keyfile const& keyfile)
{
// Null method for obsolete keys.
void (chroot::* nullmethod)(bool) = 0;
bool session = static_cast<bool>(get_facet<facet::session>());
- keyfile::get_object_value(chroot, nullmethod,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, nullmethod,
+ keyfile, get_name(),
"active",
keyfile::PRIORITY_OBSOLETE);
// Setup scripts are run depending on the chroot type in use, and is
// no longer user-configurable. They need to run for all types
// except "plain".
- keyfile::get_object_value(chroot, nullmethod,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, nullmethod,
+ keyfile, get_name(),
"run-setup-scripts",
keyfile::PRIORITY_OBSOLETE);
// Exec scripts have been removed, so these two calls do nothing
// except to warn the user that the options are no longer used.
- keyfile::get_object_value(chroot, nullmethod,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, nullmethod,
+ keyfile, get_name(),
"run-session-scripts",
keyfile::PRIORITY_OBSOLETE);
- keyfile::get_object_value(chroot, nullmethod,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, nullmethod,
+ keyfile, get_name(),
"run-exec-scripts",
keyfile::PRIORITY_OBSOLETE);
- keyfile::get_object_value(chroot, &chroot::set_profile,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_profile,
+ keyfile, get_name(),
"profile",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_script_config,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_script_config,
+ keyfile, get_name(),
"script-config",
session ?
keyfile::PRIORITY_OPTIONAL :
keyfile::PRIORITY_DEPRECATED);
- keyfile::get_object_value(chroot, nullmethod,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, nullmethod,
+ keyfile, get_name(),
"priority",
session ?
keyfile::PRIORITY_OPTIONAL :
keyfile::PRIORITY_OBSOLETE);
- keyfile::get_object_list_value(chroot, &chroot::set_aliases,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_aliases,
+ keyfile, get_name(),
"aliases",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_environment_filter,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_environment_filter,
+ keyfile, get_name(),
"environment-filter",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_description,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_description,
+ keyfile, get_name(),
"description",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_list_value(chroot, &chroot::set_users,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_users,
+ keyfile, get_name(),
"users",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_list_value(chroot, &chroot::set_groups,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_groups,
+ keyfile, get_name(),
"groups",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_list_value(chroot, &chroot::set_root_users,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_root_users,
+ keyfile, get_name(),
"root-users",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_list_value(chroot, &chroot::set_root_groups,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_root_groups,
+ keyfile, get_name(),
"root-groups",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_mount_location,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_mount_location,
+ keyfile, get_name(),
"mount-location",
session ?
keyfile::PRIORITY_REQUIRED :
keyfile::PRIORITY_DISALLOWED);
- keyfile::get_object_value(chroot, &chroot::set_name,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_name,
+ keyfile, get_name(),
"name",
session ?
keyfile::PRIORITY_OPTIONAL :
keyfile::PRIORITY_DISALLOWED);
- keyfile::get_object_list_value(chroot, &chroot::set_command_prefix,
- keyfile, chroot.get_name(),
+ keyfile::get_object_list_value(*this, &chroot::set_command_prefix,
+ keyfile, get_name(),
"command-prefix",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_verbosity,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_verbosity,
+ keyfile, get_name(),
"message-verbosity",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_preserve_environment,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_preserve_environment,
+ keyfile, get_name(),
"preserve-environment",
keyfile::PRIORITY_OPTIONAL);
- keyfile::get_object_value(chroot, &chroot::set_default_shell,
- keyfile, chroot.get_name(),
+ keyfile::get_object_value(*this, &chroot::set_default_shell,
+ keyfile, get_name(),
"shell",
keyfile::PRIORITY_OPTIONAL);
+
+ for (const auto& facet : facets)
+ facet->set_keyfile(*this, keyfile);
}
}
diff --git a/lib/sbuild/chroot/chroot.h b/lib/sbuild/chroot/chroot.h
index e8c20951..ad1b9d7b 100644
--- a/lib/sbuild/chroot/chroot.h
+++ b/lib/sbuild/chroot/chroot.h
@@ -226,7 +226,7 @@ namespace sbuild
* @returns the path.
* @todo Remove once migrated to storage facet, or delegate.
*/
- virtual std::string
+ std::string
get_path () const;
/**
@@ -501,7 +501,7 @@ namespace sbuild
* @returns the chroot type.
* @todo Delegate to storage facet name.
*/
- virtual std::string const&
+ std::string const&
get_chroot_type () const;
/**
@@ -514,18 +514,6 @@ namespace sbuild
setup_env (environment& env) const;
/**
- * Set environment. Set the environment that the setup scripts
- * will see during execution.
- *
- * @param chroot the chroot to use.
- * @param env the environment to set.
- * @todo Delegate entirely to facets.
- */
- virtual void
- setup_env (chroot const& chroot,
- environment& env) const;
-
- /**
* Lock a chroot during setup. The locking technique (if any) may
* vary depending upon the chroot type and setup stage. For
* example, during creation of an LVM snapshot a block device
@@ -572,7 +560,7 @@ namespace sbuild
* success, nonzero for failure).
* @todo Delegate to storate or other facet?
*/
- virtual void
+ void
setup_lock(setup_type type,
bool lock,
int status);
@@ -675,17 +663,6 @@ namespace sbuild
get_session_flags () const;
/**
- * Get the session flags of the chroot. These determine how the
- * Session controlling the chroot will operate.
- *
- * @param chroot the chroot to use.
- * @returns the session flags.
- * @todo Delegate entirely to facets.
- */
- virtual chroot::session_flags
- get_session_flags (chroot const& chroot) const;
-
- /**
* Print detailed information about the chroot to a stream. The
* information is printed in plain text with one line per
* property.
@@ -743,17 +720,6 @@ namespace sbuild
get_details (format_detail& detail) const;
/**
- * Get detailed information about the chroot for output.
- *
- * @param chroot the chroot to use.
- * @param detail the details to output to.
- * @todo Delegate entirely to facets
- */
- virtual void
- get_details (chroot const& chroot,
- format_detail& detail) const;
-
- /**
* Print detailed information about the chroot to a stream. The
* information is printed in plain text with one line per
* property.
@@ -773,20 +739,6 @@ namespace sbuild
void
get_keyfile (keyfile& keyfile) const;
- protected:
- /**
- * Copy the chroot properties into a keyfile. The keyfile group
- * with the name of the chroot will be set; if it already exists,
- * it will be removed before setting it.
- *
- * @param chroot the chroot to use.
- * @param keyfile the keyfile to use.
- * @todo Delegate to facets
- */
- virtual void
- get_keyfile (chroot const& chroot,
- keyfile& keyfile) const;
-
public:
/**
* Set the chroot properties from a keyfile. The chroot name must
@@ -806,29 +758,6 @@ namespace sbuild
string_list
get_used_keys () const;
- protected:
- /**
- * Get keys used during keyfile parsing. If keys are missing or
- * present when not expected, this may be used for diagnostic
- * purposes.
- */
- virtual void
- get_used_keys (string_list& used_keys) const;
-
- /**
- * Set the chroot properties from a keyfile. The chroot name must
- * have previously been set, so that the correct keyfile group may
- * be determined.
- *
- * @param chroot the chroot to use.
- * @param keyfile the keyfile to get the properties from.
- * @param used_keys a list of the keys used will be set.
- * @todo Delegate entirely to facets
- */
- virtual void
- set_keyfile (chroot& chroot,
- keyfile const& keyfile);
-
private:
/// Chroot name.
std::string name;