Chroot support for filesystem union based sessions. More...
#include <sbuild-chroot-facet-union.h>
Public Types | |
enum | error_code { UNION_TYPE_UNKNOWN, UNION_OVERLAY_ABS, UNION_UNDERLAY_ABS } |
Error codes. More... | |
typedef custom_error< error_code > | error |
Exception type. | |
typedef std::tr1::shared_ptr < chroot_facet_union > | ptr |
A shared_ptr to a chroot facet object. | |
typedef std::tr1::shared_ptr < const chroot_facet_union > | const_ptr |
A shared_ptr to a const chroot facet object. | |
Public Member Functions | |
virtual | ~chroot_facet_union () |
The destructor. | |
virtual chroot_facet::ptr | clone () const |
Copy the chroot facet. | |
std::string const & | get_name () const |
Get the name of the chroot facet. | |
void | clone_source_setup (chroot::ptr &clone) const |
bool | get_union_configured () const |
Get fs union configured state. | |
virtual std::string const & | get_union_type () const |
Get the filesystem union type. | |
virtual void | set_union_type (std::string const &union_type) |
Set the filesystem union type. | |
virtual std::string const & | get_union_mount_options () const |
Get the filesystem union mount options (branch configuration). | |
virtual void | set_union_mount_options (std::string const &union_mount_options) |
Set the filesystem union mount options (branch configuration). | |
virtual std::string const & | get_union_overlay_directory () const |
Get the union overlay directory. | |
virtual void | set_union_overlay_directory (std::string const &directory) |
Set the union overlay directory. | |
virtual std::string const & | get_union_underlay_directory () const |
Get the union underlay directory. | |
virtual void | set_union_underlay_directory (std::string const &directory) |
Set the union underlay directory. | |
virtual void | setup_env (chroot const &chroot, environment &env) const |
Set environment. | |
virtual chroot::session_flags | get_session_flags (chroot const &chroot) const |
Get the session flags of the chroot. | |
virtual void | get_details (chroot const &chroot, format_detail &detail) const |
Get detailed information about the chroot for output. | |
virtual void | get_keyfile (chroot const &chroot, keyfile &keyfile) const |
Copy the chroot properties into a keyfile. | |
virtual void | set_keyfile (chroot &chroot, keyfile const &keyfile, string_list &used_keys) |
Set the chroot properties from a keyfile. | |
Static Public Member Functions | |
static ptr | create () |
Create a chroot facet. | |
Private Member Functions | |
chroot_facet_union () | |
The constructor. | |
Private Attributes | |
std::string | union_type |
filesystem union type. | |
std::string | union_mount_options |
Union mount options (branch configuration). | |
std::string | union_overlay_directory |
Union read-write overlay directory. | |
std::string | union_underlay_directory |
Union read-only underlay directory. |
Chroot support for filesystem union based sessions.
A chroot may offer session support using a filesystem union like aufs or unionfs. A new union type may need to adapt the 10mount or 05union script to properly populate the underlay and mount directory. The overlay directory and union setup is already handled.
typedef std::tr1::shared_ptr<const chroot_facet_union> sbuild::chroot_facet_union::const_ptr |
A shared_ptr to a const chroot facet object.
Reimplemented from sbuild::chroot_facet.
Exception type.
typedef std::tr1::shared_ptr<chroot_facet_union> sbuild::chroot_facet_union::ptr |
A shared_ptr to a chroot facet object.
Reimplemented from sbuild::chroot_facet.
chroot_facet_union::chroot_facet_union | ( | ) | [private] |
chroot_facet_union::~chroot_facet_union | ( | ) | [virtual] |
The destructor.
chroot_facet::ptr chroot_facet_union::clone | ( | ) | const [virtual] |
Copy the chroot facet.
This is a virtual copy constructor.
Implements sbuild::chroot_facet.
References chroot_facet_union().
void chroot_facet_union::clone_source_setup | ( | chroot::ptr & | clone | ) | const |
References sbuild::chroot::get_facet(), and sbuild::chroot_facet::owner.
chroot_facet_union::ptr chroot_facet_union::create | ( | ) | [static] |
Create a chroot facet.
References chroot_facet_union().
Referenced by sbuild::chroot_block_device::chroot_block_device(), sbuild::chroot_directory::chroot_directory(), and sbuild::chroot_loopback::chroot_loopback().
void chroot_facet_union::get_details | ( | chroot const & | chroot, | |
format_detail & | detail | |||
) | const [virtual] |
Get detailed information about the chroot for output.
chroot | the chroot to use. | |
detail | the details to output to. |
Implements sbuild::chroot_facet.
References sbuild::_(), sbuild::format_detail::add(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), get_union_underlay_directory(), union_overlay_directory, and union_underlay_directory.
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.
chroot | the chroot to use. | |
keyfile | the keyfile to use. |
Implements sbuild::chroot_facet.
References sbuild::chroot::get_keyfile_name(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), get_union_underlay_directory(), and sbuild::basic_keyfile< K, P >::set_object_value().
std::string const & chroot_facet_union::get_name | ( | ) | const [virtual] |
sbuild::chroot::session_flags chroot_facet_union::get_session_flags | ( | chroot const & | chroot | ) | const [virtual] |
Get the session flags of the chroot.
These determine how the Session controlling the chroot will operate.
chroot | the chroot to use. |
Implements sbuild::chroot_facet.
References sbuild::chroot::get_active(), get_union_configured(), sbuild::chroot::SESSION_NOFLAGS, and sbuild::chroot::SESSION_PURGE.
bool chroot_facet_union::get_union_configured | ( | ) | const |
Get fs union configured state.
References get_union_type().
Referenced by get_details(), get_keyfile(), get_session_flags(), set_keyfile(), and setup_env().
std::string const & chroot_facet_union::get_union_mount_options | ( | ) | const [virtual] |
Get the filesystem union mount options (branch configuration).
References union_mount_options.
Referenced by get_details(), get_keyfile(), and setup_env().
std::string const & chroot_facet_union::get_union_overlay_directory | ( | ) | const [virtual] |
Get the union overlay directory.
References union_overlay_directory.
Referenced by get_details(), get_keyfile(), and setup_env().
std::string const & chroot_facet_union::get_union_type | ( | ) | const [virtual] |
Get the filesystem union type.
References union_type.
Referenced by get_details(), get_keyfile(), get_union_configured(), and setup_env().
std::string const & chroot_facet_union::get_union_underlay_directory | ( | ) | const [virtual] |
Get the union underlay directory.
References union_underlay_directory.
Referenced by get_details(), get_keyfile(), and setup_env().
void chroot_facet_union::set_keyfile | ( | chroot & | chroot, | |
keyfile const & | keyfile, | |||
string_list & | used_keys | |||
) | [virtual] |
Set the chroot properties from a keyfile.
The chroot name must have previously been set, so that the correct keyfile group may be determined.
chroot | the chroot to use. | |
keyfile | the keyfile to get the properties from. | |
used_keys | a list of the keys used will be set. |
Implements sbuild::chroot_facet.
References sbuild::chroot::get_active(), sbuild::chroot::get_facet(), sbuild::chroot::get_keyfile_name(), sbuild::basic_keyfile< K, P >::get_object_value(), get_union_configured(), sbuild::keyfile_base::PRIORITY_OPTIONAL, sbuild::keyfile_base::PRIORITY_REQUIRED, set_union_mount_options(), set_union_overlay_directory(), set_union_type(), and set_union_underlay_directory().
void chroot_facet_union::set_union_mount_options | ( | std::string const & | union_mount_options | ) | [virtual] |
Set the filesystem union mount options (branch configuration).
Normally a temporary directory is used as the writeable branch, which is removed on session end. This allows the building of a complex union which can merge multiple branches. The string has to be constructed as expected by the filesystem union type and is directly used as the mount '-o' option string.
union_mount_options | a union filesystem-specific branch description |
Referenced by set_keyfile().
void chroot_facet_union::set_union_overlay_directory | ( | std::string const & | directory | ) | [virtual] |
Set the union overlay directory.
References sbuild::is_absname().
Referenced by set_keyfile().
void chroot_facet_union::set_union_type | ( | std::string const & | union_type | ) | [virtual] |
Set the filesystem union type.
Currently supported values are aufs, unionfs and none.
union_type | the filesystem type. |
References sbuild::chroot::add_facet(), sbuild::chroot_facet_source_clonable::create(), sbuild::chroot::get_facet(), sbuild::chroot_facet::owner, sbuild::chroot::remove_facet(), union_type, and UNION_TYPE_UNKNOWN.
Referenced by set_keyfile().
void chroot_facet_union::set_union_underlay_directory | ( | std::string const & | directory | ) | [virtual] |
Set the union underlay directory.
References sbuild::is_absname().
Referenced by set_keyfile().
void chroot_facet_union::setup_env | ( | chroot const & | chroot, | |
environment & | env | |||
) | const [virtual] |
Set environment.
Set the environment that the setup scripts will see during execution.
chroot | the chroot to use. | |
env | the environment to set. |
Implements sbuild::chroot_facet.
References sbuild::environment::add(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), and get_union_underlay_directory().
std::string sbuild::chroot_facet_union::union_mount_options [private] |
Union mount options (branch configuration).
Referenced by get_union_mount_options().
std::string sbuild::chroot_facet_union::union_overlay_directory [private] |
Union read-write overlay directory.
Referenced by get_details(), and get_union_overlay_directory().
std::string sbuild::chroot_facet_union::union_type [private] |
filesystem union type.
Referenced by get_union_type(), and set_union_type().
std::string sbuild::chroot_facet_union::union_underlay_directory [private] |
Union read-only underlay directory.
Referenced by get_details(), and get_union_underlay_directory().