class Gear
Attributes
gear_name[RW]
build_path[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
built[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
checked[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
headers[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
installed[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
libs[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
obtained[R]
attribute list ========#¶ ↑
obtained: tracking flag indicating if sources have been obtained built: tracking flag indicating if the build has been completed installed: tracking flag indicating if installation/vendorization completed checked: tracking flag indicating if an installation check succeeded headers: an array of headers to check for (in include path) libs: an array of libs to check for build_path: the path where the build will occur
Public Class Methods
initialized?()
click to toggle source
# File lib/gear.rb, line 30 def self.initialized? @@initialized end
install_path(new_path = nil)
click to toggle source
# File lib/gear.rb, line 25 def self.install_path(new_path = nil) @@install_path = new_path unless new_path.nil? @@install_path end
new()
click to toggle source
# File lib/gear.rb, line 47 def initialize() puts "Gear install path set to: #{@@install_path}" @obtained = @built = @installed = @checked = false @build_path = _root_path() + "/build/#{name()}" _setup_paths() Dir.chdir(_root_path() + "/build") @@initialized = true end
Public Instance Methods
build()
click to toggle source
# File lib/gear.rb, line 63 def build() STDERR.puts "WARNING: Gear did not override build method. Nothing was built." @built = false return false end
check()
click to toggle source
# File lib/gear.rb, line 75 def check() STDERR.puts "WARNING: Gear did not override check method. Status is unknown." @checked = false return false end
disengage()
click to toggle source
# File lib/gear.rb, line 102 def disengage() uninstall && remove end
engage()
click to toggle source
# File lib/gear.rb, line 81 def engage() !check && # bail if already installed obtain && build && install && check end
gear_exec(command = "")
click to toggle source
Prefixes a command with the gearbox prefixed in the load path
# File lib/gear.rb, line 153 def gear_exec(command = "") `LD_LIBRARY_PATH=#{@@install_path}/lib:$LD_LIBRARY_PATH C_INCLUDE_PATH=#{@@install_path}/include:$C_INCLUDE_PATH PATH=#{@@install_path}/bin:$PATH #{command}` end
gear_exec_mac()
click to toggle source
# File lib/gear.rb, line 157 def gear_exec_mac() `mdfind -onlyin #{@@install_path} -name #{name} -count`.chomp.to_i end
git_obtain(repository, branch)
click to toggle source
obtain helpers ========#¶ ↑
# File lib/gear.rb, line 108 def git_obtain(repository, branch) Dir.chdir(_root_path + '/build') begin if Dir.exist? build_path @git = Git.open(build_path) @git.reset("HEAD", hard: true) @git.clean(force: true, d: true, x:true) else @git = Git.clone(repository, build_path) end rescue StandardError => e STDERR.puts "Could not obtain repository #{repository}.\n#{e}" @obtained = false return false end @git.checkout(branch) @git.pull Dir.chdir(@build_path) `git submodule update --init --recursive` @obtained = true return true end
github_obtain(user, repository, branch = 'master')
click to toggle source
# File lib/gear.rb, line 134 def github_obtain(user, repository, branch = 'master') git_obtain("https://github.com/#{user}/#{repository}.git", branch) end
install()
click to toggle source
# File lib/gear.rb, line 69 def install() STDERR.puts "WARNING: Gear did not override install method. Nothing has been installed." @installed = false return false end
name()
click to toggle source
# File lib/gear.rb, line 38 def name() self.class.gear_name end
obtain()
click to toggle source
# File lib/gear.rb, line 57 def obtain() STDERR.puts "WARNING: Gear did not override obtain method. No sources were obtained." @obtained = false return false end
remove()
click to toggle source
# File lib/gear.rb, line 89 def remove() Dir.chdir(_root_path + '/build') FileUtils.rm_rf("#{@build_path}") @obtained = false return true end
std_config_make(flags = "")
click to toggle source
# File lib/gear.rb, line 138 def std_config_make(flags = "") Dir.chdir(@build_path) `autoconf` if !File.exist? 'configure' `./confirgure --prefix#{@@install_path}` `make` end
std_make_install()
click to toggle source
# File lib/gear.rb, line 145 def std_make_install() Dir.chdir(@build_path) `make install` @installed = true return true end
target(new_target = nil)
click to toggle source
# File lib/gear.rb, line 42 def target(new_target = nil) @@install_path = new_target unless new_target.nil? @@install_path end
uninstall()
click to toggle source
# File lib/gear.rb, line 96 def uninstall() # set @installed to false on a succesfully uninstall STDERR.puts "WARNING: Gear did not override uninstall method." return false end
Private Instance Methods
_root_path()
click to toggle source
# File lib/gear.rb, line 162 def _root_path() File.expand_path('../..', __FILE__) end
_setup_paths()
click to toggle source
sets up vendor/sub directories
# File lib/gear.rb, line 167 def _setup_paths() #puts "⚙Preparing directory structure in #{@@install_path}" return if @@initialized FileUtils.mkdir_p("#{_root_path}/build") FileUtils.mkdir_p("#{@@install_path}/bin") FileUtils.mkdir_p("#{@@install_path}/include") FileUtils.mkdir_p("#{@@install_path}/lib") ENV['PATH'] = (ENV['PATH'].nil? ? "#{@@install_path}/bin" : ENV['PATH'] + ":#{@@install_path}/bin") `export PATH=#{ENV['PATH']}` #ENV['C_INCLUDE_PATH'] = ENV['C_INCLUDE_PATH'].to_s + ":#{@@install_path}/include" #ENV['CPLUS_INCLUDE_PATH'] = ENV['CPLUS_INCLUDE_PATH'].to_s + ":#{@@install_path}/include" ENV['CPATH'] = (ENV['CPATH'].nil? ? "#{@@install_path}/include" : ENV['CPATH'] + ":#{@@install_path}/include") `export CPATH=#{ENV['CPATH']}` ENV['LD_LIBRARY_PATH'] = (ENV['LD_LIBRARY_PATH'].nil? ? "#{@@install_path}/lib" : ENV['LD_LIBRARY_PATH'] + ":#{@@install_path}/lib") `export LD_LIBRARY_PATH=#{ENV['LD_LIBRARY_PATH']}` ENV['LIBRARY_PATH'] = (ENV['LIBRARY_PATH'].nil? ? "#{@@install_path}/lib" : ENV['LIBRARY_PATH'] + ":#{@@install_path}/lib") `export LIBRARY_PATH=#{ENV['LIBRARY_PATH']}` end