summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-04-28 15:09:40 +0100
committerRoger Leigh <rleigh@debian.org>2013-05-04 17:17:17 +0100
commit82df78af4c5fa44642ed36f549f84267ec67f2c9 (patch)
tree8867a18dd6de074732d82c6218579f3aad346156 /lib
parent621574f3b5a314dff4cd15d766bbe84bec29d22e (diff)
downloadschroot-82df78af4c5fa44642ed36f549f84267ec67f2c9.tar.gz
sbuild::chroot: Migrate file to storage facet
Diffstat (limited to 'lib')
-rw-r--r--lib/sbuild/Makefile.am2
-rw-r--r--lib/sbuild/chroot/facet/file.cc468
-rw-r--r--lib/sbuild/chroot/facet/file.h270
-rw-r--r--lib/sbuild/chroot/file.cc199
-rw-r--r--lib/sbuild/chroot/file.h94
5 files changed, 378 insertions, 655 deletions
diff --git a/lib/sbuild/Makefile.am b/lib/sbuild/Makefile.am
index b23c5300..498a9971 100644
--- a/lib/sbuild/Makefile.am
+++ b/lib/sbuild/Makefile.am
@@ -27,6 +27,7 @@ lib_sbuild_public_h_sources = \
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/mountable.h \
@@ -120,6 +121,7 @@ lib_sbuild_public_cc_sources = \
lib/sbuild/chroot/facet/btrfs-snapshot.cc \
lib/sbuild/chroot/facet/directory.cc \
lib/sbuild/chroot/facet/facet.cc \
+ lib/sbuild/chroot/facet/file.cc \
lib/sbuild/chroot/facet/directory-base.cc \
lib/sbuild/chroot/facet/mountable.cc \
lib/sbuild/chroot/facet/personality.cc \
diff --git a/lib/sbuild/chroot/facet/file.cc b/lib/sbuild/chroot/facet/file.cc
index c4d948e0..f58fdba5 100644
--- a/lib/sbuild/chroot/facet/file.cc
+++ b/lib/sbuild/chroot/facet/file.cc
@@ -18,19 +18,19 @@
#include <config.h>
-#include <sbuild/chroot/file.h>
-#include <sbuild/chroot/facet/session.h>
+#include <sbuild/chroot/facet/file.h>
+#include <sbuild/chroot/facet/mountable.h>
#include <sbuild/chroot/facet/session-clonable.h>
+#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/source-clonable.h>
#include "format-detail.h"
-#include "lock.h"
#include <cassert>
#include <cerrno>
-#include <cstring>
#include <boost/format.hpp>
+using std::endl;
using boost::format;
using namespace sbuild;
@@ -38,247 +38,231 @@ namespace sbuild
{
namespace chroot
{
-
- file::file ():
- chroot(),
- filename(),
- location(),
- repack(false)
- {
- add_facet(facet::source_clonable::create());
- }
-
- file::file (const file& rhs):
- chroot(rhs),
- filename(rhs.filename),
- location(rhs.location),
- repack(rhs.repack)
- {
- }
-
- file::~file ()
- {
- }
-
- chroot::chroot::ptr
- file::clone () const
- {
- return ptr(new file(*this));
- }
-
- chroot::chroot::ptr
- file::clone_session (std::string const& session_id,
- std::string const& alias,
- std::string const& user,
- bool root) const
- {
- facet::session_clonable::const_ptr psess
- (get_facet<facet::session_clonable>());
- assert(psess);
-
- ptr session(new file(*this));
- psess->clone_session_setup(*this, session, session_id, alias, user, root);
-
- return session;
- }
-
- chroot::chroot::ptr
- file::clone_source () const
- {
- file *clone_file = new file(*this);
- ptr clone(clone_file);
-
- facet::source_clonable::const_ptr psrc
- (get_facet<facet::source_clonable>());
- assert(psrc);
-
- psrc->clone_source_setup(*this, clone);
- clone_file->repack = true;
-
- return clone;
- }
-
- std::string const&
- file::get_filename () const
- {
- return this->filename;
- }
-
- void
- file::set_filename (std::string const& filename)
- {
- if (!is_absname(filename))
- throw error(filename, FILE_ABS);
-
- this->filename = filename;
- }
-
- std::string const&
- file::get_location () const
- {
- return this->location;
- }
-
- void
- file::set_location (std::string const& location)
- {
- if (!location.empty() && !is_absname(location))
- throw chroot::error(location, chroot::LOCATION_ABS);
-
- this->location = location;
- }
-
- bool
- file::get_file_repack () const
- {
- return this->repack;
- }
-
- void
- file::set_file_repack (bool repack)
- {
- this->repack = repack;
- }
-
- std::string
- file::get_path () const
- {
- std::string path(get_mount_location());
-
- if (!get_location().empty())
- path += get_location();
-
- return path;
- }
-
- std::string const&
- file::get_chroot_type () const
- {
- static const std::string type("file");
-
- return type;
- }
-
- void
- file::setup_env (chroot const& chroot,
- environment& env) const
- {
- chroot::setup_env(chroot, env);
-
- env.add("CHROOT_FILE", get_filename());
- env.add("CHROOT_LOCATION", get_location());
- env.add("CHROOT_FILE_REPACK", this->repack);
- env.add("CHROOT_FILE_UNPACK_DIR", SCHROOT_FILE_UNPACK_DIR);
- }
-
- void
- file::setup_lock (chroot::setup_type type,
- bool lock,
- int status)
- {
- // Check ownership and permissions.
- if (type == SETUP_START && lock == true)
- {
- stat file_status(this->filename);
-
- // NOTE: taken from chroot_config::check_security.
- if (file_status.uid() != 0)
- throw error(this->filename, FILE_OWNER);
- if (file_status.check_mode(stat::PERM_OTHER_WRITE))
- throw error(this->filename, FILE_PERMS);
- if (!file_status.is_regular())
- throw error(this->filename, FILE_NOTREG);
- }
-
- /* By default, file chroots do no locking. */
- /* Create or unlink session information. */
- if ((type == SETUP_START && lock == true) ||
- (type == SETUP_STOP && lock == false && status == 0))
- {
-
- bool start = (type == SETUP_START);
- setup_session_info(start);
- }
- }
-
- chroot::chroot::session_flags
- file::get_session_flags (chroot const& chroot) const
- {
- session_flags flags = SESSION_NOFLAGS;
-
- if (chroot.get_facet<facet::session>())
- flags = SESSION_PURGE;
-
- return flags;
- }
-
- void
- file::get_details (chroot const& chroot,
- format_detail& detail) const
+ namespace facet
{
- chroot::get_details(chroot, detail);
-
- if (!this->filename.empty())
- detail
- .add(_("File"), get_filename())
- .add(_("File Repack"), this->repack);
- if (!get_location().empty())
- detail.add(_("Location"), get_location());
- }
- void
- file::get_used_keys (string_list& used_keys) const
- {
- chroot::get_used_keys(used_keys);
+ file::file ():
+ storage(),
+ filename(),
+ location(),
+ repack(false)
+ {
+ }
+
+ file::file (const file& rhs):
+ storage(rhs),
+ filename(rhs.filename),
+ location(rhs.location),
+ repack(rhs.repack)
+ {
+ }
+
+ file::~file ()
+ {
+ }
+
+ void
+ file::set_chroot (chroot& chroot)
+ {
+ storage::set_chroot(chroot);
+ if (!owner->get_facet<source_clonable>())
+ owner->add_facet(source_clonable::create());
+ }
+
+ std::string const&
+ file::get_name () const
+ {
+ static const std::string name("file");
+
+ return name;
+ }
+
+ file::ptr
+ file::create ()
+ {
+ return ptr(new file());
+ }
+
+ facet::ptr
+ file::clone () const
+ {
+ return ptr(new file(*this));
+ }
+
+ std::string const&
+ file::get_filename () const
+ {
+ return this->filename;
+ }
+
+ void
+ file::set_filename (std::string const& filename)
+ {
+ if (!is_absname(filename))
+ throw error(filename, chroot::FILE_ABS);
+
+ this->filename = filename;
+ }
+
+ std::string const&
+ file::get_location () const
+ {
+ return this->location;
+ }
+
+ void
+ file::set_location (std::string const& location)
+ {
+ if (!location.empty() && !is_absname(location))
+ throw chroot::error(location, chroot::LOCATION_ABS);
+
+ this->location = location;
+ }
+
+ bool
+ file::get_file_repack () const
+ {
+ return this->repack;
+ }
+
+ void
+ file::set_file_repack (bool repack)
+ {
+ this->repack = repack;
+ }
+
+ std::string
+ file::get_path () const
+ {
+ std::string path(owner->get_mount_location());
+
+ if (!get_location().empty())
+ path += get_location();
+
+ return path;
+ }
+
+ void
+ file::setup_env (chroot const& chroot,
+ environment& env) const
+ {
+ storage::setup_env(chroot, env);
+
+ env.add("CHROOT_FILE", get_filename());
+ env.add("CHROOT_LOCATION", get_location());
+ env.add("CHROOT_FILE_REPACK", this->repack);
+ env.add("CHROOT_FILE_UNPACK_DIR", SCHROOT_FILE_UNPACK_DIR);
+ }
+
+ void
+ file::setup_lock (chroot::setup_type type,
+ bool lock,
+ int status)
+ {
+ // Check ownership and permissions.
+ if (type == chroot::SETUP_START && lock == true)
+ {
+ stat file_status(this->filename);
+
+ // NOTE: taken from chroot_config::check_security.
+ if (file_status.uid() != 0)
+ throw error(this->filename, chroot::FILE_OWNER);
+ if (file_status.check_mode(stat::PERM_OTHER_WRITE))
+ throw error(this->filename, chroot::FILE_PERMS);
+ if (!file_status.is_regular())
+ throw error(this->filename, chroot::FILE_NOTREG);
+ }
+
+ /* By default, file chroots do no locking. */
+ /* Create or unlink session information. */
+ if ((type == chroot::SETUP_START && lock == true) ||
+ (type == chroot::SETUP_STOP && lock == false && status == 0))
+ {
+
+ bool start = (type == chroot::SETUP_START);
+ owner->get_facet_strict<session>()->setup_session_info(start);
+ }
+ }
+
+ chroot::session_flags
+ file::get_session_flags (chroot const& chroot) const
+ {
+ chroot::session_flags flags = chroot::SESSION_NOFLAGS;
+
+ if (chroot.get_facet<session>())
+ flags = chroot::SESSION_PURGE;
+
+ return flags;
+ }
+
+ void
+ file::get_details (chroot const& chroot,
+ format_detail& detail) const
+ {
+ storage::get_details(chroot, detail);
+
+ if (!this->filename.empty())
+ detail
+ .add(_("File"), get_filename())
+ .add(_("File Repack"), this->repack);
+ if (!get_location().empty())
+ detail.add(_("Location"), get_location());
+ }
+
+ void
+ file::get_used_keys (string_list& used_keys) const
+ {
+ storage::get_used_keys(used_keys);
+
+ used_keys.push_back("file");
+ used_keys.push_back("location");
+ used_keys.push_back("file-repack");
+ }
+
+ void
+ file::get_keyfile (chroot const& chroot,
+ keyfile& keyfile) const
+ {
+ storage::get_keyfile(chroot, keyfile);
+
+ bool is_session = static_cast<bool>(chroot.get_facet<session>());
+
+ keyfile::set_object_value(*this, &file::get_filename,
+ keyfile, chroot.get_name(), "file");
+
+ keyfile::set_object_value(*this, &file::get_location,
+ keyfile, chroot.get_name(),
+ "location");
+
+ if (is_session)
+ keyfile::set_object_value(*this, &file::get_file_repack,
+ keyfile, chroot.get_name(), "file-repack");
+ }
+
+ void
+ file::set_keyfile (chroot& chroot,
+ keyfile const& keyfile)
+ {
+ storage::set_keyfile(chroot, keyfile);
+
+ bool is_session = static_cast<bool>(chroot.get_facet<session>());
+
+ keyfile::get_object_value(*this, &file::set_filename,
+ keyfile, chroot.get_name(), "file",
+ keyfile::PRIORITY_REQUIRED);
+
+ keyfile::get_object_value(*this, &file::set_location,
+ keyfile, chroot.get_name(),
+ "location",
+ keyfile::PRIORITY_OPTIONAL);
+
+ keyfile::get_object_value(*this, &file::set_file_repack,
+ keyfile, chroot.get_name(), "file-repack",
+ is_session ?
+ keyfile::PRIORITY_REQUIRED :
+ keyfile::PRIORITY_DISALLOWED);
+ }
- used_keys.push_back("file");
- used_keys.push_back("location");
- used_keys.push_back("file-repack");
}
-
- void
- file::get_keyfile (chroot const& chroot,
- keyfile& keyfile) const
- {
- chroot::get_keyfile(chroot, keyfile);
-
- bool session = static_cast<bool>(get_facet<facet::session>());
-
- keyfile::set_object_value(*this, &file::get_filename,
- keyfile, get_name(), "file");
-
- keyfile::set_object_value(*this, &file::get_location,
- keyfile, chroot.get_name(),
- "location");
-
- if (session)
- keyfile::set_object_value(*this, &file::get_file_repack,
- keyfile, get_name(), "file-repack");
- }
-
- void
- file::set_keyfile (chroot& chroot,
- keyfile const& keyfile)
- {
- chroot::set_keyfile(chroot, keyfile);
-
- bool session = static_cast<bool>(get_facet<facet::session>());
-
- keyfile::get_object_value(*this, &file::set_filename,
- keyfile, get_name(), "file",
- keyfile::PRIORITY_REQUIRED);
-
- keyfile::get_object_value(*this, &file::set_location,
- keyfile, chroot.get_name(),
- "location",
- keyfile::PRIORITY_OPTIONAL);
-
- keyfile::get_object_value(*this, &file::set_file_repack,
- keyfile, get_name(), "file-repack",
- session ?
- keyfile::PRIORITY_REQUIRED :
- keyfile::PRIORITY_DISALLOWED);
- }
-
}
}
diff --git a/lib/sbuild/chroot/facet/file.h b/lib/sbuild/chroot/facet/file.h
index b8d348d8..1005230b 100644
--- a/lib/sbuild/chroot/facet/file.h
+++ b/lib/sbuild/chroot/facet/file.h
@@ -16,148 +16,164 @@
*
*********************************************************************/
-#ifndef SBUILD_CHROOT_FILE_H
-#define SBUILD_CHROOT_FILE_H
+#ifndef SBUILD_CHROOT_FACET_FILE_H
+#define SBUILD_CHROOT_FACET_FILE_H
#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/storage.h>
namespace sbuild
{
namespace chroot
{
-
- /**
- * A chroot stored in a file archive (tar with optional compression).
- *
- * The archive will be unpacked and repacked on demand.
- */
- class file : public chroot
+ namespace facet
{
- protected:
- /// The constructor.
- file ();
-
- /// The copy constructor.
- file (const file& rhs);
-
- friend class chroot;
-
- public:
- /// The destructor.
- virtual ~file ();
-
- virtual chroot::chroot::ptr
- clone () const;
-
- virtual chroot::chroot::ptr
- clone_session (std::string const& session_id,
- std::string const& alias,
- std::string const& user,
- bool root) const;
-
- virtual chroot::chroot::ptr
- clone_source () const;
-
- /**
- * Get the filename used by the chroot.
- *
- * @returns the filename.
- */
- std::string const&
- get_filename () const;
-
- /**
- * Set the filename used by the chroot.
- *
- * @param filename the filename.
- */
- void
- set_filename (std::string const& filename);
-
- /**
- * Get the location. This is a path to the chroot directory
- * inside the archive (absolute path from the archive root).
- *
- * @returns the location.
- */
- virtual std::string const&
- get_location () const;
/**
- * Set the location. This is a path to the chroot directory
- * inside the archive (absolute path from the archive root).
+ * A chroot stored in a file archive (tar with optional compression).
*
- * @param location the location.
+ * The archive will be unpacked and repacked on demand.
*/
- virtual void
- set_location (std::string const& location);
-
- /**
- * Get the repack status. This is true if the unpacked archive
- * file will be repacked.
- *
- * @returns the repack status.
- */
- bool
- get_file_repack () const;
-
- /**
- * Set the file repack status. Set to true if the unpacked
- * archive file will be repacked on session cleanup, or false to
- * discard.
- *
- * @param repack the repack status.
- */
- void
- set_file_repack (bool repack);
-
- virtual std::string const&
- get_chroot_type () const;
-
- virtual void
- setup_env (chroot const& chroot,
- environment& env) const;
-
- std::string
- get_path () const;
-
- virtual session_flags
- get_session_flags (chroot const& chroot) const;
-
- protected:
- virtual void
- setup_lock (chroot::setup_type type,
- bool lock,
- int status);
-
- virtual void
- get_details (chroot const& chroot,
- format_detail& detail) const;
-
- virtual void
- get_used_keys (string_list& used_keys) const;
-
- virtual void
- get_keyfile (chroot const& chroot,
- keyfile& keyfile) const;
-
- virtual void
- set_keyfile (chroot& chroot,
- keyfile const& keyfile);
-
- private:
- /// The file to use.
- std::string filename;
- /// Location inside the mount location root.
- std::string location;
- /// Should the chroot be repacked?
- bool repack;
- };
-
+ class file : public storage
+ {
+ public:
+ /// Exception type.
+ typedef chroot::error error;
+
+ /// A shared_ptr to a chroot facet object.
+ typedef std::shared_ptr<file> ptr;
+
+ /// A shared_ptr to a const chroot facet object.
+ typedef std::shared_ptr<const file> const_ptr;
+
+ protected:
+ /// The constructor.
+ file ();
+
+ /// The copy constructor.
+ file (const file& rhs);
+
+ void
+ set_chroot (chroot& chroot);
+
+ friend class chroot;
+
+ public:
+ /// The destructor.
+ virtual ~file ();
+
+ virtual std::string const&
+ get_name () const;
+
+ /**
+ * Create a chroot facet.
+ *
+ * @returns a shared_ptr to the new chroot facet.
+ */
+ static ptr
+ create ();
+
+ facet::ptr
+ clone () const;
+
+ /**
+ * Get the filename used by the chroot.
+ *
+ * @returns the filename.
+ */
+ std::string const&
+ get_filename () const;
+
+ /**
+ * Set the filename used by the chroot.
+ *
+ * @param filename the filename.
+ */
+ void
+ set_filename (std::string const& filename);
+
+ /**
+ * Get the location. This is a path to the chroot directory
+ * inside the archive (absolute path from the archive root).
+ *
+ * @returns the location.
+ */
+ virtual std::string const&
+ get_location () const;
+
+ /**
+ * Set the location. This is a path to the chroot directory
+ * inside the archive (absolute path from the archive root).
+ *
+ * @param location the location.
+ */
+ virtual void
+ set_location (std::string const& location);
+
+ /**
+ * Get the repack status. This is true if the unpacked archive
+ * file will be repacked.
+ *
+ * @returns the repack status.
+ */
+ bool
+ get_file_repack () const;
+
+ /**
+ * Set the file repack status. Set to true if the unpacked
+ * archive file will be repacked on session cleanup, or false to
+ * discard.
+ *
+ * @param repack the repack status.
+ */
+ void
+ set_file_repack (bool repack);
+
+ virtual void
+ setup_env (chroot const& chroot,
+ environment& env) const;
+
+ std::string
+ get_path () const;
+
+ virtual chroot::session_flags
+ get_session_flags (chroot const& chroot) const;
+
+ protected:
+ virtual void
+ setup_lock (chroot::setup_type type,
+ bool lock,
+ int status);
+
+ virtual void
+ get_details (chroot const& chroot,
+ format_detail& detail) const;
+
+ virtual void
+ get_used_keys (string_list& used_keys) const;
+
+ virtual void
+ get_keyfile (chroot const& chroot,
+ keyfile& keyfile) const;
+
+ virtual void
+ set_keyfile (chroot& chroot,
+ keyfile const& keyfile);
+
+ private:
+ /// The file to use.
+ std::string filename;
+ /// Location inside the mount location root.
+ std::string location;
+ /// Should the chroot be repacked?
+ bool repack;
+ };
+
+ }
}
}
-#endif /* SBUILD_CHROOT_FILE_H */
+#endif /* SBUILD_CHROOT_FACET_FILE_H */
/*
* Local Variables:
diff --git a/lib/sbuild/chroot/file.cc b/lib/sbuild/chroot/file.cc
index 92be8cab..9b63f716 100644
--- a/lib/sbuild/chroot/file.cc
+++ b/lib/sbuild/chroot/file.cc
@@ -19,6 +19,7 @@
#include <config.h>
#include <sbuild/chroot/file.h>
+#include <sbuild/chroot/facet/file.h>
#include <sbuild/chroot/facet/session.h>
#include <sbuild/chroot/facet/session-clonable.h>
#include <sbuild/chroot/facet/source-clonable.h>
@@ -40,19 +41,13 @@ namespace sbuild
{
file::file ():
- chroot(),
- filename(),
- location(),
- repack(false)
+ chroot()
{
- add_facet(facet::source_clonable::create());
+ add_facet(facet::file::create());
}
file::file (const file& rhs):
- chroot(rhs),
- filename(rhs.filename),
- location(rhs.location),
- repack(rhs.repack)
+ chroot(rhs)
{
}
@@ -93,191 +88,11 @@ namespace sbuild
assert(psrc);
psrc->clone_source_setup(*this, clone);
- clone_file->repack = true;
- return clone;
- }
-
- std::string const&
- file::get_filename () const
- {
- return this->filename;
- }
-
- void
- file::set_filename (std::string const& filename)
- {
- if (!is_absname(filename))
- throw error(filename, FILE_ABS);
-
- this->filename = filename;
- }
-
- std::string const&
- file::get_location () const
- {
- return this->location;
- }
-
- void
- file::set_location (std::string const& location)
- {
- if (!location.empty() && !is_absname(location))
- throw chroot::error(location, chroot::LOCATION_ABS);
-
- this->location = location;
- }
-
- bool
- file::get_file_repack () const
- {
- return this->repack;
- }
-
- void
- file::set_file_repack (bool repack)
- {
- this->repack = repack;
- }
+ facet::file::ptr filefac = clone->get_facet_strict<facet::file>();
+ filefac->set_file_repack(true);
- std::string
- file::get_path () const
- {
- std::string path(get_mount_location());
-
- if (!get_location().empty())
- path += get_location();
-
- return path;
- }
-
- std::string const&
- file::get_chroot_type () const
- {
- static const std::string type("file");
-
- return type;
- }
-
- void
- file::setup_env (chroot const& chroot,
- environment& env) const
- {
- chroot::setup_env(chroot, env);
-
- env.add("CHROOT_FILE", get_filename());
- env.add("CHROOT_LOCATION", get_location());
- env.add("CHROOT_FILE_REPACK", this->repack);
- env.add("CHROOT_FILE_UNPACK_DIR", SCHROOT_FILE_UNPACK_DIR);
- }
-
- void
- file::setup_lock (chroot::setup_type type,
- bool lock,
- int status)
- {
- // Check ownership and permissions.
- if (type == SETUP_START && lock == true)
- {
- stat file_status(this->filename);
-
- // NOTE: taken from chroot_config::check_security.
- if (file_status.uid() != 0)
- throw error(this->filename, FILE_OWNER);
- if (file_status.check_mode(stat::PERM_OTHER_WRITE))
- throw error(this->filename, FILE_PERMS);
- if (!file_status.is_regular())
- throw error(this->filename, FILE_NOTREG);
- }
-
- /* By default, file chroots do no locking. */
- /* Create or unlink session information. */
- if ((type == SETUP_START && lock == true) ||
- (type == SETUP_STOP && lock == false && status == 0))
- {
-
- bool start = (type == SETUP_START);
- get_facet_strict<facet::session>()->setup_session_info(start);
- }
- }
-
- chroot::chroot::session_flags
- file::get_session_flags (chroot const& chroot) const
- {
- session_flags flags = SESSION_NOFLAGS;
-
- if (chroot.get_facet<facet::session>())
- flags = SESSION_PURGE;
-
- return flags;
- }
-
- void
- file::get_details (chroot const& chroot,
- format_detail& detail) const
- {
- chroot::get_details(chroot, detail);
-
- if (!this->filename.empty())
- detail
- .add(_("File"), get_filename())
- .add(_("File Repack"), this->repack);
- if (!get_location().empty())
- detail.add(_("Location"), get_location());
- }
-
- void
- file::get_used_keys (string_list& used_keys) const
- {
- chroot::get_used_keys(used_keys);
-
- used_keys.push_back("file");
- used_keys.push_back("location");
- used_keys.push_back("file-repack");
- }
-
- void
- file::get_keyfile (chroot const& chroot,
- keyfile& keyfile) const
- {
- chroot::get_keyfile(chroot, keyfile);
-
- bool session = static_cast<bool>(get_facet<facet::session>());
-
- keyfile::set_object_value(*this, &file::get_filename,
- keyfile, get_name(), "file");
-
- keyfile::set_object_value(*this, &file::get_location,
- keyfile, chroot.get_name(),
- "location");
-
- if (session)
- keyfile::set_object_value(*this, &file::get_file_repack,
- keyfile, get_name(), "file-repack");
- }
-
- void
- file::set_keyfile (chroot& chroot,
- keyfile const& keyfile)
- {
- chroot::set_keyfile(chroot, keyfile);
-
- bool session = static_cast<bool>(get_facet<facet::session>());
-
- keyfile::get_object_value(*this, &file::set_filename,
- keyfile, get_name(), "file",
- keyfile::PRIORITY_REQUIRED);
-
- keyfile::get_object_value(*this, &file::set_location,
- keyfile, chroot.get_name(),
- "location",
- keyfile::PRIORITY_OPTIONAL);
-
- keyfile::get_object_value(*this, &file::set_file_repack,
- keyfile, get_name(), "file-repack",
- session ?
- keyfile::PRIORITY_REQUIRED :
- keyfile::PRIORITY_DISALLOWED);
+ return clone;
}
}
diff --git a/lib/sbuild/chroot/file.h b/lib/sbuild/chroot/file.h
index b8d348d8..ab864801 100644
--- a/lib/sbuild/chroot/file.h
+++ b/lib/sbuild/chroot/file.h
@@ -58,100 +58,6 @@ namespace sbuild
virtual chroot::chroot::ptr
clone_source () const;
- /**
- * Get the filename used by the chroot.
- *
- * @returns the filename.
- */
- std::string const&
- get_filename () const;
-
- /**
- * Set the filename used by the chroot.
- *
- * @param filename the filename.
- */
- void
- set_filename (std::string const& filename);
-
- /**
- * Get the location. This is a path to the chroot directory
- * inside the archive (absolute path from the archive root).
- *
- * @returns the location.
- */
- virtual std::string const&
- get_location () const;
-
- /**
- * Set the location. This is a path to the chroot directory
- * inside the archive (absolute path from the archive root).
- *
- * @param location the location.
- */
- virtual void
- set_location (std::string const& location);
-
- /**
- * Get the repack status. This is true if the unpacked archive
- * file will be repacked.
- *
- * @returns the repack status.
- */
- bool
- get_file_repack () const;
-
- /**
- * Set the file repack status. Set to true if the unpacked
- * archive file will be repacked on session cleanup, or false to
- * discard.
- *
- * @param repack the repack status.
- */
- void
- set_file_repack (bool repack);
-
- virtual std::string const&
- get_chroot_type () const;
-
- virtual void
- setup_env (chroot const& chroot,
- environment& env) const;
-
- std::string
- get_path () const;
-
- virtual session_flags
- get_session_flags (chroot const& chroot) const;
-
- protected:
- virtual void
- setup_lock (chroot::setup_type type,
- bool lock,
- int status);
-
- virtual void
- get_details (chroot const& chroot,
- format_detail& detail) const;
-
- virtual void
- get_used_keys (string_list& used_keys) const;
-
- virtual void
- get_keyfile (chroot const& chroot,
- keyfile& keyfile) const;
-
- virtual void
- set_keyfile (chroot& chroot,
- keyfile const& keyfile);
-
- private:
- /// The file to use.
- std::string filename;
- /// Location inside the mount location root.
- std::string location;
- /// Should the chroot be repacked?
- bool repack;
};
}