Пример #1
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)
Пример #2
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)
Пример #3
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

        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
Пример #4
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', '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)
        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',
                             'wisildr.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)
Пример #5
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

        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
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
0
                '%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

        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])
Пример #10
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():
            if self.info.run_task == "cd_boot":
                src = join_path(self.info.root_dir, 'winboot', 'yldrd')
            elif self.info.flag:
                src = join_path(self.info.root_dir, 'winboot', 'yldr')
            else:
                src = join_path(self.info.root_dir, 'winboot', 'yldrd')

            if self.info.run_task == "cd_boot":
                dest = join_path(drive.path, 'yldrd')
            elif self.info.flag:
                dest = join_path(drive.path, 'yldr')
            else:
                dest = join_path(drive.path, 'yldrd')
            shutil.copyfile(src,  dest)
            run_command(['attrib', '+R', '+S', '+H', dest])

            if self.info.run_task == "cd_boot":
                src = join_path(self.info.root_dir, 'winboot', 'yldrd.mbr')
            elif self.info.flag:
                src = join_path(self.info.root_dir, 'winboot', 'yldr.mbr')
            else:
                src = join_path(self.info.root_dir, 'winboot', 'yldrd.mbr')

            if self.info.run_task == "cd_boot":
                dest = join_path(drive.path, 'yldrd.mbr')
            elif self.info.flag:
                dest = join_path(drive.path, 'yldr.mbr')
            else:
                dest = join_path(drive.path, 'yldrd.mbr')
            shutil.copyfile(src,  dest)
            run_command(['attrib', '+R', '+S', '+H', dest])

        if self.info.run_task == "cd_boot":
            mbr_path = join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:]
        elif self.info.flag:
            mbr_path = join_path(self.info.target_dir, 'winboot', 'yldr.mbr')[2:]
        else:
            mbr_path = join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:]

        bcdedit = join_path(os.getenv('SystemDrive'), 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'System32', 'bcdedit.exe')
        if not os.path.isfile(bcdedit):
            bcdedit = join_path(os.environ['systemroot'], 'sysnative', '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.run_task == "cd_boot":
            command = [bcdedit, '/create', '/d', '%s LiveCD' % self.info.distro.name, '/application', 'bootsector']
        elif self.info.flag:
            command = [bcdedit, '/create', '/d', '%s' % self.info.distro.name, '/application', 'bootsector']
        else:
            command = [bcdedit, '/create', '/d', '%s LiveCD' % self.info.distro.name, '/application', 'bootsector']
        log.debug("run command %s" %command)
        id = run_command(command)
        id = id[id.index('{'):id.index('}')+1]
        #mbr_path = self.info.flag and join_path(self.info.target_dir, 'winboot', 'yldr.mbr')[2:] or join_path(self.info.target_dir, 'winboot', 'yldrd.mbr')[2:]
        ##print mbr_path
        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'])
        registry.set_value(
            'HKEY_LOCAL_MACHINE',
            self.info.registry_key,
            'VistaBootDrive',
            id)
Пример #11
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)
Пример #12
0
                '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
        swap_size_mb = 256
        root_size_mb = total_size_mb - swap_size_mb
        if self.info.target_drive.is_fat():
            if root_size_mb > 8500:
                home_size_mb = root_size_mb - 8000
                usr_size_mb = 4000
                root_size_mb = 4000
            elif root_size_mb > 5500: