Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u3d/dependencies: add command to install Linux dependencies #25

Merged
merged 8 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The prettifyer is on by default but can be turned off to get Unity3d's raw outpu

[Information on how `prettify` works](https://github.com/DragonBox/u3d/blob/master/LOG_RULES.md)

* `u3d dependencies`: [Linux] Install dependencies that Unity don't install by default on Linux.

## Installation

```shell
Expand Down
9 changes: 9 additions & 0 deletions lib/u3d/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ def install(args: [], options: {})
Installer.install_modules(files, definition.version, installation_path: options[:installation_path])
end

def install_dependencies
unless Helper.linux?
UI.important 'u3d dependencies is Linux-only, and not needed on other OS'
return
end

LinuxDependencies.install
end

def run(options: {}, run_args: [])
version = options[:unity_version]

Expand Down
16 changes: 16 additions & 0 deletions lib/u3d/commands_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ def run
end
end

command :dependencies do |c|
c.syntax = 'u3d dependencies'
c.summary = 'Installs Unity dependencies. [Linux only]'
c.description = %(
#{c.summary}

Regarding the package manager: if dpkg is installed, u3d uses apt-get else if rpm is installed yum is used. If none of them is insalled, fails.

Regarding the dependencies themselves: only dependencies for the editor are installed. WebGL, Android and Tizen require others that you will have to install manually.
More on that: https://forum.unity3d.com/threads/unity-on-linux-release-notes-and-known-issues.350256/
)
c.action do |_args, _options|
Commands.install_dependencies
end
end

command :credentials do |c|
c.syntax = "u3d credentials <#{Commands.credentials_actions.join(' | ')}>"
c.description = 'Manages keychain credentials so u3d remembers them. [OSX only]'
Expand Down
59 changes: 59 additions & 0 deletions lib/u3d/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,63 @@ def install_exe(file_path, installation_path: nil, info: {})
end
end
end

class LinuxDependencies
# see https://forum.unity3d.com/threads/unity-on-linux-release-notes-and-known-issues.350256/
DEPENDENCIES = [
'gconf-service',
'lib32gcc1',
'lib32stdc++6',
'libasound2',
'libc6',
'libc6-i386',
'libcairo2',
'libcap2',
'libcups2',
'libdbus-1-3',
'libexpat1',
'libfontconfig1',
'libfreetype6',
'libgcc1',
'libgconf-2-4',
'libgdk-pixbuf2.0-0',
'libgl1-mesa-glx',
'libglib2.0-0',
'libglu1-mesa',
'libgtk2.0-0',
'libnspr4',
'libnss3',
'libpango1.0-0',
'libstdc++6',
'libx11-6',
'libxcomposite1',
'libxcursor1',
'libxdamage1',
'libxext6',
'libxfixes3',
'libxi6',
'libxrandr2',
'libxrender1',
'libxtst6',
'zlib1g',
'debconf',
'npm',
'libpq5' # missing from original list
].freeze

def self.install
if `which dpkg` != ''
prefix = 'apt-get -y install'
elsif `which rpm` != ''
prefix = 'yum -y install'
else
raise 'Cannot install dependencies on your Linux distribution'
end

if UI.interactive?
return unless UI.confirm "Install dependencies? (#{DEPENDENCIES.length} dependency(ies) to install)"
end
U3dCore::CommandExecutor.execute(command: "#{prefix} #{DEPENDENCIES.join(' ')}", admin: true)
end
end
end