sbuild::chroot Class Reference

Common chroot data. More...

#include <sbuild-chroot.h>

Inheritance diagram for sbuild::chroot:

Inheritance graph
[legend]
Collaboration diagram for sbuild::chroot:

Collaboration graph
[legend]
List of all members.

Public Types

typedef runtime_error_custom<
chroot
error
 Exception type.
typedef std::tr1::shared_ptr<
chroot
ptr
 A shared_ptr to a chroot object.
enum  setup_type {
  SETUP_START, SETUP_RECOVER, SETUP_STOP, RUN_START,
  RUN_STOP
}
 Type of setup to perform. More...
enum  session_flags { SESSION_CREATE = 1 << 0 }
 Chroot session properties. More...

Public Member Functions

virtual ~chroot ()
 The destructor.
virtual ptr clone () const =0
 Copy the chroot.
std::string const & get_name () const
 Get the name of the chroot.
void set_name (std::string const &name)
 Set the name of the chroot.
std::string const & get_description () const
 Get the description of the chroot.
void set_description (std::string const &description)
 Set the description of the chroot.
virtual std::string const & get_mount_location () const
 Get the mount location of the chroot.
void set_mount_location (std::string const &location)
 Set the mount location of the chroot.
virtual std::string const & get_mount_device () const
 Get the mount device of the chroot.
void set_mount_device (std::string const &device)
 Set the mount device of the chroot.
unsigned int get_priority () const
 Get the priority of the chroot.
void set_priority (unsigned int priority)
 Set the priority of a chroot.
string_list const & get_groups () const
 Get the groups allowed to access the chroot.
void set_groups (string_list const &groups)
 Set the groups allowed to access the chroot.
string_list const & get_root_groups () const
 Get the groups allowed to access the chroot as root.
void set_root_groups (string_list const &groups)
 Set the groups allowed to access the chroot as root.
string_list const & get_aliases () const
 Get the aliases of the chroot.
void set_aliases (string_list const &aliases)
 Set the aliases of the chroot.
bool get_active () const
 Get the activity status of the chroot.
void set_active (bool active)
 Set the activity status of the chroot.
bool get_run_setup_scripts () const
 Check if chroot setup scripts will be run.
void set_run_setup_scripts (bool run_setup_scripts)
 Set whether chroot setup scripts will be run.
bool get_run_session_scripts () const
 Check if chroot session scripts will be run.
void set_run_session_scripts (bool run_session_scripts)
 Set whether chroot session scripts will be run.
virtual std::string const & get_chroot_type () const =0
 Get the type of the chroot.
virtual void setup_env (environment &env)
 Set environment.
virtual void setup_lock (setup_type type, bool lock)=0
 Lock a chroot during setup.
virtual session_flags get_session_flags () const =0
 Get the session flags of the chroot.

Static Public Member Functions

static ptr create (std::string const &type)
 Create a chroot.

Protected Member Functions

 chroot ()
 The constructor.
virtual void setup_session_info (bool start)
 Set up persistent session information.
template<typename T>
format_detail< T > format_details (std::string const &name, T const &value) const
 Format a name-value pair for output.
virtual void print_details (std::ostream &stream) const
 Print detailed information about the chroot to a stream.
virtual void get_keyfile (keyfile &keyfile) const
 Copy the chroot properties into a keyfile.
virtual void set_keyfile (keyfile const &keyfile)
 Set the chroot properties from a keyfile.

Private Attributes

std::string name
 Chroot name.
std::string description
 Chroot description.
unsigned int priority
 Chroot prioroty.
string_list groups
 Groups allowed to access the chroot.
string_list root_groups
 Groups allowed to access the chroot as root.
string_list aliases
 Alternative names for the chroot.
std::string mount_location
 Location to mount chroot in the filesystem (if any).
std::string mount_device
 Block device to mount (if any).
bool active
 Chroot activity status.
bool run_setup_scripts
 Run chroot setup scripts?
bool run_session_scripts
 Run session setup scripts?

Friends

std::ostream & operator<< (std::ostream &stream, ptr const &rhs)
 Print detailed information about the chroot to a stream.
keyfile const & operator>> (keyfile const &keyfile, ptr &rhs)
 Chroot initialisation from a keyfile.
keyfileoperator<< (keyfile &keyfile, ptr const &rhs)
 Chroot serialisation to a keyfile.

Classes

class  format_detail
 Helper to perform formatting of chroot details. More...

Detailed Description

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.


Member Typedef Documentation

typedef runtime_error_custom<chroot> sbuild::chroot::error
 

Exception type.

typedef std::tr1::shared_ptr<chroot> sbuild::chroot::ptr
 

A shared_ptr to a chroot object.


Member Enumeration Documentation

enum sbuild::chroot::session_flags
 

Chroot session properties.

Enumerator:
SESSION_CREATE  The chroot supports session creation.

enum sbuild::chroot::setup_type
 

Type of setup to perform.

Enumerator:
SETUP_START  Activate a chroot.
SETUP_RECOVER  Reactivate a chroot.
SETUP_STOP  Deactivate a chroot.
RUN_START  Start running a command in an active chroot.
RUN_STOP  End running a command in an active chroot.


Constructor & Destructor Documentation

sbuild::chroot::chroot  )  [protected]
 

The constructor.

sbuild::chroot::~chroot  )  [virtual]
 

The destructor.


Member Function Documentation

virtual ptr sbuild::chroot::clone  )  const [pure virtual]
 

Copy the chroot.

This is a virtual copy constructor.

Returns:
a shared_ptr to the new copy of the chroot.

Implemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

sbuild::chroot::ptr sbuild::chroot::create std::string const &  type  )  [static]
 

Create a chroot.

This is a factory function.

Parameters:
type the type of chroot to create.
Returns:
a shared_ptr to the new chroot.

template<typename T>
format_detail<T> sbuild::chroot::format_details std::string const &  name,
T const &  value
const [inline, protected]
 

Format a name-value pair for output.

This is a convenience wrapper to construct a format_detail of the appropriate type.

Parameters:
name the name to output.
value the value to output.
Returns:
a format_detail of the appropriate type.

bool sbuild::chroot::get_active  )  const
 

Get the activity status of the chroot.

Returns:
true if active, false if inactive

string_list const & sbuild::chroot::get_aliases  )  const
 

Get the aliases of the chroot.

These are alternative names for the chroot.

Returns:
a list of names.

virtual std::string const& sbuild::chroot::get_chroot_type  )  const [pure virtual]
 

Get the type of the chroot.

Returns:
the chroot type.

Implemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

std::string const & sbuild::chroot::get_description  )  const
 

Get the description of the chroot.

Returns:
the description.

string_list const & sbuild::chroot::get_groups  )  const
 

Get the groups allowed to access the chroot.

Returns:
a list of groups.

void sbuild::chroot::get_keyfile keyfile keyfile  )  const [protected, virtual]
 

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.

Parameters:
keyfile the keyfile to use.

Reimplemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

std::string const & sbuild::chroot::get_mount_device  )  const [virtual]
 

Get the mount device of the chroot.

Returns:
the device.

Reimplemented in sbuild::chroot_block_device, and sbuild::chroot_lvm_snapshot.

std::string const & sbuild::chroot::get_mount_location  )  const [virtual]
 

Get the mount location of the chroot.

Returns:
the mount location.

Reimplemented in sbuild::chroot_plain.

std::string const & sbuild::chroot::get_name  )  const
 

Get the name of the chroot.

Returns:
the name.

unsigned int sbuild::chroot::get_priority  )  const
 

Get the priority of the chroot.

This is a number indicating whether than a ditribution is older than another.

Returns:
the priority.

string_list const & sbuild::chroot::get_root_groups  )  const
 

Get the groups allowed to access the chroot as root.

Mmebers of these groups can switch to root without authenticating themselves.

Returns:
a list of groups.

bool sbuild::chroot::get_run_session_scripts  )  const
 

Check if chroot session scripts will be run.

Returns:
true if session scripts will be run, otherwise false.

bool sbuild::chroot::get_run_setup_scripts  )  const
 

Check if chroot setup scripts will be run.

Returns:
true if setup scripts will be run, otherwise false.

virtual session_flags sbuild::chroot::get_session_flags  )  const [pure virtual]
 

Get the session flags of the chroot.

These determine how the Session controlling the chroot will operate.

Returns:
the session flags.

Implemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

void sbuild::chroot::print_details std::ostream &  stream  )  const [protected, virtual]
 

Print detailed information about the chroot to a stream.

The information is printed in plain text with one line per property.

Parameters:
stream the stream to output to.

Reimplemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

void sbuild::chroot::set_active bool  active  ) 
 

Set the activity status of the chroot.

Parameters:
active true if active, false if inactive

void sbuild::chroot::set_aliases string_list const &  aliases  ) 
 

Set the aliases of the chroot.

These are alternative names for the chroot.

Parameters:
aliases a list of names.

void sbuild::chroot::set_description std::string const &  description  ) 
 

Set the description of the chroot.

Parameters:
description the description.

void sbuild::chroot::set_groups string_list const &  groups  ) 
 

Set the groups allowed to access the chroot.

Parameters:
groups a list of groups.

void sbuild::chroot::set_keyfile keyfile const &  keyfile  )  [protected, 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.

Parameters:
keyfile the keyfile to get the properties from.

Reimplemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

void sbuild::chroot::set_mount_device std::string const &  device  ) 
 

Set the mount device of the chroot.

Parameters:
device the device.

void sbuild::chroot::set_mount_location std::string const &  location  ) 
 

Set the mount location of the chroot.

Parameters:
location the mount location.

void sbuild::chroot::set_name std::string const &  name  ) 
 

Set the name of the chroot.

Parameters:
name the name.

void sbuild::chroot::set_priority unsigned int  priority  ) 
 

Set the priority of a chroot.

This is a number indicating whether a distribution is older than another. For example, "oldstable" and "oldstable-security" might be 0, while "stable" and "stable-security" 1, "testing" 2 and "unstable" 3. The values are not important, but the difference between them is.

Parameters:
priority the priority.

void sbuild::chroot::set_root_groups string_list const &  groups  ) 
 

Set the groups allowed to access the chroot as root.

Mmebers of these groups can switch to root without authenticating themselves.

Parameters:
groups a list of groups.

void sbuild::chroot::set_run_session_scripts bool  run_session_scripts  ) 
 

Set whether chroot session scripts will be run.

Parameters:
run_session_scripts true if session scripts will be run, otherwise false.

void sbuild::chroot::set_run_setup_scripts bool  run_setup_scripts  ) 
 

Set whether chroot setup scripts will be run.

Parameters:
run_setup_scripts true if setup scripts will be run, otherwise false.

void sbuild::chroot::setup_env environment env  )  [virtual]
 

Set environment.

Set the environment that the setup scripts will see during execution.

Parameters:
env the environment to set.

Reimplemented in sbuild::chroot_block_device, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.

virtual void sbuild::chroot::setup_lock setup_type  type,
bool  lock
[pure virtual]
 

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 might require locking, but afterwards this will change to the new block device.

An error will be thrown on failure.

Parameters:
type the type of setup being performed
lock true to lock, false to unlock

void sbuild::chroot::setup_session_info bool  start  )  [protected, virtual]
 

Set up persistent session information.

Parameters:
start true if startion, or false if ending a session.


Friends And Related Function Documentation

keyfile& operator<< keyfile keyfile,
ptr const &  rhs
[friend]
 

Chroot serialisation to a keyfile.

std::ostream& operator<< std::ostream &  stream,
ptr const &  rhs
[friend]
 

Print detailed information about the chroot to a stream.

The information is printed in plain text with one line per property.

Parameters:
stream the stream to output to.
rhs the chroot to output.
Returns:
the stream.

keyfile const& operator>> keyfile const &  keyfile,
ptr rhs
[friend]
 

Chroot initialisation from a keyfile.


Member Data Documentation

bool sbuild::chroot::active [private]
 

Chroot activity status.

string_list sbuild::chroot::aliases [private]
 

Alternative names for the chroot.

std::string sbuild::chroot::description [private]
 

Chroot description.

string_list sbuild::chroot::groups [private]
 

Groups allowed to access the chroot.

std::string sbuild::chroot::mount_device [private]
 

Block device to mount (if any).

std::string sbuild::chroot::mount_location [private]
 

Location to mount chroot in the filesystem (if any).

std::string sbuild::chroot::name [private]
 

Chroot name.

unsigned int sbuild::chroot::priority [private]
 

Chroot prioroty.

string_list sbuild::chroot::root_groups [private]
 

Groups allowed to access the chroot as root.

bool sbuild::chroot::run_session_scripts [private]
 

Run session setup scripts?

bool sbuild::chroot::run_setup_scripts [private]
 

Run chroot setup scripts?


The documentation for this class was generated from the following files:
Generated on Tue Feb 21 11:02:39 2006 for schroot by  doxygen 1.4.6