예제 #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', 'wubildr.exe')
        dest = join_path(drive.path, 'wubildr.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=wubildr,$distro
        menudefault=windows,10
        [wubildr]
        device=wubildr.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', 'wubildr')
     dest = join_path(drive.path, 'wubildr')
     shutil.copyfile(src, dest)
     src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
     dest = join_path(drive.path, 'wubildr.mbr')
     shutil.copyfile(src, dest)
     run_command(['attrib', '-R', '-S', '-H', bootini])
     boot_line = 'C:\wubildr.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 undo_bcd(self, associated_task):
     bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
     if not isfile(bcdedit):
         bcdedit = join_path(os.getenv('SystemRoot'), 'sysnative', 'bcdedit.exe')
     if not os.path.isfile(bcdedit):
         bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
     if not os.path.isfile(bcdedit):
         log.error("Cannot find bcdedit")
         return
     id = registry.get_value(
         'HKEY_LOCAL_MACHINE',
         self.info.registry_key,
         'VistaBootDrive')
     if not id:
         log.debug("Could not find bcd id")
         return
     log.debug("Removing bcd entry %s" % id)
     command = [bcdedit, '/delete', id , '/f']
     try:
         run_command(command)
         registry.set_value(
             'HKEY_LOCAL_MACHINE',
             self.info.registry_key,
             'VistaBootDrive',
             "")
     except Exception, err: #this shouldn't be fatal
         log.error(err)
예제 #4
0
파일: backend.py 프로젝트: Karho/mint4win
 def expand_diskimage(self, associated_task=None):
     # TODO: might use -p to get percentage to feed into progress.
     root = join_path(self.info.disks_dir, 'root.disk')
     resize2fs = join_path(self.info.bin_dir, 'resize2fs.exe')
     resize_cmd = [resize2fs, '-f', root,
                   '%dM' % self.info.root_size_mb]
     run_command(resize_cmd)
예제 #5
0
 def expand_diskimage(self, associated_task=None):
     # TODO: might use -p to get percentage to feed into progress.
     root = join_path(self.info.disks_dir, 'root.disk')
     resize2fs = join_path(self.info.bin_dir, 'resize2fs.exe')
     resize_cmd = [resize2fs, '-f', root,
                   '%dM' % self.info.root_size_mb]
     run_command(resize_cmd)
예제 #6
0
파일: backend.py 프로젝트: Karho/mint4win
 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', 'wubildr')
     dest = join_path(drive.path, 'wubildr')
     shutil.copyfile(src,  dest)
     src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
     dest = join_path(drive.path, 'wubildr.mbr')
     shutil.copyfile(src,  dest)
     run_command(['attrib', '-R', '-S', '-H', bootini])
     boot_line = 'C:\wubildr.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])
예제 #7
0
파일: backend.py 프로젝트: lliurex/lliuwin
 def extract_diskimage(self, associated_task=None):
     # TODO: try to pipe download stream into this.
     #sevenzip = self.info.iso_extractor
     #xz = self.dimage_path
     #log.debug("  extracting %s" % (xz))
     #tarball = os.path.basename(self.dimage_path).strip('.xz')
     # 7-zip needs 7z.dll to read the xz format.
     #dec_xz = [sevenzip, 'e', '-i!' + tarball, '-so', xz]
     #dec_tar = [sevenzip, 'e', '-si', '-ttar', '-o' + self.info.disks_dir]
     #dec_xz_subp = spawn_command(dec_xz)
     #dec_tar_subp = spawn_command(dec_tar, stdin=dec_xz_subp.stdout)
     #dec_xz_subp.stdout.close()
     #dec_tar_subp.communicate()
     #if dec_tar_subp.returncode != 0:
     #    raise Exception, ('Extraction failed with code: %d' %
     #                      dec_tar_subp.returncode)
     # TODO: Checksum: http://tukaani.org/xz/xz-file-format.txt
     # Only remove downloaded image
     #if not self.info.dimage_path:
     #    os.remove(xz)
     root = join_path(self.info.disks_dir, 'root.disk')
     log.debug("%s copying to %s" % (self.info.dimage_path, root))
     shutil.copyfile(self.info.dimage_path, root)
     #Set custominstall path
     self.info.custominstall = join_path(self.info.install_dir,
                                         'custom-installation')
예제 #8
0
파일: backend.py 프로젝트: Karho/mint4win
    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', 'wubildr.exe')
        dest = join_path(drive.path, 'wubildr.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=wubildr,$distro
        menudefault=windows,10
        [wubildr]
        device=wubildr.exe
        [windows]

        REM WUBI MENU END
        '''
        write_file(configsys, config)
        run_command(['attrib', '+R', '+S', '+H', configsys])
예제 #9
0
파일: backend.py 프로젝트: Karho/mint4win
 def undo_bcd(self, associated_task):
     bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
     if not isfile(bcdedit):
         bcdedit = join_path(os.getenv('SystemRoot'), 'sysnative', 'bcdedit.exe')
     if not os.path.isfile(bcdedit):
         bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
     if not os.path.isfile(bcdedit):
         log.error("Cannot find bcdedit")
         return
     id = registry.get_value(
         'HKEY_LOCAL_MACHINE',
         self.info.registry_key,
         'VistaBootDrive')
     if not id:
         log.debug("Could not find bcd id")
         return
     log.debug("Removing bcd entry %s" % id)
     command = [bcdedit, '/delete', id , '/f']
     try:
         run_command(command)
         registry.set_value(
             'HKEY_LOCAL_MACHINE',
             self.info.registry_key,
             'VistaBootDrive',
             "")
     except Exception, err: #this shouldn't be fatal
         log.error(err)
예제 #10
0
 def select_target_dir(self):
     target_dir = join_path(self.info.target_drive.path, self.info.distro.installation_dir)
     target_dir.replace(' ', '_')
     target_dir.replace('__', '_')
     if os.path.exists(target_dir):
         raise Exception("Cannot install into %s.\nThere is another file or directory with this name.\nPlease remove it before continuing." % target_dir)
     self.info.target_dir = target_dir
     log.info('Installing into %s' % target_dir)
     self.info.icon = join_path(self.info.target_dir, self.info.distro.name + '.ico')
예제 #11
0
파일: backend.py 프로젝트: Karho/mint4win
 def select_target_dir(self):
     target_dir = join_path(self.info.target_drive.path, self.info.distro.installation_dir)
     target_dir.replace(' ', '_')
     target_dir.replace('__', '_')
     if os.path.exists(target_dir):
         raise Exception("Cannot install into %s.\nThere is another file or directory with this name.\nPlease remove it before continuing." % target_dir)
     self.info.target_dir = target_dir
     log.info('Installing into %s' % target_dir)
     self.info.icon = join_path(self.info.target_dir, self.info.distro.name + '.ico')
예제 #12
0
 def uncompress_files(self, associated_task):
     if self.info.target_drive.is_fat():
         return
     command1 = ['compact', join_path(self.info.install_boot_dir), '/U', '/A', '/F']
     command2 = ['compact', join_path(self.info.install_boot_dir,'*.*'), '/U', '/A', '/F']
     for command in [command1,command2]:
         log.debug(" ".join(command))
         try:
             run_command(command)
         except Exception, err:
             log.error(err)
예제 #13
0
파일: backend.py 프로젝트: Karho/mint4win
 def uncompress_files(self, associated_task):
     if self.info.target_drive.is_fat():
         return
     command1 = ['compact', join_path(self.info.install_boot_dir), '/U', '/A', '/F']
     command2 = ['compact', join_path(self.info.install_boot_dir,'*.*'), '/U', '/A', '/F']
     for command in [command1,command2]:
         log.debug(" ".join(command))
         try:
             run_command(command)
         except Exception, err:
             log.error(err)
예제 #14
0
 def extract_file_from_iso(self,
                           iso_path,
                           file_path,
                           output_dir=None,
                           overwrite=False):
     '''
     platform specific
     '''
     log.debug("  extracting %s from %s" % (file_path, iso_path))
     if not iso_path or not os.path.exists(iso_path):
         raise Exception('Invalid path %s' % iso_path)
     iso_path = abspath(iso_path)
     file_path = os.path.normpath(file_path)
     if not output_dir:
         output_dir = tempfile.gettempdir()
     output_file = join_path(output_dir, os.path.basename(file_path))
     if os.path.exists(output_file):
         if overwrite:
             os.unlink(output_file)
         else:
             raise Exception('Cannot overwrite %s' % output_file)
     command = [
         self.info.iso_extractor, 'e', '-i!' + file_path, '-o' + output_dir,
         iso_path
     ]
     try:
         run_command(command)
     except Exception, err:
         log.exception(err)
         output_file = None
예제 #15
0
 def create_uninstaller(self, associated_task):
     uninstaller_name = 'uninstall-%s.exe' % self.info.application_name
     uninstaller_name.replace(' ', '_')
     uninstaller_name.replace('__', '_')
     uninstaller_path = join_path(self.info.target_dir, uninstaller_name)
     if os.path.splitext(self.info.original_exe)[-1] == '.exe':
         log.debug('Copying uninstaller %s -> %s' %
                   (self.info.original_exe, uninstaller_path))
         shutil.copyfile(self.info.original_exe, uninstaller_path)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'UninstallString', uninstaller_path)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'InstallationDir', self.info.target_dir)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'DisplayName', self.info.distro.name)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'DisplayIcon', self.info.icon)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'DisplayVersion', self.info.version_revision)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'Publisher', self.info.distro.name)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'URLInfoAbout', self.info.distro.website)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                        'HelpLink', self.info.distro.support)
예제 #16
0
 def create_virtual_disks(self, associated_task):
     self.info.disks_dir
     for disk in ["root", "home", "usr", "swap"]:
         path = join_path(self.info.disks_dir, disk + ".disk")
         size_mb = int(getattr(self.info, disk + "_size_mb"))
         if size_mb:
             create_virtual_disk(path, size_mb)
예제 #17
0
파일: backend.py 프로젝트: Karho/mint4win
 def create_virtual_disks(self, associated_task):
     self.info.disks_dir
     for disk in ["root", "home", "usr", "swap"]:
         path = join_path(self.info.disks_dir, disk + ".disk")
         size_mb = int(getattr(self.info, disk + "_size_mb"))
         if size_mb:
             create_virtual_disk(path, size_mb)
예제 #18
0
    def create_uninstaller(self, associated_task):
        uninstaller_name = 'uninstall.exe'
        uninstaller_name.replace(' ', '_')
        uninstaller_name.replace('__', '_')
        uninstaller_path = join_path(self.info.target_dir, uninstaller_name)

        if self.info.run_task == "cd_boot":
            display_name = self.info.distro.name + _(" LiveCD")
        elif self.info.flag:
            display_name = self.info.distro.name
        else:
            display_name = self.info.distro.name + _(" LiveCD")

        #display_name = self.info.flag and self.info.distro.name or self.info.distro.name + _(" LiveCD")
       
        if os.path.splitext(self.info.original_exe)[-1] == '.exe':
            log.debug('Copying uninstaller %s -> %s' % (self.info.original_exe, uninstaller_path))
            shutil.copyfile(self.info.original_exe, uninstaller_path)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'UninstallString', uninstaller_path)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'InstallationDir', self.info.target_dir)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayName', display_name)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayIcon', self.info.icon)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayVersion', self.info.version_revision)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'Publisher', "www.startos.org")
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'URLInfoAbout', self.info.distro.website)
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'HelpLink', self.info.distro.support)
예제 #19
0
    def extract_file_from_iso(self, iso_path, file_path, output_dir=None, overwrite=True):
        '''
        platform specific
        '''
        log.debug("extracting %s from %s" % (file_path, iso_path))
        if not iso_path or not os.path.exists(iso_path):
            raise Exception('Invalid path %s' % iso_path)
        iso_path = abspath(iso_path)
        file_path = os.path.normpath(file_path)
        if not output_dir:
            output_dir = tempfile.gettempdir()
        output_file = join_path(output_dir, os.path.basename(file_path))
        log.debug("output_file === %s" %output_file)

        if os.path.exists(output_file):
            if overwrite:
                os.unlink(output_file)
            else:
                raise Exception('Cannot overwrite %s' % output_file)
        command = [self.info.iso_extractor, 'e', '-i!' + file_path, '-o' + output_dir, iso_path]
        log.debug("command === %s" % command)
        try:
            output = run_command(command)
        except Exception, err:
            log.exception(err)
            output_file = None
예제 #20
0
파일: backend.py 프로젝트: Karho/mint4win
 def undo_bootini(self, drive, associated_task):
     log.debug("undo_bootini %s" % drive.path)
     bootini = join_path(drive.path, 'boot.ini')
     if not os.path.isfile(bootini):
         return
     run_command(['attrib', '-R', '-S', '-H', bootini])
     remove_line_in_file(bootini, 'c:\wubildr.mbr', ignore_case=True)
     run_command(['attrib', '+R', '+S', '+H', bootini])
예제 #21
0
 def undo_bootini(self, drive, associated_task):
     log.debug("undo_bootini %s" % drive.path)
     bootini = join_path(drive.path, 'boot.ini')
     if not os.path.isfile(bootini):
         return
     run_command(['attrib', '-R', '-S', '-H', bootini])
     remove_line_in_file(bootini, 'c:\wubildr.mbr', ignore_case=True)
     run_command(['attrib', '+R', '+S', '+H', bootini])
예제 #22
0
    def select_target_dir(self):
        target_dir = join_path(self.info.target_drive.path, self.info.distro.installation_dir)
        target_dir.replace(' ', '_')
        target_dir.replace('__', '_')
        gold_target_dir = target_dir
        #if os.path.exists(target_dir):
        #    raise Exception("Cannot install into %s.\nThere is another file or directory with this name.\nPlease remove it before continuing." % target_dir)
        if self.info.run_task == "cd_boot":
            self.info.target_dir = target_dir+"-livecd"
        elif self.info.flag:
            self.info.target_dir = target_dir+"-loop"
        else:
            self.info.target_dir = target_dir+"-livecd"

        #self.info.target_dir = self.info.flag and target_dir+"-loop" or target_dir+"-livecd"
        log.info('Installing into %s' % self.info.target_dir)
        self.info.icon = join_path(self.info.target_dir, self.info.distro.name + '.ico')
예제 #23
0
 def copy_installation_files(self, associated_task):
     self.info.custominstall = join_path(self.info.install_dir,
                                         'custom-installation')
     src = join_path(self.info.data_dir, 'custom-installation')
     dest = self.info.custominstall
     log.debug('Copying %s -> %s' % (src, dest))
     shutil.copytree(src, dest)
     src = join_path(self.info.root_dir, 'winboot')
     if isdir(
             src
     ):  # make runpy will fail otherwise as winboot will not be there
         dest = join_path(self.info.target_dir, 'winboot')
         log.debug('Copying %s -> %s' % (src, dest))
         shutil.copytree(src, dest)
     dest = join_path(self.info.custominstall, 'hooks',
                      'failure-command.sh')
     msg=_('The installation failed. Logs have been saved in: %s.' \
         '\n\nNote that in verbose mode, the logs may include the password.' \
         '\n\nThe system will now reboot.')
     msg = msg % join_path(self.info.install_dir, 'installation-logs.zip')
     msg = "msg=\"%s\"" % msg
     msg = str(msg.encode('utf8'))
     replace_line_in_file(dest, 'msg=', msg)
     src = join_path(self.info.image_dir, self.info.distro.name + '.ico')
     dest = self.info.icon
     log.debug('Copying %s -> %s' % (src, dest))
     shutil.copyfile(src, dest)
예제 #24
0
 def copy_installation_files(self, associated_task):
     self.info.custominstall = join_path(self.info.install_dir, 'custom-installation')
     log.debug("custominstall === %s" %self.info.custominstall)
     src = join_path(self.info.data_dir, 'custom-installation')
     dest = self.info.custominstall
     log.debug('Copying %s -> %s' % (src, dest))
     if os.path.exists(dest):
         shutil.rmtree(dest)
     shutil.copytree(src, dest)
     src = join_path(self.info.root_dir, 'winboot')
     if isdir(src): # make runpy will fail otherwise as winboot will not be there
         dest = join_path(self.info.target_dir, 'winboot')
         log.debug('Copying %s -> %s' % (src, dest))
         if os.path.exists(dest):
             shutil.rmtree(dest)   
         shutil.copytree(src, dest)
     dest = join_path(self.info.custominstall, 'hooks', 'failure-command.sh')
     msg=_('The installation failed. Logs have been saved in: %s.' \
         '\n\nNote that in verbose mode, the logs may include the password.' \
         '\n\nThe system will now reboot.')
     msg = msg % join_path(self.info.install_dir, 'installation-logs.zip')
     msg = "msg=\"%s\"" % msg
     msg = str(msg.encode('utf8'))
     replace_line_in_file(dest, 'msg=', msg)
     src = join_path(self.info.image_dir, self.info.distro.name + '.ico')
     dest = self.info.icon
     log.debug('Copying %s -> %s' % (src, dest))
     shutil.copyfile(src, dest)
예제 #25
0
파일: backend.py 프로젝트: Karho/mint4win
 def get_windows_user_dir(self):
     homedrive = os.getenv('homedrive')
     homepath = os.getenv('homepath')
     user_directory = ""
     if homedrive and homepath:
         user_directory = join_path(homedrive, homepath)
         user_directory = user_directory.decode('ascii', 'ignore')
     log.debug('user_directory=%s' % user_directory)
     return user_directory
예제 #26
0
파일: backend.py 프로젝트: Karho/mint4win
 def diskimage_bootloader(self, associated_task=None):
     src = join_path(self.info.root_dir, 'winboot')
     dest = join_path(self.info.target_dir, 'winboot')
     if isdir(src):
         log.debug('Copying %s -> %s' % (src, dest))
         shutil.copytree(src, dest)
     src = join_path(self.info.disks_dir, 'wubildr')
     shutil.copyfile(src, join_path(dest, 'wubildr'))
     # Overwrite the copy that's in root_dir.
     for drive in self.info.drives:
         if drive.type not in ('removable', 'hd'):
             continue
         dest = join_path(drive.path, 'wubildr')
         try:
             shutil.copyfile(src, dest)
         except: # don't need to worry about failure here
             pass
     os.unlink(src)
예제 #27
0
 def backup_iso(self, associated_task=None):
     if not self.info.backup_iso:
         return
     backup_dir = self.info.previous_target_dir + "-backup"
     install_dir = join_path(self.info.previous_target_dir, "install")
     for f in os.listdir(install_dir):
         f = join_path(install_dir, f)
         if f.endswith('.iso') and os.path.isfile(f) \
         and os.path.getsize(f) > 1000000:
             log.debug("Backing up %s -> %s" % (f, backup_dir))
             if not isdir(backup_dir):
                 if isfile(backup_dir):
                     log.error("The backup directory %s is a file, skipping ISO backup" % backup_dir)
                     #TBD do something more sensible
                     return
                 os.mkdir(backup_dir)
             target_path = join_path(backup_dir, os.path.basename(f))
             shutil.move(f, target_path)
예제 #28
0
 def get_windows_user_dir(self):
     homedrive = os.getenv('homedrive')
     homepath = os.getenv('homepath')
     user_directory = ""
     if homedrive and homepath:
         user_directory = join_path(homedrive, homepath)
         user_directory = user_directory.decode('ascii', 'ignore')
     log.debug('user_directory=%s' % user_directory)
     return user_directory
예제 #29
0
 def diskimage_bootloader(self, associated_task=None):
     src = join_path(self.info.root_dir, 'winboot')
     dest = join_path(self.info.target_dir, 'winboot')
     if isdir(src):
         log.debug('Copying %s -> %s' % (src, dest))
         shutil.copytree(src, dest)
     src = join_path(self.info.disks_dir, 'wubildr')
     shutil.copyfile(src, join_path(dest, 'wubildr'))
     # Overwrite the copy that's in root_dir.
     for drive in self.info.drives:
         if drive.type not in ('removable', 'hd'):
             continue
         dest = join_path(drive.path, 'wubildr')
         try:
             shutil.copyfile(src, dest)
         except:  # don't need to worry about failure here
             pass
     os.unlink(src)
예제 #30
0
 def uncompress_target_dir(self, associated_task):
     if self.info.target_drive.is_fat():
         return
     try:
         command = ['compact', self.info.target_dir, '/U', '/A', '/F']
         run_command(command)
         command = ['compact', join_path(self.info.target_dir,'*.*'), '/U', '/A', '/F']
         run_command(command)
     except Exception, err:
         log.error(err)
예제 #31
0
파일: backend.py 프로젝트: Karho/mint4win
 def uncompress_target_dir(self, associated_task):
     if self.info.target_drive.is_fat():
         return
     try:
         command = ['compact', self.info.target_dir, '/U', '/A', '/F']
         run_command(command)
         command = ['compact', join_path(self.info.target_dir,'*.*'), '/U', '/A', '/F']
         run_command(command)
     except Exception, err:
         log.error(err)
예제 #32
0
 def check_EFI(self):
     efi = False
     if self.info.bootloader == 'vista':
         bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
         if not os.path.isfile(bcdedit):
             bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe')
         if not os.path.isfile(bcdedit):
             bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
         if not os.path.isfile(bcdedit):
             log.error("Cannot find bcdedit")
             return False
         command = [bcdedit, '/enum']
         result = run_command(command)
         result = result.lower()
         if "bootmgfw.efi" in result:
             efi = True
         if "winload.efi" in result:
             efi = True
     log.debug('EFI boot = %s' % efi)
     return efi
예제 #33
0
 def modify_EFI_folder(self, associated_task, bcdedit):
     command = [bcdedit, '/enum', '{bootmgr}']
     boot_drive = run_command(command)
     if 'partition=' in boot_drive:
         boot_drive = boot_drive[boot_drive.index('partition=') + 10:]
     else:
         boot_drive = boot_drive[boot_drive.index('device') + 24:]
     boot_drive = boot_drive[:boot_drive.index('\r')]
     log.debug("EFI boot partition %s" % boot_drive)
     # if EFI boot partition is mounted we use it
     if boot_drive[1] == ':':
         efi_drive = boot_drive
     else:
         for efi_drive in 'HIJKLMNOPQRSTUVWXYZ':
             drive = Drive(efi_drive)
             if not drive.type:
                 break
         efi_drive = efi_drive + ':'
         log.debug("Temporary EFI drive %s" % efi_drive)
     if efi_drive != boot_drive:
         run_command(['mountvol', efi_drive, '/s'])
     src = join_path(self.info.root_dir, 'winboot', 'EFI')
     src.replace(' ', '_')
     src.replace('__', '_')
     dest = join_path(efi_drive, 'EFI', self.info.target_dir[3:])
     dest.replace(' ', '_')
     dest.replace('__', '_')
     if not os.path.exists(dest):
         shutil.os.mkdir(dest)
     dest = join_path(dest, 'wubildr')
     if os.path.exists(dest):
         shutil.rmtree(dest)
     log.debug('Copying EFI folder %s -> %s' % (src, dest))
     shutil.copytree(src, dest)
     if self.get_efi_arch(associated_task, efi_drive) == "ia32":
         efi_path = join_path(dest, 'grubia32.efi')[2:]
     else:
         efi_path = join_path(dest, 'shimx64.efi')[2:]
     if efi_drive != boot_drive:
         run_command(['mountvol', efi_drive, '/d'])
     return efi_path
예제 #34
0
파일: backend.py 프로젝트: Ando02/wubiuefi
 def modify_EFI_folder(self, associated_task,bcdedit):
     command = [bcdedit, '/enum', '{bootmgr}']
     boot_drive = run_command(command)
     if 'partition=' in boot_drive:
         boot_drive = boot_drive[boot_drive.index('partition=')+10:]
     else:
         boot_drive = boot_drive[boot_drive.index('device')+24:]
     boot_drive = boot_drive[:boot_drive.index('\r')]
     log.debug("EFI boot partition %s" % boot_drive)
     # if EFI boot partition is mounted we use it
     if boot_drive[1]==':':
         efi_drive = boot_drive
     else:
         for efi_drive in 'HIJKLMNOPQRSTUVWXYZ':
             drive = Drive(efi_drive)
             if not drive.type:
                 break
         efi_drive = efi_drive + ':'
         log.debug("Temporary EFI drive %s" % efi_drive)
     if efi_drive != boot_drive:
         run_command(['mountvol', efi_drive, '/s'])
     src = join_path(self.info.root_dir, 'winboot','EFI')
     src.replace(' ', '_')
     src.replace('__', '_')
     dest = join_path(efi_drive, 'EFI',self.info.target_dir[3:])
     dest.replace(' ', '_')
     dest.replace('__', '_')
     if not os.path.exists(dest):
         shutil.os.mkdir(dest)
     dest = join_path(dest,'wubildr')
     if os.path.exists(dest):
         shutil.rmtree(dest)        
     log.debug('Copying EFI folder %s -> %s' % (src, dest))
     shutil.copytree(src,  dest)
     if self.get_efi_arch(associated_task,efi_drive)=="ia32":
         efi_path = join_path(dest, 'grubia32.efi')[2:]
     else:
         efi_path = join_path(dest, 'shimx64.efi')[2:]
     if efi_drive != boot_drive:
         run_command(['mountvol', efi_drive, '/d'])
     return efi_path
예제 #35
0
 def undo_bootloader(self, associated_task):
     winboot_files = ['wubildr', 'wubildr.mbr', 'wubildr.exe']
     self.undo_bcd(associated_task)
     for drive in self.info.drives:
         if drive.type not in ('removable', 'hd'):
             continue
         self.undo_bootini(drive, associated_task)
         self.undo_configsys(drive, associated_task)
         for f in winboot_files:
             f = join_path(drive.path, f)
             if os.path.isfile(f):
                 os.unlink(f)
예제 #36
0
파일: backend.py 프로젝트: Karho/mint4win
 def undo_bootloader(self, associated_task):
     winboot_files = ['wubildr', 'wubildr.mbr', 'wubildr.exe']
     self.undo_bcd(associated_task)
     for drive in self.info.drives:
         if drive.type not in ('removable', 'hd'):
             continue
         self.undo_bootini(drive, associated_task)
         self.undo_configsys(drive, associated_task)
         for f in winboot_files:
             f = join_path(drive.path, f)
             if os.path.isfile(f):
                 os.unlink(f)
예제 #37
0
 def undo_bootloader(self, associated_task):
     winboot_files = ['yldr', 'yldr.mbr', 'yldrd', 'yldrd.mbr']
     self.undo_bcd(associated_task)
     for drive in self.info.drives:
         if drive.type not in ('removable', 'hd'):
             continue
         self.undo_bootini(drive, associated_task)
         #self.undo_configsys(drive, associated_task)
         for f in winboot_files:
             f = join_path(drive.path, f)
             if os.path.isfile(f):
                 run_command(['attrib', '-R', '-S', '-H', f])
                 os.unlink(f)
예제 #38
0
 def create_virtual_disks(self, associated_task):
     self.info.disks_dir
     for disk in ["root", "home", "usr", "swap"]:
         path = join_path(self.info.disks_dir, disk + ".disk")
         if os.path.isfile(path):
             log.info(" ** loop file %s exists, will not be created ** " % path)
             continue
         if not getattr(self.info, disk + "_size_mb"):
             continue
         size_mb = int(getattr(self.info, disk + "_size_mb"))
         if size_mb:
             log.debug("virtual_disk === %s,size_mb === %s" %(path,size_mb))
             create_virtual_disk(path, size_mb)
예제 #39
0
    def modify_bcd(self, drive, associated_task):
        log.debug("modify_bcd %s" % drive)
        if drive is self.info.system_drive \
        or drive.path == "C:" \
        or drive.path == os.getenv('SystemDrive').upper() \
        or drive.path == self.info.target_drive.path:
            src = join_path(self.info.root_dir, 'winboot', 'wubildr')
            dest = join_path(drive.path, 'wubildr')
            shutil.copyfile(src, dest)
            src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
            dest = join_path(drive.path, 'wubildr.mbr')
            shutil.copyfile(src, dest)
        bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'sysnative',
                                'bcdedit.exe')
        # FIXME: Just test for bcdedit in the PATH.  What's the Windows
        # equivalent of `type`?
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'System32',
                                'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            log.error("Cannot find bcdedit")
            return
        if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                              'VistaBootDrive'):
            log.debug("BCD has already been modified")
            return

        if self.info.efi:
            log.debug("EFI boot")
            efi_path = self.modify_EFI_folder(associated_task, bcdedit)
            try:
                run_command(['powercfg', '/h', 'off'])
            except Exception, err:  #this shouldn't be fatal
                log.error(err)
            command = [
                bcdedit, '/copy', '{bootmgr}', '/d',
                '%s' % self.info.distro.name
            ]
            id = run_command(command)
            id = id[id.index('{'):id.index('}') + 1]
            run_command([bcdedit, '/set', id, 'path', efi_path])
            try:
                run_command([
                    bcdedit, '/set', '{fwbootmgr}', 'displayorder', id,
                    '/addlast'
                ])
                run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10'])
                run_command(
                    [bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id])
            except Exception, err:  #this shouldn't be fatal
                log.error(err)
예제 #40
0
파일: backend.py 프로젝트: Karho/mint4win
 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])
예제 #41
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])
예제 #42
0
    def modify_bcd(self, drive, associated_task):
        log.debug("modify_bcd %s" % drive)
        if drive is self.info.system_drive \
        or drive.path == "C:" \
        or drive.path == os.getenv('SystemDrive').upper():
            src = join_path(self.info.root_dir, 'winboot', 'wubildr')
            dest = join_path(drive.path, 'wubildr')
            shutil.copyfile(src, dest)
            src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
            dest = join_path(drive.path, 'wubildr.mbr')
            shutil.copyfile(src, dest)
        bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'sysnative',
                                'bcdedit.exe')
        # FIXME: Just test for bcdedit in the PATH.  What's the Windows
        # equivalent of `type`?
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'System32',
                                'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            log.error("Cannot find bcdedit")
            return
        if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                              'VistaBootDrive'):
            log.debug("BCD has already been modified")
            return

        command = [
            bcdedit, '/create', '/d',
            '%s' % self.info.distro.name, '/application', 'bootsector'
        ]
        id = run_command(command)
        id = id[id.index('{'):id.index('}') + 1]
        mbr_path = join_path(self.info.target_dir, 'winboot',
                             'wubildr.mbr')[2:]
        run_command([
            bcdedit, '/set', id, 'device',
            'partition=%s' % self.info.target_drive.path
        ])
        run_command([bcdedit, '/set', id, 'path', mbr_path])
        run_command([bcdedit, '/displayorder', id, '/addlast'])
        run_command([bcdedit, '/timeout', '10'])
        run_command([bcdedit, '/bootsequence', id])
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                           'VistaBootDrive', id)
예제 #43
0
파일: backend.py 프로젝트: Karho/mint4win
 def create_uninstaller(self, associated_task):
     uninstaller_name = 'uninstall-%s.exe'  % self.info.application_name
     uninstaller_name.replace(' ', '_')
     uninstaller_name.replace('__', '_')
     uninstaller_path = join_path(self.info.target_dir, uninstaller_name)
     if os.path.splitext(self.info.original_exe)[-1] == '.exe':
         log.debug('Copying uninstaller %s -> %s' % (self.info.original_exe, uninstaller_path))
         shutil.copyfile(self.info.original_exe, uninstaller_path)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'UninstallString', uninstaller_path)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'InstallationDir', self.info.target_dir)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayName', self.info.distro.name)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayIcon', self.info.icon)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'DisplayVersion', self.info.version_revision)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'Publisher', self.info.distro.name)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'URLInfoAbout', self.info.distro.website)
     registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'HelpLink', self.info.distro.support)
예제 #44
0
파일: backend.py 프로젝트: Ando02/wubiuefi
    def undo_bootloader(self, associated_task):
        winboot_files = ['wubildr', 'wubildr.mbr', 'wubildr.exe']
        self.undo_bcd(associated_task)
        for drive in self.info.drives:
            if drive.type not in ('removable', 'hd'):
                continue
            self.undo_bootini(drive, associated_task)
            self.undo_configsys(drive, associated_task)
            for f in winboot_files:
                f = join_path(drive.path, f)
                if os.path.isfile(f):
                    os.unlink(f)

        if self.info.efi:
            log.debug("Undo EFI boot")
            self.undo_EFI_folder(associated_task) 
            run_command(['powercfg', '/h', 'on'])
예제 #45
0
    def undo_bootloader(self, associated_task):
        winboot_files = ['wubildr', 'wubildr.mbr', 'wubildr.exe']
        self.undo_bcd(associated_task)
        for drive in self.info.drives:
            if drive.type not in ('removable', 'hd'):
                continue
            self.undo_bootini(drive, associated_task)
            self.undo_configsys(drive, associated_task)
            for f in winboot_files:
                f = join_path(drive.path, f)
                if os.path.isfile(f):
                    os.unlink(f)

        if self.info.efi:
            log.debug("Undo EFI boot")
            self.undo_EFI_folder(associated_task)
            run_command(['powercfg', '/h', 'on'])
예제 #46
0
파일: backend.py 프로젝트: Ando02/wubiuefi
 def undo_EFI_folder(self, associated_task):
     for efi_drive in 'HIJKLMNOPQRSTUVWXYZ':
         drive = Drive(efi_drive)
         if not drive.type:
             break
     efi_drive = efi_drive + ':'
     log.debug("Temporary EFI drive %s" % efi_drive)
     try: 
         run_command(['mountvol', efi_drive, '/s'])
         dest = join_path(efi_drive, 'EFI',self.info.previous_target_dir[3:],'wubildr')
         dest.replace(' ', '_')
         dest.replace('__', '_')
         if os.path.exists(dest):
             log.debug('Removing EFI folder %s' % dest)
             shutil.rmtree(dest)
         run_command(['mountvol', efi_drive, '/d'])
     except Exception, err: #this shouldn't be fatal
         log.error(err)            
예제 #47
0
 def undo_EFI_folder(self, associated_task):
     for efi_drive in 'HIJKLMNOPQRSTUVWXYZ':
         drive = Drive(efi_drive)
         if not drive.type:
             break
     efi_drive = efi_drive + ':'
     log.debug("Temporary EFI drive %s" % efi_drive)
     try:
         run_command(['mountvol', efi_drive, '/s'])
         dest = join_path(efi_drive, 'EFI',
                          self.info.previous_target_dir[3:], 'wubildr')
         dest.replace(' ', '_')
         dest.replace('__', '_')
         if os.path.exists(dest):
             log.debug('Removing EFI folder %s' % dest)
             shutil.rmtree(dest)
         run_command(['mountvol', efi_drive, '/d'])
     except Exception, err:  #this shouldn't be fatal
         log.error(err)
예제 #48
0
파일: backend.py 프로젝트: Ando02/wubiuefi
    def modify_bcd(self, drive, associated_task):
        log.debug("modify_bcd %s" % drive)
        if drive is self.info.system_drive \
        or drive.path == "C:" \
        or drive.path == os.getenv('SystemDrive').upper():
            src = join_path(self.info.root_dir, 'winboot', 'wubildr')
            dest = join_path(drive.path, 'wubildr')
            shutil.copyfile(src,  dest)
            src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
            dest = join_path(drive.path, 'wubildr.mbr')
            shutil.copyfile(src,  dest)
        bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe')
        # FIXME: Just test for bcdedit in the PATH.  What's the Windows
        # equivalent of `type`?
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            log.error("Cannot find bcdedit")
            return
        if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'):
            log.debug("BCD has already been modified")
            return

        if self.info.efi:
            log.debug("EFI boot")
            efi_path = self.modify_EFI_folder(associated_task,bcdedit)
            run_command(['powercfg', '/h', 'off'])
            command = [bcdedit, '/copy', '{bootmgr}', '/d', '%s' % self.info.distro.name]
            id = run_command(command)
            id = id[id.index('{'):id.index('}')+1]
            run_command([bcdedit, '/set', id, 'path', efi_path])
            try:
                run_command([bcdedit, '/set', '{fwbootmgr}', 'displayorder', id, '/addlast'])
                run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10'])
                run_command([bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id])
            except Exception, err: #this shouldn't be fatal
                log.error(err)
            registry.set_value(
                'HKEY_LOCAL_MACHINE',
                self.info.registry_key,
                'VistaBootDrive',
                id)
            return
예제 #49
0
파일: backend.py 프로젝트: Karho/mint4win
    def modify_bcd(self, drive, associated_task):
        log.debug("modify_bcd %s" % drive)
        if drive is self.info.system_drive \
        or drive.path == "C:" \
        or drive.path == os.getenv('SystemDrive').upper():
            src = join_path(self.info.root_dir, 'winboot', 'wubildr')
            dest = join_path(drive.path, 'wubildr')
            shutil.copyfile(src,  dest)
            src = join_path(self.info.root_dir, 'winboot', 'wubildr.mbr')
            dest = join_path(drive.path, 'wubildr.mbr')
            shutil.copyfile(src,  dest)
        bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'sysnative', 'bcdedit.exe')
        # FIXME: Just test for bcdedit in the PATH.  What's the Windows
        # equivalent of `type`?
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            log.error("Cannot find bcdedit")
            return
        if registry.get_value('HKEY_LOCAL_MACHINE', self.info.registry_key, 'VistaBootDrive'):
            log.debug("BCD has already been modified")
            return

        command = [bcdedit, '/create', '/d', '%s' % self.info.distro.name, '/application', 'bootsector']
        id = run_command(command)
        id = id[id.index('{'):id.index('}')+1]
        mbr_path = join_path(self.info.target_dir, 'winboot', 'wubildr.mbr')[2:]
        run_command([bcdedit, '/set', id, 'device', 'partition=%s' % self.info.target_drive.path])
        run_command([bcdedit, '/set', id, 'path', mbr_path])
        run_command([bcdedit, '/displayorder', id, '/addlast'])
        run_command([bcdedit, '/timeout', '10'])
        run_command([bcdedit, '/bootsequence', id])
        registry.set_value(
            'HKEY_LOCAL_MACHINE',
            self.info.registry_key,
            'VistaBootDrive',
            id)
예제 #50
0
파일: backend.py 프로젝트: Ando02/wubiuefi
 def get_efi_arch(self, associated_task, efi_drive):
     machine=0
     bootmgfw=join_path(efi_drive,'EFI','Microsoft','Boot','bootmgfw.efi')
     if os.path.exists(bootmgfw):
         f=open(bootmgfw, 'rb')
         s=f.read(2)
         if s=='MZ':
             f.seek(60)
             s=f.read(4)
             header_offset=struct.unpack("<L", s)[0]
             f.seek(header_offset+4)
             s=f.read(2)
             machine=struct.unpack("<H", s)[0]
         f.close()
     if machine==332:
         efi_arch = "ia32"
     elif machine==34404:
         efi_arch = "x64"
     else:
         efi_arch ="unknown"
     log.debug("efi_arch=%s" % efi_arch)
     return efi_arch
예제 #51
0
 def get_efi_arch(self, associated_task, efi_drive):
     machine = 0
     bootmgfw = join_path(efi_drive, 'EFI', 'Microsoft', 'Boot',
                          'bootmgfw.efi')
     if os.path.exists(bootmgfw):
         f = open(bootmgfw, 'rb')
         s = f.read(2)
         if s == 'MZ':
             f.seek(60)
             s = f.read(4)
             header_offset = struct.unpack("<L", s)[0]
             f.seek(header_offset + 4)
             s = f.read(2)
             machine = struct.unpack("<H", s)[0]
         f.close()
     if machine == 332:
         efi_arch = "ia32"
     elif machine == 34404:
         efi_arch = "x64"
     else:
         efi_arch = "unknown"
     log.debug("efi_arch=%s" % efi_arch)
     return efi_arch
예제 #52
0
 def create_swap_diskimage(self, associated_task=None):
     path = join_path(self.info.disks_dir, 'swap.disk')
     # fsutil works in bytes.
     swap_size = '%d' % (self.info.swap_size_mb * 1024 * 1024)
     create_cmd = ['fsutil', 'file', 'createnew', path, swap_size]
     run_command(create_cmd)
예제 #53
0
파일: backend.py 프로젝트: Karho/mint4win
 def create_swap_diskimage(self, associated_task=None):
     path = join_path(self.info.disks_dir, 'swap.disk')
     # fsutil works in bytes.
     swap_size = '%d' % (self.info.swap_size_mb * 1024 * 1024)
     create_cmd = ['fsutil', 'file', 'createnew', path, swap_size]
     run_command(create_cmd)
예제 #54
0
 def __init__(self, *args, **kargs):
     Backend.__init__(self, *args, **kargs)
     self.info.iso_extractor = join_path(self.info.bin_dir, '7z.exe')
     self.info.cpuid = join_path(self.info.bin_dir, 'cpuid.dll')
     log.debug('7z=%s' % self.info.iso_extractor)
     self.cache = {}
예제 #55
0
                run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10'])
                run_command(
                    [bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id])
            except Exception, err:  #this shouldn't be fatal
                log.error(err)
            registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                               'VistaBootDrive', id)
            return

        command = [
            bcdedit, '/create', '/d',
            '%s' % self.info.distro.name, '/application', 'bootsector'
        ]
        id = run_command(command)
        id = id[id.index('{'):id.index('}') + 1]
        mbr_path = join_path(self.info.target_dir, 'winboot',
                             'wubildr.mbr')[2:]
        run_command([
            bcdedit, '/set', id, 'device',
            'partition=%s' % self.info.target_drive.path
        ])
        run_command([bcdedit, '/set', id, 'path', mbr_path])
        run_command([bcdedit, '/displayorder', id, '/addlast'])
        run_command([bcdedit, '/timeout', '10'])
        run_command([bcdedit, '/bootsequence', id])
        registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                           'VistaBootDrive', id)

    def choose_disk_sizes(self, associated_task):
        total_size_mb = self.info.installation_size_mb
        home_size_mb = 0
        usr_size_mb = 0
예제 #56
0
파일: backend.py 프로젝트: lliurex/lliuwin
 def diskimage_bootloader(self, associated_task=None):
     src = join_path(self.info.root_dir, 'winboot')
     dest = join_path(self.info.target_dir, 'winboot')
     if isdir(src):
         log.debug('Copying %s -> %s' % (src, dest))
         shutil.copytree(src, dest)
예제 #57
0
파일: backend.py 프로젝트: Karho/mint4win
 def __init__(self, *args, **kargs):
     Backend.__init__(self, *args, **kargs)
     self.info.iso_extractor = join_path(self.info.bin_dir, '7z.exe')
     self.info.cpuid = join_path(self.info.bin_dir, 'cpuid.dll')
     log.debug('7z=%s' % self.info.iso_extractor)
     self.cache = {}
예제 #58
0
파일: backend.py 프로젝트: lliurex/lliuwin
 id = run_command(command)
 id = id[id.index('{'):id.index('}') + 1]
 run_command([bcdedit, '/set', id, 'path', efi_path])
 try:
     #                run_command([bcdedit, '/set', '{fwbootmgr}', 'displayorder', id, '/addlast'])
     run_command([bcdedit, '/set', '{fwbootmgr}', 'timeout', '10'])
     run_command(
         [bcdedit, '/set', '{fwbootmgr}', 'bootsequence', id])
 except Exception, err:  #this shouldn't be fatal
     log.error(err)
 registry.set_value('HKEY_LOCAL_MACHINE', self.info.registry_key,
                    'VistaBootDrive', id)
 #Generate switchto file
 desktop = os.path.join(os.path.join(os.environ['USERPROFILE']),
                        'Desktop')
 batFile = join_path(self.info.target_dir, 'switchLliurex.ps1')
 log.debug("BAT %s" % batFile)
 with open(batFile, 'w') as f:
     f.write("%s /set \"{fwbootmgr}\" bootsequence \"%s\"\n" %
             (bcdedit, id))
     f.write("shutdown /t 1 /r\n")
 #Generate shortcut
 vbsFile = join_path(self.info.target_dir, 'batShortcut.vbs')
 log.debug("VBS %s" % vbsFile)
 with open(vbsFile, 'w') as f:
     f.write('Set oWS = WScript.CreateObject("WScript.Shell")\n')
     f.write('sLinkFile = "%s\LliureX.lnk"\n' % desktop)
     f.write('Set oLink = oWS.CreateShortcut(sLinkFile)\n')
     f.write(
         'oLink.TargetPath = "powershell.exe -noexit -ExecutionPolicy Bypass &\"& \"\"%s\"\"\""\n'
         % batFile)