diff options
author | Roger Leigh <rleigh@debian.org> | 2013-05-04 12:51:37 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2013-05-04 17:17:17 +0100 |
commit | 46e7e32d5a8c3a63958919183f4c2f0224bbf8d2 (patch) | |
tree | 9bc1c886cb0b5693d9f7518fd833b603b4bfebac /lib/sbuild | |
parent | 92c23e71a30cd243b3289b990b0bf93b19e0d4c2 (diff) | |
download | schroot-46e7e32d5a8c3a63958919183f4c2f0224bbf8d2.tar.gz |
sbuild::chroot::facet: Add copy argument to set_chroot
This prevent erroneous re-adding of facets when cloning
chroots.
Diffstat (limited to 'lib/sbuild')
-rw-r--r-- | lib/sbuild/chroot/chroot.cc | 2 | ||||
-rw-r--r-- | lib/sbuild/chroot/chroot.h | 2 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/block-device-base.cc | 7 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/block-device-base.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/block-device.cc | 7 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/block-device.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/btrfs-snapshot.cc | 5 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/btrfs-snapshot.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/directory.cc | 5 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/directory.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/facet.cc | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/facet.h | 11 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/file.cc | 5 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/file.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/loopback.cc | 7 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/loopback.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/lvm-snapshot.cc | 7 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/lvm-snapshot.h | 3 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/plain.cc | 6 | ||||
-rw-r--r-- | lib/sbuild/chroot/facet/plain.h | 3 |
20 files changed, 58 insertions, 33 deletions
diff --git a/lib/sbuild/chroot/chroot.cc b/lib/sbuild/chroot/chroot.cc index 681c1114..0e6b0eac 100644 --- a/lib/sbuild/chroot/chroot.cc +++ b/lib/sbuild/chroot/chroot.cc @@ -149,7 +149,7 @@ namespace sbuild for (const auto& facet : rhs.facets) { facet_ptr fp = facet->clone(); - fp->set_chroot(*this); + fp->set_chroot(*this, true); facets.push_back(fp); } } diff --git a/lib/sbuild/chroot/chroot.h b/lib/sbuild/chroot/chroot.h index 71f939c0..2d8b2fbc 100644 --- a/lib/sbuild/chroot/chroot.h +++ b/lib/sbuild/chroot/chroot.h @@ -904,7 +904,7 @@ namespace sbuild throw error(type_name<T>(), FACET_PRESENT); } - new_facet->set_chroot(*this); + new_facet->set_chroot(*this, false); facets.push_back(new_facet); } diff --git a/lib/sbuild/chroot/facet/block-device-base.cc b/lib/sbuild/chroot/facet/block-device-base.cc index 13aa42e6..411d9091 100644 --- a/lib/sbuild/chroot/facet/block-device-base.cc +++ b/lib/sbuild/chroot/facet/block-device-base.cc @@ -55,10 +55,11 @@ namespace sbuild } void - block_device_base::set_chroot (chroot& chroot) + block_device_base::set_chroot (chroot& chroot, + bool copy) { - facet::set_chroot(chroot); - if (!this->owner->get_facet<mountable>()) + facet::set_chroot(chroot, copy); + if (!copy && !this->owner->get_facet<mountable>()) this->owner->add_facet(mountable::create()); } diff --git a/lib/sbuild/chroot/facet/block-device-base.h b/lib/sbuild/chroot/facet/block-device-base.h index 5903ccdc..4e5bc35d 100644 --- a/lib/sbuild/chroot/facet/block-device-base.h +++ b/lib/sbuild/chroot/facet/block-device-base.h @@ -60,7 +60,8 @@ namespace sbuild protected: void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); public: /** diff --git a/lib/sbuild/chroot/facet/block-device.cc b/lib/sbuild/chroot/facet/block-device.cc index 343f894b..7d8eacd2 100644 --- a/lib/sbuild/chroot/facet/block-device.cc +++ b/lib/sbuild/chroot/facet/block-device.cc @@ -82,11 +82,12 @@ namespace sbuild #endif // SBUILD_FEATURE_LVMSNAP void - block_device::set_chroot (chroot& chroot) + block_device::set_chroot (chroot& chroot, + bool copy) { - block_device_base::set_chroot(chroot); + block_device_base::set_chroot(chroot, copy); #ifdef SBUILD_FEATURE_UNION - if (!owner->get_facet<fsunion>()) + if (!copy && !owner->get_facet<fsunion>()) owner->add_facet(fsunion::create()); #endif // SBUILD_FEATURE_UNION } diff --git a/lib/sbuild/chroot/facet/block-device.h b/lib/sbuild/chroot/facet/block-device.h index 7456bb36..2da03fdc 100644 --- a/lib/sbuild/chroot/facet/block-device.h +++ b/lib/sbuild/chroot/facet/block-device.h @@ -57,7 +57,8 @@ namespace sbuild #endif void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; #ifdef SBUILD_FEATURE_LVMSNAP diff --git a/lib/sbuild/chroot/facet/btrfs-snapshot.cc b/lib/sbuild/chroot/facet/btrfs-snapshot.cc index fde33666..3be652f7 100644 --- a/lib/sbuild/chroot/facet/btrfs-snapshot.cc +++ b/lib/sbuild/chroot/facet/btrfs-snapshot.cc @@ -78,10 +78,11 @@ namespace sbuild } void - btrfs_snapshot::set_chroot (chroot& chroot) + btrfs_snapshot::set_chroot (chroot& chroot, + bool copy) { storage::set_chroot(chroot); - if (!owner->get_facet<source_clonable>()) + if (!copy && !owner->get_facet<source_clonable>()) owner->add_facet(source_clonable::create()); } diff --git a/lib/sbuild/chroot/facet/btrfs-snapshot.h b/lib/sbuild/chroot/facet/btrfs-snapshot.h index 240cb642..2d7407ec 100644 --- a/lib/sbuild/chroot/facet/btrfs-snapshot.h +++ b/lib/sbuild/chroot/facet/btrfs-snapshot.h @@ -55,7 +55,8 @@ namespace sbuild btrfs_snapshot (const btrfs_snapshot& rhs); void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; diff --git a/lib/sbuild/chroot/facet/directory.cc b/lib/sbuild/chroot/facet/directory.cc index 461c9edb..10c354ba 100644 --- a/lib/sbuild/chroot/facet/directory.cc +++ b/lib/sbuild/chroot/facet/directory.cc @@ -78,11 +78,12 @@ namespace sbuild #endif // SBUILD_FEATURE_BTRFSSNAP void - directory::set_chroot (chroot& chroot) + directory::set_chroot (chroot& chroot, + bool copy) { directory_base::set_chroot(chroot); #ifdef SBUILD_FEATURE_UNION - if (!owner->get_facet<fsunion>()) + if (!copy && !owner->get_facet<fsunion>()) owner->add_facet(fsunion::create()); #endif // SBUILD_FEATURE_UNION } diff --git a/lib/sbuild/chroot/facet/directory.h b/lib/sbuild/chroot/facet/directory.h index 69af7c66..a2189564 100644 --- a/lib/sbuild/chroot/facet/directory.h +++ b/lib/sbuild/chroot/facet/directory.h @@ -60,7 +60,8 @@ namespace sbuild #endif // SBUILD_FEATURE_BTRFSSNAP void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; #ifdef SBUILD_FEATURE_BTRFSSNAP diff --git a/lib/sbuild/chroot/facet/facet.cc b/lib/sbuild/chroot/facet/facet.cc index 3c3ca996..9cc44e77 100644 --- a/lib/sbuild/chroot/facet/facet.cc +++ b/lib/sbuild/chroot/facet/facet.cc @@ -43,7 +43,8 @@ namespace sbuild } void - facet::set_chroot (chroot& chroot) + facet::set_chroot (chroot& chroot, + bool copy) { this->owner = &chroot; } diff --git a/lib/sbuild/chroot/facet/facet.h b/lib/sbuild/chroot/facet/facet.h index aa4333bd..5550ba71 100644 --- a/lib/sbuild/chroot/facet/facet.h +++ b/lib/sbuild/chroot/facet/facet.h @@ -58,12 +58,19 @@ namespace sbuild facet (); /** - * Set containing chroot. + * Set containing chroot. The copy parameter is used to + * inform the facet if it is new or a copy; this is intended + * to allow additional facets to only be added if the facet is + * new, for example, to avoid re-adding removed facets when + * copying a chroot. * * @param chroot the chroot containing this facet. + * @param copy true if the facet has been copied, or false if + * this is a new instance. */ virtual void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy = false); friend class ::sbuild::chroot::chroot; diff --git a/lib/sbuild/chroot/facet/file.cc b/lib/sbuild/chroot/facet/file.cc index 81fcab02..ab35484f 100644 --- a/lib/sbuild/chroot/facet/file.cc +++ b/lib/sbuild/chroot/facet/file.cc @@ -77,10 +77,11 @@ namespace sbuild } void - file::set_chroot (chroot& chroot) + file::set_chroot (chroot& chroot, + bool copy) { storage::set_chroot(chroot); - if (!owner->get_facet<source_clonable>()) + if (!copy && !owner->get_facet<source_clonable>()) owner->add_facet(source_clonable::create()); } diff --git a/lib/sbuild/chroot/facet/file.h b/lib/sbuild/chroot/facet/file.h index a2d91386..b48b57fe 100644 --- a/lib/sbuild/chroot/facet/file.h +++ b/lib/sbuild/chroot/facet/file.h @@ -55,7 +55,8 @@ namespace sbuild file (const file& rhs); void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; diff --git a/lib/sbuild/chroot/facet/loopback.cc b/lib/sbuild/chroot/facet/loopback.cc index 54e806f9..5795434d 100644 --- a/lib/sbuild/chroot/facet/loopback.cc +++ b/lib/sbuild/chroot/facet/loopback.cc @@ -72,13 +72,14 @@ namespace sbuild } void - loopback::set_chroot (chroot& chroot) + loopback::set_chroot (chroot& chroot, + bool copy) { storage::set_chroot(chroot); - if (!owner->get_facet<mountable>()) + if (!copy && !owner->get_facet<mountable>()) owner->add_facet(mountable::create()); #ifdef SBUILD_FEATURE_UNION - if (!owner->get_facet<fsunion>()) + if (!copy && !owner->get_facet<fsunion>()) owner->add_facet(fsunion::create()); #endif // SBUILD_FEATURE_UNION } diff --git a/lib/sbuild/chroot/facet/loopback.h b/lib/sbuild/chroot/facet/loopback.h index b2ba6f25..a9b86bf8 100644 --- a/lib/sbuild/chroot/facet/loopback.h +++ b/lib/sbuild/chroot/facet/loopback.h @@ -54,7 +54,8 @@ namespace sbuild loopback (const loopback& rhs); void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; diff --git a/lib/sbuild/chroot/facet/lvm-snapshot.cc b/lib/sbuild/chroot/facet/lvm-snapshot.cc index 77669947..430e5e08 100644 --- a/lib/sbuild/chroot/facet/lvm-snapshot.cc +++ b/lib/sbuild/chroot/facet/lvm-snapshot.cc @@ -75,10 +75,11 @@ namespace sbuild } void - lvm_snapshot::set_chroot (chroot& chroot) + lvm_snapshot::set_chroot (chroot& chroot, + bool copy) { - block_device_base::set_chroot(chroot); - if (!owner->get_facet<source_clonable>()) + block_device_base::set_chroot(chroot, copy); + if (!copy && !owner->get_facet<source_clonable>()) owner->add_facet(source_clonable::create()); } diff --git a/lib/sbuild/chroot/facet/lvm-snapshot.h b/lib/sbuild/chroot/facet/lvm-snapshot.h index dc542d1a..2c28481a 100644 --- a/lib/sbuild/chroot/facet/lvm-snapshot.h +++ b/lib/sbuild/chroot/facet/lvm-snapshot.h @@ -51,7 +51,8 @@ namespace sbuild lvm_snapshot (const lvm_snapshot& rhs); void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; diff --git a/lib/sbuild/chroot/facet/plain.cc b/lib/sbuild/chroot/facet/plain.cc index 6bd5acbd..007a8e02 100644 --- a/lib/sbuild/chroot/facet/plain.cc +++ b/lib/sbuild/chroot/facet/plain.cc @@ -69,10 +69,12 @@ namespace sbuild } void - plain::set_chroot (chroot& chroot) + plain::set_chroot (chroot& chroot, + bool copy) { directory_base::set_chroot(chroot); - owner->remove_facet<session_clonable>(); + if (!copy) + owner->remove_facet<session_clonable>(); } std::string const& diff --git a/lib/sbuild/chroot/facet/plain.h b/lib/sbuild/chroot/facet/plain.h index b5e68662..073f8a4a 100644 --- a/lib/sbuild/chroot/facet/plain.h +++ b/lib/sbuild/chroot/facet/plain.h @@ -53,7 +53,8 @@ namespace sbuild plain (const plain& rhs); void - set_chroot (chroot& chroot); + set_chroot (chroot& chroot, + bool copy); friend class chroot; |