Class: Bunchr::Software
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Bunchr::Software
- Includes:
- Utils
- Defined in:
- lib/bunchr/software.rb
Instance Attribute Summary collapse
-
#build_commands ⇒ Object
Returns the value of attribute build_commands.
-
#build_environment ⇒ Object
Returns the value of attribute build_environment.
-
#download_commands ⇒ Object
Returns the value of attribute download_commands.
-
#download_environment ⇒ Object
Returns the value of attribute download_environment.
-
#install_commands ⇒ Object
Returns the value of attribute install_commands.
-
#install_environment ⇒ Object
Returns the value of attribute install_environment.
-
#name ⇒ Object
Returns the value of attribute name.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#build ⇒ Object
Execute all the build commands.
-
#define ⇒ Object
Define all the tasks in the namespace of the
name
of this task. - #define_build ⇒ Object
- #define_download ⇒ Object
- #define_install ⇒ Object
-
#depends_on(dependency) ⇒ Object
depend on a Software object to be built and installed.
- #dotfile(name) ⇒ Object
- #dotfile!(name) ⇒ Object
-
#download ⇒ Object
Execute all the build commands.
- #download_dir ⇒ Object
-
#initialize {|_self| ... } ⇒ Software
constructor
A new instance of Software.
-
#install ⇒ Object
Execute all the install commands.
-
#work_dir ⇒ Object
The directory this task unpacks into.
-
#work_dir=(pd) ⇒ Object
override the directory that the local source unpacks into if it is not
name-version
.
Methods included from Utils
Constructor Details
#initialize {|_self| ... } ⇒ Software
Returns a new instance of Software.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bunchr/software.rb', line 16 def initialize() @name = nil @version = nil @install_commands = [] @build_commands = [] @download_commands = [] @install_environment = {} @build_environment = {} @download_environment = {} yield self if block_given? define unless name.nil? end |
Instance Attribute Details
#build_commands ⇒ Object
Returns the value of attribute build_commands.
13 14 15 |
# File 'lib/bunchr/software.rb', line 13 def build_commands @build_commands end |
#build_environment ⇒ Object
Returns the value of attribute build_environment.
14 15 16 |
# File 'lib/bunchr/software.rb', line 14 def build_environment @build_environment end |
#download_commands ⇒ Object
Returns the value of attribute download_commands.
13 14 15 |
# File 'lib/bunchr/software.rb', line 13 def download_commands @download_commands end |
#download_environment ⇒ Object
Returns the value of attribute download_environment.
14 15 16 |
# File 'lib/bunchr/software.rb', line 14 def download_environment @download_environment end |
#install_commands ⇒ Object
Returns the value of attribute install_commands.
13 14 15 |
# File 'lib/bunchr/software.rb', line 13 def install_commands @install_commands end |
#install_environment ⇒ Object
Returns the value of attribute install_environment.
14 15 16 |
# File 'lib/bunchr/software.rb', line 14 def install_environment @install_environment end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/bunchr/software.rb', line 12 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/bunchr/software.rb', line 12 def version @version end |
Instance Method Details
#build ⇒ Object
Execute all the build commands
133 134 135 136 137 |
# File 'lib/bunchr/software.rb', line 133 def build build_commands.each do |cmd| sh(cmd, build_environment, work_dir) end end |
#define ⇒ Object
Define all the tasks in the namespace of the name
of this task.
The dependency chain is:
:install => :build => :download
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bunchr/software.rb', line 54 def define logger.debug "Defining tasks for software:#{name} #{version}" namespace 'software' do namespace name do define_download define_build define_install task :done => "software:#{name}:install" task :default => "software:#{name}:done" end desc "Download, build, and install #{name} #{version}" task name => "#{name}:default" end end |
#define_build ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bunchr/software.rb', line 92 def define_build desc "Build #{name} #{version}" task :build => dotfile('build') do logger.info "#{name} #{version} built" end file dotfile('build') => "software:#{name}:download" do logger.info "Building #{name} #{version}" Dir.chdir(work_dir) do build end dotfile!('build') end ::CLEAN << dotfile('build') end |
#define_download ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/bunchr/software.rb', line 73 def define_download directory download_dir desc "Download #{name} #{version}" task :download => dotfile('download') do logger.info "#{name} #{version} downloaded" end file dotfile('download') => download_dir do logger.info "Downloading #{name} #{version}" Dir.chdir(download_dir) do download end dotfile!('download') end ::CLEAN << dotfile('download') ::CLEAN << download_dir end |
#define_install ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/bunchr/software.rb', line 108 def define_install desc "Install #{name} #{version}" task :install => dotfile('install') do logger.info "#{name} #{version} is installed" end file dotfile('install') => "software:#{name}:build" do logger.info "Installing #{name} #{version}" Dir.chdir(work_dir) do install end dotfile!('install') end ::CLEAN << dotfile('install') end |
#depends_on(dependency) ⇒ Object
depend on a Bunchr::Software object to be built and installed
147 148 149 150 151 152 153 |
# File 'lib/bunchr/software.rb', line 147 def depends_on(dependency) namespace 'software' do namespace name do task :build => "software:#{dependency}:done" end end end |
#dotfile(name) ⇒ Object
155 156 157 |
# File 'lib/bunchr/software.rb', line 155 def dotfile(name) File.join(download_dir, ".#{name}") end |
#dotfile!(name) ⇒ Object
159 160 161 |
# File 'lib/bunchr/software.rb', line 159 def dotfile!(name) File.open(dotfile(name), "w") { |f| puts Time.now } end |
#download ⇒ Object
Execute all the build commands
126 127 128 129 130 |
# File 'lib/bunchr/software.rb', line 126 def download download_commands.each do |cmd| sh(cmd, download_environment, download_dir) end end |
#download_dir ⇒ Object
29 30 31 |
# File 'lib/bunchr/software.rb', line 29 def download_dir File.join(Bunchr.build_dir, name) end |
#install ⇒ Object
Execute all the install commands
140 141 142 143 144 |
# File 'lib/bunchr/software.rb', line 140 def install install_commands.each do |cmd| sh(cmd, install_environment, work_dir) end end |
#work_dir ⇒ Object
The directory this task unpacks into
34 35 36 |
# File 'lib/bunchr/software.rb', line 34 def work_dir @work_dir ||= File.join(download_dir, "#{name + (version ? "-#{version}" : "") }") end |
#work_dir=(pd) ⇒ Object
override the directory that the local source unpacks into if it is not name-version
. If pd is an absolute path, use it. Otherwise, prepend with
41 42 43 44 45 46 47 |
# File 'lib/bunchr/software.rb', line 41 def work_dir=(pd) if pd =~ /^\// @work_dir = pd else @work_dir = File.join(download_dir, pd) end end |