summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-04-28 22:02:13 +0100
committerRoger Leigh <rleigh@debian.org>2013-05-04 17:17:17 +0100
commitc19190106d8339b4a7760e7b3bdfb0e9354fc4a8 (patch)
tree7fcc034d40d2e331b70e5b35bf2d54728db4016b /lib
parent1951bfce584a87b695da7d7c06fefed95b00feb5 (diff)
downloadschroot-c19190106d8339b4a7760e7b3bdfb0e9354fc4a8.tar.gz
sbuild::chroot::facet: Add factory class
All instantiable facets (not base classes and interfaces) are registered with the factory, and may be created via the factory interface.
Diffstat (limited to 'lib')
-rw-r--r--lib/sbuild/Makefile.am8
-rw-r--r--lib/sbuild/chroot/facet/block-device.cc15
-rw-r--r--lib/sbuild/chroot/facet/btrfs-snapshot.cc15
-rw-r--r--lib/sbuild/chroot/facet/btrfs-snapshot.h2
-rw-r--r--lib/sbuild/chroot/facet/custom.cc15
-rw-r--r--lib/sbuild/chroot/facet/directory-base.h14
-rw-r--r--lib/sbuild/chroot/facet/directory.cc15
-rw-r--r--lib/sbuild/chroot/facet/directory.h5
-rw-r--r--lib/sbuild/chroot/facet/factory.cc80
-rw-r--r--lib/sbuild/chroot/facet/factory.h73
-rw-r--r--lib/sbuild/chroot/facet/file.cc15
-rw-r--r--lib/sbuild/chroot/facet/fsunion.cc15
-rw-r--r--lib/sbuild/chroot/facet/loopback.cc14
-rw-r--r--lib/sbuild/chroot/facet/lvm-snapshot.cc14
-rw-r--r--lib/sbuild/chroot/facet/mountable.cc15
-rw-r--r--lib/sbuild/chroot/facet/personality.cc15
-rw-r--r--lib/sbuild/chroot/facet/plain.cc15
-rw-r--r--lib/sbuild/chroot/facet/plain.h6
-rw-r--r--lib/sbuild/chroot/facet/session-clonable.cc15
-rw-r--r--lib/sbuild/chroot/facet/session.cc15
-rw-r--r--lib/sbuild/chroot/facet/source-clonable.cc15
-rw-r--r--lib/sbuild/chroot/facet/source.cc15
-rw-r--r--lib/sbuild/chroot/facet/unshare.cc15
-rw-r--r--lib/sbuild/chroot/facet/userdata.cc15
-rw-r--r--lib/schroot-common/main.cc24
25 files changed, 432 insertions, 33 deletions
diff --git a/lib/sbuild/Makefile.am b/lib/sbuild/Makefile.am
index 51279724..3be12b47 100644
--- a/lib/sbuild/Makefile.am
+++ b/lib/sbuild/Makefile.am
@@ -26,10 +26,11 @@ lib_sbuild_public_h_sources = \
lib/sbuild/chroot/directory.h \
lib/sbuild/chroot/directory-base.h \
lib/sbuild/chroot/facet/btrfs-snapshot.cc \
- lib/sbuild/chroot/facet/facet.h \
- lib/sbuild/chroot/facet/file.h \
lib/sbuild/chroot/facet/directory.h \
lib/sbuild/chroot/facet/directory-base.h \
+ lib/sbuild/chroot/facet/facet.h \
+ lib/sbuild/chroot/facet/factory.h \
+ lib/sbuild/chroot/facet/file.h \
lib/sbuild/chroot/facet/loopback.h \
lib/sbuild/chroot/facet/mountable.h \
lib/sbuild/chroot/facet/personality.h \
@@ -121,9 +122,10 @@ lib_sbuild_public_cc_sources = \
lib/sbuild/chroot/directory-base.cc \
lib/sbuild/chroot/facet/btrfs-snapshot.cc \
lib/sbuild/chroot/facet/directory.cc \
+ lib/sbuild/chroot/facet/directory-base.cc \
lib/sbuild/chroot/facet/facet.cc \
+ lib/sbuild/chroot/facet/factory.cc \
lib/sbuild/chroot/facet/file.cc \
- lib/sbuild/chroot/facet/directory-base.cc \
lib/sbuild/chroot/facet/loopback.cc \
lib/sbuild/chroot/facet/mountable.cc \
lib/sbuild/chroot/facet/personality.cc \
diff --git a/lib/sbuild/chroot/facet/block-device.cc b/lib/sbuild/chroot/facet/block-device.cc
index 0d9f08f4..343f894b 100644
--- a/lib/sbuild/chroot/facet/block-device.cc
+++ b/lib/sbuild/chroot/facet/block-device.cc
@@ -20,6 +20,7 @@
#include <sbuild/chroot/facet/block-device.h>
#include <sbuild/chroot/facet/lvm-snapshot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include <sbuild/chroot/facet/source-clonable.h>
@@ -45,6 +46,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info block_device_info =
+ {
+ "block-device",
+ N_("Support for ‘block-device’ chroots"),
+ []() -> facet::ptr { return block_device::create(); }
+ };
+
+ factory block_device_register(block_device_info);
+
+ }
+
block_device::block_device ():
block_device_base()
{
diff --git a/lib/sbuild/chroot/facet/btrfs-snapshot.cc b/lib/sbuild/chroot/facet/btrfs-snapshot.cc
index f0c2ba3b..5a864628 100644
--- a/lib/sbuild/chroot/facet/btrfs-snapshot.cc
+++ b/lib/sbuild/chroot/facet/btrfs-snapshot.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/facet/btrfs-snapshot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include <sbuild/chroot/facet/session.h>
@@ -41,6 +42,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info btrfs_snapshot_info =
+ {
+ "btrfs-snapshot",
+ N_("Support for ‘btrfs-snapshot’ chroots"),
+ []() -> facet::ptr { return btrfs_snapshot::create(); }
+ };
+
+ factory btrfs_snapshot_register(btrfs_snapshot_info);
+
+ }
+
btrfs_snapshot::btrfs_snapshot ():
storage(),
source_subvolume(),
diff --git a/lib/sbuild/chroot/facet/btrfs-snapshot.h b/lib/sbuild/chroot/facet/btrfs-snapshot.h
index 5f92c9ed..bebb0e2f 100644
--- a/lib/sbuild/chroot/facet/btrfs-snapshot.h
+++ b/lib/sbuild/chroot/facet/btrfs-snapshot.h
@@ -30,7 +30,7 @@ namespace sbuild
{
/**
- * A chroot stored on an BTRFS subvolume.
+ * A chroot stored on a Btrfs subvolume.
*
* A snapshot subvolume will be created and mounted on demand.
*/
diff --git a/lib/sbuild/chroot/facet/custom.cc b/lib/sbuild/chroot/facet/custom.cc
index 806d69bf..1b0e45dd 100644
--- a/lib/sbuild/chroot/facet/custom.cc
+++ b/lib/sbuild/chroot/facet/custom.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/custom.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include <sbuild/chroot/facet/source-clonable.h>
@@ -39,6 +40,20 @@ namespace sbuild
namespace chroot
{
+ namespace
+ {
+
+ factory::facet_info custom_info =
+ {
+ "custom",
+ N_("Support for ‘custom’ chroots"),
+ []() -> facet::ptr { return custom::create(); }
+ };
+
+ factory custom_register(custom_info);
+
+ }
+
custom::custom ():
chroot(),
purgeable(false)
diff --git a/lib/sbuild/chroot/facet/directory-base.h b/lib/sbuild/chroot/facet/directory-base.h
index e52366b8..06ca907d 100644
--- a/lib/sbuild/chroot/facet/directory-base.h
+++ b/lib/sbuild/chroot/facet/directory-base.h
@@ -30,14 +30,16 @@ namespace sbuild
{
/**
- * A base class for block-device chroots.
+ * A base class for chroots located in a local directory.
*
- * This class doesn't implement a chroot (get_chroot_type
- * is not implemented).
+ * This class doesn't implement a chroot (get_chroot_type is not
+ * implemented). plain and directory chroots inherit from this
+ * class.
*
- * Originally lvm-snapshot inherited from the block-device chroot,
- * but this was changed when union support was introduced. This
- * design prevents lvm-snapshot offering union based sessions.
+ * Originally plain inherited from the directory chroot, but this
+ * had to be changed when union support was introduced. As plain
+ * chroots don't run any setup scripts and basically just call
+ * 'chroot' on a directory, they can't support union based sessions.
*/
class directory_base : public storage
{
diff --git a/lib/sbuild/chroot/facet/directory.cc b/lib/sbuild/chroot/facet/directory.cc
index 40597919..461c9edb 100644
--- a/lib/sbuild/chroot/facet/directory.cc
+++ b/lib/sbuild/chroot/facet/directory.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/facet/directory.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/fsunion.h>
#include <sbuild/chroot/facet/session.h>
#include "format-detail.h"
@@ -40,6 +41,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info directory_info =
+ {
+ "directory",
+ N_("Support for ‘directory’ chroots"),
+ []() -> facet::ptr { return directory::create(); }
+ };
+
+ factory directory_register(directory_info);
+
+ }
+
directory::directory ():
directory_base()
{
diff --git a/lib/sbuild/chroot/facet/directory.h b/lib/sbuild/chroot/facet/directory.h
index 4594783a..69af7c66 100644
--- a/lib/sbuild/chroot/facet/directory.h
+++ b/lib/sbuild/chroot/facet/directory.h
@@ -33,9 +33,10 @@ namespace sbuild
{
/**
- * A chroot stored on an unmounted block device.
+ * A chroot located in the filesystem.
*
- * The device will be mounted on demand.
+ * It runs setup scripts and can provide multiple sessions
+ * using the union facet.
*/
class directory : public directory_base
{
diff --git a/lib/sbuild/chroot/facet/factory.cc b/lib/sbuild/chroot/facet/factory.cc
new file mode 100644
index 00000000..8a842437
--- /dev/null
+++ b/lib/sbuild/chroot/facet/factory.cc
@@ -0,0 +1,80 @@
+/* Copyright © 2011-2013 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#include <config.h>
+
+#include <iostream>
+
+#include <sbuild/chroot/facet/factory.h>
+#include <sbuild/i18n.h>
+
+#include <boost/format.hpp>
+
+namespace sbuild
+{
+ namespace chroot
+ {
+ namespace facet
+ {
+
+ factory::factory(const facet_info& info)
+ {
+ registered_facets().insert(std::make_pair(info.name, &info));
+ }
+
+ factory::~factory()
+ {
+ }
+
+ std::ostream&
+ factory::print_facets(std::ostream& stream)
+ {
+ boost::format fmt(" %1$-17s %2%\n");
+
+ const map_type& facets = registered_facets();
+ for (const auto& facet : facets)
+ stream << fmt % facet.first % gettext(facet.second->description);
+
+ return stream;
+ }
+
+ facet::ptr
+ factory::create (const std::string& name)
+ {
+ facet::ptr ret;
+
+ const map_type& facets = registered_facets();
+
+ map_type::const_iterator info = facets.find(name);
+ if (info == facets.end())
+ throw chroot::error(name, chroot::FACET_INVALID);
+ ret = info->second->create();
+
+ return ret;
+ }
+
+ factory::map_type&
+ factory::registered_facets ()
+ {
+ static map_type facets;
+ return facets;
+ }
+
+ }
+ }
+}
diff --git a/lib/sbuild/chroot/facet/factory.h b/lib/sbuild/chroot/facet/factory.h
new file mode 100644
index 00000000..15e6ad4d
--- /dev/null
+++ b/lib/sbuild/chroot/facet/factory.h
@@ -0,0 +1,73 @@
+/* Copyright © 2011-2013 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#ifndef SBUILD_CHROOT_FACET_FACTORY_H
+#define SBUILD_CHROOT_FACET_FACTORY_H
+
+#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/facet.h>
+
+#include <map>
+#include <ostream>
+#include <string>
+
+namespace sbuild
+{
+ namespace chroot
+ {
+ namespace facet
+ {
+
+ class factory
+ {
+ public:
+ struct facet_info
+ {
+ std::string name;
+ std::string description;
+ facet::ptr (*create)();
+ };
+
+ factory (const facet_info& info);
+
+ ~factory ();
+
+ static std::ostream&
+ print_facets (std::ostream& stream);
+
+ static facet::ptr
+ create (const std::string& name);
+
+ private:
+ typedef std::map<std::string,const facet_info *> map_type;
+
+ static map_type&
+ registered_facets ();
+ };
+
+ }
+ }
+}
+
+#endif /* SBUILD_CHROOT_FACET_FACTORY_H */
+
+/*
+ * Local Variables:
+ * mode:C++
+ * End:
+ */
diff --git a/lib/sbuild/chroot/facet/file.cc b/lib/sbuild/chroot/facet/file.cc
index f58fdba5..2d289e69 100644
--- a/lib/sbuild/chroot/facet/file.cc
+++ b/lib/sbuild/chroot/facet/file.cc
@@ -18,6 +18,7 @@
#include <config.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/file.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/chroot/facet/session-clonable.h>
@@ -41,6 +42,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info file_info =
+ {
+ "file",
+ N_("Support for ‘file’ chroots"),
+ []() -> facet::ptr { return file::create(); }
+ };
+
+ factory file_register(file_info);
+
+ }
+
file::file ():
storage(),
filename(),
diff --git a/lib/sbuild/chroot/facet/fsunion.cc b/lib/sbuild/chroot/facet/fsunion.cc
index 31ed95fe..156bc1d4 100644
--- a/lib/sbuild/chroot/facet/fsunion.cc
+++ b/lib/sbuild/chroot/facet/fsunion.cc
@@ -20,6 +20,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/fsunion.h>
#include <sbuild/chroot/facet/source-clonable.h>
@@ -45,6 +46,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info fsunion_info =
+ {
+ "union",
+ N_("Support for filesystem unioning"),
+ []() -> facet::ptr { return fsunion::create(); }
+ };
+
+ factory fsunion_register(fsunion_info);
+
+ }
+
template<>
error<fsunion::error_code>::map_type
error<fsunion::error_code>::error_strings =
diff --git a/lib/sbuild/chroot/facet/loopback.cc b/lib/sbuild/chroot/facet/loopback.cc
index 22a4601d..fe2e7bd8 100644
--- a/lib/sbuild/chroot/facet/loopback.cc
+++ b/lib/sbuild/chroot/facet/loopback.cc
@@ -18,6 +18,7 @@
#include <config.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/fsunion.h>
#include <sbuild/chroot/facet/loopback.h>
#include <sbuild/chroot/facet/mountable.h>
@@ -40,6 +41,19 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+ factory::facet_info loopback_info =
+ {
+ "loopback",
+ N_("Support for ‘loopback’ chroots"),
+ []() -> facet::ptr { return loopback::create(); }
+ };
+
+ factory loopback_register(loopback_info);
+
+ }
+
loopback::loopback ():
storage(),
filename()
diff --git a/lib/sbuild/chroot/facet/lvm-snapshot.cc b/lib/sbuild/chroot/facet/lvm-snapshot.cc
index 3f66a41b..fbc97222 100644
--- a/lib/sbuild/chroot/facet/lvm-snapshot.cc
+++ b/lib/sbuild/chroot/facet/lvm-snapshot.cc
@@ -18,6 +18,7 @@
#include <config.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/block-device.h>
#include <sbuild/chroot/facet/lvm-snapshot.h>
#include <sbuild/chroot/facet/mountable.h>
@@ -42,6 +43,19 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+ factory::facet_info lvm_snapshot_info =
+ {
+ "lvm-snapshot",
+ N_("Support for ‘lvm-snapshot’ chroots"),
+ []() -> facet::ptr { return lvm_snapshot::create(); }
+ };
+
+ factory lvm_snapshot_register(lvm_snapshot_info);
+
+ }
+
lvm_snapshot::lvm_snapshot ():
block_device_base(),
snapshot_device(),
diff --git a/lib/sbuild/chroot/facet/mountable.cc b/lib/sbuild/chroot/facet/mountable.cc
index 5b2d6cc0..c58dba6c 100644
--- a/lib/sbuild/chroot/facet/mountable.cc
+++ b/lib/sbuild/chroot/facet/mountable.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/chroot/facet/session.h>
@@ -37,6 +38,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info mountable_info =
+ {
+ "mountable",
+ N_("Support for filesystem mounting"),
+ []() -> facet::ptr { return mountable::create(); }
+ };
+
+ factory mountable_register(mountable_info);
+
+ }
+
mountable::mountable ():
facet(),
mount_device(),
diff --git a/lib/sbuild/chroot/facet/personality.cc b/lib/sbuild/chroot/facet/personality.cc
index 8e78d7c4..8b985ebe 100644
--- a/lib/sbuild/chroot/facet/personality.cc
+++ b/lib/sbuild/chroot/facet/personality.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/personality.h>
#include <boost/format.hpp>
@@ -33,6 +34,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info personality_info =
+ {
+ "personality",
+ N_("Linux kernel Application Binary Interface switching"),
+ []() -> facet::ptr { return personality::create(); }
+ };
+
+ factory personality_register(personality_info);
+
+ }
+
personality::personality ():
facet(),
persona()
diff --git a/lib/sbuild/chroot/facet/plain.cc b/lib/sbuild/chroot/facet/plain.cc
index f97904ce..6bd5acbd 100644
--- a/lib/sbuild/chroot/facet/plain.cc
+++ b/lib/sbuild/chroot/facet/plain.cc
@@ -18,6 +18,7 @@
#include <config.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/plain.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include "format-detail.h"
@@ -39,6 +40,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info plain_info =
+ {
+ "plain",
+ N_("Support for ‘plain’ chroots"),
+ []() -> facet::ptr { return plain::create(); }
+ };
+
+ factory plain_register(plain_info);
+
+ }
+
plain::plain ():
directory_base()
{
diff --git a/lib/sbuild/chroot/facet/plain.h b/lib/sbuild/chroot/facet/plain.h
index 70c938ed..b5e68662 100644
--- a/lib/sbuild/chroot/facet/plain.h
+++ b/lib/sbuild/chroot/facet/plain.h
@@ -30,9 +30,11 @@ namespace sbuild
{
/**
- * A chroot stored on an unmounted block device.
+ * A chroot located in the filesystem (scripts disabled).
*
- * The device will be mounted on demand.
+ * This doesn't run any setup scripts and doesn't provide any
+ * session support. If you need any of these functions, the
+ * directory chroot type is more suited to your needs.
*/
class plain : public directory_base
{
diff --git a/lib/sbuild/chroot/facet/session-clonable.cc b/lib/sbuild/chroot/facet/session-clonable.cc
index 6479e61b..fc0af6aa 100644
--- a/lib/sbuild/chroot/facet/session-clonable.cc
+++ b/lib/sbuild/chroot/facet/session-clonable.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/session-clonable.h>
@@ -56,6 +57,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info session_clonable_info =
+ {
+ "session-clonable",
+ N_("Support for session chroot cloning"),
+ []() -> facet::ptr { return session_clonable::create(); }
+ };
+
+ factory session_clonable_register(session_clonable_info);
+
+ }
+
session_clonable::session_clonable ():
facet()
{
diff --git a/lib/sbuild/chroot/facet/session.cc b/lib/sbuild/chroot/facet/session.cc
index 2ebe37b9..f6a7f6a4 100644
--- a/lib/sbuild/chroot/facet/session.cc
+++ b/lib/sbuild/chroot/facet/session.cc
@@ -20,6 +20,7 @@
#include <sbuild/chroot/chroot.h>
#include <sbuild/chroot/config.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/keyfile-writer.h>
#include <sbuild/lock.h>
@@ -45,6 +46,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info session_info =
+ {
+ "session",
+ N_("Support for session chroots"),
+ []() -> facet::ptr { return session::create(); }
+ };
+
+ factory session_register(session_info);
+
+ }
+
session::session ():
facet(),
original_chroot_name(),
diff --git a/lib/sbuild/chroot/facet/source-clonable.cc b/lib/sbuild/chroot/facet/source-clonable.cc
index b02fabc2..52ddbaa9 100644
--- a/lib/sbuild/chroot/facet/source-clonable.cc
+++ b/lib/sbuild/chroot/facet/source-clonable.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/source-clonable.h>
#include <sbuild/chroot/facet/source.h>
@@ -39,6 +40,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info source_clonable_info =
+ {
+ "source-clonable",
+ N_("Support for source chroot cloning"),
+ []() -> facet::ptr { return source_clonable::create(); }
+ };
+
+ factory source_clonable_register(source_clonable_info);
+
+ }
+
source_clonable::source_clonable ():
facet(),
source_clone(true),
diff --git a/lib/sbuild/chroot/facet/source.cc b/lib/sbuild/chroot/facet/source.cc
index 723cc360..ef595b79 100644
--- a/lib/sbuild/chroot/facet/source.cc
+++ b/lib/sbuild/chroot/facet/source.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/source.h>
#include <cassert>
@@ -34,6 +35,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info source_info =
+ {
+ "source",
+ N_("Support for source chroots"),
+ []() -> facet::ptr { return source::create(); }
+ };
+
+ factory source_register(source_info);
+
+ }
+
source::source ():
facet()
{
diff --git a/lib/sbuild/chroot/facet/unshare.cc b/lib/sbuild/chroot/facet/unshare.cc
index 2bb86ee1..d90ff597 100644
--- a/lib/sbuild/chroot/facet/unshare.cc
+++ b/lib/sbuild/chroot/facet/unshare.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/unshare.h>
#include "feature.h"
@@ -49,6 +50,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info unshare_info =
+ {
+ "unshare",
+ N_("Linux dissassociation of shared execution context"),
+ []() -> facet::ptr { return unshare::create(); }
+ };
+
+ factory unshare_register(unshare_info);
+
+ }
+
template<>
error<unshare::error_code>::map_type
error<unshare::error_code>::error_strings =
diff --git a/lib/sbuild/chroot/facet/userdata.cc b/lib/sbuild/chroot/facet/userdata.cc
index 32aea626..19f26be3 100644
--- a/lib/sbuild/chroot/facet/userdata.cc
+++ b/lib/sbuild/chroot/facet/userdata.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/chroot/facet/userdata.h>
#include "regex.h"
@@ -75,6 +76,20 @@ namespace sbuild
namespace facet
{
+ namespace
+ {
+
+ factory::facet_info userdata_info =
+ {
+ "userdata",
+ N_("User setting of custom configuration parameters"),
+ []() -> facet::ptr { return userdata::create(); }
+ };
+
+ factory userdata_register(userdata_info);
+
+ }
+
template<>
error<userdata::error_code>::map_type
error<userdata::error_code>::error_strings =
diff --git a/lib/schroot-common/main.cc b/lib/schroot-common/main.cc
index 19406a51..850a11a6 100644
--- a/lib/schroot-common/main.cc
+++ b/lib/schroot-common/main.cc
@@ -26,6 +26,7 @@
#include <sbuild/auth/pam-conv.h>
#include <sbuild/auth/pam-conv-tty.h>
#endif // SBUILD_FEATURE_PAM
+#include <sbuild/chroot/facet/factory.h>
#include <sbuild/keyfile-writer.h>
#include <cstdlib>
@@ -78,26 +79,11 @@ main::action_version (std::ostream& stream)
{
bin_common::main::action_version(stream);
- format feature(" %1$-12s %2%\n");
-
stream << '\n'
- << _("Available chroot types:") << '\n';
-#ifdef SBUILD_FEATURE_BLOCKDEV
- stream << feature % "BLOCKDEV" % _("Support for ‘block-device’ chroots");
-#endif
-#ifdef SBUILD_FEATURE_BTRFSSNAP
- stream << feature % "BTRFSSNAP" % _("Support for ‘btrfs-snapshot’ chroots");
-#endif
- stream << feature % "CUSTOM" % _("Support for ‘custom’ chroots");
- stream << feature % "DIRECTORY" % _("Support for ‘directory’ chroots");
- stream << feature % "FILE" % _("Support for ‘file’ chroots");
-#ifdef SBUILD_FEATURE_LOOPBACK
- stream << feature % "LOOPBACK" % _("Support for ‘loopback’ chroots");
-#endif
-#ifdef SBUILD_FEATURE_LVMSNAP
- stream << feature % "LVMSNAP" % _("Support for ‘lvm-snapshot’ chroots");
-#endif
- stream << feature % "PLAIN" % _("Support for ‘plain’ chroots");
+ << _("Installed chroot facets:")
+ << '\n';
+ sbuild::chroot::facet::factory::print_facets(stream);
+
stream << std::flush;
}