1 | /* Copyright © 2005-2008 Roger Leigh <rleigh@debian.org> |
---|
2 | * |
---|
3 | * schroot is free software: you can redistribute it and/or modify it |
---|
4 | * under the terms of the GNU General Public License as published by |
---|
5 | * the Free Software Foundation, either version 3 of the License, or |
---|
6 | * (at your option) any later version. |
---|
7 | * |
---|
8 | * schroot is distributed in the hope that it will be useful, but |
---|
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | * General Public License for more details. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program. If not, see |
---|
15 | * <http://www.gnu.org/licenses/>. |
---|
16 | * |
---|
17 | *********************************************************************/ |
---|
18 | |
---|
19 | #include <config.h> |
---|
20 | |
---|
21 | #include "sbuild-chroot-block-device.h" |
---|
22 | #include "sbuild-chroot-facet-session-clonable.h" |
---|
23 | #ifdef SBUILD_FEATURE_UNION |
---|
24 | #include "sbuild-chroot-facet-union.h" |
---|
25 | #endif // SBUILD_FEATURE_UNION |
---|
26 | #include "sbuild-format-detail.h" |
---|
27 | #include "sbuild-lock.h" |
---|
28 | #include "sbuild-util.h" |
---|
29 | |
---|
30 | #include <cassert> |
---|
31 | #include <cerrno> |
---|
32 | #include <cstring> |
---|
33 | |
---|
34 | #include <boost/format.hpp> |
---|
35 | |
---|
36 | using boost::format; |
---|
37 | using namespace sbuild; |
---|
38 | |
---|
39 | chroot_block_device::chroot_block_device (): |
---|
40 | chroot_block_device_base() |
---|
41 | { |
---|
42 | #ifdef SBUILD_FEATURE_UNION |
---|
43 | add_facet(sbuild::chroot_facet_union::create()); |
---|
44 | #endif // SBUILD_FEATURE_UNION |
---|
45 | } |
---|
46 | |
---|
47 | chroot_block_device::~chroot_block_device () |
---|
48 | { |
---|
49 | } |
---|
50 | |
---|
51 | chroot_block_device::chroot_block_device (const chroot_block_device& rhs): |
---|
52 | chroot_block_device_base(rhs) |
---|
53 | { |
---|
54 | } |
---|
55 | |
---|
56 | chroot_block_device::chroot_block_device (const chroot_lvm_snapshot& rhs): |
---|
57 | chroot_block_device_base(rhs) |
---|
58 | { |
---|
59 | #ifdef SBUILD_FEATURE_UNION |
---|
60 | if (!get_facet<sbuild::chroot_facet_union>()) |
---|
61 | add_facet(sbuild::chroot_facet_union::create()); |
---|
62 | #endif // SBUILD_FEATURE_UNION |
---|
63 | } |
---|
64 | |
---|
65 | sbuild::chroot::ptr |
---|
66 | chroot_block_device::clone () const |
---|
67 | { |
---|
68 | return ptr(new chroot_block_device(*this)); |
---|
69 | } |
---|
70 | |
---|
71 | sbuild::chroot::ptr |
---|
72 | chroot_block_device::clone_session (std::string const& session_id, |
---|
73 | std::string const& user, |
---|
74 | bool root) const |
---|
75 | { |
---|
76 | chroot_facet_session_clonable::const_ptr psess |
---|
77 | (get_facet<chroot_facet_session_clonable>()); |
---|
78 | assert(psess); |
---|
79 | |
---|
80 | ptr session(new chroot_block_device(*this)); |
---|
81 | psess->clone_session_setup(session, session_id, user, root); |
---|
82 | |
---|
83 | return session; |
---|
84 | } |
---|
85 | |
---|
86 | sbuild::chroot::ptr |
---|
87 | chroot_block_device::clone_source () const |
---|
88 | { |
---|
89 | ptr clone; |
---|
90 | |
---|
91 | #ifdef SBUILD_FEATURE_UNION |
---|
92 | chroot_facet_union::const_ptr puni(get_facet<chroot_facet_union>()); |
---|
93 | assert(puni); |
---|
94 | |
---|
95 | if (puni->get_union_configured()) |
---|
96 | { |
---|
97 | clone = ptr(new chroot_block_device(*this)); |
---|
98 | puni->clone_source_setup(clone); |
---|
99 | } |
---|
100 | #endif // SBUILD_FEATURE_UNION |
---|
101 | |
---|
102 | return clone; |
---|
103 | } |
---|
104 | |
---|
105 | void |
---|
106 | chroot_block_device::setup_env (chroot const& chroot, |
---|
107 | environment& env) const |
---|
108 | { |
---|
109 | chroot_block_device_base::setup_env(chroot, env); |
---|
110 | } |
---|
111 | |
---|
112 | sbuild::chroot::session_flags |
---|
113 | chroot_block_device::get_session_flags (chroot const& chroot) const |
---|
114 | { |
---|
115 | return chroot_block_device_base::get_session_flags(chroot); |
---|
116 | } |
---|
117 | |
---|
118 | void |
---|
119 | chroot_block_device::get_details (chroot const& chroot, |
---|
120 | format_detail& detail) const |
---|
121 | { |
---|
122 | chroot_block_device_base::get_details(chroot, detail); |
---|
123 | } |
---|
124 | |
---|
125 | void |
---|
126 | chroot_block_device::get_keyfile (chroot const& chroot, |
---|
127 | keyfile& keyfile) const |
---|
128 | { |
---|
129 | chroot_block_device_base::get_keyfile(chroot, keyfile); |
---|
130 | } |
---|
131 | |
---|
132 | void |
---|
133 | chroot_block_device::set_keyfile (chroot& chroot, |
---|
134 | keyfile const& keyfile, |
---|
135 | string_list& used_keys) |
---|
136 | { |
---|
137 | chroot_block_device_base::set_keyfile(chroot, keyfile, used_keys); |
---|
138 | } |
---|