> Feature request: please also check where /proc should be ignored in > piuparts code. One place I found is the code for the '-s' option (save > tarball), which now generates a tar of my /proc
You're right, I missed to test this case. I think writing back the tarball is the only place, where /proc should not be mounted. It would be nice, if /proc/* could simply be excluded, but this is possible only in Python 2.6. I modified the patch (see attachment), which now changes these things: 1. moves mount_proc() to the ctor of the Chroot class, eliminating the need to call it from various places. /proc is mounted as soon as the chroot is configured. For exporting the chroot to a tarball, /proc gets unmounted first and mounted again afterwards. 2. Did some small refactorings to the ctor code of the Chroot class to elimintate some duplication and a double call of apt-get update. 3. Allow the tarball to be written also with -s, when -b is used. This might be useful, to get an updated and minimized tarball from the base.tar.gz provided with the -b argument. Tobias
diff -Nur piuparts.svn.orig/piuparts.py piuparts.svn/piuparts.py --- piuparts.svn.orig/piuparts.py 2008-04-30 22:45:43.000000000 +0200 +++ piuparts.svn/piuparts.py 2008-05-01 00:48:57.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,6 +572,12 @@ def pack_into_tgz(self, result): """Tar and compress all files in the chroot.""" logging.debug("Saving %s to %s." % (self.name, result)) + + # don't try to tar a mounted /proc - it would be nicer to just + # exclude /proc/* from the taball, but this is only available + # in python 2.6 + self.unmount_proc() + try: tf = tarfile.open(result, "w:gz") tf.add(self.name, arcname=".") @@ -571,6 +587,8 @@ (result, detail)) panic() + self.mount_proc() + def unpack_from_tgz(self, tarball): """Unpack a tarball to a chroot.""" logging.debug("Unpacking %s into %s" % (tarball, self.name)) @@ -608,9 +626,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 +648,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 +1403,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 +1465,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 +1473,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 +1494,6 @@ chroot.check_for_no_processes() chroot.check_for_broken_symlinks() - chroot.unmount_proc() - return check_results(chroot, root_info, file_owners) @@ -1521,9 +1531,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 +1549,6 @@ chroot.check_for_no_processes() - chroot.mount_proc() - chroot.run(["apt-get", "update"]) chroot.install_packages_by_name(packages) @@ -1565,8 +1571,6 @@ chroot.check_for_no_processes() - chroot.unmount_proc() - if root_tgz != settings.basetgz: remove_files([root_tgz]) chroot.remove()
signature.asc
Description: OpenPGP digital signature