sbuild::Chroot Class Reference

Common chroot data. More...

#include <sbuild-chroot.h>

Inheritance diagram for sbuild::Chroot:

Inheritance graph
[legend]
List of all members.

Public Types

typedef runtime_error_custom<
Chroot
error
 Exception type.
enum  SetupType {
  SETUP_START, SETUP_RECOVER, SETUP_STOP, RUN_START,
  RUN_STOP
}
 Type of setup to perform. More...
enum  SessionFlags { SESSION_CREATE = 1 << 0 }
 Chroot session properties. More...

Public Member Functions

 Chroot ()
 The constructor.
 Chroot (const keyfile &keyfile, const std::string &group)
 The constructor.
virtual ~Chroot ()
 The destructor.
virtual Chrootclone () const =0
 Copy the chroot.
const std::string & get_name () const
 Get the name of the chroot.
void set_name (const std::string &name)
 Set the name of the chroot.
const std::string & get_description () const
 Get the description of the chroot.
void set_description (const std::string &description)
 Set the description of the chroot.
virtual const std::string & get_mount_location () const
 Get the mount location of the chroot.
void set_mount_location (const std::string &location)
 Set the mount location of the chroot.
virtual const std::string & get_mount_device () const
 Get the mount device of the chroot.
void set_mount_device (const std::string &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.
const string_list & get_groups () const
 Get the groups allowed to access the chroot.
void set_groups (const string_list &groups)
 Set the groups allowed to access the chroot.
const string_list & get_root_groups () const
 Get the groups allowed to access the chroot as root.
void set_root_groups (const string_list &groups)
 Set the groups allowed to access the chroot as root.
const string_list & get_aliases () const
 Get the aliases of the chroot.
void set_aliases (const string_list &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 const std::string & get_chroot_type () const =0
 Get the type of the chroot.
virtual void setup_env (env_list &env)
 Set environment.
virtual void setup_lock (SetupType type, bool lock)=0
 Lock a chroot during setup.
virtual SessionFlags get_session_flags () const =0
 Get the session flags of the chroot.
virtual void print_details (std::ostream &stream) const
 Print detailed information about the chroot to a stream.
virtual void print_config (std::ostream &stream) const
 Print the configuration group for a chroot in the format required by schroot.conf.

Protected Types

typedef format_detail< std::string > format_detail_string
 Convenience type to format a string.
typedef format_detail< int > format_detail_int
 Convenience type to format an integer.
typedef format_detail< bool > format_detail_bool
 Convenience type to format a bool.
typedef format_detail< string_list > format_detail_strv
 Convenience type to format a string list.

Protected Member Functions

void read_keyfile (const keyfile &keyfile, const std::string &group)
 Read chroot configuration 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?

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 Enumeration Documentation

enum sbuild::Chroot::SessionFlags
 

Chroot session properties.

Enumerator:
SESSION_CREATE  The chroot supports session creation.

enum sbuild::Chroot::SetupType
 

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

Chroot::Chroot const keyfile keyfile,
const std::string &  group
 

The constructor.

Initialise from an open keyfile.

Parameters:
keyfile the configuration file
group the keyfile group (chroot name)


Member Function Documentation

virtual Chroot* sbuild::Chroot::clone  )  const [pure virtual]
 

Copy the chroot.

This is a virtual copy constructor.

Returns:
a copy of the chroot.

Implemented in sbuild::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

bool Chroot::get_active  )  const
 

Get the activity status of the chroot.

Returns:
true if active, false if inactive

const string_list & Chroot::get_aliases  )  const
 

Get the aliases of the chroot.

These are alternative names for the chroot.

Returns:
a list of names.

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

Get the type of the chroot.

Returns:
the chroot type.

Implemented in sbuild::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

const std::string & Chroot::get_description  )  const
 

Get the description of the chroot.

Returns:
the description.

const string_list & Chroot::get_groups  )  const
 

Get the groups allowed to access the chroot.

Returns:
a list of groups.

const std::string & Chroot::get_mount_device  )  const [virtual]
 

Get the mount device of the chroot.

Returns:
the device.

Reimplemented in sbuild::ChrootBlockDevice, and sbuild::ChrootLvmSnapshot.

const std::string & Chroot::get_mount_location  )  const [virtual]
 

Get the mount location of the chroot.

Returns:
the mount location.

Reimplemented in sbuild::ChrootPlain.

const std::string & Chroot::get_name  )  const
 

Get the name of the chroot.

Returns:
the name.

unsigned int 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.

const string_list & 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 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 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 SessionFlags 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::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

void Chroot::print_config std::ostream &  stream  )  const [virtual]
 

Print the configuration group for a chroot in the format required by schroot.conf.

Parameters:
stream the stream to output to.
Todo:
Replace with proper serialisation code to stream to a keyfile.

Reimplemented in sbuild::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

void Chroot::print_details std::ostream &  stream  )  const [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::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

void Chroot::read_keyfile const keyfile keyfile,
const std::string &  group
[protected]
 

Read chroot configuration from a keyfile.

Parameters:
keyfile the configuration file
group the keyfile group (chroot name)

Reimplemented in sbuild::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

void Chroot::set_active bool  active  ) 
 

Set the activity status of the chroot.

Parameters:
active true if active, false if inactive

void Chroot::set_aliases const string_list &  aliases  ) 
 

Set the aliases of the chroot.

These are alternative names for the chroot.

Parameters:
aliases a list of names.

void Chroot::set_description const std::string &  description  ) 
 

Set the description of the chroot.

Parameters:
description the description.

void Chroot::set_groups const string_list &  groups  ) 
 

Set the groups allowed to access the chroot.

Parameters:
groups a list of groups.

void Chroot::set_mount_device const std::string &  device  ) 
 

Set the mount device of the chroot.

Parameters:
device the device.

void Chroot::set_mount_location const std::string &  location  ) 
 

Set the mount location of the chroot.

Parameters:
location the mount location.

void Chroot::set_name const std::string &  name  ) 
 

Set the name of the chroot.

Parameters:
name the name.

void 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 Chroot::set_root_groups const string_list &  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 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 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 Chroot::setup_env env_list &  env  )  [virtual]
 

Set environment.

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

Parameters:
env the environment to set.

Reimplemented in sbuild::ChrootBlockDevice, sbuild::ChrootLvmSnapshot, and sbuild::ChrootPlain.

virtual void sbuild::Chroot::setup_lock SetupType  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


The documentation for this class was generated from the following files:
Generated on Thu Dec 29 17:20:05 2005 for schroot by  doxygen 1.4.5