[Piuparts-devel] [PATCH 1/3] add remove_temp_tgz_file() method

Andreas Beckmann debian at abeckmann.de
Sat Nov 5 22:00:52 UTC 2011


add remove_temp_tgz_file(), the counterpart to create_temp_tgz_file()

Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

---
 piuparts.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/piuparts.py b/piuparts.py
index a731af2..2dfc8a5 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -641,6 +641,12 @@ class Chroot:
         (fd, temp_tgz) = create_temp_file()
         return temp_tgz
 
+    def remove_temp_tgz_file(self, temp_tgz):
+        """Remove the file that was used as a temporary tgz file"""
+        # Yes, remove_files() would work just as well, but putting it in
+        # the interface for Chroot allows the VirtServ hack to work.
+        remove_files([temp_tgz])
+
     def pack_into_tgz(self, result):
         """Tar and compress all files in the chroot."""
         logging.debug("Saving %s to %s." % (self.name, result))
@@ -1249,6 +1255,9 @@ class VirtServ(Chroot):
     #  adt-virt revert
     def create_temp_tgz_file(self):
         return self
+    def remove_temp_tgz_file(self, tgz):
+        if tgz is not self: self._fail('removing a tgz not supported')
+        # FIXME: anything else to do here?
     def pack_into_tgz(self, tgz):
         if tgz is not self: self._fail('packing into tgz not supported')
         if not 'revert' in self._caps: self._fail('testbed cannot revert')
@@ -1883,7 +1892,7 @@ def install_and_upgrade_between_distros(filenames, packages):
     chroot.check_for_no_processes()
     
     if root_tgz != settings.basetgz:
-        remove_files([root_tgz])
+        chroot.remove_temp_tgz_file(root_tgz)
     chroot.remove()
     dont_do_on_panic(cid)
 
-- 
tg: (ee53b21..) t/feat/remove_temp_tgz_file (depends on: develop)



More information about the Piuparts-devel mailing list