def _process_files(self, ctx): ''' Process files for a given version ''' if not 'result' in ctx: logging.error('updater_runner: no result') self._schedule() return length, body, error = ctx.pop('result') if length == -1: logging.error('updater_runner: %s', str(error)) self._schedule() return logging.info('updater_runner: %d-bytes tarball', len(body)) # Save tarball and signature on disk updater_utils.tarball_save(self.basedir, ctx['vinfo'], body) updater_utils.signature_save(self.basedir, ctx['vinfo'], ctx['signature']) # Verify signature using OpenSSL updater_verify.dgst_verify(updater_utils.signature_path( self.basedir, ctx['vinfo']), updater_utils.tarball_path( self.basedir, ctx['vinfo'])) logging.info('updater_runner: signature OK') updater_install.install(self.basedir, ctx['vinfo']) logging.info('updater_win32: extracted tarball') self.install(ctx, body)
def install(self, ctx, body): ''' Install new version on Windows ''' # Save tarball updater_utils.tarball_save(self.basedir, ctx['vinfo'], body) # Extract from tarball updater_install.install(self.basedir, ctx['vinfo']) # Make file names versiondir = utils_path.join(self.basedir, ctx['vinfo']) exefile = utils_path.join(versiondir, 'neubotw.exe') uninst = utils_path.join(versiondir, 'uninstall.exe') cmdline = '"%s" start' % exefile cmdline_k = '"%s" start -k' % exefile # # Overwrite the version of Neubot that is executed when # the user logs in. # regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, _winreg.KEY_WRITE) _winreg.SetValueEx(regkey, "Neubot", 0, _winreg.REG_SZ, cmdline) _winreg.CloseKey(regkey) # Update the registry to reference the new uninstaller regkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Uninstall\Neubot", 0, _winreg.KEY_WRITE) _winreg.SetValueEx(regkey, "DisplayName", 0, _winreg.REG_SZ, "Neubot " + utils_version.to_canonical(ctx['vinfo'])) _winreg.SetValueEx(regkey, "UninstallString", 0, _winreg.REG_SZ, uninst) _winreg.CloseKey(regkey) # # Run the new version of Neubot and tell it that this # version should be stopped before proceeding with normal # startup. # subprocess.Popen(cmdline_k, close_fds=True)