commit 3591fbd69a554c5b04341a1ae6255d2e7e8312ff Author: Alex Dehnert Date: Thu Jun 28 17:02:27 2012 -0700 Fix installing Lucid and other VMs on a Precise host (LP:1008225) This fixes two issues: * Starting in Lucid, it appears that upstart gets installed after initctl is moved out of the way. Because the initctl move was accomplished using os.rename, the reinstall was replacing our stub initctl with a real initctl, which was allowing cron to start. By using dpkg-divert instead, the installed initctl will get moved out of the way as well. * For reasons unclear to me, Hardy appears to be suffering from the mysterious process keeping /dev busy that Michael Vogt found in Oneiric. Thus, I've moved his sleep for one second work-around all the way back to Hardy. diff --git a/VMBuilder/plugins/ubuntu/edgy.py b/VMBuilder/plugins/ubuntu/edgy.py index 9c2081d..eef8a98 100644 --- a/VMBuilder/plugins/ubuntu/edgy.py +++ b/VMBuilder/plugins/ubuntu/edgy.py @@ -72,13 +72,20 @@ proc /proc proc defaults self.install_from_template('/etc/timezone', 'timezone', { 'timezone' : timezone }) self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'tzdata') + def divert_file(self, path, add): + full_path = '%s/%s' % (self.context.chroot_dir, path) + renamed_path = '%s.real' % (full_path, ) + if add: (src, dst) = full_path, renamed_path + else: (src, dst) = renamed_path, full_path + os.rename(src, dst) + def prevent_daemons_starting(self): super(Edgy, self).prevent_daemons_starting() - initctl = '%s/sbin/initctl' % (self.context.chroot_dir,) - os.rename(initctl, '%s.REAL' % (initctl,)) + initctl = '/sbin/initctl' + self.divert_file(initctl, True) self.install_from_template('/sbin/initctl', 'initctl-stub', mode=0755) def unprevent_daemons_starting(self): super(Edgy, self).unprevent_daemons_starting() - initctl = '%s/sbin/initctl' % (self.context.chroot_dir,) - os.rename('%s.REAL' % (initctl,), initctl) + initctl = '/sbin/initctl' + self.divert_file(initctl, False) diff --git a/VMBuilder/plugins/ubuntu/hardy.py b/VMBuilder/plugins/ubuntu/hardy.py index dcf661a..6925bb7 100644 --- a/VMBuilder/plugins/ubuntu/hardy.py +++ b/VMBuilder/plugins/ubuntu/hardy.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +import time from VMBuilder.plugins.ubuntu.gutsy import Gutsy class Hardy(Gutsy): @@ -56,3 +57,9 @@ class Hardy(Gutsy): def has_256_bit_inode_ext3_support(self): return True + + def unmount_dev(self): + # no idea why, but something keep /dev busy briefly during the + # bootstrap + time.sleep(1) + super(Hardy, self).unmount_dev() diff --git a/VMBuilder/plugins/ubuntu/lucid.py b/VMBuilder/plugins/ubuntu/lucid.py index 77238a9..16bde3c 100644 --- a/VMBuilder/plugins/ubuntu/lucid.py +++ b/VMBuilder/plugins/ubuntu/lucid.py @@ -16,8 +16,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +import os +from VMBuilder.util import run_cmd from VMBuilder.plugins.ubuntu.karmic import Karmic class Lucid(Karmic): valid_flavours = { 'i386' : ['386', 'generic', 'generic-pae', 'virtual'], 'amd64' : ['generic', 'preempt', 'server', 'virtual'] } + + def divert_file(self, path, add): + if add: action = "--add" + else: action = "--remove" + if not add: + os.remove('%s/%s' % (self.context.chroot_dir, path)) + run_cmd('chroot', self.context.chroot_dir, 'dpkg-divert', '--local', '--rename', action, path) diff --git a/VMBuilder/plugins/ubuntu/oneiric.py b/VMBuilder/plugins/ubuntu/oneiric.py index 64228cb..9a9baa3 100644 --- a/VMBuilder/plugins/ubuntu/oneiric.py +++ b/VMBuilder/plugins/ubuntu/oneiric.py @@ -16,13 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -import time from VMBuilder.plugins.ubuntu.natty import Natty class Oneiric(Natty): - - def unmount_dev(self): - # no idea why, but something keep /dev busy briefly during the - # bootstrap - time.sleep(1) - super(Oneiric, self).unmount_dev() + pass