示例#1
0
    def modify_configsys(self, drive, associated_task):
        log.debug("modify_configsys %s" % drive.path)
        configsys = join_path(drive.path, 'config.sys')
        if not os.path.isfile(configsys):
            return
        src = join_path(self.info.root_dir, 'winboot', 'wisildr.exe')
        dest = join_path(drive.path, 'wisildr.exe')
        shutil.copyfile(src, dest)
        run_command(['attrib', '-R', '-S', '-H', configsys])
        config = read_file(configsys)
        if 'REM WUBI MENU START\n' in config:
            log.debug("Configsys has already been modified")
            return

        config += '''
        REM WUBI MENU START
        [menu]
        menucolor=15,0
        menuitem=windows,Windows
        menuitem=wisildr,$distro
        menudefault=windows,10
        [wisildr]
        device=wisildr.exe
        [windows]

        REM WUBI MENU END
        '''
        write_file(configsys, config)
        run_command(['attrib', '+R', '+S', '+H', configsys])
示例#2
0
 def modify_bootini(self, drive, associated_task):
     log.debug("modify_bootini %s" % drive.path)
     bootini = join_path(drive.path, 'boot.ini')
     if not os.path.isfile(bootini):
         log.debug("Could not find boot.ini %s" % bootini)
         return
     src = join_path(self.info.root_dir, 'winboot', 'wisildr')
     dest = join_path(drive.path, 'wisildr')
     shutil.copyfile(src, dest)
     src = join_path(self.info.root_dir, 'winboot', 'wisildr.mbr')
     dest = join_path(drive.path, 'wisildr.mbr')
     shutil.copyfile(src, dest)
     run_command(['attrib', '-R', '-S', '-H', bootini])
     boot_line = 'C:\wisildr.mbr = "%s"' % self.info.distro.name
     old_line = boot_line[:boot_line.index("=")].strip().lower()
     # ConfigParser gets confused by the ':' and changes the options order
     content = read_file(bootini)
     if content[-1] != '\n':
         content += '\n'
     lines = content.split('\n')
     is_section = False
     for i, line in enumerate(lines):
         if line.strip().lower() == "[operating systems]":
             is_section = True
         elif line.strip().startswith("["):
             is_section = False
         if is_section and line.strip().lower().startswith(old_line):
             lines[i] = boot_line
             break
         if is_section and not line.strip():
             lines.insert(i, boot_line)
             break
     content = '\n'.join(lines)
     write_file(bootini, content)
     run_command(['attrib', '+R', '+S', '+H', bootini])
示例#3
0
    def modify_configsys(self, drive, associated_task):
        log.debug("modify_configsys %s" % drive.path)
        configsys = join_path(drive.path, 'config.sys')
        if not os.path.isfile(configsys):
            return
        src = join_path(self.info.root_dir, 'winboot', 'wisildr.exe')
        dest = join_path(drive.path, 'wisildr.exe')
        shutil.copyfile(src,  dest)
        run_command(['attrib', '-R', '-S', '-H', configsys])
        config = read_file(configsys)
        if 'REM WUBI MENU START\n' in config:
            log.debug("Configsys has already been modified")
            return

        config += '''
        REM WUBI MENU START
        [menu]
        menucolor=15,0
        menuitem=windows,Windows
        menuitem=wisildr,$distro
        menudefault=windows,10
        [wisildr]
        device=wisildr.exe
        [windows]

        REM WUBI MENU END
        '''
        write_file(configsys, config)
        run_command(['attrib', '+R', '+S', '+H', configsys])
示例#4
0
 def modify_bootini(self, drive, associated_task):
     log.debug("modify_bootini %s" % drive.path)
     bootini = join_path(drive.path, 'boot.ini')
     if not os.path.isfile(bootini):
         log.debug("Could not find boot.ini %s" % bootini)
         return
     src = join_path(self.info.root_dir, 'winboot', 'wisildr')
     dest = join_path(drive.path, 'wisildr')
     shutil.copyfile(src,  dest)
     src = join_path(self.info.root_dir, 'winboot', 'wisildr.mbr')
     dest = join_path(drive.path, 'wisildr.mbr')
     shutil.copyfile(src,  dest)
     run_command(['attrib', '-R', '-S', '-H', bootini])
     boot_line = 'C:\wisildr.mbr = "%s"' % self.info.distro.name
     old_line = boot_line[:boot_line.index("=")].strip().lower()
     # ConfigParser gets confused by the ':' and changes the options order
     content = read_file(bootini)
     if content[-1] != '\n':
         content += '\n'
     lines = content.split('\n')
     is_section = False
     for i,line in enumerate(lines):
         if line.strip().lower() == "[operating systems]":
             is_section = True
         elif line.strip().startswith("["):
             is_section = False
         if is_section and line.strip().lower().startswith(old_line):
             lines[i] = boot_line
             break
         if is_section and not line.strip():
             lines.insert(i, boot_line)
             break
     content = '\n'.join(lines)
     write_file(bootini, content)
     run_command(['attrib', '+R', '+S', '+H', bootini])
示例#5
0
 def undo_configsys(self, drive, associated_task):
     log.debug("undo_configsys %s" % drive)
     configsys = join_path(drive.path, 'config.sys')
     if not os.path.isfile(configsys):
         return
     run_command(['attrib', '-R', '-S', '-H', configsys])
     config = read_file(configsys)
     s = config.find('REM WUBI MENU START\n')
     e = config.find('REM WUBI MENU END\n')
     if s > 0 and e > 0:
         e += len('REM WUBI MENU END')
     config = config[:s] + config[e:]
     write_file(configsys, config)
     run_command(['attrib', '+R', '+S', '+H', configsys])
示例#6
0
 def undo_configsys(self, drive, associated_task):
     log.debug("undo_configsys %s" % drive)
     configsys = join_path(drive.path, 'config.sys')
     if not os.path.isfile(configsys):
         return
     run_command(['attrib', '-R', '-S', '-H', configsys])
     config = read_file(configsys)
     s = config.find('REM WUBI MENU START\n')
     e = config.find('REM WUBI MENU END\n')
     if s > 0 and e > 0:
         e += len('REM WUBI MENU END')
     config = config[:s] + config[e:]
     write_file(configsys, config)
     run_command(['attrib', '+R', '+S', '+H', configsys])