build-tool 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +28 -1
  3. data/Manifest.txt +91 -52
  4. data/README.txt +63 -0
  5. data/Rakefile +20 -23
  6. data/bin/build-tool +53 -0
  7. data/lib/build-tool.rb +7 -0
  8. data/lib/build-tool/GUI.rb +360 -0
  9. data/lib/build-tool/application.rb +84 -0
  10. data/lib/build-tool/build-system/autoconf.rb +60 -0
  11. data/lib/build-tool/build-system/base.rb +142 -0
  12. data/lib/build-tool/build-system/cmake.rb +119 -0
  13. data/lib/build-tool/build-system/custom.rb +115 -0
  14. data/lib/build-tool/build-system/qt.rb +113 -0
  15. data/lib/build-tool/cfg/lexer.rb +558 -0
  16. data/lib/build-tool/cfg/lexer.rex +248 -0
  17. data/lib/build-tool/cfg/lexer_base.rb +82 -0
  18. data/lib/build-tool/cfg/node.rb +94 -0
  19. data/lib/build-tool/cfg/parser.rb +871 -0
  20. data/lib/build-tool/cfg/parser.y +279 -0
  21. data/lib/build-tool/cfg/visitor.rb +471 -0
  22. data/lib/build-tool/commands.rb +639 -0
  23. data/lib/build-tool/commands/build.rb +120 -0
  24. data/lib/build-tool/commands/configure.rb +73 -0
  25. data/lib/build-tool/commands/ctags.rb +46 -0
  26. data/lib/build-tool/commands/environments.rb +29 -0
  27. data/lib/build-tool/commands/environments/list.rb +37 -0
  28. data/lib/build-tool/commands/environments/set.rb +33 -0
  29. data/lib/build-tool/commands/fetch.rb +50 -0
  30. data/lib/build-tool/commands/files.rb +73 -0
  31. data/lib/build-tool/commands/help.rb +22 -0
  32. data/lib/build-tool/commands/info.rb +48 -0
  33. data/lib/build-tool/commands/install.rb +56 -0
  34. data/lib/build-tool/commands/modules.rb +29 -0
  35. data/lib/build-tool/commands/modules/info.rb +75 -0
  36. data/lib/build-tool/commands/modules/list.rb +49 -0
  37. data/lib/build-tool/commands/modules/shell.rb +40 -0
  38. data/lib/build-tool/commands/rebase.rb +46 -0
  39. data/lib/build-tool/commands/recipes.rb +32 -0
  40. data/lib/build-tool/commands/recipes/info.rb +46 -0
  41. data/lib/build-tool/commands/recipes/install.rb +184 -0
  42. data/lib/build-tool/commands/recipes/list.rb +33 -0
  43. data/lib/build-tool/configuration.rb +115 -0
  44. data/lib/build-tool/environment.rb +119 -0
  45. data/lib/build-tool/errors.rb +9 -0
  46. data/lib/build-tool/module.rb +366 -0
  47. data/lib/build-tool/pluginbase.rb +43 -0
  48. data/lib/build-tool/recipe.rb +180 -0
  49. data/lib/build-tool/repository.rb +59 -0
  50. data/lib/build-tool/server.rb +43 -0
  51. data/lib/build-tool/singleton.rb +50 -0
  52. data/lib/build-tool/sshkey.rb +22 -0
  53. data/lib/build-tool/vcs/base.rb +105 -0
  54. data/lib/build-tool/vcs/git-svn.rb +154 -0
  55. data/lib/build-tool/vcs/git.rb +187 -0
  56. data/lib/build-tool/vcs/svn.rb +136 -0
  57. data/lib/mj/logging.rb +31 -0
  58. data/lib/mj/tools/ssh.rb +64 -0
  59. data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
  60. data/lib/mj/visitor.rb +21 -0
  61. data/recipes/kde/files/finish_installation.sh +16 -0
  62. data/recipes/kde/files/kde4.desktop +22 -0
  63. data/recipes/kde/files/xsession +89 -0
  64. data/recipes/kde/info.yaml +10 -0
  65. data/recipes/kde/recipe +585 -0
  66. data/recipes/kde/recipe-local +90 -0
  67. data/recipes/kde/settings.yaml +52 -0
  68. data/recipes/kde43/info.yaml +10 -0
  69. data/recipes/kde43/recipe +256 -0
  70. data/recipes/kde43/recipe-local +90 -0
  71. data/recipes/kde43/settings.yaml +32 -0
  72. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
  73. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
  74. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
  75. data/recipes/kdeqt4.6/info.yaml +7 -0
  76. data/recipes/kdeqt4.6/recipe +155 -0
  77. data/recipes/kdeqt4.6/recipe-local +30 -0
  78. data/recipes/kdeqt4.6/settings.yaml +27 -0
  79. data/tags +745 -0
  80. data/tasks/genfiles.rake +28 -0
  81. data/tasks/rdoc.rake +34 -0
  82. data/tasks/rspec.rake +21 -0
  83. data/test.rb +28 -0
  84. data/test/commands/test_build.rb +29 -0
  85. data/test/test_build_system.rb +98 -0
  86. data/test/test_cli.rb +61 -0
  87. data/test/test_command.rb +175 -0
  88. data/test/test_configuration_parser.rb +542 -0
  89. data/test/test_environment.rb +82 -0
  90. data/test/test_helper.rb +39 -7
  91. data/test/test_module.rb +158 -0
  92. data/test/test_repository.rb +75 -0
  93. data/test/test_singleton.rb +51 -0
  94. data/test/test_ssh_key.rb +14 -0
  95. data/test/test_svn_parser.rb +28 -0
  96. data/test/test_vcs.rb +33 -0
  97. metadata +139 -90
  98. metadata.gz.sig +0 -0
  99. data/PostInstall.txt +0 -3
  100. data/TODO +0 -2
  101. data/bin/kde-build.rb +0 -21
  102. data/config/website.yml +0 -2
  103. data/config/website.yml.sample +0 -2
  104. data/lib/kde-build.rb +0 -18
  105. data/lib/kde-build/application.rb +0 -270
  106. data/lib/kde-build/build_system.rb +0 -28
  107. data/lib/kde-build/build_system/autoconf.rb +0 -108
  108. data/lib/kde-build/build_system/base.rb +0 -139
  109. data/lib/kde-build/build_system/cmake.rb +0 -94
  110. data/lib/kde-build/build_system/qtcopy.rb +0 -127
  111. data/lib/kde-build/command.rb +0 -42
  112. data/lib/kde-build/command/build.rb +0 -106
  113. data/lib/kde-build/command/compile.rb +0 -39
  114. data/lib/kde-build/command/configure.rb +0 -48
  115. data/lib/kde-build/command/ctags.rb +0 -41
  116. data/lib/kde-build/command/fetch.rb +0 -33
  117. data/lib/kde-build/command/help.rb +0 -71
  118. data/lib/kde-build/command/info.rb +0 -45
  119. data/lib/kde-build/command/install.rb +0 -39
  120. data/lib/kde-build/command/module_based.rb +0 -44
  121. data/lib/kde-build/command/rebase.rb +0 -50
  122. data/lib/kde-build/command/version.rb +0 -43
  123. data/lib/kde-build/configuration.rb +0 -209
  124. data/lib/kde-build/exception.rb +0 -6
  125. data/lib/kde-build/metaaid.rb +0 -18
  126. data/lib/kde-build/module.rb +0 -227
  127. data/lib/kde-build/module_configuration.rb +0 -107
  128. data/lib/kde-build/moduleregistry.rb +0 -85
  129. data/lib/kde-build/tools/ctags.rb +0 -59
  130. data/lib/kde-build/tools/logging.rb +0 -49
  131. data/lib/kde-build/tools/make.rb +0 -58
  132. data/lib/kde-build/tools/ssh.rb +0 -47
  133. data/lib/kde-build/vcs.rb +0 -28
  134. data/lib/kde-build/vcs/base.rb +0 -85
  135. data/lib/kde-build/vcs/git-svn.rb +0 -139
  136. data/lib/kde-build/vcs/git.rb +0 -121
  137. data/lib/kde-build/vcs/svn.rb +0 -102
  138. data/script/console +0 -10
  139. data/script/destroy +0 -14
  140. data/script/generate +0 -14
  141. data/script/txt2html +0 -71
  142. data/test.yaml.tmpl +0 -632
  143. data/test/test_kde-build.rb +0 -11
  144. data/test/test_vcs_svn.rb +0 -44
  145. data/website/index.html +0 -84
  146. data/website/index.txt +0 -59
  147. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  148. data/website/stylesheets/screen.css +0 -159
  149. data/website/template.html.erb +0 -50
@@ -0,0 +1,9 @@
1
+ module BuildTool
2
+
3
+ # Base class for all BuildTool Errors
4
+ class Error < StandardError; end
5
+
6
+ # A configuration error happened.
7
+ class ConfigurationError < Error; end
8
+
9
+ end
@@ -0,0 +1,366 @@
1
+ # require 'gbs_signal_slot'
2
+ require 'mj/tools/ssh'
3
+ require 'ftools'
4
+
5
+
6
+ module BuildTool
7
+
8
+ #
9
+ # Represents the information associated with a buildable module.
10
+ #
11
+ class Module
12
+
13
+ # Create a module
14
+ def initialize( name, parent = nil )
15
+ if name.nil?
16
+ raise StandardError, "Module name is required!"
17
+ end
18
+ @name = name
19
+ @parent = parent
20
+ @local_path = nil
21
+ @build_prefix = nil
22
+ @remote_path = nil
23
+ @environment = nil
24
+ @build_system = nil
25
+ @repository = nil
26
+ @install_prefix = nil
27
+ @is_template = false
28
+ @vcs_configuration = nil
29
+ end
30
+
31
+ #
32
+ ### ATTRIBUTES
33
+ #
34
+
35
+ # not inherited
36
+ def build_directory
37
+ "#{build_prefix_required}/bld/#{local_path}"
38
+ end
39
+
40
+ def build_prefix=( path )
41
+ if path
42
+ @build_prefix = Pathname.new( File.expand_path( path ) )
43
+ else
44
+ @build_prefix = nil
45
+ end
46
+ end
47
+
48
+ def build_prefix
49
+ # Return our own buildsystem if there is one
50
+ return @build_prefix if @build_prefix
51
+ # Return our parents buildsystem if there is one
52
+ return @parent.build_prefix if @parent && @parent.build_prefix
53
+ # Nothing
54
+ nil
55
+ end
56
+
57
+ # Will throw a exception if build_prefix is not set
58
+ def build_prefix_required
59
+ return self.build_prefix if self.build_prefix
60
+ raise ConfigurationError, "No build prefix configured for #{name}!"
61
+ end
62
+
63
+ # Build system
64
+ attr_writer :build_system
65
+
66
+ def build_system
67
+ # Return our own buildsystem if there is one
68
+ return @build_system if @build_system
69
+ # Return our parents buildsystem if there is one
70
+ if @parent && @parent.build_system
71
+ @build_system = @parent.build_system.dup
72
+ @build_system.module = self
73
+ return @build_system
74
+ end
75
+ # Nothing
76
+ nil
77
+ end
78
+
79
+ # Will throw a exception if build_system is not set
80
+ def build_system_required
81
+ return self.build_system if self.build_system
82
+ # *TODO* try to guess the build system
83
+ raise ConfigurationError, "No build system configured for #{name}!"
84
+ end
85
+
86
+ def checkedout?
87
+ vcs_required.checkedout?
88
+ end
89
+
90
+ def configured?
91
+ build_system_required.configured?
92
+ end
93
+
94
+ def description
95
+ @description || "no description"
96
+ end
97
+
98
+ # Environment
99
+ attr_writer :environment
100
+
101
+ def environment
102
+ # Return our own buildsystem if there is one
103
+ return @environment if @environment
104
+ # Return our parents buildsystem if there is one
105
+ return @parent.environment if @parent && @parent.environment
106
+ # Nothing
107
+ nil
108
+ end
109
+
110
+ # Will throw a exception if environment is not set
111
+ def environment_required
112
+ return self.environment if self.environment
113
+ raise ConfigurationError, "No environment configured for #{name}!"
114
+ end
115
+
116
+ # Installation prefix
117
+ def install_prefix=( path )
118
+ if path
119
+ @install_prefix = Pathname.new( File.expand_path( path.to_s ) )
120
+ else
121
+ @install_prefix = nil
122
+ end
123
+ end
124
+
125
+ def install_prefix
126
+ # Return our own buildsystem if there is one
127
+ return @install_prefix if @install_prefix
128
+ # Return our parents buildsystem if there is one
129
+ return @parent.install_prefix if @parent && @parent.install_prefix
130
+ # Nothing
131
+ nil
132
+ end
133
+
134
+ # Will throw a exception if install_prefix is not set
135
+ def install_prefix_required
136
+ return self.install_prefix if self.install_prefix
137
+ raise ConfigurationError, "No install prefix configured for #{name}!"
138
+ end
139
+
140
+ attr_writer :is_template
141
+ def is_template?
142
+ @is_template
143
+ end
144
+
145
+ def local_path=( local_path )
146
+ raise ConfigurationError, "Attempt to set local_path for module template #{name}" if is_template?
147
+ @local_path = local_path
148
+ end
149
+
150
+ def local_path
151
+ @local_path || @name
152
+ end
153
+
154
+ # The module name
155
+ attr_reader :name
156
+
157
+ # Remote path
158
+ def remote_path=( remote_path )
159
+ raise ConfigurationError, "Attempt to set remote_path for module template #{name}" if is_template?
160
+ @remote_path = remote_path
161
+ end
162
+
163
+ def remote_path
164
+ @remote_path || @name
165
+ end
166
+
167
+ # Repository
168
+ def repository=( repository )
169
+ @repository = repository
170
+ end
171
+
172
+ def repository
173
+ return @repository if @repository
174
+ return @parent.repository if @parent && @parent.repository
175
+ end
176
+
177
+ def repository_required
178
+ repo = self.repository
179
+ return repo if repo
180
+ raise ConfigurationError, "No repository configured for #{name}!"
181
+ end
182
+
183
+ def source_directory
184
+ "#{build_prefix_required}/src/#{local_path}"
185
+ end
186
+ alias source_directory_required source_directory
187
+
188
+ def vcs
189
+ return vcs_configuration.vcs( self ) if vcs_configuration
190
+ nil
191
+ end
192
+
193
+ attr_writer :vcs_configuration
194
+ def vcs_configuration
195
+ return @vcs_configuration if @vcs_configuration
196
+ return @parent.vcs_configuration if @parent
197
+ nil
198
+ end
199
+
200
+ def vcs_configuration_required
201
+ if @vcs_configuration
202
+ vc = @vcs_configuration
203
+ elsif @parent
204
+ vc = @parent.vcs_configuration
205
+ else
206
+ vc = nil
207
+ end
208
+ if vc.nil?
209
+ raise ConfigurationError, "No version control system configure for module #{name}."
210
+ end
211
+ return vc
212
+ end
213
+
214
+ def vcs_required
215
+ if repository.nil?
216
+ raise ConfigurationError, "No repository specified for module #{name}."
217
+ end
218
+ if remote_path.nil?
219
+ raise ConfigurationError, "No remote path specified for module #{name}."
220
+ end
221
+ if source_directory.nil?
222
+ raise ConfigurationError, "No source directory specified for module #{name}."
223
+ end
224
+ return vcs_configuration_required.vcs( self )
225
+ end
226
+
227
+ #
228
+ ### ACTIONS
229
+ #
230
+ def clean( logdir, remove_build_directory = false )
231
+ while_logging_to logdir, '10_clean' do
232
+ if remove_build_directory
233
+ logger.info "Removing build directory."
234
+ build_system_required.remove_build_directory
235
+ else
236
+ logger.info "Cleaning build directory."
237
+ build_system_required.make( "clean" )
238
+ end
239
+ end
240
+ end
241
+
242
+
243
+ # Clone the repository.
244
+ def clone( logdir )
245
+ while_logging_to logdir, '20_fetch' do
246
+ logger.info "Creating local checkout."
247
+ vcs_required.clone
248
+ end
249
+ end
250
+
251
+ # Fetch changes from the remote repository. Do not change the local
252
+ # checkout.
253
+ def fetch( logdir )
254
+ if !vcs_required.fetching_supported?
255
+ logger.info "Fetching/Rebase not supported by vcs #{vcs.name}. Doing it in one step."
256
+ end
257
+ while_logging_to logdir, '20_fetch' do
258
+ logger.info "Fetching remote changes."
259
+ vcs.fetch
260
+ end
261
+ end
262
+
263
+ # Update the local changes with remote changes. Do not fetch changes
264
+ # from the remote repository.
265
+ def rebase( logdir )
266
+ if !vcs_required.fetching_supported?
267
+ logger.info "Fetching not supported by vcs #{vcs.name}."
268
+ return
269
+ end
270
+ while_logging_to logdir, '30_rebase' do
271
+ logger.info "Rebasing against remote changes."
272
+ vcs.rebase
273
+ end
274
+ end
275
+
276
+ def configure( logdir )
277
+ while_logging_to logdir, '40_configure' do
278
+ logger.info "Configuring."
279
+ if !$noop and !vcs_required.checkedout?
280
+ raise ConfigurationError, "Failed to configure: Module is not checked out."
281
+ end
282
+ build_system_required.configure
283
+ end
284
+ end
285
+
286
+ def reconfigure( logdir )
287
+ while_logging_to logdir, '40_configure' do
288
+ logger.info "Recreating configuration."
289
+ if !$noop and !vcs_required.checkedout?
290
+ raise ConfigurationError, "Module is not checked out. Enable updating."
291
+ end
292
+ build_system_required.reconfigure
293
+ end
294
+ end
295
+
296
+ # Call make
297
+ def make( logdir, target = nil )
298
+ while_logging_to logdir, '50_build' do
299
+ logger.info "Building module."
300
+ build_system_required.make( target )
301
+ end
302
+ end
303
+
304
+ def install( logdir, fast = false )
305
+ while_logging_to logdir, '60_install' do
306
+ logger.info "Installing module."
307
+ build_system_required.install( fast )
308
+ end
309
+ end
310
+
311
+ # Check if an ssh-key is required and active it if necessary
312
+ def prepare_for_vcs_access
313
+ if key = repository_required.sshkey
314
+ if !MJ::Tools::SSH::has_key? key.file
315
+ MJ::Tools::SSH::add_key key.file
316
+ end
317
+ end
318
+ return true
319
+ end
320
+
321
+ def prepare_for_installation
322
+ prefix = install_prefix_required
323
+ if !prefix.exist? or !prefix.writable?
324
+ begin
325
+ FileUtils.mkdir_p prefix.to_s
326
+ rescue Errno::EACCES => e
327
+ logger.error "#{name}: The directory #{prefix.to_s} is not writable! Installation will fail!"
328
+ return false
329
+ end
330
+ end
331
+ return true
332
+ end
333
+
334
+ #########
335
+ protected
336
+ #########
337
+
338
+ def while_logging_to( logdir, fname, level = :trace, &block )
339
+ dirname = "#{logdir}/#{name}"
340
+ FileUtils.mkdir_p( dirname )
341
+ Logging.logger['root'].add_appenders(
342
+ Logging.appenders.file(
343
+ fname,
344
+ :filename => dirname + '/' + fname,
345
+ :layout => Logging::Layouts::Pattern.new( :pattern => '%m\n' ),
346
+ :level => level ))
347
+
348
+ begin
349
+ yield
350
+ rescue Interrupt => e
351
+ logger.error "User Interrupt!"
352
+ raise e
353
+ rescue Exception => e
354
+ logger.error "#{e.class}:#{e.message}"
355
+ got_exception = true
356
+ raise e
357
+ ensure
358
+ Logging.logger['root'].remove_appenders( fname )
359
+ logger.info("More information in #{dirname}/#{fname}") if got_exception
360
+ end
361
+ end
362
+
363
+ end # Module
364
+
365
+
366
+ end # module BuildTool
@@ -0,0 +1,43 @@
1
+ module BuildTool
2
+
3
+
4
+ #
5
+ # Mixin which implements basic plugin functionality.
6
+ #
7
+ module PluginBase
8
+
9
+ # Class methods
10
+ module ClassMethods
11
+
12
+ def register_plugin( child )
13
+ logger.debug "Registering plugin #{child}"
14
+ child.registered_plugins << child
15
+ end
16
+
17
+ # Called if the class is inherited
18
+ def inherited( child )
19
+ child.register_plugin( child )
20
+ end
21
+
22
+ def registered_plugins
23
+ @@registered_plugins
24
+ end
25
+
26
+ def registered_plugins=( val )
27
+ @@registered_plugins = val
28
+ end
29
+
30
+ end
31
+
32
+
33
+ # Mixin the class methods
34
+ def self.included( base )
35
+ base.extend( ClassMethods )
36
+ base.registered_plugins = Array.new
37
+ # puts "#{base} #{base.registered_plugins.inspect}"
38
+ end
39
+
40
+ end # class PluginBase
41
+
42
+
43
+ end
@@ -0,0 +1,180 @@
1
+ require 'yaml'
2
+
3
+ module BuildTool
4
+
5
+ #
6
+ #
7
+ #
8
+ class Recipe
9
+
10
+ attr_accessor :name
11
+ attr_accessor :global_path
12
+ attr_reader :settings
13
+
14
+ def initialize( name )
15
+ raise StandardError if name.nil?
16
+ @name = name
17
+ @metainfo_loaded = false
18
+ @short_description = "no description"
19
+ @long_description = "no description"
20
+ @global_path = Recipe.find_recipe( @name )
21
+ end
22
+
23
+ def browse_repository
24
+ return @browse_repository if @metainfo_loaded
25
+ load_metainfo
26
+ @browse_repository
27
+ end
28
+
29
+ # We look in
30
+ # local_config_file_path()/
31
+ # global_config_file_path()/
32
+ # for the file name @name. Name is allowed to be a path
33
+ def find_first_config_file( name )
34
+ if (pn = local_config_file_path( name )).exist?
35
+ return pn
36
+ end
37
+ if (pn = global_config_file_path( name )).exist?
38
+ return pn
39
+ end
40
+ return nil
41
+ end
42
+
43
+ def long_description
44
+ return @long_description if @metainfo_loaded
45
+ load_metainfo
46
+ @long_description
47
+ end
48
+
49
+ def load_metainfo
50
+ begin
51
+ file = YAML.load_file( metainfo_file_path )
52
+ @long_description = file['LONG']
53
+ @short_description = file['SHORT']
54
+ @website = file['WEBSITE']
55
+ @repository = file['REPOSITORY']
56
+ @browse_repository = file['BROWSE_REPOSITORY']
57
+ rescue Errno::ENOENT => e
58
+ logger.verbose "No description file found for recipe #{name}."
59
+ @short_description = "No description file provided!"
60
+ rescue ArgumentError => e
61
+ logger.verbose "Invalid description file found for for recipe #{name}."
62
+ @short_description = "Description File invalid!"
63
+ end
64
+ @metainfo_loaded = true
65
+ end
66
+
67
+ def load( local_config_name, settings )
68
+ @local_config_name = local_config_name
69
+ raise StandardError, "Usage: recipe.load( settings )" if settings.nil?
70
+ @settings = settings
71
+ configuration = Configuration.new( self )
72
+
73
+ # Load the recipe
74
+ logger.debug "Loading #{global_config_file_path( "recipe" )}"
75
+ configuration = load_from_file( global_config_file_path( "recipe" ), configuration )
76
+
77
+ # Load the local modifications to the recipe if any
78
+ local_config_file = local_config_file_path( "recipe" )
79
+ if local_config_file.exist?
80
+ logger.debug "Loading #{local_config_file}"
81
+ load_from_file( local_config_file, configuration )
82
+ end
83
+ configuration
84
+ end
85
+
86
+ def load_from_file( file, configuration )
87
+ # Get the file content
88
+ recipe = File.read( file )
89
+ # Create the parser
90
+ parser = Cfg::Parser.new( configuration )
91
+ # Create the ERB
92
+ erb = ERB.new( recipe, nil, "%<>" )
93
+ # Fill the env for ERB
94
+ b = binding
95
+ settings = @settings
96
+ # Call the parser with the ERBed file content and return the
97
+ # result
98
+ conf = parser.parse_string( erb.result(b), file )
99
+ end
100
+
101
+ def local_config_file_path(name)
102
+ Pathname.new( BuildTool::Application::instance.local_configuration_dir ).
103
+ join( @local_config_name, name)
104
+ end
105
+
106
+ def global_config_file_path( name )
107
+ return @global_path.join(name)
108
+ end
109
+
110
+ def repository
111
+ return @repository if @metainfo_loaded
112
+ load_metainfo
113
+ @repository
114
+ end
115
+
116
+ def short_description
117
+ return @short_description if @metainfo_loaded
118
+ load_metainfo
119
+ @short_description
120
+ end
121
+
122
+ def metainfo_file_path
123
+ return @global_path.join('info.yaml')
124
+ end
125
+
126
+ def files_path
127
+ return @global_path.join('files')
128
+ end
129
+
130
+ def website
131
+ return @website if @metainfo_loaded
132
+ load_metainfo
133
+ @website
134
+ end
135
+
136
+ #################
137
+ # CLASS METHODS #
138
+ #################
139
+ def self.config_directories
140
+ return [
141
+ Pathname.new( BuildTool::Application::instance.local_configuration_dir ).join( "recipes" ),
142
+ Pathname.new( BuildTool::Application::instance.application_root ).join( "recipes" )
143
+ ]
144
+ end
145
+
146
+ def self.all_recipes
147
+ recipes = {}
148
+ self.config_directories.each do |dir|
149
+ # Skip directories that don't exist
150
+ next if !dir.exist?
151
+ Dir.foreach( dir ) { |name|
152
+ next if name == '..'
153
+ next if name == '.'
154
+ pn = Pathname.new(dir).join(name)
155
+ next if !pn.directory?
156
+ next if recipes.has_key?(name)
157
+ recipes[name] = Recipe.new(name)
158
+ }
159
+ end
160
+ recipes
161
+ end
162
+
163
+ # Find recipe name. We look in
164
+ # 1. <local_configuration_dir>/recipes/<name>
165
+ # 2. <application_root>/recipes/<name>
166
+ #
167
+ # The first one found is returned
168
+ def self.find_recipe( name )
169
+ self.config_directories.each do |dir|
170
+ recipe = dir.join( name )
171
+ return recipe if recipe.join('recipe').exist?
172
+ end
173
+ raise ConfigurationError, "Recipe #{name} not found!";
174
+ end
175
+
176
+
177
+ end # class Recipe
178
+
179
+
180
+ end # module BuildTool