class U3d::WindowsInstaller
rubocop:enable ClassLength
Public Instance Methods
install(file_path, version, installation_path: nil, info: nil)
click to toggle source
# File lib/u3d/installer.rb, line 470 def install(file_path, version, installation_path: nil, info: nil) extension = File.extname(file_path) raise "Installation of #{extension} files is not supported on Windows" unless %w[.po .zip .exe .msi].include? extension path = installation_path || File.join(DEFAULT_WINDOWS_INSTALL, format(UNITY_DIR, version: version)) if extension == '.po' install_po(file_path, version, info: info) elsif extension == '.zip' install_zip(file_path, version, info: info) else install_exe(file_path, installation_path: path, info: info) end end
install_exe(file_path, installation_path: nil, info: nil)
click to toggle source
# File lib/u3d/installer.rb, line 483 def install_exe(file_path, installation_path: nil, info: nil) installation_path ||= DEFAULT_WINDOWS_INSTALL final_path = U3dCore::Helper.windows_path(installation_path) Utils.ensure_dir(final_path) begin command = nil if info.command command = info.command if /msiexec/ =~ command command.sub!(/{FILENAME}/, '"' + U3dCore::Helper.windows_path(file_path) + '"') else command.sub!(/{FILENAME}/, file_path.argescape) end command.sub!(/{INSTDIR}/, final_path) command.sub!(/{DOCDIR}/, final_path) command.sub!(/{MODULEDIR}/, final_path) command.sub!(%r{\/D=}, '/S /D=') unless %r{\/S} =~ command end command ||= file_path.argescape U3dCore::CommandExecutor.execute(command: command, admin: true) rescue StandardError => e UI.error "Failed to install package at #{file_path}: #{e}" else UI.success "Successfully installed #{info.name}" end end
installed()
click to toggle source
# File lib/u3d/installer.rb, line 459 def installed find_installations_with_path( default_root_path: DEFAULT_WINDOWS_INSTALL, postfix: %w[ Unity* Editor Uninstall.exe ] ) { |path| WindowsInstallation.new(root_path: File.expand_path('../..', path)) } end
sanitize_install(unity, long: false, dry_run: false)
click to toggle source
# File lib/u3d/installer.rb, line 448 def sanitize_install(unity, long: false, dry_run: false) source_path = File.expand_path(unity.root_path) parent = File.expand_path('..', source_path) dir_name = format(long ? UNITY_DIR_LONG : UNITY_DIR, version: unity.version, build_number: unity.build_number) new_path = File.join(parent, dir_name) moved = U3dCore::AdminTools.move_os_file(:win, source_path, new_path, dry_run: dry_run) unity.root_path = new_path if moved && !dry_run end
uninstall(unity: nil)
click to toggle source
# File lib/u3d/installer.rb, line 510 def uninstall(unity: nil) UI.verbose("Uninstalling Unity at '#{unity.root_path}'...") uninstall_exe = File.join(unity.root_path, 'Editor', 'Uninstall.exe') command = "#{uninstall_exe.argescape} /S" UI.message("Although the uninstall process completed, it takes a few seconds before the files are actually removed") U3dCore::CommandExecutor.execute(command: command, admin: true) rescue StandardError => e UI.error "Failed to uninstall unity at #{unity.path}: #{e}" else UI.success "Successfully uninstalled '#{unity.root_path}'" end