Lars Wirzenius wrote:

> I remember having some problem calling tar directly back in the ancient
> pre-history of piuparts, but since I can't remember what it was, and
> since it's been almost three years and everything has changed since
> then, I say go for it. If it turns out to be a problem, we'll fix it.

Ok. Here's the same patch as before, but now using tar, so unmounting
/proc is not necessary anymore - ./proc/* simply gets excluded from the
tarball.


Tobias
diff -Nur piuparts.orig/piuparts.py piuparts.svn/piuparts.py
--- piuparts.orig/piuparts.py   2008-05-04 14:48:47.000000000 +0200
+++ piuparts.svn/piuparts.py    2008-05-04 14:37:22.000000000 +0200
@@ -530,19 +537,22 @@
         """Create a chroot according to user's wishes."""
         self.create_temp_dir()
         id = do_on_panic(self.remove)
+
         if settings.basetgz:
             self.unpack_from_tgz(settings.basetgz)
-            self.configure_chroot()
-            self.run(["apt-get", "update"])
-            self.run(["apt-get", "-yf", "upgrade"])
-            self.minimize()
-            self.run(["apt-get", "clean"])
         else:
             self.setup_minimal_chroot()
-            self.run(["apt-get", "update"])
-            self.run(["apt-get", "clean"])
-            if settings.savetgz:
-                self.pack_into_tgz(settings.savetgz)
+
+        self.configure_chroot()
+        self.mount_proc()
+        if settings.basetgz:
+            self.run(["apt-get", "-yf", "upgrade"])
+        self.minimize()
+        self.run(["apt-get", "clean"])
+
+        if settings.savetgz:
+            self.pack_into_tgz(settings.savetgz)
+
         dont_do_on_panic(id)
 
     def remove(self):
@@ -562,14 +572,8 @@
     def pack_into_tgz(self, result):
         """Tar and compress all files in the chroot."""
         logging.debug("Saving %s to %s." % (self.name, result))
-        try:
-            tf = tarfile.open(result, "w:gz")
-            tf.add(self.name, arcname=".")
-            tf.close()
-        except tarfile.TarError, detail:
-            logging.error("Couldn't create tar file %s: %s" % 
-                          (result, detail))
-            panic()
+
+        run(['tar', '--exclude', './proc/*', '-czf', result, '-C', self.name, 
'./'])
 
     def unpack_from_tgz(self, tarball):
         """Unpack a tarball to a chroot."""
@@ -608,9 +612,6 @@
               (settings.debian_distros[0], self.name))
         run(["debootstrap", "--resolve-deps", settings.debian_distros[0], 
              self.name, settings.debian_mirrors[0][0]])
-        self.configure_chroot()
-        self.run(["apt-get", "update"])
-        self.minimize()
 
     def minimize(self):
         """Minimize a chroot by removing (almost all) unnecessary packages"""
@@ -633,6 +634,7 @@
             self.create_apt_sources(settings.debian_distros[0])
         self.create_apt_conf()
         self.create_policy_rc_d()
+        self.run(["apt-get", "update"])
 
     def upgrade_to_distros(self, distros, packages):
         """Upgrade a chroot installation to each successive distro."""
@@ -1387,7 +1389,6 @@
        chroot, with packages in states given by 'selections'."""
 
     # Install packages into the chroot.
-    chroot.mount_proc()
 
     if settings.warn_on_others:
         # Create a metapackage with dependencies from the given packages
@@ -1450,7 +1451,6 @@
     chroot.restore_selections(changes, packages)
     
     chroot.check_for_broken_symlinks()
-    chroot.unmount_proc()
 
     return check_results(chroot, root_info, file_owners, deps_info=deps_info)
 
@@ -1459,8 +1459,6 @@
     """Install package via apt-get, then upgrade from package files.
     Return True if successful, False if not."""
 
-    chroot.mount_proc()
-
     # First install via apt-get.
     chroot.install_packages_by_name(package_names)
     
@@ -1482,8 +1480,6 @@
     chroot.check_for_no_processes()
     chroot.check_for_broken_symlinks()
 
-    chroot.unmount_proc()
-
     return check_results(chroot, root_info, file_owners)
 
 
@@ -1521,9 +1517,7 @@
     if settings.endmeta:
         root_info, selections = load_meta_data(settings.endmeta)
     else:
-        chroot.mount_proc()
         chroot.upgrade_to_distros(settings.debian_distros[1:], [])
-        chroot.unmount_proc()
         chroot.run(["apt-get", "clean"])
 
         root_info = chroot.save_meta_data()
@@ -1541,8 +1535,6 @@
 
     chroot.check_for_no_processes()
     
-    chroot.mount_proc()
-
     chroot.run(["apt-get", "update"])
     chroot.install_packages_by_name(packages)
 
@@ -1565,8 +1557,6 @@
 
     chroot.check_for_no_processes()
     
-    chroot.unmount_proc()
-
     if root_tgz != settings.basetgz:
         remove_files([root_tgz])
     chroot.remove()

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to