[buildd-tools-devel] [PATCH 14/17] [chroot_fs_union] Configure fs union support
Jan-Marek Glogowski
glogow at fbihome.de
Tue Jun 30 18:05:52 UTC 2009
Add configure switch to disable fs union support.
---
configure.ac | 28 ++++++++++++++++++++++++++++
sbuild/Makefile.am | 16 +++++++++++++---
sbuild/sbuild-chroot-block-device.cc | 14 ++++++++++++++
sbuild/sbuild-chroot-directory.cc | 18 +++++++++++++++++-
sbuild/sbuild-chroot-loopback.cc | 20 ++++++++++++++++++--
sbuild/sbuild-session.cc | 6 +++++-
6 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1b29cff..2b3f719 100644
--- a/configure.ac
+++ b/configure.ac
@@ -219,6 +219,17 @@ AC_ARG_ENABLE([uuid], [AS_HELP_STRING([--enable-uuid], [Enable support for UUIDs
[enable_uuid="auto"])
AC_MSG_RESULT([$enable_uuid])
+AC_MSG_CHECKING([whether to enable support for union mounts])
+AC_ARG_ENABLE([union], [AS_HELP_STRING([--enable-union], [Enable support for union mounts])],
+ [ case "${enableval}" in
+ yes) enable_union="yes" ;;
+ no) enable_union="no" ;;
+ *) AC_MSG_RESULT([unknown])
+ AC_MSG_ERROR([bad value ${enableval} for --enable-union]) ;;
+ esac],
+ [enable_union="auto"])
+AC_MSG_RESULT([$enable_union])
+
AC_MSG_CHECKING([whether to enable doxygen documentation])
AC_ARG_ENABLE([doxygen], [AS_HELP_STRING([--enable-doxygen], [Enable doxygen documentation])],
[ case "${enableval}" in
@@ -470,6 +481,23 @@ if test "$BUILD_LOOPBACK" = "yes"; then
AC_DEFINE(SBUILD_FEATURE_LOOPBACK, 1)
fi
+AC_MSG_CHECKING([whether to build union support])
+BUILD_UNION="yes"
+if test "$enable_unionshot" = "yes"; then
+ :
+elif test "$enable_unionshot" = "no"; then
+ BUILD_UNION="no"
+elif test "$enable_unionshot" = "auto"; then
+ BUILD_UNION="yes"
+fi
+AC_MSG_RESULT([$BUILD_UNION])
+
+AM_CONDITIONAL([BUILD_UNION], [test "$BUILD_UNION" = "yes"])
+AH_TEMPLATE(SBUILD_FEATURE_UNION, [Set if the union filesystem type is present])
+if test "$BUILD_UNION" = "yes"; then
+ AC_DEFINE(SBUILD_FEATURE_UNION, 1)
+fi
+
AC_MSG_CHECKING([for boost::program_options::variables_map in -lboost_program_options-mt])
saved_LIBS="${LIBS}"
LIBS="${LIBS} -lboost_program_options-mt"
diff --git a/sbuild/Makefile.am b/sbuild/Makefile.am
index c8cb481..5c29893 100644
--- a/sbuild/Makefile.am
+++ b/sbuild/Makefile.am
@@ -34,7 +34,6 @@ sbuild_public_h_sources = \
sbuild-chroot-block-device.h \
sbuild-chroot-directory.h \
sbuild-chroot-file.h \
- sbuild-chroot-fs-union.h \
sbuild-chroot-mountable.h \
sbuild-chroot-plain.h \
sbuild-chroot-source.h \
@@ -89,13 +88,17 @@ sbuild_public_loopback_h_sources = \
sbuild-chroot-loopback.h
endif
+if BUILD_UNION
+sbuild_public_union_h_sources = \
+ sbuild-chroot-fs-union.h
+endif
+
sbuild_public_cc_sources = \
sbuild-auth.cc \
sbuild-auth-null.cc \
sbuild-chroot.cc \
sbuild-chroot-directory.cc \
sbuild-chroot-file.cc \
- sbuild-chroot-fs-union.cc \
sbuild-chroot-mountable.cc \
sbuild-chroot-plain.cc \
sbuild-chroot-source.cc \
@@ -140,6 +143,11 @@ sbuild_public_loopback_cc_sources = \
sbuild-chroot-loopback.cc
endif
+if BUILD_UNION
+sbuild_public_union_cc_sources = \
+ sbuild-chroot-fs-union.cc
+endif
+
pkgincludedir = $(includedir)/sbuild
pkginclude_HEADERS = \
@@ -156,7 +164,9 @@ libsbuild_la_SOURCES = \
$(sbuild_public_lvmsnap_h_sources) \
$(sbuild_public_lvmsnap_cc_sources) \
$(sbuild_public_loopback_h_sources) \
- $(sbuild_public_loopback_cc_sources)
+ $(sbuild_public_loopback_cc_sources) \
+ $(sbuild_public_union_h_sources) \
+ $(sbuild_public_union_cc_sources)
nodist_libsbuild_la_SOURCES = \
sbuild-config.h
diff --git a/sbuild/sbuild-chroot-block-device.cc b/sbuild/sbuild-chroot-block-device.cc
index fe279b7..f5b47fb 100644
--- a/sbuild/sbuild-chroot-block-device.cc
+++ b/sbuild/sbuild-chroot-block-device.cc
@@ -33,7 +33,9 @@ using namespace sbuild;
chroot_block_device::chroot_block_device ():
chroot(),
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union(),
+#endif
chroot_mountable(),
device()
{
@@ -54,10 +56,12 @@ chroot_block_device::clone_source () const
{
ptr clone;
+#ifdef SBUILD_FEATURE_UNION
if (get_fs_union_configured()) {
clone = ptr(new chroot_block_device(*this));
chroot_source::clone_source_setup(clone);
}
+#endif
return ptr(clone);
}
@@ -108,7 +112,9 @@ void
chroot_block_device::setup_env (environment& env)
{
chroot::setup_env(env);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::setup_env(env);
+#endif
chroot_mountable::setup_env(env);
env.add("CHROOT_DEVICE", get_device());
@@ -176,7 +182,9 @@ sbuild::chroot::session_flags
chroot_block_device::get_session_flags () const
{
return SESSION_NOFLAGS
+#ifdef SBUILD_FEATURE_UNION
| chroot_fs_union::get_session_flags()
+#endif
| chroot_mountable::get_session_flags();
}
@@ -184,7 +192,9 @@ void
chroot_block_device::get_details (format_detail& detail) const
{
chroot::get_details(detail);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_details(detail);
+#endif
chroot_mountable::get_details(detail);
if (!this->device.empty())
@@ -195,7 +205,9 @@ void
chroot_block_device::get_keyfile (keyfile& keyfile) const
{
chroot::get_keyfile(keyfile);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_keyfile(keyfile);
+#endif
chroot_mountable::get_keyfile(keyfile);
keyfile::set_object_value(*this, &chroot_block_device::get_device,
@@ -207,7 +219,9 @@ chroot_block_device::set_keyfile (keyfile const& keyfile,
string_list& used_keys)
{
chroot::set_keyfile(keyfile, used_keys);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::set_keyfile(keyfile, used_keys);
+#endif
chroot_mountable::set_keyfile(keyfile, used_keys);
keyfile::get_object_value(*this, &chroot_block_device::set_device,
diff --git a/sbuild/sbuild-chroot-directory.cc b/sbuild/sbuild-chroot-directory.cc
index 2859cc9..1aff50e 100644
--- a/sbuild/sbuild-chroot-directory.cc
+++ b/sbuild/sbuild-chroot-directory.cc
@@ -32,8 +32,12 @@
using namespace sbuild;
chroot_directory::chroot_directory ():
- chroot_fs_union(),
+#ifdef SBUILD_FEATURE_UNION
+ chroot_plain(),
+ chroot_fs_union()
+#else
chroot_plain()
+#endif
{
set_run_setup_scripts(true);
}
@@ -53,10 +57,12 @@ chroot_directory::clone_source () const
{
ptr clone;
+#ifdef SBUILD_FEATURE_UNION
if (get_fs_union_configured()) {
clone = ptr(new chroot_directory(*this));
chroot_source::clone_source_setup(clone);
}
+#endif
return ptr(clone);
}
@@ -70,7 +76,9 @@ chroot_directory::get_path () const
void
chroot_directory::setup_env (environment& env)
{
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::setup_env(env);
+#endif
chroot_plain::setup_env(env);
}
@@ -99,22 +107,28 @@ chroot_directory::setup_lock (chroot::setup_type type,
sbuild::chroot::session_flags
chroot_directory::get_session_flags () const
{
+#ifdef SBUILD_FEATURE_UNION
if (get_fs_union_configured())
return chroot_fs_union::get_session_flags();
+#endif
return SESSION_CREATE;
}
void
chroot_directory::get_details (format_detail& detail) const
{
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_details(detail);
+#endif
chroot_plain::get_details(detail);
}
void
chroot_directory::get_keyfile (keyfile& keyfile) const
{
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_keyfile(keyfile);
+#endif
chroot_plain::get_keyfile(keyfile);
}
@@ -122,6 +136,8 @@ void
chroot_directory::set_keyfile (keyfile const& keyfile,
string_list& used_keys)
{
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::set_keyfile(keyfile, used_keys);
+#endif
chroot_plain::set_keyfile(keyfile, used_keys);
}
diff --git a/sbuild/sbuild-chroot-loopback.cc b/sbuild/sbuild-chroot-loopback.cc
index 12e0a1e..607f194 100644
--- a/sbuild/sbuild-chroot-loopback.cc
+++ b/sbuild/sbuild-chroot-loopback.cc
@@ -33,7 +33,9 @@ using namespace sbuild;
chroot_loopback::chroot_loopback ():
chroot(),
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union(),
+#endif
chroot_mountable(),
file()
{
@@ -54,10 +56,12 @@ chroot_loopback::clone_source () const
{
ptr clone;
+#ifdef SBUILD_FEATURE_UNION
if (get_fs_union_configured()) {
clone = ptr(new chroot_loopback(*this));
chroot_source::clone_source_setup(clone);
}
+#endif
return ptr(clone);
}
@@ -107,7 +111,9 @@ void
chroot_loopback::setup_env (environment& env)
{
chroot::setup_env(env);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::setup_env(env);
+#endif
chroot_mountable::setup_env(env);
env.add("CHROOT_FILE", get_file());
@@ -132,6 +138,7 @@ chroot_loopback::setup_lock (chroot::setup_type type,
throw chroot::error(this->file, FILE_NOTREG);
}
+#ifdef SBUILD_FEATURE_UNION
/**
* By default, loopback chroots do no locking, but can create sessions
* using filesystem unions.
@@ -143,21 +150,26 @@ chroot_loopback::setup_lock (chroot::setup_type type,
bool start = (type == SETUP_START);
setup_session_info(start);
}
+#endif
}
sbuild::chroot::session_flags
chroot_loopback::get_session_flags () const
{
return SESSION_NOFLAGS
- | chroot_mountable::get_session_flags()
- | chroot_fs_union::get_session_flags();
+#ifdef SBUILD_FEATURE_UNION
+ | chroot_fs_union::get_session_flags()
+#endif
+ | chroot_mountable::get_session_flags();
}
void
chroot_loopback::get_details (format_detail& detail) const
{
chroot::get_details(detail);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_details(detail);
+#endif
chroot_mountable::get_details(detail);
if (!this->file.empty())
@@ -168,7 +180,9 @@ void
chroot_loopback::get_keyfile (keyfile& keyfile) const
{
chroot::get_keyfile(keyfile);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::get_keyfile(keyfile);
+#endif
chroot_mountable::get_keyfile(keyfile);
keyfile::set_object_value(*this, &chroot_loopback::get_file,
@@ -180,7 +194,9 @@ chroot_loopback::set_keyfile (keyfile const& keyfile,
string_list& used_keys)
{
chroot::set_keyfile(keyfile, used_keys);
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union::set_keyfile(keyfile, used_keys);
+#endif
chroot_mountable::set_keyfile(keyfile, used_keys);
keyfile::get_object_value(*this, &chroot_loopback::set_file,
diff --git a/sbuild/sbuild-session.cc b/sbuild/sbuild-session.cc
index 172251b..0dea8bc 100644
--- a/sbuild/sbuild-session.cc
+++ b/sbuild/sbuild-session.cc
@@ -24,7 +24,9 @@
#ifdef SBUILD_FEATURE_LVMSNAP
#include "sbuild-chroot-lvm-snapshot.h"
#endif // SBUILD_FEATURE_LVMSNAP
+#ifdef SBUILD_FEATURE_UNION
#include "sbuild-chroot-fs-union.h"
+#endif // SBUILD_FEATURE_UNION
#include "sbuild-ctty.h"
#include "sbuild-run-parts.h"
#include "sbuild-session.h"
@@ -638,7 +640,7 @@ session::run_impl ()
#ifdef SBUILD_FEATURE_LVMSNAP
/* LVM devices need the snapshot device name specifying. */
- chroot_lvm_snapshot *snapshot = 0;
+ chroot_lvm_snapshot *snapshot;
if ((snapshot = dynamic_cast<chroot_lvm_snapshot *>(chroot.get())) != 0)
{
std::string dir(dirname(snapshot->get_device(), '/'));
@@ -647,6 +649,7 @@ session::run_impl ()
}
#endif // SBUILD_FEATURE_LVMSNAP
+#ifdef SBUILD_FEATURE_UNION
chroot_fs_union *fsunion;
if ((fsunion = dynamic_cast<chroot_fs_union *>(chroot.get())) != 0)
{
@@ -658,6 +661,7 @@ session::run_impl ()
underlay += "/" + this->session_id;
fsunion->set_fs_union_underlay_directory(underlay);
}
+#endif // SBUILD_FEATURE_UNION
try
{
--
1.6.3.2
More information about the Buildd-tools-devel
mailing list