コード例 #1
0
ファイル: upgrade.py プロジェクト: abiquo/anaconda-ee
def mountRootPartition(anaconda, rootInfo, oldfsset, allowDirty = 0,
		       warnDirty = 0, readOnly = 0):
    (root, rootFs) = rootInfo

    diskset = partedUtils.DiskSet(anaconda)
    encryptedDevices = anaconda.id.partitions.encryptedDevices
    diskset.openDevices()
    for cryptoDev in encryptedDevices.values():
        cryptoDev.openDevice()
    diskset.startMPath()
    diskset.startDmRaid()
    diskset.startMdRaid()
    for cryptoDev in encryptedDevices.values():
        cryptoDev.openDevice()
    lvm.vgscan()
    lvm.vgactivate()
    for cryptoDev in encryptedDevices.values():
        if cryptoDev.openDevice():
            log.warning("failed to open encrypted device %s" % (cryptoDev.getDevice(encrypted=True)))

    log.info("going to mount %s on %s as %s" %(root, anaconda.rootPath, rootFs))
    isys.mount(root, anaconda.rootPath, rootFs)

    oldfsset.reset()
    newfsset = readFstab(anaconda)
    for entry in newfsset.entries:
        oldfsset.add(entry)

    isys.umount(anaconda.rootPath)

    dirtyDevs = oldfsset.hasDirtyFilesystems(anaconda.rootPath)
    if not allowDirty and dirtyDevs != []:
        lvm.vgdeactivate()
        diskset.stopMdRaid()
        diskset.stopDmRaid()
        diskset.stopMPath()
        anaconda.intf.messageWindow(_("Dirty File Systems"),
                           _("The following file systems for your Linux system "
                             "were not unmounted cleanly.  Please boot your "
                             "Linux installation, let the file systems be "
                             "checked and shut down cleanly to upgrade.\n"
                             "%s" %(getDirtyDevString(dirtyDevs),)))
        sys.exit(0)
    elif warnDirty and dirtyDevs != []:
        rc = anaconda.intf.messageWindow(_("Dirty File Systems"),
                                _("The following file systems for your Linux "
                                  "system were not unmounted cleanly.  Would "
                                  "you like to mount them anyway?\n"
                                  "%s" % (getDirtyDevString(dirtyDevs,))),
                                type = "yesno")
        if rc == 0:
            return -1

    if flags.setupFilesystems:
        oldfsset.mountFilesystems(anaconda, readOnly = readOnly)

    if (not oldfsset.getEntryByMountPoint("/") or
        not oldfsset.getEntryByMountPoint("/").fsystem or
        not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()):
        raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support"
コード例 #2
0
ファイル: common.py プロジェクト: MagicGroup/magicinstaller2
def umount_dev(mntdir, rmdir=True):
    def umount_loop_dev(mntdir):
        cmd = '/bin/umount'
        argv = [mntdir]
        cmdres = run_bash(cmd, argv)
        if cmdres['ret']:
            return False, str(cmdres['err'])
        else:
            loop_dev, isopath = LOOP_DEVICES[mntdir]
            cmd = '/sbin/losetup'
            argv = ['-d', loop_dev]
            cmdres = run_bash(cmd, argv)
            if cmdres['ret']:
                return False, str(cmdres['err'])
            else:
                free_loop(loop_dev)
                LOOP_DEVICES.pop(mntdir, '')
                return True, ''

    isys.sync()
    if USE_ISYS:
        try:
            isys.umount(mntdir)
        except SystemError, e:
            errmsg = "umount_dev: umount failed: %s\n" % str(e)
            logger.e(errmsg)
            return False, errmsg
コード例 #3
0
def umount_dev(mntdir, rmdir=True):
    def umount_loop_dev(mntdir):
        cmd = '/bin/umount'
        argv = [mntdir]
        cmdres = run_bash(cmd, argv)
        if cmdres['ret']:
            return False, str(cmdres['err'])
        else:
            loop_dev, isopath = LOOP_DEVICES[mntdir]
            cmd = '/sbin/losetup'
            argv = ['-d', loop_dev]
            cmdres = run_bash(cmd, argv)
            if cmdres['ret']:
                return False, str(cmdres['err'])
            else:
                free_loop(loop_dev)
                LOOP_DEVICES.pop(mntdir, '')
                return True, ''

    isys.sync()
    if USE_ISYS:
        try:
            isys.umount(mntdir)
        except SystemError, e:
            errmsg = "umount_dev: umount failed: %s\n" % str(e)
            logger.e(errmsg)
            return False, errmsg
コード例 #4
0
ファイル: harddrive.py プロジェクト: abelboldu/anaconda-ee
    def umountMedia(self):
	if self.mediaIsMounted:
	    isys.umount(self.tree)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.umountDirectory()
	    self.mediaIsMounted = 0
コード例 #5
0
ファイル: image.py プロジェクト: rossonet/Strumenti-RCloud
    def umountImage(self):
	if self.currentMedia:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.currentMedia = []
コード例 #6
0
 def filesDone(self):
     # we're trying to unmount the CD here.  if it fails, oh well,
     # they'll reboot soon enough I guess :)
     try:
         isys.umount("/mnt/source")
     except Exception, e:
         log.error("unable to unmount source in filesDone: %s" %(e,))
コード例 #7
0
    def umountImage(self):
	if self.currentMedia:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.currentMedia = []
コード例 #8
0
ファイル: image.py プロジェクト: rossonet/Strumenti-RCloud
 def filesDone(self):
     # we're trying to unmount the CD here.  if it fails, oh well,
     # they'll reboot soon enough I guess :)
     try:
         isys.umount("/mnt/source")
     except Exception, e:
         log.error("unable to unmount source in filesDone: %s" %(e,))
コード例 #9
0
    def umountImage(self):
	if self.imageMounted:
	    isys.umount(self.mntPoint)
	    isys.makeDevInode("loop3", "/tmp/loop3")
	    isys.unlosetup("/tmp/loop3")
	    self.mntPoint = None
	    self.imageMounted = 0
コード例 #10
0
    def findExistingRootPartitions(self, intf, mountpoint, upgradeany = 0):
        """Return a list of all of the partitions which look like a root fs."""
        rootparts = []

        self.startAllRaid()

        for dev, devices, level, numActive in self.mdList:
            (errno, msg) = (None, None)
            found = 0
            for fs in fsset.getFStoTry(dev):
                try:
                    isys.mount(dev, mountpoint, fs, readOnly = 1)
                    found = 1
                    break
                except SystemError, (errno, msg):
                    pass

            if found:
                if os.access (mountpoint + '/etc/fstab', os.R_OK):
                    relstr = getRedHatReleaseString(mountpoint)
                    cmdline = open('/proc/cmdline', 'r').read()
                    
                    if ((cmdline.find("upgradeany") != -1) or
                        (upgradeany == 1) or
                        (productMatches(relstr, productName))):
                        rootparts.append ((dev, fs, relstr))
                isys.umount(mountpoint)
コード例 #11
0
ファイル: harddrive.py プロジェクト: adiabuk/progeny_projects
 def umountMedia(self):
     if self.mediaIsMounted:
         isys.umount(self.tree)
         isys.makeDevInode("loop3", "/tmp/loop3")
         isys.unlosetup("/tmp/loop3")
         self.umountDirectory()
         self.tree = None
         self.mediaIsMounted = 0
コード例 #12
0
def copyExceptionToFloppy(anaconda):
    # in test mode have save to floppy option just copy to new name
    if not flags.setupFilesystems:
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/test-anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to /tmp/test-anacdump.txt")
            pass

        anaconda.intf.__del__()
        return 2

    while 1:
        # Bail if they hit the cancel button.
        rc = anaconda.intf.dumpWindow()
        if rc:
            return 1

        device = anaconda.id.floppyDevice
        file = "/tmp/floppy"
        try:
            isys.makeDevInode(device, file)
        except SystemError:
            pass

        try:
            fd = os.open(file, os.O_RDONLY)
        except:
            continue

        os.close(fd)

        if rhpl.getArch() != "ia64":
            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect(cmd, ["/tmp/floppy"],
                                   stdout='/dev/tty5',
                                   stderr='/dev/tty5')

        try:
            isys.mount(device, "/tmp/crash", fstype="vfat")
        except SystemError:
            continue

        # copy trace dump we wrote to local storage to floppy
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/crash/anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to floppy")
            return 2

        isys.umount("/tmp/crash")
        return 0
コード例 #13
0
def mountRootPartition(intf,
                       rootInfo,
                       oldfsset,
                       instPath,
                       allowDirty=0,
                       raiseErrors=0,
                       warnDirty=0,
                       readOnly=0):
    (root, rootFs) = rootInfo

    diskset = partedUtils.DiskSet()
    diskset.openDevices()
    diskset.startAllRaid()
    lvm.vgscan()
    lvm.vgactivate()

    log("going to mount %s on %s as %s" % (root, instPath, rootFs))
    isys.mount(root, instPath, rootFs)

    oldfsset.reset()
    newfsset = fsset.readFstab(instPath + '/etc/fstab', intf)
    for entry in newfsset.entries:
        oldfsset.add(entry)

    isys.umount(instPath)

    dirtyDevs = oldfsset.hasDirtyFilesystems(instPath)
    if not allowDirty and dirtyDevs != []:
        diskset.stopAllRaid()
        lvm.vgdeactivate()
        intf.messageWindow(
            _("Dirty File Systems"),
            _("The following file systems for your Linux system "
              "were not unmounted cleanly.  Please boot your "
              "Linux installation, let the file systems be "
              "checked and shut down cleanly to upgrade.\n"
              "%s" % (getDirtyDevString(dirtyDevs), )))
        sys.exit(0)
    elif warnDirty and dirtyDevs != []:
        rc = intf.messageWindow(_("Dirty File Systems"),
                                _("The following file systems for your Linux "
                                  "system were not unmounted cleanly.  Would "
                                  "you like to mount them anyway?\n"
                                  "%s" % (getDirtyDevString(dirtyDevs, ))),
                                type="yesno")
        if rc == 0:
            return -1

    if flags.setupFilesystems:
        oldfsset.mountFilesystems(instPath, readOnly=readOnly)

    # XXX we should properly support 'auto' at some point
    if (not oldfsset.getEntryByMountPoint("/")
            or not oldfsset.getEntryByMountPoint("/").fsystem
            or not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()):
        raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support"
コード例 #14
0
 def _unmountNonFstabDirs(self, anaconda):
     # unmount things that aren't listed in /etc/fstab.  *sigh*
     dirs = []
     if flags.selinux:
         dirs.append("/sys/fs/selinux")
     for dir in dirs:
         try:
             isys.umount("%s/%s" %(anaconda.rootPath,dir), removeDir = False)
         except Exception, e:
             log.error("unable to unmount %s: %s" %(dir, e))
コード例 #15
0
ファイル: livecd.py プロジェクト: abiquo/anaconda-ee-el6
 def _unmountNonFstabDirs(self, anaconda):
     # unmount things that aren't listed in /etc/fstab.  *sigh*
     dirs = []
     if flags.selinux:
         dirs.append("/selinux")
     for dir in dirs:
         try:
             isys.umount("%s/%s" %(anaconda.rootPath,dir), removeDir = False)
         except Exception, e:
             log.error("unable to unmount %s: %s" %(dir, e))
コード例 #16
0
ファイル: exception.py プロジェクト: abelboldu/anaconda-ee
def copyExceptionToFloppy (anaconda):
    # in test mode have save to floppy option just copy to new name
    if not flags.setupFilesystems:
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/test-anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to /tmp/test-anacdump.txt")
            pass

        anaconda.intf.__del__ ()
        return 2

    while 1:
        # Bail if they hit the cancel button.
        rc = anaconda.intf.dumpWindow()
        if rc:
            return 1

        device = anaconda.id.floppyDevice
        file = "/tmp/floppy"
        try:
            isys.makeDevInode(device, file)
        except SystemError:
            pass
        
        try:
            fd = os.open(file, os.O_RDONLY)
        except:
            continue

        os.close(fd)

        if rhpl.getArch() != "ia64":
            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect (cmd, ["/tmp/floppy"], stdout = '/dev/tty5',
                                    stderr = '/dev/tty5')

        try:
            isys.mount(device, "/tmp/crash", fstype = "vfat")
        except SystemError:
            continue

        # copy trace dump we wrote to local storage to floppy
        try:
            shutil.copyfile("/tmp/anacdump.txt", "/tmp/crash/anacdump.txt")
        except:
            log.error("Failed to copy anacdump.txt to floppy")
            return 2

        isys.umount("/tmp/crash")
        return 0
コード例 #17
0
 def unmountCD(self):
     done = 0
     while done == 0:
         try:
             isys.umount("/mnt/source")
             self.currentMedia = []
             break
         except Exception, e:
             log.error("exception in unmountCD: %s" %(e,))
             self.messageWindow(_("Error"),
                                _("An error occurred unmounting the CD.  "
                                  "Please make sure you're not accessing "
                                  "%s from the shell on tty2 "
                                  "and then click OK to retry.")
                                % ("/mnt/source",))
コード例 #18
0
ファイル: image.py プロジェクト: rossonet/Strumenti-RCloud
 def unmountCD(self):
     done = 0
     while done == 0:
         try:
             isys.umount("/mnt/source")
             self.currentMedia = []
             break
         except Exception, e:
             log.error("exception in unmountCD: %s" %(e,))
             self.messageWindow(_("Error"),
                                _("An error occurred unmounting the CD.  "
                                  "Please make sure you're not accessing "
                                  "%s from the shell on tty2 "
                                  "and then click OK to retry.")
                                % ("/mnt/source",))
コード例 #19
0
ファイル: fs.py プロジェクト: 274914765/python
    def unmount(self):
        """ Unmount this filesystem. """
        if not self.exists:
            raise FSError("filesystem has not been created")

        if not self._mountpoint:
            # not mounted
            return

        if not os.path.exists(self._mountpoint):
            raise FSError("mountpoint does not exist")

        rc = isys.umount(self._mountpoint, removeDir = False)
        if rc:
            raise FSError("umount failed")

        self._mountpoint = None
コード例 #20
0
ファイル: fs.py プロジェクト: geamul/anaconda
    def unmount(self):
        """ Unmount this filesystem. """
        if not self.exists:
            raise FSError("filesystem has not been created")

        if not self._mountpoint:
            # not mounted
            return

        if not os.path.exists(self._mountpoint):
            raise FSError("mountpoint does not exist")

        rc = isys.umount(self._mountpoint, removeDir=False)
        if rc:
            raise FSError("umount failed")

        self._mountpoint = None
コード例 #21
0
def findIsoImages(path, messageWindow):
    files = os.listdir(path)
    arch = _arch
    discImages = {}

    for file in files:
	what = path + '/' + file
	if not isys.isIsoImage(what):
            continue

	isys.makeDevInode("loop2", "/tmp/loop2")

	try:
	    isys.losetup("/tmp/loop2", what, readOnly = 1)
	except SystemError:
	    continue

	try:
	    isys.mount("loop2", "/mnt/cdimage", fstype = "iso9660",
		       readOnly = 1)
	    for num in range(1, 10):
		if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                    f = open("/mnt/cdimage/.discinfo")
                    try:
                        f.readline() # skip timestamp
                        f.readline() # skip release description
                        discArch = string.strip(f.readline()) # read architecture
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discArch = None
                        discNum = [ 0 ]

                    f.close()

                    if num not in discNum or discArch != arch:
                        continue

                    # if it's disc1, it needs to have RedHat/base/stage2.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/%s/base/stage2.img" % (productPath,),
                                  os.R_OK)):
                        continue
                    
		    # warn user if images appears to be wrong size
		    if os.stat(what)[stat.ST_SIZE] % 2048:
			rc = messageWindow(_("Warning"),
	       "The ISO image %s has a size which is not "
	       "a multiple of 2048 bytes.  This may mean "
	       "it was corrupted on transfer to this computer."
	       "\n\n"
               "It is recommended that you reboot and abort your "
               "installation, but you can choose to continue if "
               "you think this is in error." % (file,),
                                           type="custom",
                                           custom_icon="warning",
                                           custom_buttons= [_("_Reboot"),
                                                            _("_Continue")])
                        if rc == 0:
			    sys.exit(0)

		    discImages[num] = file

	    isys.umount("/mnt/cdimage")
	except SystemError:
	    pass

	isys.makeDevInode("loop2", '/tmp/' + "loop2")
	isys.unlosetup("/tmp/loop2")

    return discImages
コード例 #22
0
ファイル: __init__.py プロジェクト: mx2x/silvereye
    def postAction(self, anaconda):
        silvereye.InstallClass.postAction(self, anaconda)

        # XXX: use proper constants for path names
        def copy_script(src, dest, mode=0770):
            shutil.copyfile('/tmp/updates/scripts/%s' % src,
                            '%s%s' % (anaconda.rootPath, dest))
            os.chmod('%s%s' % (anaconda.rootPath, dest), mode)

        def copy_file(src, dest):
            copy_script(src, dest, mode=0644)

        copy_script('eucalyptus-frontend-config.sh',
                    '/usr/local/sbin/eucalyptus-frontend-config')
        copy_script('eucalyptus-teardown',
                    '/usr/local/sbin/eucalyptus-teardown')
        copy_script('install-unpacked-image.py',
                    '/usr/local/sbin/install-unpacked-image.py')
        copy_script('eucalyptus-setup.init', '/etc/init.d/eucalyptus-setup')
        copy_script('register_cloud_start',
                    '/usr/local/sbin/register_cloud_start',
                    mode=0755)

        os.mkdir('%s/tmp/img' % anaconda.rootPath)
        # EKI
        shutil.copyfile('/tmp/updates/scripts/vmlinuz-kexec',
                        '%s/tmp/img/vmlinuz-kexec' % anaconda.rootPath)

        # ERI
        shutil.copyfile('/tmp/updates/scripts/initramfs-kexec',
                        '%s/tmp/img/initramfs-kexec' % anaconda.rootPath)

        # Image kickstart
        newks = open('%s/tmp/ks-centos6.cfg' % anaconda.rootPath, 'w')
        ayum = anaconda.backend.ayum

        for repo in ayum.repos.listEnabled():
            newks.write('repo --name=%s --baseurl=%s\n' %
                        (repo.name, repo.baseurl[0]))
        for line in open('/tmp/updates/ks-centos6.cfg', 'r').readlines():
            if line.startswith('repo '):
                continue
            newks.write(line)
        newks.close()

        # Image creation script
        copy_script('ami_creator.py', '/tmp/ami_creator.py')

        # XXX clean this up
        bindmount = False
        if ayum._baseRepoURL and ayum._baseRepoURL.startswith("file://"):
            os.mkdir('/mnt/sysimage/mnt/source')
            isys.mount('/mnt/source',
                       '/mnt/sysimage/mnt/source',
                       bindMount=True)
            bindmount = True

        # eucalyptus.conf fragment from config screen
        w = anaconda.intf.progressWindow(
            _("Creating EMI"), _("Creating an initial CentOS 6 EMI."), 100)
        shutil.copyfile(
            '/tmp/eucalyptus.conf',
            '%s/etc/eucalyptus/eucalyptus.conf.anaconda' % anaconda.rootPath)
        copy_script(
            'eucalyptus-firstboot-final.py',
            '/usr/share/firstboot/modules/eucalyptus-firstboot-final.py')

        postscriptlines = """
/usr/sbin/euca_conf --upgrade-conf /etc/eucalyptus/eucalyptus.conf.anaconda
chkconfig dnsmasq off
chkconfig eucalyptus-cloud off
chkconfig eucalyptus-setup on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/frontend-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)

        # TODO: Add status line for text mode
        pkgstatus = None
        if anaconda.id.displayMode == 'g':
            import gtk
            pkgstatus = gtk.Label("Preparing to install...")
            w.window.child.add(pkgstatus)
            pkgstatus.show()

        messages = '/root/ami-creation.log'
        rc = iutil.execWithCallback(
            '/bin/sh',
            ['-c', 'cd /tmp/img; /tmp/ami_creator.py -c /tmp/ks-centos6.cfg'],
            stdin=messages,
            stdout=messages,
            stderr=messages,
            root='/mnt/sysimage',
            callback=imageProgress,
            callback_data=ImageProgress(w, pkgstatus))

        if bindmount:
            isys.umount('/mnt/sysimage/mnt/source')
        w.pop()
コード例 #23
0
    def getRPMFilename(self, h, timer, callback=None):
        if h[1000002] == None or 1000002 not in h.keys():
            log ("header for %s has no disc location tag, assuming it's"
                 "on the current CD" %(h[1000000],))
        elif h[1000002] not in self.currentDisc:
	    timer.stop()
            log("switching from iso %s to %s for %s-%s-%s.%s" %(self.currentDisc, h[1000002], h['name'], h['version'], h['release'], h['arch']))

            if os.access("/mnt/source/.discinfo", os.R_OK):
                f = open("/mnt/source/.discinfo")
                timestamp = f.readline().strip()
                f.close()
            else:
                timestamp = self.timestamp

            if self.timestamp is None:
                self.timestamp = timestamp

	    needed = h[1000002]

            # if self.currentDisc is empty, then we shouldn't have anything
            # mounted.  double-check by trying to unmount, but we don't want
            # to get into a loop of trying to unmount forever.  if
            # self.currentDisc is set, then it should still be mounted and
            # we want to loop until it unmounts successfully
            if not self.currentDisc:
                try:
                    isys.umount("/mnt/source")
                except:
                    pass
            else:
                self.unmountCD()

	    done = 0

	    cdlist = []
	    for (dev, something, descript) in \
		    kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
                cdlist.append(dev)

	    for dev in cdlist:
		try:
		    if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
			       readOnly = 1):
			if os.access("/mnt/source/.discinfo", os.R_OK):
			    f = open("/mnt/source/.discinfo")
			    newStamp = f.readline().strip()
                            try:
                                descr = f.readline().strip()
                            except:
                                descr = None
                            try:
                                arch = f.readline().strip()
                            except:
                                arch = None
                            try:
                                discNum = getDiscNums(f.readline().strip())
                            except:
                                discNum = [ 0 ]
			    f.close()
			    if (newStamp == timestamp and
                                arch == _arch and
                                needed in discNum):
				done = 1
                                self.currentDisc = discNum

			if not done:
			    isys.umount("/mnt/source")
		except:
		    pass

		if done:
		    break

	    if not done:
		isys.ejectCdrom(self.device)

	    while not done:
		self.messageWindow(_("Change CDROM"), 
		    _("Please insert disc %d to continue.") % needed)

		try:
		    if isys.mount(self.device, "/mnt/source", 
				  fstype = "iso9660", readOnly = 1):
			time.sleep(3)
			isys.mount(self.device, "/mnt/source", 
				   fstype = "iso9660", readOnly = 1)
		    

                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
			newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
			f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
			    done = 1
                            self.currentDisc = discNum
                            # make /tmp/cdrom again so cd gets ejected
                            isys.makeDevInode(self.device, "/tmp/cdrom")

		    if not done:
			self.messageWindow(_("Wrong CDROM"),
				_("That's not the correct %s CDROM.")
                                           % (productName,))
			isys.umount("/mnt/source")
			isys.ejectCdrom(self.device)
		except:
		    self.messageWindow(_("Error"), 
			    _("The CDROM could not be mounted."))

	    timer.start()

        # if we haven't read a timestamp yet, let's try to get one
        if (self.timestamp is None and
            os.access("/mnt/source/.discinfo", os.R_OK)):
            try:
                f = open("/mnt/source/.discinfo")
                self.timestamp = f.readline().strip()
                f.close()
            except:
                pass

        tmppath = self.getTempPath()
        tries = 0
        # FIXME: should retry a few times then prompt for new cd
        while tries < 5:
            try:
                shutil.copy("%s/%s/RPMS/%s" % (self.tree, productPath,
                                               h[1000000]),
                            tmppath + h[1000000])
            except IOError, (errnum, msg):
                log("IOError %s occurred copying %s: %s",
                    errnum, h[1000000], str(msg))
                time.sleep(5)
            else:
                break
            tries = tries + 1
コード例 #24
0
def findIsoImages(path, messageWindow):
    flush = os.stat(path)
    files = os.listdir(path)
    arch = _arch
    discImages = {}

    for file in files:
        what = path + '/' + file
        if not isys.isIsoImage(what):
            continue

        try:
            isys.losetup("/dev/loop2", what, readOnly = 1)
        except SystemError:
            continue

        try:
            isys.mount("/dev/loop2", "/mnt/cdimage", fstype = "iso9660",
                       readOnly = True)
            for num in range(1, 10):
                if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                    f = open("/mnt/cdimage/.discinfo")
                    try:
                        f.readline() # skip timestamp
                        f.readline() # skip release description
                        discArch = string.strip(f.readline()) # read architecture
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discArch = None
                        discNum = [ 0 ]

                    f.close()

                    if num not in discNum or discArch != arch:
                        continue

                    # if it's disc1, it needs to have images/install.img
                    if (num == 1 and not
                        os.access("/mnt/cdimage/images/install.img", os.R_OK)):
                        log.warning("%s doesn't have a install.img, skipping" %(what,))
                        continue
                    # we only install binary packages, so let's look for a
                    # product/ dir and hope that this avoids getting
                    # discs from the src.rpm set
                    if not os.path.isdir("/mnt/cdimage/%s" %(productPath,)):
                        log.warning("%s doesn't have binary RPMS, skipping" %(what,))
                        continue

                    # warn user if images appears to be wrong size
                    if os.stat(what)[stat.ST_SIZE] % 2048:
                        rc = messageWindow(_("Warning"),
                             _("The ISO image %s has a size which is not "
                               "a multiple of 2048 bytes.  This may mean "
                               "it was corrupted on transfer to this computer."
                               "\n\n"
                               "It is recommended that you exit and abort your "
                               "installation, but you can choose to continue if "
                               "you think this is in error.") % (file,),
                               type="custom", custom_icon="warning",
                               custom_buttons= [_("_Exit installer"),
                                                _("_Continue")])
                        if rc == 0:
                            sys.exit(0)

                    discImages[num] = file

            isys.umount("/mnt/cdimage", removeDir=False)
        except SystemError:
            pass

        isys.unlosetup("/dev/loop2")

    return discImages
コード例 #25
0
ファイル: harddrive.py プロジェクト: abelboldu/anaconda-ee
    def umountDirectory(self):
	if self.isoDirIsMounted:
	    isys.umount(self.isoDir)
	    self.isoDirIsMounted = 0
コード例 #26
0
ファイル: image.py プロジェクト: darkshram/aldos-anaconda
def umountImage(tree, currentMedia):
    if currentMedia is not None:
        isys.umount(tree, removeDir=False)
コード例 #27
0
def mountRootPartition(anaconda,
                       rootInfo,
                       oldfsset,
                       allowDirty=0,
                       warnDirty=0,
                       readOnly=0):
    (root, rootFs) = rootInfo

    diskset = partedUtils.DiskSet(anaconda)
    encryptedDevices = anaconda.id.partitions.encryptedDevices
    diskset.openDevices()
    for cryptoDev in encryptedDevices.values():
        cryptoDev.openDevice()
    diskset.startMPath()
    diskset.startDmRaid()
    diskset.startMdRaid()
    for cryptoDev in encryptedDevices.values():
        cryptoDev.openDevice()
    lvm.vgscan()
    lvm.vgactivate()
    for cryptoDev in encryptedDevices.values():
        if cryptoDev.openDevice():
            log.warning("failed to open encrypted device %s" %
                        (cryptoDev.getDevice(encrypted=True)))

    log.info("going to mount %s on %s as %s" %
             (root, anaconda.rootPath, rootFs))
    isys.mount(root, anaconda.rootPath, rootFs)

    oldfsset.reset()
    newfsset = readFstab(anaconda)
    for entry in newfsset.entries:
        oldfsset.add(entry)

    isys.umount(anaconda.rootPath)

    dirtyDevs = oldfsset.hasDirtyFilesystems(anaconda.rootPath)
    if not allowDirty and dirtyDevs != []:
        lvm.vgdeactivate()
        diskset.stopMdRaid()
        diskset.stopDmRaid()
        diskset.stopMPath()
        anaconda.intf.messageWindow(
            _("Dirty File Systems"),
            _("The following file systems for your Linux system "
              "were not unmounted cleanly.  Please boot your "
              "Linux installation, let the file systems be "
              "checked and shut down cleanly to upgrade.\n"
              "%s" % (getDirtyDevString(dirtyDevs), )))
        sys.exit(0)
    elif warnDirty and dirtyDevs != []:
        rc = anaconda.intf.messageWindow(
            _("Dirty File Systems"),
            _("The following file systems for your Linux "
              "system were not unmounted cleanly.  Would "
              "you like to mount them anyway?\n"
              "%s" % (getDirtyDevString(dirtyDevs, ))),
            type="yesno")
        if rc == 0:
            return -1

    if flags.setupFilesystems:
        oldfsset.mountFilesystems(anaconda, readOnly=readOnly)

    if (not oldfsset.getEntryByMountPoint("/")
            or not oldfsset.getEntryByMountPoint("/").fsystem
            or not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()):
        raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support"
コード例 #28
0
ファイル: harddrive.py プロジェクト: adiabuk/progeny_projects
 def umountDirectory(self):
     if self.isoDirIsMounted:
         isys.umount(self.isoDir)
         self.tree = None
         self.isoDirIsMounted = 0
コード例 #29
0
ファイル: image.py プロジェクト: mattias-ohlsson/anaconda
def umountImage(tree):
    if os.path.ismount(tree):
        isys.umount(tree, removeDir=False)
コード例 #30
0
            else:
                msg = _("An error occurred transferring the install image "
                        "to your hard drive. You are probably out of disk "
                        "space.")

            anaconda.intf.messageWindow(_("Error"), msg)
            try:
                os.unlink(self._loopbackFile)
            except:
                pass

            return 1

        isys.lochangefd("/dev/loop0", self._loopbackFile)
        if os.path.ismount("/mnt/stage2"):
            isys.umount("/mnt/stage2")

    def removeInstallImage(self):
        if self._loopbackFile:
            try:
                os.unlink(self._loopbackFile)
            except SystemError:
                pass
   
    def freetmp(self, anaconda):
    # installs that don't use /mnt/stage2 hold the install.img on
    # a tmpfs, free this ram if things are tight.
        stage2img = "/tmp/install.img"
        if os.path.exists(stage2img):
            # free up /tmp for more memory before yum is called,
            if self.mountInstallImage(anaconda, stage2img):
コード例 #31
0
def umountImage(tree, currentMedia, loopdev):
    if currentMedia is not None:
        isys.umount(tree, removeDir=False)
        if loopdev:
            isys.unlosetup(loopdev)
コード例 #32
0
ファイル: __init__.py プロジェクト: AsherBond/silvereye
    def postAction(self, anaconda):
        silvereye.InstallClass.postAction(self, anaconda)
        # XXX: use proper constants for path names
        def copy_script(src, dest, mode=0770):
            shutil.copyfile('/tmp/updates/scripts/%s' % src,
                            '%s%s' % (anaconda.rootPath, dest))
            os.chmod('%s%s' % (anaconda.rootPath, dest), mode)

        def copy_file(src, dest):
            copy_script(src, dest, mode=0644)

        copy_script('eucalyptus-frontend-config.sh',
                    '/usr/local/sbin/eucalyptus-frontend-config')
        copy_script('eucalyptus-teardown',
                    '/usr/local/sbin/eucalyptus-teardown')
        copy_script('install-unpacked-image.py',
                    '/usr/local/sbin/install-unpacked-image.py')
        copy_script('eucalyptus-setup.init',
                    '/etc/init.d/eucalyptus-setup')
        copy_script('register_cloud_start',
                    '/usr/local/sbin/register_cloud_start', mode=0755)

        os.mkdir('%s/tmp/img' % anaconda.rootPath)
        # EKI
        shutil.copyfile('/tmp/updates/scripts/vmlinuz-kexec',
                        '%s/tmp/img/vmlinuz-kexec' % anaconda.rootPath)

        # ERI
        shutil.copyfile('/tmp/updates/scripts/initramfs-kexec',
                        '%s/tmp/img/initramfs-kexec' % anaconda.rootPath)

        # Image kickstart
        newks = open('%s/tmp/ks-centos6.cfg' % anaconda.rootPath, 'w')
        ayum = anaconda.backend.ayum

        for repo in ayum.repos.listEnabled():
            newks.write('repo --name=%s --baseurl=%s\n' % (repo.name, repo.baseurl[0]))
        for line in open('/tmp/updates/ks-centos6.cfg', 'r').readlines():
            if line.startswith('repo '):
                continue
            newks.write(line)
        newks.close()

        # Image creation script
        copy_script('ami_creator.py', '/tmp/ami_creator.py')

        # XXX clean this up
        bindmount = False
        if ayum._baseRepoURL and ayum._baseRepoURL.startswith("file://"):
            os.mkdir('/mnt/sysimage/mnt/source')
            isys.mount('/mnt/source', '/mnt/sysimage/mnt/source', bindMount=True)
            bindmount = True

        # eucalyptus.conf fragment from config screen
        w = anaconda.intf.progressWindow(_("Creating EMI"), 
                                     _("Creating an initial CentOS 6 EMI."), 100)
        shutil.copyfile('/tmp/eucalyptus.conf',
                        '%s/etc/eucalyptus/eucalyptus.conf.anaconda' % anaconda.rootPath)
        copy_script('eucalyptus-firstboot-final.py',
                    '/usr/share/firstboot/modules/eucalyptus-firstboot-final.py')

        postscriptlines ="""
/usr/sbin/euca_conf --upgrade-conf /etc/eucalyptus/eucalyptus.conf.anaconda
chkconfig dnsmasq off
chkconfig eucalyptus-cloud off
chkconfig eucalyptus-setup on
"""
        postscript = AnacondaKSScript(postscriptlines,
                                      inChroot=True,
                                      logfile='/root/frontend-ks-post.log',
                                      type=KS_SCRIPT_POST)
        postscript.run(anaconda.rootPath, flags.serial, anaconda.intf)

        # TODO: Add status line for text mode
        pkgstatus = None
        if anaconda.id.displayMode == 'g':
            import gtk
            pkgstatus = gtk.Label("Preparing to install...")
            w.window.child.add(pkgstatus)
            pkgstatus.show()

        messages = '/root/ami-creation.log'
        rc = iutil.execWithCallback('/bin/sh' , ['-c', 'cd /tmp/img; /tmp/ami_creator.py -c /tmp/ks-centos6.cfg'],
                                    stdin = messages, stdout = messages, stderr = messages,
                                    root = '/mnt/sysimage', callback=imageProgress, 
                                    callback_data=ImageProgress(w, pkgstatus))

        if bindmount:
            isys.umount('/mnt/sysimage/mnt/source')
        w.pop()
コード例 #33
0
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
コード例 #34
0
def umountImage(tree, currentMedia):
    if currentMedia is not None:
        isys.umount(tree, removeDir=False)
        isys.unlosetup("/dev/loop1")
コード例 #35
0
ファイル: image.py プロジェクト: 274914765/python
def umountImage(tree, currentMedia, loopdev):
    if currentMedia is not None:
        isys.umount(tree, removeDir=False)
        if loopdev:
            isys.unlosetup(loopdev)
コード例 #36
0
class DiskSet:
    """The disks in the system."""

    skippedDisks = []
    mdList = []
    def __init__ (self):
        self.disks = {}
        self.onlyPrimary = None

    def onlyPrimaryParts(self):
        for disk in self.disks.values():
            if disk.type.check_feature(parted.DISK_TYPE_EXTENDED):
                return 0

        return 1
        

    def startAllRaid(self):
        """Start all of the raid devices associated with the DiskSet."""
        driveList = []
        origDriveList = self.driveList()
        for drive in origDriveList:
            if not drive in DiskSet.skippedDisks:
                driveList.append(drive)
        DiskSet.mdList.extend(raid.startAllRaid(driveList))

    def stopAllRaid(self):
        """Stop all of the raid devices associated with the DiskSet."""
        raid.stopAllRaid(DiskSet.mdList)
        while DiskSet.mdList:
            DiskSet.mdList.pop()

    def getLabels(self):
        """Return a list of all of the labels used on partitions."""
        labels = {}
        
        drives = self.disks.keys()
        drives.sort()

        for drive in drives:
            disk = self.disks[drive]
            func = lambda part: (part.is_active() and
                                 not (part.get_flag(parted.PARTITION_RAID)
                                      or part.get_flag(parted.PARTITION_LVM))
                                 and part.fs_type
                                 and (part.fs_type.name in ("ext2",
                                                            "ext3", "xfs")))
            parts = filter_partitions(disk, func)
            for part in parts:
                node = get_partition_name(part)
                label = isys.readFSLabel(node)
                if label:
                    labels[node] = label

        for dev, devices, level, numActive in DiskSet.mdList:
            label = isys.readFSLabel(dev)
            if label:
                labels[dev] = label

        return labels

    def findExistingRootPartitions(self, intf, mountpoint, upgradeany = 0):
        """Return a list of all of the partitions which look like a root fs."""
        rootparts = []

        self.startAllRaid()

        for dev, devices, level, numActive in self.mdList:
            (errno, msg) = (None, None)
            found = 0
            for fs in fsset.getFStoTry(dev):
                try:
                    isys.mount(dev, mountpoint, fs, readOnly = 1)
                    found = 1
                    break
                except SystemError, (errno, msg):
                    pass

            if found:
                if os.access (mountpoint + '/etc/fstab', os.R_OK):
                    relstr = getRedHatReleaseString(mountpoint)
                    cmdline = open('/proc/cmdline', 'r').read()
                    
                    if ((cmdline.find("upgradeany") != -1) or
                        (upgradeany == 1) or
                        (productMatches(relstr, productName))):
                        rootparts.append ((dev, fs, relstr))
                isys.umount(mountpoint)

        # now, look for candidate lvm roots
	lvm.vgscan()
	lvm.vgactivate()

        for (vg, lv, size) in lvm.lvlist():
            dev = "/dev/%s/%s" %(vg, lv)
            found = 0
            for fs in fsset.getFStoTry(dev):
                try:
                    isys.mount(dev, mountpoint, fs, readOnly = 1)
                    found = 1
                    break
                except SystemError:
                    pass

            if found:
                if os.access (mountpoint + '/etc/fstab', os.R_OK):
                    relstr = getRedHatReleaseString(mountpoint)
                    cmdline = open('/proc/cmdline', 'r').read()
                    
                    if ((cmdline.find("upgradeany") != -1) or
                        (upgradeany == 1) or
                        (productMatches(relstr, productName))):
                        rootparts.append ((dev, fs, relstr))
                isys.umount(mountpoint)

	lvm.vgdeactivate()

        # don't stop raid until after we've looked for lvm on top of it
        self.stopAllRaid()

        drives = self.disks.keys()
        drives.sort()

        for drive in drives:
            disk = self.disks[drive]
            part = disk.next_partition ()
            while part:
                if (part.is_active()
                    and (part.get_flag(parted.PARTITION_RAID)
                         or part.get_flag(parted.PARTITION_LVM))):
                    pass
                elif (part.fs_type and
                      part.fs_type.name in fsset.getUsableLinuxFs()):
                    node = get_partition_name(part)
		    try:
			isys.mount(node, mountpoint, part.fs_type.name)
		    except SystemError, (errno, msg):
			intf.messageWindow(_("Error"),
                                           _("Error mounting file system on "
                                             "%s: %s") % (node, msg))
                        part = disk.next_partition(part)
			continue
		    if os.access (mountpoint + '/etc/fstab', os.R_OK):
                        relstr = getRedHatReleaseString(mountpoint)
                        cmdline = open('/proc/cmdline', 'r').read()

                        if ((cmdline.find("upgradeany") != -1) or
                            (upgradeany == 1) or
                            (productMatches(relstr, productName))):
                            rootparts.append ((node, part.fs_type.name,
                                               relstr))
		    isys.umount(mountpoint)
                    
                part = disk.next_partition(part)
コード例 #37
0
ファイル: image.py プロジェクト: rossonet/Strumenti-RCloud
    def switchMedia(self, mediano, filename=""):
        log.info("switching from CD %s to %s for %s" %(self.currentMedia, mediano, filename))
        if mediano in self.currentMedia:
            return
        if os.access("/mnt/source/.discinfo", os.R_OK):
            f = open("/mnt/source/.discinfo")
            timestamp = f.readline().strip()
            f.close()
        else:
            timestamp = self.timestamp

        if self.timestamp is None:
            self.timestamp = timestamp

        needed = mediano

        # if self.currentMedia is empty, then we shouldn't have anything
        # mounted.  double-check by trying to unmount, but we don't want
        # to get into a loop of trying to unmount forever.  if
        # self.currentMedia is set, then it should still be mounted and
        # we want to loop until it unmounts successfully
        if not self.currentMedia:
            try:
                isys.umount("/mnt/source")
            except:
                pass
        else:
            self.unmountCD()

        done = 0

        cdlist = []
        for (dev, something, descript) in \
                kudzu.probe(kudzu.CLASS_CDROM, kudzu.BUS_UNSPEC, 0):
            cdlist.append(dev)

        for dev in cdlist:
            try:
                if not isys.mount(dev, "/mnt/source", fstype = "iso9660", 
                           readOnly = 1):
                    if os.access("/mnt/source/.discinfo", os.R_OK):
                        f = open("/mnt/source/.discinfo")
                        newStamp = f.readline().strip()
                        try:
                            descr = f.readline().strip()
                        except:
                            descr = None
                        try:
                            arch = f.readline().strip()
                        except:
                            arch = None
                        try:
                            discNum = getDiscNums(f.readline().strip())
                        except:
                            discNum = [ 0 ]
                        f.close()
                        if (newStamp == timestamp and
                            arch == _arch and
                            needed in discNum):
                            done = 1
                            self.currentMedia = discNum

                    if not done:
                        isys.umount("/mnt/source")
            except:
                pass

            if done:
                break

        if not done:
            if self.noeject:
                log.info("noeject in effect, not ejecting cdrom")
            else:
                isys.ejectCdrom(self.device)

        while not done:
            if self.intf is not None:
                self.intf.beep()

            self.messageWindow(_("Change CDROM"), 
                _("Please insert %s disc %d to continue.") % (productName,
                                                              needed))
            try:
                if isys.mount(self.device, "/mnt/source", 
                              fstype = "iso9660", readOnly = 1):
                    time.sleep(3)
                    isys.mount(self.device, "/mnt/source", 
                               fstype = "iso9660", readOnly = 1)
                

                if os.access("/mnt/source/.discinfo", os.R_OK):
                    f = open("/mnt/source/.discinfo")
                    newStamp = f.readline().strip()
                    try:
                        descr = f.readline().strip()
                    except:
                        descr = None
                    try:
                        arch = f.readline().strip()
                    except:
                        arch = None
                    try:
                        discNum = getDiscNums(f.readline().strip())
                    except:
                        discNum = [ 0 ]
                    f.close()
                    if (newStamp == timestamp and
                        arch == _arch and
                        needed in discNum):
                        done = 1
                        self.currentMedia = discNum
                        # make /tmp/cdrom again so cd gets ejected
                        isys.makeDevInode(self.device, "/tmp/cdrom")

                if not done:
                    self.messageWindow(_("Wrong CDROM"),
                            _("That's not the correct %s CDROM.")
                                       % (productName,))
                    isys.umount("/mnt/source")
                    if self.noeject:
                        log.info("noeject in effect, not ejecting cdrom")
                    else:
                        isys.ejectCdrom(self.device)
            except:
                self.messageWindow(_("Error"), 
                        _("Unable to access the CDROM."))
コード例 #38
0
    if case == "6":
        isys.sync()
    if case == "7":
        my_swap = "/dev/sda7"
        isys.swapon(my_swap)
    if case == "8":
        my_swap = "/dev/sda7"
        isys.swapoff(my_swap)
    procpath = "tgtsys/proc"
    syspath = "tgtsys/sys"
    if case == "9":
        if not os.path.exists(procpath):
            os.makedirs(procpath)
        if not os.path.exists(syspath):
            os.makedirs(syspath)
        isys.mount("proc", "proc", procpath)
        isys.mount("sysfs", "sys", syspath)
    if case == "10":
        isys.umount(procpath)
        isys.umount(syspath)
        try:
            os.rmdir(procpath)
        except:
            pass
        try:
            os.rmdir(syspath)
        except:
            pass

    # fstype_map[]
コード例 #39
0
    if case == '6':
        isys.sync()
    if case == '7':
        my_swap = "/dev/sda7"
        isys.swapon(my_swap)
    if case == '8':
        my_swap = "/dev/sda7"
        isys.swapoff(my_swap)
    procpath = 'tgtsys/proc'
    syspath = 'tgtsys/sys'
    if case == '9':
        if not os.path.exists(procpath):
            os.makedirs(procpath)
        if not os.path.exists(syspath):
            os.makedirs(syspath)
        isys.mount('proc', 'proc', procpath)
        isys.mount('sysfs', 'sys', syspath)
    if case == '10':
        isys.umount(procpath)
        isys.umount(syspath)
        try:
            os.rmdir(procpath)
        except:
            pass
        try:
            os.rmdir(syspath)
        except:
            pass

    #fstype_map[]
コード例 #40
0
ファイル: image.py プロジェクト: mattias-ohlsson/anaconda
def findFirstIsoImage(path, messageWindow):
    """
    Find the first iso image in path
    This also supports specifying a specific .iso image

    Returns the full path to the image
    """
    flush = os.stat(path)
    arch = _arch

    if os.path.isfile(path) and path.endswith(".iso"):
        files = [os.path.basename(path)]
        path = os.path.dirname(path)
    else:
        files = os.listdir(path)

    for fn in files:
        what = path + '/' + fn
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        log.debug("mounting %s on /mnt/install/cdimage", what)
        try:
            isys.mount(what, "/mnt/install/cdimage", fstype="iso9660", readOnly=True)
        except SystemError:
            continue

        if not os.access("/mnt/install/cdimage/.discinfo", os.R_OK):
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        log.debug("Reading .discinfo")
        f = open("/mnt/install/cdimage/.discinfo")
        f.readline() # skip timestamp
        f.readline() # skip release description
        discArch = f.readline().strip() # read architecture
        f.close()

        log.debug("discArch = %s" % discArch)
        if discArch != arch:
            log.warning("findFirstIsoImage: architectures mismatch: %s, %s" %
                        (discArch, arch))
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        # If there's no repodata, there's no point in trying to
        # install from it.
        if not os.access("/mnt/install/cdimage/repodata", os.R_OK):
            log.warning("%s doesn't have repodata, skipping" %(what,))
            isys.umount("/mnt/install/cdimage", removeDir=False)
            continue

        # warn user if images appears to be wrong size
        if os.stat(what)[stat.ST_SIZE] % 2048:
            rc = messageWindow(_("Warning"),
                 _("The ISO image %s has a size which is not "
                   "a multiple of 2048 bytes.  This may mean "
                   "it was corrupted on transfer to this computer."
                   "\n\n"
                   "It is recommended that you exit and abort your "
                   "installation, but you can choose to continue if "
                   "you think this is in error.") % (fn,),
                   type="custom", custom_icon="warning",
                   custom_buttons= [_("_Exit installer"),
                                    _("_Continue")])
            if rc == 0:
                sys.exit(0)

        log.info("Found disc at %s" % fn)
        isys.umount("/mnt/install/cdimage", removeDir=False)
        return what

    return None
コード例 #41
0
def findFirstIsoImage(path, messageWindow):
    flush = os.stat(path)
    files = os.listdir(path)
    arch = _arch

    for file in files:
        what = path + '/' + file
        log.debug("Checking %s" % (what))
        if not isys.isIsoImage(what):
            continue

        try:
            log.debug("mounting %s on /mnt/cdimage", what)
            isys.mount(what, "/mnt/cdimage", fstype = "iso9660", readOnly = True)

            if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                log.debug("Reading .discinfo")
                f = open("/mnt/cdimage/.discinfo")
                try:
                    f.readline() # skip timestamp
                    f.readline() # skip release description
                    discArch = string.strip(f.readline()) # read architecture
                except:
                    discArch = None

                f.close()

                log.debug("discArch = %s" % discArch)
                if discArch != arch:
                    isys.umount("/mnt/cdimage", removeDir=False)
                    continue

                # If there's no repodata, there's no point in trying to
                # install from it.
                if not os.access("/mnt/cdimage/repodata", os.R_OK):
                    log.warning("%s doesn't have repodata, skipping" %(what,))
                    isys.umount("/mnt/cdimage", removeDir=False)
                    continue

                # warn user if images appears to be wrong size
                if os.stat(what)[stat.ST_SIZE] % 2048:
                    rc = messageWindow(_("Warning"),
                         _("The ISO image %s has a size which is not "
                           "a multiple of 2048 bytes.  This may mean "
                           "it was corrupted on transfer to this computer."
                           "\n\n"
                           "It is recommended that you exit and abort your "
                           "installation, but you can choose to continue if "
                           "you think this is in error.") % (file,),
                           type="custom", custom_icon="warning",
                           custom_buttons= [_("_Exit installer"),
                                            _("_Continue")])
                    if rc == 0:
                        sys.exit(0)

                log.info("Found disc at %s" % file)
                isys.umount("/mnt/cdimage", removeDir=False)
                return file
        except SystemError:
            pass

    return None
コード例 #42
0
ファイル: exception.py プロジェクト: adiabuk/progeny_projects
            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect(cmd,
                                   args,
                                   stdout='/dev/tty5',
                                   stderr='/dev/tty5')

        try:
            isys.mount(device, "/tmp/crash", fstype="vfat")
        except SystemError:
            continue

        # copy trace dump we wrote to local storage to floppy
        try:
            iutil.copyFile("/tmp/anacdump.txt", "/tmp/crash/anacdump.txt")
        except:
            log("Failed to copy anacdump.txt to floppy")
            pass

        isys.umount("/tmp/crash")

        intf.messageWindow(
            _("Dump Written"),
            _("Your system's state has been successfully written to the "
              "floppy. Your system will now be reset."))

        intf.__del__()
        os.kill(os.getpid(), signal.SIGKILL)
コード例 #43
0
        # Test iso9660 mount.
        fstype = fstype_map["iso9660"][0]
        dev_path = "/mnt/sda12/MagicLinux-2.5-1.iso"
        mntpoint = "/media/loop1"
        if not os.path.exists(mntpoint):
            os.mkdir(mntpoint)
        ext_flags = "loop"
        # ext_flags can be remount,ro,user,noauto,unhide... and other optlist in -o
        # option.
        isys.mount(fstype, dev_path, mntpoint, ext_flags)

    if case == '3':
        # Test umount function.
        for key in my_fs.keys():
            mntpoint = "/media/%s" % key
            isys.umount(mntpoint)
            if os.path.exists(mntpoint):
                try:
                    os.rmdir(mntpoint)
                except:
                    pass

    if case == '4':
        # Test umount iso function.
        dev_path = "/mnt/sda12/MagicLinux-2.5-1.iso"
        mntpoint = "/media/loop1"
        isys.umount(mntpoint)
        if os.path.exists(mntpoint):
            try:
                os.rmdir(mntpoint)
            except: