[Piuparts-devel] [PATCH 2/3] limit the scope the temp_tgz exists

Andreas Beckmann debian at abeckmann.de
Sat Nov 5 22:01:53 UTC 2011


simplify the temp_tgz handling, limit the scope where it exists
add note where to use it for restore
print whe notice about --end-meta a bit earlier and only if applicable

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

---
 piuparts.py |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/piuparts.py b/piuparts.py
index 2dfc8a5..e5e18bb 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1833,16 +1833,15 @@ def install_and_upgrade_between_distros(filenames, packages):
     chroot.create()
     cid = do_on_panic(chroot.remove)
 
-    if settings.basetgz:
-        root_tgz = settings.basetgz
-    else:
-        root_tgz = chroot.create_temp_tgz_file()
-        chroot.pack_into_tgz(root_tgz)
-        
     if settings.end_meta:
         # load root_info and selections
         root_info, selections = load_meta_data(settings.end_meta)
     else:
+        if not settings.basetgz:
+            temp_tgz = chroot.create_temp_tgz_file()
+            # FIXME: on panic remove temp_tgz
+            chroot.pack_into_tgz(temp_tgz)
+
         chroot.upgrade_to_distros(settings.debian_distros[1:], [])
         chroot.run(["apt-get", "clean"])
 
@@ -1856,13 +1855,19 @@ def install_and_upgrade_between_distros(filenames, packages):
     
         chroot.remove()
         dont_do_on_panic(cid)
+
+        # leave indication in logfile why we do what we do
+        logging.info("Notice: package selections and meta data from target disto saved, now starting over from source distro. See the description of --save-end-meta and --end-meta to learn why this is neccessary and how to possibly avoid it.")
+
         chroot = get_chroot()
-        chroot.create()
+        if settings.basetgz:
+            chroot.create()
+        else:
+            # FIXME: restore from temp_tgz
+            chroot.remove_temp_tgz_file(temp_tgz)
+            chroot.create()
         cid = do_on_panic(chroot.remove)
 
-    # leave indication in logfile why we do what we do
-    logging.info("Notice: package selections and meta data from target disto saved, now starting over from source distro. See the description of --save-end-meta and --end-meta to learn why this is neccessary and how to possibly avoid it.")
-
     chroot.check_for_no_processes()
 
     chroot.run(["apt-get", "update"])
@@ -1891,8 +1896,6 @@ def install_and_upgrade_between_distros(filenames, packages):
 
     chroot.check_for_no_processes()
     
-    if root_tgz != settings.basetgz:
-        chroot.remove_temp_tgz_file(root_tgz)
     chroot.remove()
     dont_do_on_panic(cid)
 
-- 
tg: (b1dc817..) t/style/tmptgz (depends on: t/feat/remove_temp_tgz_file)



More information about the Piuparts-devel mailing list