On Mon, 2011-05-23 at 14:37 +0200, Ales Kozumplik wrote: > This is because the information that FSSet provides depends on the > information udev is able to provide and this is incomplete for certain > virtual DVD drives. The right answer seems to be either "NACK -- this is a udev bug" or "ACK, conditional on you filing a bug against udev". In the latter case, maybe we should even make a statement that the hack will be removed prior to F16 Alpha so don't let up on udev maintainers for a real fix. Dave > > Unittest for iutil.is_dev_mounted_on() included. > > Resolves: rhbz#702511 > --- > pyanaconda/iutil.py | 8 ++++++++ > pyanaconda/yuminstall.py | 11 +++++------ > tests/pyanaconda_test/iutil_test.py | 31 +++++++++++++++++++++++++++++++ > 3 files changed, 44 insertions(+), 6 deletions(-) > create mode 100644 tests/pyanaconda_test/iutil_test.py > > diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py > index 2387576..e77c5a4 100644 > --- a/pyanaconda/iutil.py > +++ b/pyanaconda/iutil.py > @@ -965,3 +965,11 @@ def fork_orphan(): > # the original process waits for the intermediate child > os.waitpid(intermediate, 0) > return 1 > + > +def is_dev_mounted_on(dev, mountpoint): > + regex = re.compile("^%s on (\S*)" % dev) > + for line in execWithCapture("mount", []).splitlines(): > + m = regex.match(line) > + if m and m.group(1) == mountpoint: > + return True > + return False > diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py > index 378d4a1..4211257 100644 > --- a/pyanaconda/yuminstall.py > +++ b/pyanaconda/yuminstall.py > @@ -375,7 +375,11 @@ class AnacondaYum(yum.YumBase): > # See if there's any media mounted on self.tree before continuing. > # This saves a useless eject and insert if the user has already put > # the disc in the drive. > - if not self.anaconda.storage.fsset.mountpoints.has_key(self.tree): > + if iutil.is_dev_mounted_on(dev.path, self.tree): > + if verifyMedia(self.tree, None): > + return > + dev.format.unmount() > + else: > try: > dev.format.mount() > > @@ -385,11 +389,6 @@ class AnacondaYum(yum.YumBase): > dev.format.unmount() > except Exception: > pass > - else: > - if verifyMedia(self.tree, None): > - return > - > - dev.format.unmount() > > dev.eject() > > diff --git a/tests/pyanaconda_test/iutil_test.py b/tests/pyanaconda_test/iutil_test.py > new file mode 100644 > index 0000000..164351d > --- /dev/null > +++ b/tests/pyanaconda_test/iutil_test.py > @@ -0,0 +1,31 @@ > +import mock > + > + > +class IutilTest(mock.TestCase): > + def setUp(self): > + self.setupModules( > + ['_isys', 'logging', 'pyanaconda.anaconda_log', 'block']) > + > + from pyanaconda import iutil > + iutil.log = mock.Mock() > + iutil.log = mock.Mock() > + > + def tearDown(self): > + self.tearDownModules() > + > + def is_dev_mounted_on_test(self): > + from pyanaconda import iutil > + iutil.execWithCapture = mock.Mock() > + iutil.execWithCapture.return_value = """ > +rootfs on / type rootfs (rw,relatime) > +/proc on /proc type proc (rw,relatime) > +/dev on /dev type tmpfs (rw,relatime,seclabel) > +/dev/pts on /dev/pts type devpts (rw,relatime,seclabel,mode=600,ptmxmode=000) > +/sys on /sys type sysfs (rw,relatime,seclabel) > +none on /tmp type tmpfs (rw,relatime,seclabel,size=256000k) > +/dev/sr0 on /mnt/source type iso9660 (ro,relatime) > +/selinux on /selinux type selinuxfs (rw,relatime) > +""" > + self.assertTrue(iutil.is_dev_mounted_on("/dev/sr0", "/mnt/source")) > + self.assertTrue(iutil.is_dev_mounted_on("rootfs", "/")) > + self.assertFalse(iutil.is_dev_mounted_on("/dev/sr0", "/mnt/sysimage")) _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list