Class: BuildTool::Module
- Inherits:
-
Object
- Object
- BuildTool::Module
- Defined in:
- lib/build-tool/module.rb
Overview
Represents the information associated with a buildable module.
Instance Attribute Summary collapse
-
#active ⇒ Object
writeonly
Sets the attribute active.
- #build_system ⇒ Object
- #description ⇒ Object
- #environment ⇒ Object
-
#feature ⇒ Object
writeonly
ATTRIBUTES.
-
#is_template ⇒ Object
writeonly
Sets the attribute is_template.
- #long_description ⇒ Object
-
#name ⇒ Object
readonly
The module name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#patches ⇒ Object
readonly
Returns the value of attribute patches.
- #vcs_configuration ⇒ Object
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#build_directory ⇒ Object
not inherited.
- #build_prefix ⇒ Object
- #build_prefix=(path) ⇒ Object
-
#build_prefix_required ⇒ Object
Will throw a exception if build_prefix is not set.
-
#build_system_required ⇒ Object
Will throw a exception if build_system is not set.
- #checkedout? ⇒ Boolean
-
#clean ⇒ Object
ACTIONS.
-
#cleanup_after_vcs_access ⇒ Object
Cleanup after vcs_access.
-
#clone ⇒ Object
Clone the repository.
- #configure ⇒ Object
- #configured? ⇒ Boolean
-
#environment_required ⇒ Object
Will throw a exception if environment is not set.
-
#fetch ⇒ Object
Fetch changes from the remote repository.
-
#gc ⇒ Object
Garbage collect.
-
#initialize(name, parent = nil) ⇒ Module
constructor
Create a module.
- #install(fast = false) ⇒ Object
- #install_prefix ⇒ Object
-
#install_prefix=(path) ⇒ Object
Installation prefix.
-
#install_prefix_required ⇒ Object
Will throw a exception if install_prefix is not set.
- #is_template? ⇒ Boolean
- #local_path ⇒ Object
- #local_path=(local_path) ⇒ Object
-
#make(target = nil) ⇒ Object
Call make.
- #our_build_system ⇒ Object
-
#prepare_for_fetch ⇒ Object
Check if an ssh-key is required and active it if necessary.
- #prepare_for_installation ⇒ Object
-
#prepare_for_rebase ⇒ Object
Check if an ssh-key is required and active it if necessary.
-
#ready_for_fetch ⇒ Object
Check if an ssh-key is required and active it if necessary.
- #ready_for_rebase ⇒ Object
-
#rebase ⇒ Object
Update the local changes with remote changes.
- #reconfigure ⇒ Object
- #remote_path ⇒ Object
-
#remote_path=(remote_path) ⇒ Object
Remote path.
- #remove_build_directory ⇒ Object
- #source_directory ⇒ Object (also: #source_directory_required)
- #to_s ⇒ Object
- #vcs ⇒ Object
- #vcs_configuration_required ⇒ Object
- #vcs_required ⇒ Object
Constructor Details
#initialize(name, parent = nil) ⇒ Module
Create a module
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/build-tool/module.rb', line 13 def initialize( name, parent = nil ) if name.nil? raise StandardError, "Module name is required!" end @active = nil @patches = Array.new @name = name @parent = parent @local_path = nil @build_prefix = nil @remote_path = nil @environment = nil @build_system = nil @install_prefix = nil @is_template = false @vcs_configuration = nil @feature = nil @long_description = nil @description = nil end |
Instance Attribute Details
#active=(value) ⇒ Object (writeonly)
Sets the attribute active
39 40 41 |
# File 'lib/build-tool/module.rb', line 39 def active=(value) @active = value end |
#build_system ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/build-tool/module.rb', line 91 def build_system # Return our own buildsystem if there is one return @build_system if @build_system # Return our parents buildsystem if there is one if @parent && @parent.build_system @build_system = @parent.build_system.dup @build_system.module = self return @build_system end # Nothing nil end |
#description ⇒ Object
128 129 130 |
# File 'lib/build-tool/module.rb', line 128 def description @description end |
#environment ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/build-tool/module.rb', line 135 def environment # Return our own buildsystem if there is one return @environment if @environment # Return our parents buildsystem if there is one return @parent.environment if @parent && @parent.environment # Nothing nil end |
#feature=(value) ⇒ Object (writeonly)
ATTRIBUTES
38 39 40 |
# File 'lib/build-tool/module.rb', line 38 def feature=(value) @feature = value end |
#is_template=(value) ⇒ Object (writeonly)
Sets the attribute is_template
183 184 185 |
# File 'lib/build-tool/module.rb', line 183 def is_template=(value) @is_template = value end |
#long_description ⇒ Object
198 199 200 |
# File 'lib/build-tool/module.rb', line 198 def long_description @long_description end |
#name ⇒ Object (readonly)
The module name
203 204 205 |
# File 'lib/build-tool/module.rb', line 203 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
41 42 43 |
# File 'lib/build-tool/module.rb', line 41 def parent @parent end |
#patches ⇒ Object (readonly)
Returns the value of attribute patches.
40 41 42 |
# File 'lib/build-tool/module.rb', line 40 def patches @patches end |
#vcs_configuration ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/build-tool/module.rb', line 226 def vcs_configuration return @vcs_configuration if @vcs_configuration if @parent && @parent.vcs_configuration # puts "copying vcs for #{name} from #{@parent.name}" vc = @parent.vcs_configuration.class.new vc.copy_configuration( @parent.vcs_configuration ) @vcs_configuration = vc return vc end nil end |
Instance Method Details
#active? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/build-tool/module.rb', line 43 def active? # If the module is activated that wins if @active.nil? if @feature.nil? return true else return @feature.active? end else return @active end end |
#build_directory ⇒ Object
not inherited
57 58 59 |
# File 'lib/build-tool/module.rb', line 57 def build_directory build_prefix_required.join("bld", local_path) end |
#build_prefix ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/build-tool/module.rb', line 73 def build_prefix # Return our own buildsystem if there is one return @build_prefix if @build_prefix # Return our parents buildsystem if there is one return @parent.build_prefix if @parent && @parent.build_prefix # Nothing nil end |
#build_prefix=(path) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/build-tool/module.rb', line 61 def build_prefix=( path ) if path path = Pathname.new( path.sub( /\$HOME/, '~' ) ) if path.to_s[0] != '~' and path.relative? raise ConfigurationError, "Build-prefix '#{path}' is relative!" end @build_prefix = path. else @build_prefix = nil end end |
#build_prefix_required ⇒ Object
Will throw a exception if build_prefix is not set
83 84 85 86 |
# File 'lib/build-tool/module.rb', line 83 def build_prefix_required return self.build_prefix if self.build_prefix raise ConfigurationError, "No build prefix configured for #{name}!" end |
#build_system_required ⇒ Object
Will throw a exception if build_system is not set
109 110 111 112 113 |
# File 'lib/build-tool/module.rb', line 109 def build_system_required return self.build_system if self.build_system # *TODO* try to guess the build system raise ConfigurationError, "No build system configured for #{name}!" end |
#checkedout? ⇒ Boolean
115 116 117 |
# File 'lib/build-tool/module.rb', line 115 def checkedout? vcs_required.checkedout? end |
#clean ⇒ Object
ACTIONS
256 257 258 |
# File 'lib/build-tool/module.rb', line 256 def clean build_system_required.make( "clean" ) end |
#cleanup_after_vcs_access ⇒ Object
Cleanup after vcs_access
312 313 314 315 316 317 318 319 320 321 |
# File 'lib/build-tool/module.rb', line 312 def cleanup_after_vcs_access if MJ::Tools::SSH::has_keys? logger.info "" logger.info "#### Cleaning up the ssh keys" MJ::Tools::SSH::keys.each do |file| logger.info " - Removing key #{file}" end MJ::Tools::SSH::cleanup() end end |
#clone ⇒ Object
Clone the repository.
265 266 267 268 269 270 271 272 273 |
# File 'lib/build-tool/module.rb', line 265 def clone vcs_required.clone if !patches.empty? if !vcs.patches_supported? raise NotImplementedError, "Patch support not implemented for vcs #{vcs.name}" end vcs_required.apply_patches( patches ) end end |
#configure ⇒ Object
294 295 296 |
# File 'lib/build-tool/module.rb', line 294 def configure build_system_required.configure end |
#configured? ⇒ Boolean
119 120 121 122 123 124 125 |
# File 'lib/build-tool/module.rb', line 119 def configured? if build_system return build_system.configured? else return false end end |
#environment_required ⇒ Object
Will throw a exception if environment is not set
145 146 147 148 |
# File 'lib/build-tool/module.rb', line 145 def environment_required return self.environment if self.environment raise ConfigurationError, "No environment configured for #{name}!" end |
#fetch ⇒ Object
Fetch changes from the remote repository. Do not change the local checkout.
277 278 279 |
# File 'lib/build-tool/module.rb', line 277 def fetch vcs_required.fetch end |
#gc ⇒ Object
Garbage collect
151 152 153 |
# File 'lib/build-tool/module.rb', line 151 def gc vcs.gc end |
#install(fast = false) ⇒ Object
307 308 309 |
# File 'lib/build-tool/module.rb', line 307 def install( fast = false ) build_system_required.install( fast ) end |
#install_prefix ⇒ Object
168 169 170 171 172 173 174 175 |
# File 'lib/build-tool/module.rb', line 168 def install_prefix # Return our own buildsystem if there is one return @install_prefix if @install_prefix # Return our parents buildsystem if there is one return @parent.install_prefix if @parent && @parent.install_prefix # Nothing nil end |
#install_prefix=(path) ⇒ Object
Installation prefix
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/build-tool/module.rb', line 156 def install_prefix=( path ) if path path = Pathname.new( path.sub( /\$HOME/, '~' ) ) if path.to_s[0] != '~' and path.relative? raise ConfigurationError, "Install-prefix '#{path}' is relative!" end @install_prefix = path. else @install_prefix = nil end end |
#install_prefix_required ⇒ Object
Will throw a exception if install_prefix is not set
178 179 180 181 |
# File 'lib/build-tool/module.rb', line 178 def install_prefix_required return self.install_prefix if self.install_prefix raise ConfigurationError, "No install prefix configured for #{name}!" end |
#is_template? ⇒ Boolean
184 185 186 |
# File 'lib/build-tool/module.rb', line 184 def is_template? @is_template end |
#local_path ⇒ Object
193 194 195 |
# File 'lib/build-tool/module.rb', line 193 def local_path @local_path || @name end |
#local_path=(local_path) ⇒ Object
188 189 190 191 |
# File 'lib/build-tool/module.rb', line 188 def local_path=( local_path ) raise ConfigurationError, "Attempt to set local_path for module template #{name}" if is_template? @local_path = local_path end |
#make(target = nil) ⇒ Object
Call make
303 304 305 |
# File 'lib/build-tool/module.rb', line 303 def make( target = nil ) build_system_required.make( target ) end |
#our_build_system ⇒ Object
104 105 106 |
# File 'lib/build-tool/module.rb', line 104 def our_build_system @build_system end |
#prepare_for_fetch ⇒ Object
Check if an ssh-key is required and active it if necessary
324 325 326 327 328 329 |
# File 'lib/build-tool/module.rb', line 324 def prepare_for_fetch if vcs return vcs.prepare_for_fetch end true end |
#prepare_for_installation ⇒ Object
355 356 357 |
# File 'lib/build-tool/module.rb', line 355 def prepare_for_installation return build_system_required.prepare_for_installation end |
#prepare_for_rebase ⇒ Object
Check if an ssh-key is required and active it if necessary
332 333 334 335 336 337 |
# File 'lib/build-tool/module.rb', line 332 def prepare_for_rebase if vcs return vcs.prepare_for_rebase end true end |
#ready_for_fetch ⇒ Object
Check if an ssh-key is required and active it if necessary
340 341 342 343 344 345 |
# File 'lib/build-tool/module.rb', line 340 def ready_for_fetch if vcs return vcs.ready_for_fetch end true end |
#ready_for_rebase ⇒ Object
347 348 349 350 351 352 |
# File 'lib/build-tool/module.rb', line 347 def ready_for_rebase if vcs return vcs.ready_for_rebase end true end |
#rebase ⇒ Object
Update the local changes with remote changes. Do not fetch changes from the remote repository.
283 284 285 286 287 288 289 290 291 292 |
# File 'lib/build-tool/module.rb', line 283 def rebase vcs_required.rebase if !patches.empty? if !vcs.patches_supported? raise NotImplementedError, "Patch support not implemented for vcs #{vcs.name}" end vcs_required.apply_patches( patches ) end build_system_required.after_rebase end |
#reconfigure ⇒ Object
298 299 300 |
# File 'lib/build-tool/module.rb', line 298 def reconfigure build_system_required.reconfigure end |
#remote_path ⇒ Object
211 212 213 |
# File 'lib/build-tool/module.rb', line 211 def remote_path @remote_path || @name end |
#remote_path=(remote_path) ⇒ Object
Remote path
206 207 208 209 |
# File 'lib/build-tool/module.rb', line 206 def remote_path=( remote_path ) raise ConfigurationError, "Attempt to set remote_path for module template #{name}" if is_template? @remote_path = remote_path end |
#remove_build_directory ⇒ Object
260 261 262 |
# File 'lib/build-tool/module.rb', line 260 def remove_build_directory build_system_required.remove_build_directory end |
#source_directory ⇒ Object Also known as: source_directory_required
215 216 217 |
# File 'lib/build-tool/module.rb', line 215 def source_directory build_prefix_required.join("src", local_path) end |
#to_s ⇒ Object
359 360 361 |
# File 'lib/build-tool/module.rb', line 359 def to_s "#{object_id}: #{name}" end |
#vcs ⇒ Object
220 221 222 223 |
# File 'lib/build-tool/module.rb', line 220 def vcs return vcs_configuration.vcs( self ) if vcs_configuration nil end |
#vcs_configuration_required ⇒ Object
238 239 240 241 242 243 244 |
# File 'lib/build-tool/module.rb', line 238 def vcs_configuration_required vc = vcs_configuration if vc.nil? raise ConfigurationError, "No version control system configure for module #{name}." end return vc end |
#vcs_required ⇒ Object
246 247 248 249 250 251 |
# File 'lib/build-tool/module.rb', line 246 def vcs_required if source_directory.nil? raise ConfigurationError, "No source directory specified for module #{name}." end return vcs_configuration_required.vcs( self ) end |