예제 #1
0
def install_disc_prep(mia, operid, dev, fstype, bootiso_relpath, reldir):
    '''
        Install each disc prepare work.
        We should mount each iso to prepare packages source(for disc).
    '''
    global dev_hd # the harddisk device where save packages.
    global dev_iso # the iso where save pkgs.
    global dev_mnt_dir # the current hd or iso mount dir
    dolog('instpkg_disc_prep(%s, %s, %s, %s)\n' % \
          (dev, fstype, bootiso_relpath, reldir))
    ############################## Mount Start #####################################
    dev_hd = MiDevice(dev, fstype)
    if not dev_hd.do_mount(): #### NOTE: carefully handle this device's mount.
        msg = 'Mount device %s Failed, install operate can not continue' % dev_hd.get_dev()
        logger.e(msg)
        return msg
    dev_mnt_dir = dev_hd.get_mountdir()    
    if bootiso_relpath:
        # an iso file on harddisk
        dev_iso = MiDevice(dev_hd.get_file_path(bootiso_relpath), 'iso9660')
        if not dev_iso.do_mount(): #### NOTE: carefully handle this device's mount.
            dev_hd.do_umount(); dev_hd = None
            msg = 'Mount device %s Failed, install operate can not continue!!!' % dev_iso.get_dev()
            logger.e(msg)
            dev_iso = None
            return msg
        dev_mnt_dir = dev_iso.get_mountdir()
    
    ############################## Mount Finished #####################################
    return  0
예제 #2
0
 def mount_each(tgt_root_dev, tgt_other_dev, tgt_other_type, tgt_other_mpoint):
     if tgt_other_dev and tgt_root_dev != tgt_other_dev:
         mnt_point = os.path.join(CF.D.TGTSYS_ROOT, tgt_other_mpoint.lstrip('/'))
         dev_tgt_other = MiDevice(tgt_other_dev, tgt_other_type, mnt_point)
         
         if not dev_tgt_other.do_mount(): #### NOTE: carefully handle this device's mount.
             logger.e('Mount device %s Failed, install operate can not continue' % dev_tgt_other.get_dev())
             self.umount_tgt_device()
             return False
         else:
             self.mounted_devs.append(dev_tgt_other)
         return True
     else:
         logger.e('Can not run to here!! The root file system had been mounted before!!')
         return False
예제 #3
0
    def mount_tgt_device(self):
        tgt_root_dev, tgt_root_type = self.get_devinfo_by_mpoint('/')
        
        tgt_swap_dev, tgt_swap_type = self.get_devinfo_by_mpoint('USE')
        if tgt_swap_dev and os.path.exists(tgt_swap_dev):
            os.system('swapon %s' % tgt_swap_dev)

        #### mount root device
        mnt_point = CF.D.TGTSYS_ROOT
        dev_tgt_root = MiDevice(tgt_root_dev, tgt_root_type, mnt_point)
        if not dev_tgt_root.do_mount(): #### NOTE: carefully handle this device's mount.
            logger.e('Mount device %s Failed, install operate can not continue' % dev_tgt_root.get_dev())
            return False
        else:
            self.mounted_devs.append(dev_tgt_root)
        def mount_each(tgt_root_dev, tgt_other_dev, tgt_other_type, tgt_other_mpoint):
            if tgt_other_dev and tgt_root_dev != tgt_other_dev:
                mnt_point = os.path.join(CF.D.TGTSYS_ROOT, tgt_other_mpoint.lstrip('/'))
                dev_tgt_other = MiDevice(tgt_other_dev, tgt_other_type, mnt_point)
                
                if not dev_tgt_other.do_mount(): #### NOTE: carefully handle this device's mount.
                    logger.e('Mount device %s Failed, install operate can not continue' % dev_tgt_other.get_dev())
                    self.umount_tgt_device()
                    return False
                else:
                    self.mounted_devs.append(dev_tgt_other)
                return True
            else:
                logger.e('Can not run to here!! The root file system had been mounted before!!')
                return False
                    
        for mpoint, dev_, type_ in self.tgtsys_devinfo:
            if mpoint not in ('/', 'USE'):
                if not mount_each(tgt_root_dev, dev_, type_, mpoint):
                    return False
        
        # mount -t proc proc myroot/proc/
        mnt_point = os.path.join(CF.D.TGTSYS_ROOT, 'proc')
        ret, msg = mount_dev('proc', 'proc', mntdir=mnt_point,flags=None)
        if not ret:
            logger.e("Error: mount proc on target failed '%s'" % msg)
            return False
        self.mounted_devs.append(mnt_point)

        # mount -t sysfs sys myroot/sys/
        mnt_point = os.path.join(CF.D.TGTSYS_ROOT, 'sys')
        ret, msg = mount_dev('sysfs', 'sys', mntdir=mnt_point,flags=None)
        if not ret:
            logger.e("Error: mount sys on target failed '%s'" % msg)
            return False
        self.mounted_devs.append(mnt_point)

        # mount -o bind /dev myroot/dev/
        mnt_point = os.path.join(CF.D.TGTSYS_ROOT, 'dev')
        ret, msg = mount_dev(None, '/dev', mntdir=mnt_point,flags='bind')
        if not ret:
            logger.e("Error: mount /dev on target failed '%s'" % msg)
            return False
        self.mounted_devs.append(mnt_point)
        
        res = run_bash('mount')
        logger.d(''''Mount target system partition finished, check the mount output please:)
%s
%s
        ''' % ('\n'.join(res['out']), '\n'.join(res['err'])))
        return True