summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2006-07-09 19:46:48 +0000
committerRoger Leigh <rleigh@debian.org>2006-07-09 19:46:48 +0000
commitcffa08d3863fe8cac865188806f6fa6429401103 (patch)
treeb8e425993a72a32a831d9aec45b4a0177249fb4a
parent8dd0e8dbe44811c0a846a802b8fc75feff110ec2 (diff)
downloadschroot-cffa08d3863fe8cac865188806f6fa6429401103.tar.gz
* NEWS: Document the new "directory" chroot type.
* schroot/schroot.conf.5.in, schroot/schroot-setup.5.in: Document new "directory" chroot type. * schroot/setup/00check, schroot/setup/10mount, schroot/setup/00check: Add logic for "directory" CHROOT_TYPE. The "directory" type will mount the chroot location with --rbind, like "plain", but will additionally mount filesystems like all other chroot types. * sbuild/Makefile.am: Add sbuild-chroot-directory.(cc|h). * sbuild/sbuild-chroot.cc (create): Add support for the "directory" chroot type. * sbuild/sbuild-chroot-plain.(cc|h): chroot_plain derives from chroot_directory. It is exactly the same as directory except for the chroot name. * sbuild/sbuild-chroot-directory.(cc|h): New files. The directory class is based upon the "plain" chroot type.
-rw-r--r--ChangeLog25
-rw-r--r--NEWS4
-rw-r--r--sbuild/Makefile.am2
-rw-r--r--sbuild/sbuild-chroot-directory.cc148
-rw-r--r--sbuild/sbuild-chroot-directory.h98
-rw-r--r--sbuild/sbuild-chroot-plain.cc86
-rw-r--r--sbuild/sbuild-chroot-plain.h46
-rw-r--r--sbuild/sbuild-chroot.cc5
-rwxr-xr-xschroot/exec/00check2
-rw-r--r--schroot/schroot-setup.5.in2
-rw-r--r--schroot/schroot.conf.5.in26
-rwxr-xr-xschroot/setup/00check4
-rwxr-xr-xschroot/setup/10mount4
13 files changed, 305 insertions, 147 deletions
diff --git a/ChangeLog b/ChangeLog
index 3434051e..673cd79a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
2006-07-09 Roger Leigh <rleigh@debian.org>
+ * NEWS: Document the new "directory" chroot type.
+
+ * schroot/schroot.conf.5.in, schroot/schroot-setup.5.in: Document
+ new "directory" chroot type.
+
+ * schroot/setup/00check, schroot/setup/10mount,
+ schroot/setup/00check: Add logic for "directory" CHROOT_TYPE. The
+ "directory" type will mount the chroot location with --rbind, like
+ "plain", but will additionally mount filesystems like all other
+ chroot types.
+
+ * sbuild/Makefile.am: Add sbuild-chroot-directory.(cc|h).
+
+ * sbuild/sbuild-chroot.cc (create): Add support for the
+ "directory" chroot type.
+
+ * sbuild/sbuild-chroot-plain.(cc|h): chroot_plain derives from
+ chroot_directory. It is exactly the same as directory except for
+ the chroot name.
+
+ * sbuild/sbuild-chroot-directory.(cc|h): New files. The directory
+ class is based upon the "plain" chroot type.
+
+2006-07-09 Roger Leigh <rleigh@debian.org>
+
* sbuild/sbuild-dirstream.h: The dirstream extraction operator is
declared outside the class, in addition to the friend declaration.
This fixes a compilation error with GCC 4.2. Thanks to Martin
diff --git a/NEWS b/NEWS
index d53b6a8a..064d78e3 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ configuration.
* Major changes in 0.99.3:
+ 1) A new chroot type, "directory", has been added. This is the same
+ as the "plain" type, but additionally allows filesystem mounting
+ when setup scripts are enabled.
+
* Major changes in 0.99.2:
1) A --debug option has been added to all programs. Its use is
diff --git a/sbuild/Makefile.am b/sbuild/Makefile.am
index 65f9fc84..beb2fe5e 100644
--- a/sbuild/Makefile.am
+++ b/sbuild/Makefile.am
@@ -37,6 +37,7 @@ sbuild_public_h_sources = \
sbuild-auth-message.h \
sbuild-chroot.h \
sbuild-chroot-block-device.h \
+ sbuild-chroot-directory.h \
sbuild-chroot-file.h \
sbuild-chroot-lvm-snapshot.h \
sbuild-chroot-plain.h \
@@ -69,6 +70,7 @@ sbuild_public_cc_sources = \
sbuild-auth-message.cc \
sbuild-chroot.cc \
sbuild-chroot-block-device.cc \
+ sbuild-chroot-directory.cc \
sbuild-chroot-file.cc \
sbuild-chroot-lvm-snapshot.cc \
sbuild-chroot-plain.cc \
diff --git a/sbuild/sbuild-chroot-directory.cc b/sbuild/sbuild-chroot-directory.cc
new file mode 100644
index 00000000..766b5389
--- /dev/null
+++ b/sbuild/sbuild-chroot-directory.cc
@@ -0,0 +1,148 @@
+/* Copyright © 2005-2006 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *********************************************************************/
+
+#include <config.h>
+
+#include "sbuild-chroot-directory.h"
+#include "sbuild-format-detail.h"
+#include "sbuild-lock.h"
+
+#include <cerrno>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
+
+using namespace sbuild;
+
+chroot_directory::chroot_directory ():
+ chroot()
+{
+}
+
+chroot_directory::~chroot_directory ()
+{
+}
+
+sbuild::chroot::ptr
+chroot_directory::clone () const
+{
+ return ptr(new chroot_directory(*this));
+}
+
+std::string const&
+chroot_directory::get_location () const
+{
+ return chroot::get_location();
+}
+
+void
+chroot_directory::set_location (std::string const& location)
+{
+ if (!is_absname(location))
+ throw error(location, LOCATION_ABS);
+
+ chroot::set_location(location);
+}
+
+std::string
+chroot_directory::get_path () const
+{
+ // When running setup scripts, we are session-capable, so the path
+ // is the bind-mounted location, rather than the original location.
+ if (get_run_setup_scripts() == true)
+ return get_mount_location();
+ else
+ return get_location();
+}
+
+std::string const&
+chroot_directory::get_chroot_type () const
+{
+ static const std::string type("directory");
+
+ return type;
+}
+
+void
+chroot_directory::setup_env (environment& env)
+{
+ this->chroot::setup_env(env);
+
+ env.add("CHROOT_LOCATION", get_location());
+}
+
+void
+chroot_directory::setup_lock (setup_type type,
+ bool lock,
+ int status)
+{
+ /* By default, directory chroots do no locking. */
+ /* Create or unlink session information. */
+ if (get_run_setup_scripts() == true)
+ {
+ if ((type == SETUP_START && lock == true) ||
+ (type == SETUP_STOP && lock == false && status == 0))
+ {
+ bool start = (type == SETUP_START);
+ setup_session_info(start);
+ }
+ }
+}
+
+sbuild::chroot::session_flags
+chroot_directory::get_session_flags () const
+{
+ if (get_run_setup_scripts() == true)
+ return SESSION_CREATE;
+ else
+ return static_cast<session_flags>(0);
+}
+
+void
+chroot_directory::get_details (format_detail& detail) const
+{
+ chroot::get_details(detail);
+}
+
+void
+chroot_directory::get_keyfile (keyfile& keyfile) const
+{
+ chroot::get_keyfile(keyfile);
+
+ keyfile::set_object_value(*this, &chroot_directory::get_location,
+ keyfile, get_name(), "location");
+}
+
+void
+chroot_directory::set_keyfile (keyfile const& keyfile)
+{
+ chroot::set_keyfile(keyfile);
+
+ keyfile::get_object_value(*this, &chroot_directory::set_location,
+ keyfile, get_name(), "location",
+ keyfile::PRIORITY_REQUIRED);
+}
+
+/*
+ * Local Variables:
+ * mode:C++
+ * End:
+ */
diff --git a/sbuild/sbuild-chroot-directory.h b/sbuild/sbuild-chroot-directory.h
new file mode 100644
index 00000000..736a6759
--- /dev/null
+++ b/sbuild/sbuild-chroot-directory.h
@@ -0,0 +1,98 @@
+/* Copyright © 2005-2006 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *********************************************************************/
+
+#ifndef SBUILD_CHROOT_DIRECTORY_H
+#define SBUILD_CHROOT_DIRECTORY_H
+
+#include <sbuild/sbuild-chroot.h>
+
+namespace sbuild
+{
+
+ /**
+ * A chroot located on a mounted filesystem.
+ */
+ class chroot_directory : virtual public chroot
+ {
+ protected:
+ /// The constructor.
+ chroot_directory ();
+
+ friend class chroot;
+
+ public:
+ /// The destructor.
+ virtual ~chroot_directory ();
+
+ virtual chroot::ptr
+ clone () const;
+
+ /**
+ * Get the directory location of the chroot.
+ *
+ * @returns the location.
+ */
+ virtual std::string const&
+ get_location () const;
+
+ /**
+ * Set the directory location of the chroot.
+ *
+ * @param location the location.
+ */
+ virtual void
+ set_location (std::string const& location);
+
+ virtual std::string
+ get_path () const;
+
+ virtual std::string const&
+ get_chroot_type () const;
+
+ virtual void
+ setup_env (environment& env);
+
+ virtual session_flags
+ get_session_flags () const;
+
+ protected:
+ virtual void
+ setup_lock (setup_type type,
+ bool lock,
+ int status);
+
+ virtual void
+ get_details (format_detail& detail) const;
+
+ virtual void
+ get_keyfile (keyfile& keyfile) const;
+
+ virtual void
+ set_keyfile (keyfile const& keyfile);
+ };
+
+}
+
+#endif /* SBUILD_CHROOT_DIRECTORY_H */
+
+/*
+ * Local Variables:
+ * mode:C++
+ * End:
+ */
diff --git a/sbuild/sbuild-chroot-plain.cc b/sbuild/sbuild-chroot-plain.cc
index af1588e7..2d489df8 100644
--- a/sbuild/sbuild-chroot-plain.cc
+++ b/sbuild/sbuild-chroot-plain.cc
@@ -48,32 +48,6 @@ chroot_plain::clone () const
}
std::string const&
-chroot_plain::get_location () const
-{
- return chroot::get_location();
-}
-
-void
-chroot_plain::set_location (std::string const& location)
-{
- if (!is_absname(location))
- throw error(location, LOCATION_ABS);
-
- chroot::set_location(location);
-}
-
-std::string
-chroot_plain::get_path () const
-{
- // When running setup scripts, we are session-capable, so the path
- // is the bind-mounted location, rather than the original location.
- if (get_run_setup_scripts() == true)
- return get_mount_location();
- else
- return get_location();
-}
-
-std::string const&
chroot_plain::get_chroot_type () const
{
static const std::string type("plain");
@@ -81,66 +55,6 @@ chroot_plain::get_chroot_type () const
return type;
}
-void
-chroot_plain::setup_env (environment& env)
-{
- this->chroot::setup_env(env);
-
- env.add("CHROOT_LOCATION", get_location());
-}
-
-void
-chroot_plain::setup_lock (setup_type type,
- bool lock,
- int status)
-{
- /* By default, plain chroots do no locking. */
- /* Create or unlink session information. */
- if (get_run_setup_scripts() == true)
- {
- if ((type == SETUP_START && lock == true) ||
- (type == SETUP_STOP && lock == false && status == 0))
- {
- bool start = (type == SETUP_START);
- setup_session_info(start);
- }
- }
-}
-
-sbuild::chroot::session_flags
-chroot_plain::get_session_flags () const
-{
- if (get_run_setup_scripts() == true)
- return SESSION_CREATE;
- else
- return static_cast<session_flags>(0);
-}
-
-void
-chroot_plain::get_details (format_detail& detail) const
-{
- chroot::get_details(detail);
-}
-
-void
-chroot_plain::get_keyfile (keyfile& keyfile) const
-{
- chroot::get_keyfile(keyfile);
-
- keyfile::set_object_value(*this, &chroot_plain::get_location,
- keyfile, get_name(), "location");
-}
-
-void
-chroot_plain::set_keyfile (keyfile const& keyfile)
-{
- chroot::set_keyfile(keyfile);
-
- keyfile::get_object_value(*this, &chroot_plain::set_location,
- keyfile, get_name(), "location",
- keyfile::PRIORITY_REQUIRED);
-}
-
/*
* Local Variables:
* mode:C++
diff --git a/sbuild/sbuild-chroot-plain.h b/sbuild/sbuild-chroot-plain.h
index 0a52ca07..ea958b86 100644
--- a/sbuild/sbuild-chroot-plain.h
+++ b/sbuild/sbuild-chroot-plain.h
@@ -20,15 +20,15 @@
#ifndef SBUILD_CHROOT_PLAIN_H
#define SBUILD_CHROOT_PLAIN_H
-#include <sbuild/sbuild-chroot.h>
+#include <sbuild/sbuild-chroot-directory.h>
namespace sbuild
{
/**
- * A chroot located on a mounted filesystem.
+ * A chroot located on a mounted filesystem (mounts disabled).
*/
- class chroot_plain : virtual public chroot
+ class chroot_plain : public chroot_directory
{
protected:
/// The constructor.
@@ -43,48 +43,8 @@ namespace sbuild
virtual chroot::ptr
clone () const;
- /**
- * Get the directory location of the chroot.
- *
- * @returns the location.
- */
- virtual std::string const&
- get_location () const;
-
- /**
- * Set the directory location of the chroot.
- *
- * @param location the location.
- */
- virtual void
- set_location (std::string const& location);
-
- virtual std::string
- get_path () const;
-
virtual std::string const&
get_chroot_type () const;
-
- virtual void
- setup_env (environment& env);
-
- virtual session_flags
- get_session_flags () const;
-
- protected:
- virtual void
- setup_lock (setup_type type,
- bool lock,
- int status);
-
- virtual void
- get_details (format_detail& detail) const;
-
- virtual void
- get_keyfile (keyfile& keyfile) const;
-
- virtual void
- set_keyfile (keyfile const& keyfile);
};
}
diff --git a/sbuild/sbuild-chroot.cc b/sbuild/sbuild-chroot.cc
index 4932a229..39844114 100644
--- a/sbuild/sbuild-chroot.cc
+++ b/sbuild/sbuild-chroot.cc
@@ -20,6 +20,7 @@
#include <config.h>
#include "sbuild-chroot.h"
+#include "sbuild-chroot-directory.h"
#include "sbuild-chroot-plain.h"
#include "sbuild-chroot-file.h"
#include "sbuild-chroot-block-device.h"
@@ -118,7 +119,9 @@ sbuild::chroot::create (std::string const& type)
{
chroot *new_chroot = 0;
- if (type == "plain")
+ if (type == "directory")
+ new_chroot = new chroot_directory();
+ else if (type == "plain")
new_chroot = new chroot_plain();
else if (type == "file")
new_chroot = new chroot_file();
diff --git a/schroot/exec/00check b/schroot/exec/00check
index b45fa187..1e76bd66 100755
--- a/schroot/exec/00check
+++ b/schroot/exec/00check
@@ -16,7 +16,7 @@ if [ $1 = "exec-start" ]; then
echo "CHROOT_LOCATION=$CHROOT_LOCATION"
echo "CHROOT_PATH=$CHROOT_PATH"
echo "CHROOT_MOUNT_DEVICE=$CHROOT_MOUNT_DEVICE"
- if [ "$CHROOT_TYPE" = "plain" ]; then
+ if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
:
elif [ "$CHROOT_TYPE" = "file" ]; then
echo "CHROOT_FILE=$CHROOT_FILE"
diff --git a/schroot/schroot-setup.5.in b/schroot/schroot-setup.5.in
index c1bcc3ba..646372a4 100644
--- a/schroot/schroot-setup.5.in
+++ b/schroot/schroot-setup.5.in
@@ -104,7 +104,7 @@ to access the chroots.
CHROOT_MOUNT_DEVICE
The device containing the chroot root filesystem. This is only set for chroots
which require mounting.
-.SS Plain chroot variables
+.SS Plain and directory chroot variables
.TP
CHROOT_LOCATION
The location of the chroot. This is useful for creating files, or copying
diff --git a/schroot/schroot.conf.5.in b/schroot/schroot.conf.5.in
index 1382f10e..49eea95f 100644
--- a/schroot/schroot.conf.5.in
+++ b/schroot/schroot.conf.5.in
@@ -43,9 +43,9 @@ For example,
This is then followed by several key-value pairs:
.TP
.B type=\fItype\fP
-The type of the chroot. Valid types are \[lq]plain\[rq], \[lq]file\[rq],
-\[lq]block\-device\[rq] and \[lq]lvm\-snapshot\[rq]. If empty or omitted, the
-default type is \[lq]plain\[rq].
+The type of the chroot. Valid types are \[lq]plain\[rq], \[lq]directory\[rq],
+\[lq]file\[rq], \[lq]block\-device\[rq] and \[lq]lvm\-snapshot\[rq]. If empty
+or omitted, the default type is \[lq]plain\[rq].
.TP
.B description=\fIdescription\fP
A short description of the chroot. This may be localised for different
@@ -92,11 +92,12 @@ Set whether chroot setup scripts will be run. The default is not to run setup
scripts (\[lq]false\[rq]), for safety reasons (so it won't clobber your passwd
and other critical files). The default for session-managed chroots
(\[lq]file\[rq] and \[lq]lvm\-snapshot\[rq]) is to run setup scripts. If
-\fItype\fP is set to a value other than \[lq]plain\[rq], setup scripts are
-\fBrequired\fP to mount and configure the chroot environment. If enabled for a
-\[lq]plain\[rq] chroot, the chroot will support simple session management (not
-true session management, because it does not make a copy of the chroot). If
-your chroots are exclusively controlled by schroot, set to \[lq]true\[rq].
+\fItype\fP is set to a value other than \[lq]plain\[rq] or \[lq]directory\[rq],
+setup scripts are \fBrequired\fP to mount and configure the chroot environment.
+If enabled for a \[lq]plain\[rq] or \[lq]directory\[rq] chroot, the chroot will
+support simple session management (not true session management, because it does
+not make a copy of the chroot). If your chroots are exclusively controlled by
+schroot, set to \[lq]true\[rq].
.TP
.B run\-exec\-scripts=\fItrue\fP|\fIfalse\fP
Set whether chroot execution scripts will be run. The default is the same as
@@ -120,10 +121,13 @@ Linux are \[lq]bsd\[rq], \[lq]hpux\[rq], \[lq]irix32\[rq], \[lq]irix64\[rq],
\[lq]linux32\[rq], is the option required. The only valid option for non-Linux
systems is \[lq]undefined\[rq]. The default value is \[lq]undefined\[rq].
.SS
-Plain chroots
+Plain and directory chroots
.PP
-Chroots of type \[lq]plain\[rq] are directories accessible in the filesystem.
-They have an additional (mandatory) configuration option:
+Chroots of type \[lq]plain\[rq] or \[lq]directory\[rq] are directories
+accessible in the filesystem. The two types are equivalent except for the fact
+that if \fIrun-setup-scripts\fP is set to \[lq]true\[rq] for plain chroots,
+filesystem mounting is disabled. They have an additional (mandatory)
+configuration option:
.TP
.B location=\fIdirectory\fP
The directory containing the chroot environment. This is where the root will
diff --git a/schroot/setup/00check b/schroot/setup/00check
index 61b31aab..2c0a57da 100755
--- a/schroot/setup/00check
+++ b/schroot/setup/00check
@@ -16,7 +16,7 @@ if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
echo "CHROOT_LOCATION=$CHROOT_LOCATION"
echo "CHROOT_PATH=$CHROOT_PATH"
echo "CHROOT_MOUNT_DEVICE=$CHROOT_MOUNT_DEVICE"
- if [ "$CHROOT_TYPE" = "plain" ]; then
+ if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
:
elif [ "$CHROOT_TYPE" = "file" ]; then
echo "CHROOT_FILE=$CHROOT_FILE"
@@ -33,7 +33,7 @@ if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
fi
case "$CHROOT_TYPE" in
- plain)
+ plain | directory)
if [ ! -d "$CHROOT_LOCATION" ]; then
echo "Directory '$CHROOT_LOCATION' does not exist"
exit 1
diff --git a/schroot/setup/10mount b/schroot/setup/10mount
index 10470384..9ab1c82e 100755
--- a/schroot/setup/10mount
+++ b/schroot/setup/10mount
@@ -41,9 +41,9 @@ if [ "$AUTH_VERBOSITY" = "verbose" ]; then
# FSCK_VERBOSE="-V"
fi
-if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
+if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
- if [ "$CHROOT_TYPE" = "plain" ]; then
+ if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ]; then
CHROOT_MOUNT_OPTIONS="--rbind"
CHROOT_MOUNT_DEVICE="$CHROOT_LOCATION"
fi