[Piuparts-devel] [PATCH 3/3] restore initial chroot from tmptgz

Andreas Beckmann debian at abeckmann.de
Sat Nov 5 22:03:47 UTC 2011


Unless --basetgz is given, install_and_upgrade_between_distros() creates a
temporary tgz of the source distribution chroot.  Use this to initialize
the source distribution chroot for the second round (when actual package
installations are performed).  No need to run debootstrap again.

FIXME: should there be a do_on_panic(remove temp_tgz)?

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

---
 piuparts.py |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/piuparts.py b/piuparts.py
index 8b6278c..bf8307a 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -581,21 +581,23 @@ class Chroot:
         os.chmod(self.name, 0755)
         logging.debug("Created temporary directory %s" % self.name)
 
-    def create(self):
+    def create(self, temp_tgz = None):
         """Create a chroot according to user's wishes."""
         self.create_temp_dir()
         cid = do_on_panic(self.remove)
 
-        if settings.basetgz:
+        if temp_tgz:
+            self.unpack_from_tgz(temp_tgz)
+        elif settings.basetgz:
             self.unpack_from_tgz(settings.basetgz)
         elif settings.lvm_volume:
             self.setup_from_lvm(settings.lvm_volume)
         else:
             self.setup_minimal_chroot()
 
-        self.configure_chroot()
         self.mount_proc()
         self.mount_selinux()
+        self.configure_chroot()
         if settings.basetgz:
             self.run(["apt-get", "-yf", "upgrade"])
         self.minimize()
@@ -615,7 +617,7 @@ class Chroot:
         if settings.scriptsdir is not None: 
             self.run_scripts("post_setup")
 
-        if settings.savetgz:
+        if settings.savetgz and not temp_tgz:
             self.pack_into_tgz(settings.savetgz)
 
         dont_do_on_panic(cid)
@@ -1863,9 +1865,8 @@ def install_and_upgrade_between_distros(filenames, packages):
         if settings.basetgz:
             chroot.create()
         else:
-            # FIXME: restore from temp_tgz
+            chroot.create(temp_tgz)
             chroot.remove_temp_tgz_file(temp_tgz)
-            chroot.create()
         cid = do_on_panic(chroot.remove)
 
     chroot.check_for_no_processes()
-- 
tg: (ae5386b..) t/fix/tmptgz (depends on: t/style/tmptgz t/feat/tar--one-file-system)



More information about the Piuparts-devel mailing list