build-tool 0.6.2 → 0.6.3

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.
data/History.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ == Version 0.6.3
2
+ === Enhancements
3
+ - <tt>module shell<</tt>: Add <tt>--batch</tt> option.
4
+ - Archive Buildsystem now supports xz archives.
5
+
6
+ === Bugfixes
7
+ - Reordering modules in the recipe did not change the build order.
8
+ - Features no longer present in the recipe were not deleted from the db.
9
+
1
10
  == Version 0.6.2
2
11
  === Features
3
12
  - <tt>environment set</tt>: Add <tt>--command</tt> option (Execute command and return)
@@ -4,17 +4,12 @@
4
4
  Logging.init :debug2, :debug, :trace, :verbose, :info, :warn, :error
5
5
  include Logging.globally
6
6
 
7
- require 'optparse'
8
- require 'erb'
9
- require 'yaml'
10
-
11
7
  require 'mj/logging'
12
8
 
13
9
  require "build-tool/errors"
14
10
  require 'build-tool/singleton'
15
11
 
16
12
  require 'active_record'
17
- require 'sqlite3'
18
13
 
19
14
  $noop = false
20
15
 
@@ -54,72 +49,7 @@ def configuration
54
49
  require 'build-tool/recipe'
55
50
 
56
51
  # Read the configuration from the database
57
- @configuration = Configuration.new()
58
- @configuration.load()
59
-
60
- #
61
- ### MIGRATION FROM 0.5 START
62
- #
63
- # First load the old settings file if it exists. For new style the settings are
64
- # correctly loaded from the database already.
65
- file = local_settings_file_path
66
- if file.exist?
67
- logger.info "Loading old style settings file #{file}."
68
- YAML.load( File.open( file, 'r:UTF-8' ) ).each do |n, v|
69
- case n
70
- when 'RECIPE'
71
- n = "BUILD_TOOL.RECIPE"
72
- logger.debug( " %s='%s'" % [ n, v ] )
73
- s = ( @configuration.settings[ n ] or Setting.new( :name => n ) )
74
- s.value = v
75
- @configuration.add_setting( s )
76
- when 'SETTINGS'
77
- v.each do |n, v|
78
- logger.debug( " %s='%s'" % [ n, v ] )
79
- s = ( @configuration.settings[ n ] or Setting.new( :name => n ) )
80
- s.value = v
81
- @configuration.add_setting( s )
82
- end
83
- else
84
- logger.warn( 'Unknown setting %s found in %s' % [ n, file ] )
85
- end
86
- end
87
- @configuration.save()
88
- # Now rename the old file.
89
- file.rename( file.to_s + '_0.5' )
90
- logger.info( "Renamed old style settings file to #{file}_0.5. Please delete later!" )
91
- end
92
- #
93
- ### MIGRATION FROM 0.5 END
94
- #
95
-
96
-
97
- # Find the recipe. Will throw an exception if recipe is invalid.
98
- recipe = BuildTool::Recipe.new( @configuration.settings['BUILD_TOOL.RECIPE'].value )
99
- logger.debug( 'Determined associated recipe as %s ( %s )' % [ recipe.name, recipe.global_path ] )
100
- @configuration.recipe = recipe
101
-
102
- # Initialize the settings from the settings.yaml file from the recipe
103
- logger.debug( 'Loading configuration values from recipe:settings.yaml' )
104
- YAML.load( File.open( recipe.global_config_file_path( 'settings.yaml' ), 'r:UTF-8' ) ).each do |v|
105
- name = v['name']
106
- logger.debug2( ' - Setting %s' % name )
107
- s = ( @configuration.settings[ name ] or Setting.new( :name => name ) )
108
- s.description = v['description']
109
- s.default = v['default']
110
- s.seen = true
111
- @configuration.add_setting( s )
112
- end
113
-
114
- # Load the recipe
115
- logger.debug( 'Loading recipe %s' % recipe.name )
116
- @configuration = recipe.load( name, @configuration )
117
-
118
- # Save possible changes to the configuration.
119
- @configuration.save
120
-
121
- # Migrate the recipe (if necessary)
122
- @configuration.migrate()
52
+ @configuration = BuildToolConfiguration.new( name, local_settings_file_path )
123
53
 
124
54
  # Finished.
125
55
  @configuration
@@ -294,8 +294,7 @@ def visit_FeatureNode( node )
294
294
  end
295
295
  # Create a new feature if needed
296
296
  if @feature.nil?
297
- @feature = BuildTool::Feature.create( :name => name, :parent => configuration.active_feature )
298
- configuration.add_feature( @feature )
297
+ @feature = configuration.create_feature( name, configuration.active_feature )
299
298
  end
300
299
  # Set it as the current feature
301
300
  old_feat = configuration.active_feature
@@ -676,16 +675,20 @@ def visit_ModuleDeclarationNode( node )
676
675
  # Check if the module is alread defined. If yes we reopen it.
677
676
  @module = configuration.module( name )
678
677
  if @module.nil?
679
- @module = BuildTool::Module.create( { :name => name } )
680
- configuration.add_module( @module )
681
- end
682
-
683
- if inheritance
678
+ @module = configuration.create_module( name )
684
679
 
685
- if @module.found_in_recipe
686
- raise ConfigurationError, "Attempt to change a module #{name} while specifying inheritance!"
680
+ # Only add a module to a feature if it is the first time declared.
681
+ if !configuration.active_feature.nil?
682
+ @module.feature = configuration.active_feature
683
+ configuration.active_feature.modules << @module
687
684
  end
688
685
 
686
+ elsif inheritance
687
+
688
+ raise ConfigurationError, "Attempt to change a module #{name} while specifying inheritance!"
689
+ end
690
+
691
+ if inheritance
689
692
  parentName = node.values[2]
690
693
  parent = configuration.module( parentName )
691
694
  if parent.nil?
@@ -696,17 +699,6 @@ def visit_ModuleDeclarationNode( node )
696
699
  @module.parent = parent
697
700
  end
698
701
 
699
- # Only add a module to a feature if it is the first time declared.
700
- if !@module.found_in_recipe
701
- if !configuration.active_feature.nil?
702
- @module.feature = configuration.active_feature
703
- configuration.active_feature.modules << @module
704
- end
705
- end
706
-
707
- # Mark the module as found in the recipe
708
- @module.found_in_recipe = true
709
-
710
702
  # Work on the child nodes.
711
703
  begin
712
704
  self.visit_nodes( stmts )
@@ -90,14 +90,13 @@ def while_logging( level = :trace, &block )
90
90
 
91
91
  class Clean < Base
92
92
 
93
- def initialize( command, mod, remove_build_directory )
93
+ def initialize( command, mod )
94
94
  super( command, 10, :clean, mod )
95
- @remove_build_directory = remove_build_directory
96
95
  end
97
96
 
98
97
  def execute()
99
98
  logger.info "Cleaning"
100
- @module.clean( @remove_build_directory )
99
+ @module.clean()
101
100
  end
102
101
 
103
102
  end
@@ -8,7 +8,7 @@ module BuildTool; module Commands; module Modules
8
8
  #
9
9
  # BuildCommand
10
10
  #
11
- class MyShell < Standard
11
+ class MyShell < ModuleBasedCommand
12
12
 
13
13
  include MJ::Tools::SubProcess
14
14
 
@@ -17,7 +17,17 @@ class MyShell < Standard
17
17
  long_description [
18
18
  "Opens a new shell with the exact environment used to build the MODULE and",
19
19
  "then executes the given shell command. It then waits for the shell command",
20
- "to finish and returns its exit code. The default command is $SHELL." ]
20
+ "to finish and returns its exit code. The default command is $SHELL.",
21
+ "",
22
+ "The option --batch makes it possible to execute one command for many modules",
23
+ "but will not return the exit code. Instead the exit code will only show if",
24
+ "build-tool encountered a problem.",
25
+ "",
26
+ "The working directory is the build directory.",
27
+ "",
28
+ "The following environment variables will be set.",
29
+ "BT_SOURCE Source directory path"
30
+ ]
21
31
 
22
32
  def initialize_options
23
33
  options.banner = "Usage: #{self.fullname} [OPTIONS]... MODULE"
@@ -33,25 +43,37 @@ def initialize_options
33
43
  options.on( "-d", "--detach", "Detach the process and return immediately" ) {
34
44
  @detach = true
35
45
  }
46
+
47
+ @batch = false
48
+ options.on( "--batch", "Execute the command for many modules." ) {
49
+ @batch = true
50
+ }
36
51
  super
37
52
 
38
53
  end
39
54
 
40
55
  def do_execute( args )
41
- # Check the number of commandline args
42
- if args.length != 1
43
- return usage( "Wrong number of arguments" )
44
- end
45
-
46
- # Translate argument into modules
47
- mod = complete_modules( args[0] )
48
- if mod.length != 1
49
- return usage( "This command only works on one module" )
56
+ if @batch
57
+ super( args )
58
+ else
59
+ # Check the number of commandline args
60
+ if args.length != 1
61
+ return usage( "Wrong number of arguments" )
62
+ end
63
+
64
+ # Translate argument into modules
65
+ mod = complete_modules( args[0] )
66
+ if mod.length != 1
67
+ return usage( "This command only works on one module" )
68
+ end
69
+
70
+ return do_execute_module( mod[0] )
50
71
  end
72
+ end
51
73
 
52
- # Get our one and only module
74
+ def do_execute_module( mod )
53
75
  verbose "> #{@command}"
54
- rc = mod[0].environment.shell( @command, { detach: @detach } )
76
+ rc = mod.shell( @command, { detach: @detach } )
55
77
  verbose "> #{rc}" if not @detach
56
78
  verbose "> send to background" if @detach
57
79
 
@@ -48,7 +48,7 @@ def do_execute( args )
48
48
  repo.fetch("origin")
49
49
  end
50
50
 
51
- repo.log('HEAD..%s' % branch ).each do |line|
51
+ repo.log('HEAD..origin/%s' % branch ).each do |line|
52
52
  info( line )
53
53
  end
54
54
 
@@ -79,17 +79,51 @@ def feature( name )
79
79
  @features[name]
80
80
  end
81
81
 
82
- def add_feature( feature )
83
- @features[feature.path] = feature
82
+ def create_feature( name, parent = active_feature )
83
+
84
+ if parent
85
+ path = "#{parent.path}/#{name}"
86
+ else
87
+ path = "#{name}"
88
+ end
89
+
90
+ if @features.has_key?( path )
91
+ raise StandardError, "Attempt to create already existing feature #{name}"
92
+ end
93
+
94
+ if @cached_features.has_key?( path )
95
+ # Found in cache. Add it for real and remove from cache.
96
+ logger.debug( "Getting feature #{path} from cache" )
97
+ add_feature( @cached_features[ path] )
98
+ @cached_features.delete( path)
99
+ else
100
+ logger.debug( "Creating feature #{path}" )
101
+ add_feature( BuildTool::Feature.create(
102
+ :name => name,
103
+ :parent => parent ) )
104
+ end
105
+ @features[path]
84
106
  end
85
107
 
86
108
  def module( name )
87
109
  @module[name]
88
110
  end
89
111
 
90
- def add_module( mod )
91
- @module[mod.name] = mod
92
- @modules << mod
112
+ def create_module( name )
113
+ if @module.has_key?( name )
114
+ raise StandardError, "Attempt to create already existing module #{name}"
115
+ end
116
+
117
+ if @cached_modules.has_key?( name )
118
+ # Found in cache. Add it for real and remove from cache.
119
+ logger.debug( "Getting module #{name} from cache" )
120
+ add_module( @cached_modules[ name ] )
121
+ @cached_modules.delete( name )
122
+ else
123
+ logger.debug( "Creating module #{name}" )
124
+ add_module( BuildTool::Module.create( { :name => name } ) )
125
+ end
126
+ @module[name]
93
127
  end
94
128
 
95
129
  def repository( name )
@@ -133,6 +167,9 @@ def initialize()
133
167
  @active_feature = nil
134
168
  @features = {}
135
169
  @settings = {}
170
+ @cached_modules = {}
171
+ @cached_features = {}
172
+ base_load()
136
173
  end
137
174
 
138
175
  def vcs( name )
@@ -208,32 +245,16 @@ def save
208
245
  end
209
246
  end
210
247
 
211
- def load
212
- logger.debug "Loading features from database."
213
- BuildTool::Feature.all.each do |f|
214
- logger.debug2 " - Feature %s" % [ f.name ]
215
- add_feature( f )
216
- end
217
- logger.debug "Loading modules from database."
218
- BuildTool::Module.all.each do |m|
219
- logger.debug2 " - Module %s" % [ m.name ]
220
- add_module( m )
221
- end
222
- logger.debug "Loading settings from database."
223
- BuildTool::Setting.all.each do |s|
224
- logger.debug2 " - Setting %s: %s" % [ s.name, s.value ]
225
- add_setting( s )
226
- end
227
- end
228
-
229
248
  def truncate
230
249
  logger.debug "Deleting all features from database."
231
250
  BuildTool::Feature.delete_all()
232
251
  @features = {}
252
+ @cached_features = {}
233
253
  logger.debug "Deleting all modules from database."
234
254
  BuildTool::Module.delete_all()
235
255
  @module = {}
236
256
  @modules = []
257
+ @cached_modules = {}
237
258
  logger.debug "Deleting all settings from database."
238
259
  BuildTool::Setting.delete_all()
239
260
  @settings = {}
@@ -247,16 +268,20 @@ def truncate
247
268
  def migrate()
248
269
 
249
270
  logger.debug( 'Checking for obsolete modules in db.' )
250
- for mod in @modules.reverse() do
251
- if not mod.found_in_recipe
252
- logger.info 'Module %s no longer supported by recipe. Removing it from db.' % [ mod.name ]
253
- # Remove it from our bookkeeping first.
254
- @module.delete( mod.name )
255
- @modules.delete( mod )
256
- # Remove it from the db
257
- mod.destroy()
258
- end
271
+ for mod in @cached_modules.values() do
272
+ logger.info 'Module %s no longer supported by recipe. Removing it from db.' % [ mod.name ]
273
+ # Remove it from the db
274
+ mod.destroy()
275
+ end
276
+ @cached_modules = {}
277
+
278
+ logger.debug( 'Checking for obsolete features in db.' )
279
+ for feat in @cached_features.values() do
280
+ logger.info 'Feature %s no longer supported by recipe. Removing it from db.' % [ feat.path ]
281
+ # Remove it from the db
282
+ feat.destroy()
259
283
  end
284
+ @cached_features = {}
260
285
 
261
286
  logger.debug( 'Checking for obsolete settings in db.' )
262
287
  settings.each do |n, s|
@@ -353,6 +378,121 @@ def complete_modules( name, include_templates = false, all = false, resume_from
353
378
  return res
354
379
  end
355
380
 
381
+
382
+ #######
383
+ private
384
+ #######
385
+
386
+ def base_load()
387
+
388
+ logger.debug "Loading features from database."
389
+ BuildTool::Feature.all.each do |f|
390
+ logger.debug2 " - Feature %s" % [ f.path ]
391
+ @cached_features[f.path] = f
392
+ end
393
+
394
+ logger.debug "Loading modules from database."
395
+ BuildTool::Module.all.each do |m|
396
+ logger.debug2 " - Module %s" % [ m.name ]
397
+ @cached_modules[m.name] = m
398
+ end
399
+
400
+ logger.debug "Loading settings from database."
401
+ BuildTool::Setting.all.each do |s|
402
+ logger.debug2 " - Setting %s: %s" % [ s.name, s.value ]
403
+ add_setting( s )
404
+ end
405
+
406
+ end
407
+
408
+ def add_module( mod )
409
+ @module[mod.name] = mod
410
+ @modules << mod
411
+ end
412
+
413
+ def add_feature( feature )
414
+ @features[feature.path] = feature
415
+ end
416
+
417
+
356
418
  end # Configuration
357
419
 
420
+ class BuildToolConfiguration < Configuration
421
+
422
+ def initialize( name, settings_file )
423
+ super()
424
+ load( name, settings_file )
425
+ end
426
+
427
+ #######
428
+ private
429
+ #######
430
+
431
+ def load( name, settings_file )
432
+
433
+ #
434
+ ### MIGRATION FROM 0.5 START
435
+ #
436
+ # First load the old settings file if it exists. For new style the settings are
437
+ # correctly loaded from the database already.
438
+ if ( not settings_file.nil? ) and settings_file.exist?
439
+ logger.info "Loading old style settings file #{file}."
440
+ YAML.load( File.open( file, 'r:UTF-8' ) ).each do |n, v|
441
+ case n
442
+ when 'RECIPE'
443
+ n = "BUILD_TOOL.RECIPE"
444
+ logger.debug( " %s='%s'" % [ n, v ] )
445
+ s = ( settings[ n ] or Setting.new( :name => n ) )
446
+ s.value = v
447
+ add_setting( s )
448
+ when 'SETTINGS'
449
+ v.each do |n, v|
450
+ logger.debug( " %s='%s'" % [ n, v ] )
451
+ s = ( settings[ n ] or Setting.new( :name => n ) )
452
+ s.value = v
453
+ add_setting( s )
454
+ end
455
+ else
456
+ logger.warn( 'Unknown setting %s found in %s' % [ n, file ] )
457
+ end
458
+ end
459
+ save()
460
+ # Now rename the old file.
461
+ file.rename( file.to_s + '_0.5' )
462
+ logger.info( "Renamed old style settings file to #{file}_0.5. Please delete later!" )
463
+ end
464
+ #
465
+ ### MIGRATION FROM 0.5 END
466
+ #
467
+
468
+ # Find the recipe. Will throw an exception if recipe is invalid.
469
+ @recipe = BuildTool::Recipe.new( settings['BUILD_TOOL.RECIPE'].value )
470
+ logger.debug( 'Determined associated recipe as %s ( %s )' % [ recipe.name, recipe.global_path ] )
471
+
472
+ # Initialize the settings from the settings.yaml file from the recipe
473
+ logger.debug( 'Loading configuration values from recipe:settings.yaml' )
474
+ YAML.load( File.open( recipe.global_config_file_path( 'settings.yaml' ), 'r:UTF-8' ) ).each do |v|
475
+ sname = v['name']
476
+ logger.debug2( ' - Setting %s' % sname )
477
+ s = ( settings[ sname ] or Setting.new( :name => sname ) )
478
+ s.description = v['description']
479
+ s.default = v['default']
480
+ s.seen = true
481
+ add_setting( s )
482
+ end
483
+
484
+ # Load the recipe
485
+ logger.debug( 'Loading recipe %s' % recipe.name )
486
+ recipe.load( name, self )
487
+
488
+ # Save possible changes to the configuration.
489
+ save()
490
+
491
+ # Migrate the recipe (if necessary)
492
+ migrate()
493
+
494
+ end
495
+
496
+ end
497
+
358
498
  end # module BuildTool
@@ -77,11 +77,12 @@ def set( name, value )
77
77
  def shell( command = nil, options = {} )
78
78
  wd = options[ :wd ]
79
79
  detach = options[ :detach ] || false
80
+ envvars = options[ :envvars ] || {}
80
81
 
81
82
  begin
82
83
  logger.verbose( "BUILD_TOOL_ENV = #{name}" )
83
84
  ENV['BUILD_TOOL_ENV'] = name
84
- self.class.adjust_environment( wd, values ) {
85
+ self.class.adjust_environment( wd, values.merge( envvars ) ) {
85
86
  pid = Process.fork {
86
87
  exec( command )
87
88
  }
@@ -41,7 +41,6 @@ def my_initialize()
41
41
  @vcs_configuration = nil
42
42
  @feature = nil
43
43
  @default_active = true
44
- @found_in_recipe = false
45
44
  @parent = nil
46
45
 
47
46
  @long_description = nil
@@ -59,9 +58,6 @@ def my_initialize()
59
58
  # The previous version of this module.
60
59
  attr_accessor :parent
61
60
 
62
- # Signals wether the module was found in the recipe or only in the database.
63
- attr_accessor :found_in_recipe
64
-
65
61
  # The default state of the feature
66
62
  attr_accessor :default_active
67
63
 
@@ -451,6 +447,16 @@ def prepare_for_installation
451
447
  return build_system_required.prepare_for_installation
452
448
  end
453
449
 
450
+ def shell( command = nil, options = {} )
451
+
452
+ envvars = options[ :envvars ] || {}
453
+ options[ :envvars ] = envvars.merge( {
454
+ 'BT_SOURCE' => source_directory.to_s
455
+ } )
456
+
457
+ environment.shell( command, options )
458
+ end
459
+
454
460
  def to_s
455
461
  "#{object_id}: #{name}"
456
462
  end
@@ -1,5 +1,6 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
 
3
+ require 'erb'
3
4
  require 'yaml'
4
5
 
5
6
  require 'build-tool/cfg/parser'
@@ -145,13 +145,24 @@ def guess_top_level_directory
145
145
  return "<topdir>" if $noop
146
146
  topdir = nil
147
147
  if archive_name =~ /(\.tgz|\.tar\.gz)$/
148
- if self.class.execute( "gunzip -c #{archive_local_path} | tar tf -" ) { |line|
148
+ if self.class.execute( "gunzip -c #{archive_local_path} | tar tf -" ) { |line|
149
149
  rc = /^([^\/]*)\//.match( line )
150
150
  if topdir and topdir != rc[1]
151
151
  raise StandardError, "Unable to determine toplevel directory for archive #{archive_name}!"
152
152
  end
153
153
  topdir = rc[1]
154
- } != 0
154
+ } != 0
155
+ # No topdir
156
+ return nil
157
+ end
158
+ elsif archive_name =~ /(\.txz|\.tar\.xz)$/
159
+ if self.class.execute( "xz -dc #{archive_local_path} | tar tf -" ) { |line|
160
+ rc = /^([^\/]*)\//.match( line )
161
+ if topdir and topdir != rc[1]
162
+ raise StandardError, "Unable to determine toplevel directory for archive #{archive_name}!"
163
+ end
164
+ topdir = rc[1]
165
+ } != 0
155
166
  # No topdir
156
167
  return nil
157
168
  end
@@ -185,6 +196,15 @@ def rebase( verbose = false )
185
196
  if self.class.execute( cmd ) != 0
186
197
  raise StandardError, "Failed to unpack the archive: $?"
187
198
  end
199
+ elsif archive_name =~ /(\.txz|\.tar\.xz)$/
200
+ if guess_top_level_directory()
201
+ cmd = "xz -dc #{archive_local_path} | tar --strip-components=1 --extract --file=- --directory=#{local_path}"
202
+ else
203
+ cmd = "xz -dc #{archive_local_path} | tar --strip-components=0 --extract --file=- --directory=#{local_path}"
204
+ end
205
+ if self.class.execute( cmd ) != 0
206
+ raise StandardError, "Failed to unpack the archive: $?"
207
+ end
188
208
  else
189
209
  raise NotImplementedError, "No idea how to unpack the archive"
190
210
  end
@@ -26,5 +26,5 @@ def recipe_version()
26
26
 
27
27
  end
28
28
 
29
- VERSION = Version.new( 0, 6, 2 )
29
+ VERSION = Version.new( 0, 6, 3 )
30
30
  end
@@ -48,41 +48,52 @@ def execute( command, wd = ENV["HOME"], env = nil )
48
48
 
49
49
  # Helper method to adjust LANG to "C"
50
50
  def adjust_environment( wd=nil, env=nil, lang="C" )
51
- if wd and !$noop
52
- cwd = Dir.getwd
53
- Dir.chdir(wd)
54
- end
55
- # Set the environment the user wants
56
- oldenv = Hash.new
57
- if env
58
- env.each do |var, value|
59
- oldenv[var] = ENV[var]
60
- if value.nil? or value == ""
61
- next if ENV.has_key?( value )
62
- ENV[var] = nil
63
- logger.verbose "Removing #{var} from environment"
64
- else
65
- logger.verbose "#{var} = #{value}"
66
- ENV[var] = value
51
+ begin
52
+ # Go to the working directory if given
53
+ if wd
54
+ cwd = Dir.getwd
55
+ Dir.chdir(wd) if not $noop
56
+ logger.debug( "Changed working directory from #{cwd} to #{wd}" )
57
+ end
58
+
59
+ # Set the environment the user wants
60
+ oldenv = Hash.new
61
+ if env
62
+ env.each do |var, value|
63
+ oldenv[var] = ENV[var]
64
+ if value.nil? or value == ""
65
+ next if ENV.has_key?( value )
66
+ ENV[var] = nil
67
+ logger.verbose "Removing #{var} from environment"
68
+ else
69
+ logger.verbose "#{var} = #{value}"
70
+ ENV[var] = value
71
+ end
67
72
  end
68
73
  end
74
+ # Save old LANG setting and switch to 'C'
75
+ oldlang = ENV['LANG']
76
+ ENV['LANG'] = lang
77
+ yield
78
+ # Reset the old LANG setting
79
+ ENV['LANG'] = oldlang
80
+ # Reset our changes to ENV
81
+ oldenv.each do |var, value|
82
+ ENV[var] = value
83
+ end
84
+
85
+ ensure
86
+ # Reset the current working directory
87
+ if wd
88
+ logger.debug( "Changed working directory back to #{cwd}" )
89
+ Dir.chdir(cwd) if not $noop
90
+ end
91
+
69
92
  end
70
- # Save old LANG setting and switch to 'C'
71
- oldlang = ENV['LANG']
72
- ENV['LANG'] = lang
73
- yield
74
- # Reset the old LANG setting
75
- ENV['LANG'] = oldlang
76
- # Reset our changes to ENV
77
- oldenv.each do |var, value|
78
- ENV[var] = value
79
- end
80
- # Reset the current working directory
81
- if wd and !$noop
82
- Dir.chdir(cwd)
83
- end
84
- end
85
- end
93
+
94
+ end # adjust_environment()
95
+
96
+ end # module ClassMethods
86
97
 
87
98
  #########
88
99
  protected
@@ -55,7 +55,6 @@ def setup
55
55
  @configuration.save()
56
56
 
57
57
  @configuration = BuildTool::Configuration.new()
58
- @configuration.load()
59
58
  @parser = BuildTool::Cfg::Parser.new( @configuration )
60
59
  @localparser = BuildTool::Cfg::Parser.new( @configuration, false )
61
60
  assert_nothing_raised() { @parser.parse_string <<-EOF }
@@ -87,7 +87,6 @@ module "test_disabled"
87
87
  @configuration.save()
88
88
 
89
89
  @configuration = BuildTool::Configuration.new()
90
- @configuration.load()
91
90
  @parser = BuildTool::Cfg::Parser.new( @configuration )
92
91
  @localparser = BuildTool::Cfg::Parser.new( @configuration, false )
93
92
  assert_nothing_raised() { @parser.parse_string <<-EOF }
@@ -118,7 +117,6 @@ module "obsolete"
118
117
  assert_not_nil( @configuration.module( 'obsolete' ) )
119
118
 
120
119
  @configuration = BuildTool::Configuration.new()
121
- @configuration.load()
122
120
  @parser = BuildTool::Cfg::Parser.new( @configuration )
123
121
  @localparser = BuildTool::Cfg::Parser.new( @configuration, false )
124
122
  assert_nothing_raised() { @parser.parse_string <<-EOF }
@@ -126,14 +124,13 @@ module "remains"
126
124
  end
127
125
  EOF
128
126
 
129
- # Now check the parsed configuration. Still the same
127
+ # Now check the parsed configuration. Missing obsolete.
130
128
  assert_not_nil( @configuration.module( 'remains' ) )
131
- assert_not_nil( @configuration.module( 'obsolete' ) )
132
129
 
133
130
  # Migrate
134
131
  @configuration.migrate()
135
132
 
136
- # Now check the parsed configuration. Not the same anymore.
133
+ # Now check the parsed configuration. Still the same.
137
134
  assert_not_nil( @configuration.module( 'remains' ) )
138
135
  assert_nil( @configuration.module( 'obsolete' ) )
139
136
  end
@@ -70,4 +70,86 @@ module "test_inherit" < "base"
70
70
  'The build directory is correctly set' )
71
71
  end
72
72
 
73
+ test "The recipe dictates the order of modules. Not the database." do
74
+ assert_nothing_raised() { @parser.parse_string <<-EOF }
75
+ log-directory "$HOME/test/log"
76
+
77
+ module "first"
78
+ end
79
+
80
+ module "second"
81
+ end
82
+ EOF
83
+ # Now check the parsed configuration
84
+ assert_equal( [ 'first', 'second' ], @configuration.modules.map { |m| m.name } )
85
+
86
+ # Save the config
87
+ @configuration.save
88
+
89
+ # And start again with reversed order.
90
+ @configuration = BuildTool::Configuration.new()
91
+ @parser = BuildTool::Cfg::Parser.new( @configuration )
92
+ assert_nothing_raised() { @parser.parse_string <<-EOF }
93
+ log-directory "$HOME/test/log"
94
+
95
+ module "second"
96
+ end
97
+
98
+ module "first"
99
+ end
100
+
101
+ EOF
102
+ # Now check the parsed configuration
103
+ assert_equal( [ 'second', 'first' ], @configuration.modules.map { |m| m.name } )
104
+ end
105
+
106
+ test "Obsolete Features will be removed." do
107
+ assert_nothing_raised() { @parser.parse_string <<-EOF }
108
+ log-directory "$HOME/test/log"
109
+
110
+ feature "A"
111
+ module "first"
112
+ end
113
+ end
114
+
115
+ feature "B"
116
+ module "second"
117
+ end
118
+ end
119
+
120
+ feature "C"
121
+ module "third"
122
+ end
123
+ end
124
+ EOF
125
+ # Now check the parsed configuration
126
+ assert_equal( [ 'first', 'second', 'third' ], @configuration.modules.map { |m| m.name } )
127
+ assert_equal( [ 'A', 'B', 'C' ], @configuration.features.keys.sort )
128
+
129
+ # Save the config
130
+ @configuration.save
131
+
132
+ # And start again with reversed order.
133
+ @configuration = BuildTool::Configuration.new()
134
+ @parser = BuildTool::Cfg::Parser.new( @configuration )
135
+ assert_nothing_raised() { @parser.parse_string <<-EOF }
136
+ log-directory "$HOME/test/log"
137
+
138
+ feature "A"
139
+ module "first"
140
+ end
141
+ end
142
+
143
+ feature "D"
144
+ module "fourth"
145
+ end
146
+ end
147
+
148
+ EOF
149
+ @configuration.migrate()
150
+ # Now check the parsed configuration
151
+ assert_equal( [ 'first', 'fourth' ], @configuration.modules.map { |m| m.name } )
152
+ assert_equal( [ 'A', 'D' ], @configuration.features.keys.sort )
153
+ end
154
+
73
155
  end
metadata CHANGED
@@ -1,135 +1,192 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: build-tool
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 3
10
+ version: 0.6.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Michael Jansen
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-04-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-05-27 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: logging
16
- requirement: &5733800 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 6
33
+ - 0
21
34
  version: 1.6.0
22
35
  type: :runtime
23
- prerelease: false
24
- version_requirements: *5733800
25
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
26
38
  name: activerecord
27
- requirement: &5733160 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
28
41
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 13
46
+ segments:
47
+ - 3
48
+ - 2
49
+ - 1
32
50
  version: 3.2.1
33
51
  type: :runtime
34
- prerelease: false
35
- version_requirements: *5733160
36
- - !ruby/object:Gem::Dependency
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
37
54
  name: sqlite3
38
- requirement: &5732520 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
39
57
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 17
62
+ segments:
63
+ - 1
64
+ - 3
65
+ - 5
43
66
  version: 1.3.5
44
67
  type: :runtime
45
- prerelease: false
46
- version_requirements: *5732520
47
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
48
70
  name: ansi
49
- requirement: &5731580 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
50
73
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 1
80
+ - 4
81
+ - 2
54
82
  version: 1.4.2
55
83
  type: :runtime
56
- prerelease: false
57
- version_requirements: *5731580
58
- - !ruby/object:Gem::Dependency
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
59
86
  name: grit
60
- requirement: &5731060 !ruby/object:Gem::Requirement
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
61
89
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 29
94
+ segments:
95
+ - 2
96
+ - 4
97
+ - 1
65
98
  version: 2.4.1
66
99
  type: :runtime
67
- prerelease: false
68
- version_requirements: *5731060
69
- - !ruby/object:Gem::Dependency
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
70
102
  name: racc
71
- requirement: &5730500 !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
72
105
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 9
110
+ segments:
111
+ - 1
112
+ - 4
113
+ - 7
76
114
  version: 1.4.7
77
115
  type: :development
78
- prerelease: false
79
- version_requirements: *5730500
80
- - !ruby/object:Gem::Dependency
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
81
118
  name: rexical
82
- requirement: &5730040 !ruby/object:Gem::Requirement
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
83
121
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 29
126
+ segments:
127
+ - 1
128
+ - 0
129
+ - 5
87
130
  version: 1.0.5
88
131
  type: :development
89
- prerelease: false
90
- version_requirements: *5730040
91
- - !ruby/object:Gem::Dependency
132
+ version_requirements: *id007
133
+ - !ruby/object:Gem::Dependency
92
134
  name: rake
93
- requirement: &5758900 !ruby/object:Gem::Requirement
135
+ prerelease: false
136
+ requirement: &id008 !ruby/object:Gem::Requirement
94
137
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 63
142
+ segments:
143
+ - 0
144
+ - 9
145
+ - 2
98
146
  version: 0.9.2
99
147
  type: :development
100
- prerelease: false
101
- version_requirements: *5758900
102
- - !ruby/object:Gem::Dependency
148
+ version_requirements: *id008
149
+ - !ruby/object:Gem::Dependency
103
150
  name: yard
104
- requirement: &5758400 !ruby/object:Gem::Requirement
151
+ prerelease: false
152
+ requirement: &id009 !ruby/object:Gem::Requirement
105
153
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 9
158
+ segments:
159
+ - 0
160
+ - 7
161
+ - 5
109
162
  version: 0.7.5
110
163
  type: :development
111
- prerelease: false
112
- version_requirements: *5758400
113
- - !ruby/object:Gem::Dependency
164
+ version_requirements: *id009
165
+ - !ruby/object:Gem::Dependency
114
166
  name: turn
115
- requirement: &5757740 !ruby/object:Gem::Requirement
167
+ prerelease: false
168
+ requirement: &id010 !ruby/object:Gem::Requirement
116
169
  none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0.9'
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 25
174
+ segments:
175
+ - 0
176
+ - 9
177
+ version: "0.9"
121
178
  type: :development
122
- prerelease: false
123
- version_requirements: *5757740
124
- description: ! "\n The tool helps \n\n ...\n "
125
- email:
179
+ version_requirements: *id010
180
+ description: "\n The tool helps \n\n ...\n "
181
+ email:
126
182
  - info@michael-jansen.biz
127
- executables:
183
+ executables:
128
184
  - build-tool
129
185
  extensions: []
130
- extra_rdoc_files:
186
+
187
+ extra_rdoc_files:
131
188
  - README.rdoc
132
- files:
189
+ files:
133
190
  - .gitattributes
134
191
  - .gitignore
135
192
  - .rvmrc
@@ -262,35 +319,51 @@ files:
262
319
  - test/unit/svn_configuration_test.rb
263
320
  - lib/build-tool/cfg/parser.rb
264
321
  - lib/build-tool/cfg/lexer.rb
322
+ has_rdoc: true
265
323
  homepage: http://michael-jansen.biz
266
- licenses:
324
+ licenses:
267
325
  - GPL-V2+
268
- post_install_message: ! "Thank you for using build-tool. For documentation see http://michael-jansen.biz/build-tool
269
- .\nReport bugs to kde (at) michael-jansen.biz. \n\nTo start with build-tool try
270
- the following commands:\n> build-tool recipe add git://gitorious.org/build-tool/kde-trunk-recipe.git
271
- kde\n> build-tool recipe list\n> build-tool recipe install kde\n\n"
326
+ post_install_message: |+
327
+ Thank you for using build-tool. For documentation see http://michael-jansen.biz/build-tool .
328
+ Report bugs to kde (at) michael-jansen.biz.
329
+
330
+ To start with build-tool try the following commands:
331
+ > build-tool recipe add git://gitorious.org/build-tool/kde-trunk-recipe.git kde
332
+ > build-tool recipe list
333
+ > build-tool recipe install kde
334
+
272
335
  rdoc_options: []
273
- require_paths:
336
+
337
+ require_paths:
274
338
  - lib
275
- required_ruby_version: !ruby/object:Gem::Requirement
339
+ required_ruby_version: !ruby/object:Gem::Requirement
276
340
  none: false
277
- requirements:
278
- - - ! '>='
279
- - !ruby/object:Gem::Version
341
+ requirements:
342
+ - - ">="
343
+ - !ruby/object:Gem::Version
344
+ hash: 55
345
+ segments:
346
+ - 1
347
+ - 9
348
+ - 2
280
349
  version: 1.9.2
281
- required_rubygems_version: !ruby/object:Gem::Requirement
350
+ required_rubygems_version: !ruby/object:Gem::Requirement
282
351
  none: false
283
- requirements:
284
- - - ! '>='
285
- - !ruby/object:Gem::Version
286
- version: '0'
352
+ requirements:
353
+ - - ">="
354
+ - !ruby/object:Gem::Version
355
+ hash: 3
356
+ segments:
357
+ - 0
358
+ version: "0"
287
359
  requirements: []
360
+
288
361
  rubyforge_project: build-tool
289
- rubygems_version: 1.8.15
362
+ rubygems_version: 1.5.0
290
363
  signing_key:
291
364
  specification_version: 3
292
365
  summary: A tool helping to download, configure and compile from sources.
293
- test_files:
366
+ test_files:
294
367
  - test/integration/configuration_test.rb
295
368
  - test/integration/history_test.rb
296
369
  - test/integration/parser_bazar_test.rb
@@ -316,4 +389,3 @@ test_files:
316
389
  - test/unit/repository_test.rb
317
390
  - test/unit/server_test.rb
318
391
  - test/unit/svn_configuration_test.rb
319
- has_rdoc: