summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--sbuild/sbuild-chroot.cc50
-rw-r--r--sbuild/sbuild-chroot.h12
3 files changed, 47 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index b1525206..fb9427da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2006-07-13 Roger Leigh <rleigh@debian.org>
+ * sbuild/sbuild-chroot.h: API documentation corrections.
+
+ * sbuild/sbuild-chroot.cc
+ (set_persona): New overloaded function to set the personality by
+ name.
+ (set_keyfile): Set the personality using
+ keyfile::get_object_value.
+
+2006-07-13 Roger Leigh <rleigh@debian.org>
+
* All sources use error<> in place of custom_error_base<>, and
std::runtime_error in place of runtime_error.
diff --git a/sbuild/sbuild-chroot.cc b/sbuild/sbuild-chroot.cc
index a2adfbd8..cc8c6933 100644
--- a/sbuild/sbuild-chroot.cc
+++ b/sbuild/sbuild-chroot.cc
@@ -356,6 +356,28 @@ sbuild::chroot::set_persona (personality const& persona)
}
void
+sbuild::chroot::set_persona (std::string const& persona)
+{
+ personality new_persona (persona);
+
+ if (new_persona.get_name() == "undefined" &&
+ new_persona.get_name() != persona)
+ {
+ std::ostringstream plist;
+ personality::print_personalities(plist);
+
+ // TODO: include line numbers by throwing an exception.
+ log_warning()
+ << format(_("%1% chroot: personality \"%2%\" is unknown.\n"))
+ % get_name() % persona;
+ log_info()
+ << format(_("Valid personalities: %1%\n")) % plist.str();
+ }
+
+ set_persona(new_persona);
+}
+
+void
sbuild::chroot::setup_env (environment& env)
{
env.add("CHROOT_TYPE", get_chroot_type());
@@ -597,30 +619,12 @@ sbuild::chroot::set_keyfile (keyfile const& keyfile)
keyfile, get_name(), "command-prefix",
keyfile::PRIORITY_OPTIONAL);
- // TODO: Add stream operators to persona.
- std::string persona_name;
- if (keyfile.get_value(get_name(), "personality",
- keyfile::PRIORITY_OPTIONAL,
- persona_name))
- {
- personality persona (persona_name);
-
- if (persona.get_name() == "undefined" &&
- persona.get_name() != persona_name)
- {
- std::ostringstream plist;
- personality::print_personalities(plist);
-
- // TODO: include line numbers.
- log_warning()
- << format(_("%1% chroot: personality \"%2%\" is unknown.\n"))
- % get_name() % persona_name;
- log_info()
- << format(_("Valid personalities: %1%\n")) % plist.str();
- }
+ void (chroot::* pptr)(std::string const& persona);
+ pptr = &chroot::set_persona;
+ keyfile::get_object_value(*this, pptr,
+ keyfile, get_name(), "personality",
+ keyfile::PRIORITY_OPTIONAL);
- set_persona(persona);
- }
}
/*
diff --git a/sbuild/sbuild-chroot.h b/sbuild/sbuild-chroot.h
index 24f95662..d09d6ce3 100644
--- a/sbuild/sbuild-chroot.h
+++ b/sbuild/sbuild-chroot.h
@@ -408,7 +408,7 @@ namespace sbuild
/**
* Get the process execution domain for the chroot.
*
- * @returns the command prefix.
+ * @returns the personality.
*/
personality const&
get_persona () const;
@@ -416,12 +416,20 @@ namespace sbuild
/**
* Set the process execution domain for the chroot.
*
- * @param persona the command prefix.
+ * @param persona the personality.
*/
void
set_persona (personality const& persona);
/**
+ * Set the process execution domain for the chroot.
+ *
+ * @param persona the personality.
+ */
+ void
+ set_persona (std::string const& persona);
+
+ /**
* Get the type of the chroot.
*
* @returns the chroot type.