diff options
-rw-r--r-- | ChangeLog | 36 | ||||
-rwxr-xr-x | bin/schroot/exec/00check | 4 | ||||
-rw-r--r-- | bin/schroot/schroot-setup.5.in | 9 | ||||
-rwxr-xr-x | bin/schroot/setup/00check | 4 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-block-device.cc | 2 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-directory.cc | 2 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-source.cc | 92 | ||||
-rw-r--r-- | sbuild/sbuild-chroot-source.h | 2 | ||||
-rw-r--r-- | sbuild/sbuild-chroot.cc | 9 | ||||
-rw-r--r-- | sbuild/sbuild-chroot.h | 2 |
10 files changed, 125 insertions, 37 deletions
@@ -1,3 +1,39 @@ +2008-01-17 Roger Leigh <rleigh@debian.org> + + * bin/schroot/schroot-setup.5.in: Document SCHROOT_SESSION_CREATE, + SCHROOT_SESSION_CLONE, and SCHROOT_SESSION_PURGE, + + * bin/schroot/setup/00check, bin/schroot/exec/00check: Print + SCHROOT_SESSION_CREATE, SCHROOT_SESSION_CLONE, + SCHROOT_SESSION_PURGE, FSTAB and SBUILD values. + + * sbuild/sbuild-chroot-block-device.cc, + sbuild-chroot-directory.cc: Use SESSION_NOFLAGS. + + * sbuild/sbuild-chroot-source.cc: + (chroot_source::chroot_source): Explicitly initialise all member. + (chroot_source::clone_source_setup): Set is_source when cloning a + source chroot. + (chroot_source::get_session_flags): Set session flags + appropriately for source chroots, active cloned chroots and + inactive non-cloned chroots. + (chroot_source::get_details): Only list extra source chroot + configuration options for non-source chroots. + (chroot_source::get_keyfile): Only get for non-source chroots. + (chroot_source::set_keyfile): Only set for non-source chroots. + + * sbuild/sbuild-chroot-source.h: Add is_source member. + + * sbuild/sbuild-chroot.cc + (chroot::setup_env): Add SCHROOT_SESSION_CREATE, + SCHROOT_SESSION_CLONE, and SCHROOT_SESSION_PURGE to the + environment. + (chroot::get_details): Display SCHROOT_SESSION_CREATE, + SCHROOT_SESSION_CLONE, and SCHROOT_SESSION_PURGE. + + * sbuild/sbuild-chroot.h: Add SESSION_NOFLAGS and SESSION_PURGE to + session_flags. + 2008-01-16 Roger Leigh <rleigh@debian.org> * NEWS: Update. diff --git a/bin/schroot/exec/00check b/bin/schroot/exec/00check index e45a862e..c6ac95ca 100755 --- a/bin/schroot/exec/00check +++ b/bin/schroot/exec/00check @@ -54,6 +54,10 @@ if [ $1 = "exec-start" ]; then echo "CHROOT_LVM_SNAPSHOT_OPTIONS=$CHROOT_LVM_SNAPSHOT_OPTIONS" fi fi + echo "CHROOT_SESSION_CREATE=$CHROOT_SESSION_CREATE" + echo "CHROOT_SESSION_CLONE=$CHROOT_SESSION_CLONE" + echo "CHROOT_SESSION_PURGE=$CHROOT_SESSION_PURGE" + echo "FSTAB=$FSTAB" echo "SBUILD=$SBUILD" fi diff --git a/bin/schroot/schroot-setup.5.in b/bin/schroot/schroot-setup.5.in index e5a02fb1..fb3df799 100644 --- a/bin/schroot/schroot-setup.5.in +++ b/bin/schroot/schroot-setup.5.in @@ -76,6 +76,15 @@ The process ID of the schroot process. SESSION_ID The session identifier. .TP +CHROOT_SESSION_CREATE +Set to \[oq]true\[cq] if a session will be created, otherwise \[oq]false\[cq]. +.TP +CHROOT_SESSION_CLONE +Set to \[oq]true\[cq] if a session will be cloned, otherwise \[oq]false\[cq]. +.TP +CHROOT_SESSION_PURGE +Set to \[oq]true\[cq] if a session will be purged, otherwise \[oq]false\[cq]. +.TP CHROOT_TYPE The type of the chroot. This is useful for restricting a setup task to particular types of chroot (e.g. only block devices or LVM snapshots). diff --git a/bin/schroot/setup/00check b/bin/schroot/setup/00check index 65906594..c76ee011 100755 --- a/bin/schroot/setup/00check +++ b/bin/schroot/setup/00check @@ -54,6 +54,10 @@ if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then echo "CHROOT_LVM_SNAPSHOT_OPTIONS=$CHROOT_LVM_SNAPSHOT_OPTIONS" fi fi + echo "CHROOT_SESSION_CREATE=$CHROOT_SESSION_CREATE" + echo "CHROOT_SESSION_CLONE=$CHROOT_SESSION_CLONE" + echo "CHROOT_SESSION_PURGE=$CHROOT_SESSION_PURGE" + echo "FSTAB=$FSTAB" echo "SBUILD=$SBUILD" fi diff --git a/sbuild/sbuild-chroot-block-device.cc b/sbuild/sbuild-chroot-block-device.cc index 97f5643f..032c7284 100644 --- a/sbuild/sbuild-chroot-block-device.cc +++ b/sbuild/sbuild-chroot-block-device.cc @@ -162,7 +162,7 @@ chroot_block_device::setup_lock (chroot::setup_type type, sbuild::chroot::session_flags chroot_block_device::get_session_flags () const { - return static_cast<session_flags>(0); + return SESSION_NOFLAGS; } void diff --git a/sbuild/sbuild-chroot-directory.cc b/sbuild/sbuild-chroot-directory.cc index bd2dad89..bce8c308 100644 --- a/sbuild/sbuild-chroot-directory.cc +++ b/sbuild/sbuild-chroot-directory.cc @@ -104,7 +104,7 @@ chroot_directory::get_session_flags () const if (get_run_setup_scripts() == true) return SESSION_CREATE; else - return static_cast<session_flags>(0); + return SESSION_NOFLAGS; } void diff --git a/sbuild/sbuild-chroot-source.cc b/sbuild/sbuild-chroot-source.cc index 3a31a1ea..3a9581dc 100644 --- a/sbuild/sbuild-chroot-source.cc +++ b/sbuild/sbuild-chroot-source.cc @@ -30,7 +30,12 @@ using boost::format; using namespace sbuild; chroot_source::chroot_source (): - chroot() + chroot(), + is_source(false), + source_users(), + source_groups(), + source_root_users(), + source_root_groups() { } @@ -56,6 +61,10 @@ chroot_source::clone_source_setup (chroot::ptr& clone) const ++alias) source_aliases.push_back(*alias + "-source"); clone->set_aliases(source_aliases); + + std::tr1::shared_ptr<chroot_source> source(std::tr1::dynamic_pointer_cast<chroot_source>(clone)); + if (source) + source->is_source = true; } string_list const& @@ -114,56 +123,71 @@ chroot_source::setup_env (environment& env) sbuild::chroot::session_flags chroot_source::get_session_flags () const { - return SESSION_CLONE; + if (this->is_source) + // -source chroots are not clonable. + return SESSION_NOFLAGS; + else if (get_active()) + //Active chroots are already cloned, but need purging. + return SESSION_PURGE; + else // Inactive, not -source. + // Inactive chroots are clonable. + return SESSION_CLONE; } void chroot_source::get_details (format_detail& detail) const { - detail - .add(_("Source Users"), get_source_users()) - .add(_("Source Groups"), get_source_groups()) - .add(_("Source Root Users"), get_source_root_users()) - .add(_("Source Root Groups"), get_source_root_groups()); + if (!this->is_source) + detail + .add(_("Source Users"), get_source_users()) + .add(_("Source Groups"), get_source_groups()) + .add(_("Source Root Users"), get_source_root_users()) + .add(_("Source Root Groups"), get_source_root_groups()); } void chroot_source::get_keyfile (keyfile& keyfile) const { - keyfile::set_object_list_value(*this, &chroot_source::get_source_users, - keyfile, get_name(), "source-users"); + if (!this->is_source) + { + keyfile::set_object_list_value(*this, &chroot_source::get_source_users, + keyfile, get_name(), "source-users"); - keyfile::set_object_list_value(*this, &chroot_source::get_source_groups, - keyfile, get_name(), "source-groups"); + keyfile::set_object_list_value(*this, &chroot_source::get_source_groups, + keyfile, get_name(), "source-groups"); - keyfile::set_object_list_value(*this, &chroot_source::get_source_root_users, - keyfile, get_name(), "source-root-users"); + keyfile::set_object_list_value(*this, &chroot_source::get_source_root_users, + keyfile, get_name(), "source-root-users"); - keyfile::set_object_list_value(*this, &chroot_source::get_source_root_groups, - keyfile, get_name(), "source-root-groups"); + keyfile::set_object_list_value(*this, &chroot_source::get_source_root_groups, + keyfile, get_name(), "source-root-groups"); + } } void chroot_source::set_keyfile (keyfile const& keyfile, string_list& used_keys) { - keyfile::get_object_list_value(*this, &chroot_source::set_source_users, - keyfile, get_name(), "source-users", - keyfile::PRIORITY_OPTIONAL); - used_keys.push_back("source-users"); - - keyfile::get_object_list_value(*this, &chroot_source::set_source_groups, - keyfile, get_name(), "source-groups", - keyfile::PRIORITY_OPTIONAL); - used_keys.push_back("source-groups"); - - keyfile::get_object_list_value(*this, &chroot_source::set_source_root_users, - keyfile, get_name(), "source-root-users", - keyfile::PRIORITY_OPTIONAL); - used_keys.push_back("source-root-users"); - - keyfile::get_object_list_value(*this, &chroot_source::set_source_root_groups, - keyfile, get_name(), "source-root-groups", - keyfile::PRIORITY_OPTIONAL); - used_keys.push_back("source-root-groups"); + if (!this->is_source) + { + keyfile::get_object_list_value(*this, &chroot_source::set_source_users, + keyfile, get_name(), "source-users", + keyfile::PRIORITY_OPTIONAL); + used_keys.push_back("source-users"); + + keyfile::get_object_list_value(*this, &chroot_source::set_source_groups, + keyfile, get_name(), "source-groups", + keyfile::PRIORITY_OPTIONAL); + used_keys.push_back("source-groups"); + + keyfile::get_object_list_value(*this, &chroot_source::set_source_root_users, + keyfile, get_name(), "source-root-users", + keyfile::PRIORITY_OPTIONAL); + used_keys.push_back("source-root-users"); + + keyfile::get_object_list_value(*this, &chroot_source::set_source_root_groups, + keyfile, get_name(), "source-root-groups", + keyfile::PRIORITY_OPTIONAL); + used_keys.push_back("source-root-groups"); + } } diff --git a/sbuild/sbuild-chroot-source.h b/sbuild/sbuild-chroot-source.h index 670526ac..5913ba7b 100644 --- a/sbuild/sbuild-chroot-source.h +++ b/sbuild/sbuild-chroot-source.h @@ -159,6 +159,8 @@ namespace sbuild string_list& used_keys); private: + /// Is the chroot source or clone? + bool is_source; /// Users allowed to access the source chroot. string_list source_users; /// Groups allowed to access the source chroot. diff --git a/sbuild/sbuild-chroot.cc b/sbuild/sbuild-chroot.cc index 8ae6045e..ff5280de 100644 --- a/sbuild/sbuild-chroot.cc +++ b/sbuild/sbuild-chroot.cc @@ -389,6 +389,9 @@ sbuild::chroot::setup_env (environment& env) env.add("CHROOT_PATH", get_path()); env.add("CHROOT_MOUNT_DEVICE", get_mount_device()); env.add("CHROOT_SCRIPT_CONFIG", normalname(std::string(PACKAGE_SYSCONF_DIR) + '/' + get_script_config())); + env.add("CHROOT_SESSION_CREATE", get_session_flags() & SESSION_CREATE); + env.add("CHROOT_SESSION_CLONE", get_session_flags() & SESSION_CLONE); + env.add("CHROOT_SESSION_PURGE", get_session_flags() & SESSION_PURGE); } void @@ -475,7 +478,11 @@ sbuild::chroot::get_details (format_detail& detail) const .add(_("Run Execution Scripts"), get_run_exec_scripts()) .add(_("Script Configuration"), get_script_config()) .add(_("Session Managed"), - static_cast<bool>(get_session_flags() & chroot::SESSION_CREATE)); + static_cast<bool>(get_session_flags() & chroot::SESSION_CREATE)) + .add(_("Session Cloned"), + static_cast<bool>(get_session_flags() & chroot::SESSION_CLONE)) + .add(_("Session Purged"), + static_cast<bool>(get_session_flags() & chroot::SESSION_PURGE)); if (!get_command_prefix().empty()) detail.add(_("Command Prefix"), get_command_prefix()); diff --git a/sbuild/sbuild-chroot.h b/sbuild/sbuild-chroot.h index 2910f744..12f9f1ae 100644 --- a/sbuild/sbuild-chroot.h +++ b/sbuild/sbuild-chroot.h @@ -56,8 +56,10 @@ namespace sbuild /// Chroot session properties enum session_flags { + SESSION_NOFLAGS = 0, ///< No flags are set. SESSION_CREATE = 1 << 0, ///< The chroot supports session creation. SESSION_CLONE = 1 << 1 ///< The chroot supports cloning. + SESSION_PURGE = 1 << 2 ///< The chroot should be purged. }; /// Error codes. |