build-tool 0.5.7 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/.yardopts +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +56 -0
- data/History.txt +64 -0
- data/README.txt +0 -7
- data/Rakefile +8 -56
- data/bin/build-tool +4 -1
- data/build-tool.gemspec +62 -0
- data/db/migrations/20110703074000_add_command_logs.rb +17 -0
- data/db/migrations/20110703075000_add_module_logs.rb +20 -0
- data/db/migrations/20110815170000_add_features.rb +17 -0
- data/db/migrations/20120103204700_add_modules.rb +17 -0
- data/db/migrations/20120106181200_add_settings.rb +18 -0
- data/lib/build-tool.rb +3 -4
- data/lib/build-tool/application.rb +127 -37
- data/lib/build-tool/build-system/autoconf.rb +2 -8
- data/lib/build-tool/build-system/base.rb +12 -4
- data/lib/build-tool/build-system/cmake.rb +2 -0
- data/lib/build-tool/build-system/custom.rb +2 -0
- data/lib/build-tool/build-system/kdel10n.rb +2 -0
- data/lib/build-tool/build-system/make.rb +2 -0
- data/lib/build-tool/build-system/none.rb +2 -0
- data/lib/build-tool/build-system/qmake.rb +2 -0
- data/lib/build-tool/build-system/qt.rb +4 -0
- data/lib/build-tool/cfg/lexer.rex +40 -8
- data/lib/build-tool/cfg/lexer_base.rb +3 -1
- data/lib/build-tool/cfg/node.rb +17 -1
- data/lib/build-tool/cfg/parser.y +92 -10
- data/lib/build-tool/cfg/visitor.rb +202 -78
- data/lib/build-tool/command_actions.rb +26 -10
- data/lib/build-tool/commands.rb +289 -197
- data/lib/build-tool/commands/build.rb +13 -9
- data/lib/build-tool/commands/configuration.rb +25 -0
- data/lib/build-tool/commands/configuration/edit.rb +42 -0
- data/lib/build-tool/commands/configuration/list.rb +48 -0
- data/lib/build-tool/commands/configure.rb +9 -5
- data/lib/build-tool/commands/ctags.rb +8 -3
- data/lib/build-tool/commands/environments.rb +2 -4
- data/lib/build-tool/commands/environments/list.rb +13 -10
- data/lib/build-tool/commands/environments/set.rb +5 -1
- data/lib/build-tool/commands/features.rb +24 -0
- data/lib/build-tool/commands/features/disable.rb +70 -0
- data/lib/build-tool/commands/features/enable.rb +66 -0
- data/lib/build-tool/commands/features/list.rb +92 -0
- data/lib/build-tool/commands/fetch.rb +9 -3
- data/lib/build-tool/commands/files.rb +9 -5
- data/lib/build-tool/commands/gc.rb +48 -15
- data/lib/build-tool/commands/history.rb +21 -16
- data/lib/build-tool/commands/info.rb +16 -13
- data/lib/build-tool/commands/install.rb +8 -4
- data/lib/build-tool/commands/modules.rb +2 -4
- data/lib/build-tool/commands/modules/cleanup.rb +52 -0
- data/lib/build-tool/commands/modules/disable.rb +95 -0
- data/lib/build-tool/commands/modules/enable.rb +52 -0
- data/lib/build-tool/commands/modules/info.rb +44 -35
- data/lib/build-tool/commands/modules/list.rb +67 -15
- data/lib/build-tool/commands/modules/shell.rb +8 -2
- data/lib/build-tool/commands/rebase.rb +15 -7
- data/lib/build-tool/commands/recipes.rb +2 -4
- data/lib/build-tool/commands/recipes/add.rb +16 -2
- data/lib/build-tool/commands/recipes/edit.rb +72 -0
- data/lib/build-tool/commands/recipes/incoming.rb +11 -7
- data/lib/build-tool/commands/recipes/info.rb +12 -8
- data/lib/build-tool/commands/recipes/install.rb +37 -42
- data/lib/build-tool/commands/recipes/list.rb +6 -2
- data/lib/build-tool/configuration.rb +88 -3
- data/lib/build-tool/environment.rb +2 -0
- data/lib/build-tool/errors.rb +5 -0
- data/lib/build-tool/history.rb +3 -181
- data/lib/build-tool/model/command_log.rb +93 -0
- data/lib/build-tool/model/feature.rb +80 -0
- data/lib/build-tool/{module.rb → model/module.rb} +110 -29
- data/lib/build-tool/model/module_log.rb +64 -0
- data/lib/build-tool/model/setting.rb +84 -0
- data/lib/build-tool/recipe.rb +40 -18
- data/lib/build-tool/repository.rb +39 -33
- data/lib/build-tool/server.rb +27 -3
- data/lib/build-tool/singleton.rb +2 -0
- data/lib/build-tool/sshkey.rb +2 -0
- data/lib/build-tool/state_helper.rb +64 -0
- data/lib/build-tool/vcs/archive.rb +3 -1
- data/lib/build-tool/vcs/base.rb +13 -0
- data/lib/build-tool/vcs/git-svn.rb +36 -14
- data/lib/build-tool/vcs/git.rb +180 -44
- data/lib/build-tool/vcs/mercurial.rb +25 -13
- data/lib/build-tool/vcs/svn.rb +20 -15
- data/lib/build-tool/version.rb +30 -0
- data/lib/mj/error.rb +2 -0
- data/lib/mj/logging.rb +2 -0
- data/lib/mj/mixins/inherited_attributes.rb +73 -0
- data/lib/mj/tools/editor.rb +34 -0
- data/lib/mj/tools/ssh.rb +2 -0
- data/lib/mj/tools/subprocess.rb +2 -1
- data/lib/mj/vcs/git.rb +14 -2
- data/lib/mj/visitor.rb +22 -0
- data/tasks/db.rake +36 -0
- data/tasks/racc.rake +14 -0
- data/tasks/rdoc.rake +8 -0
- data/tasks/rexical.rake +14 -0
- data/tasks/test.rake +21 -0
- data/test/integration/history_test.rb +88 -0
- data/test/integration/parser_configuration.rb +36 -0
- data/test/integration/parser_environment_parser.rb +156 -0
- data/test/integration/parser_feature_test.rb +75 -0
- data/test/integration/parser_git-svn_test.rb +92 -0
- data/test/integration/parser_git_test.rb +97 -0
- data/test/integration/parser_mercurial_test.rb +77 -0
- data/test/integration/parser_module_test.rb +103 -0
- data/test/integration/parser_svn_test.rb +92 -0
- data/test/integration/parser_test.rb +73 -0
- data/test/test_helper.rb +61 -0
- data/test/unit/configuration_test.rb +36 -0
- data/test/unit/git_configuration_test.rb +163 -0
- data/test/unit/git_svn_configuration_test.rb +240 -0
- data/test/unit/mercurial_configuration_test.rb +64 -0
- data/test/unit/model/command_log_test.rb +103 -0
- data/test/unit/model/feature_test.rb +29 -0
- data/test/unit/model/module_log_test.rb +70 -0
- data/test/unit/model/module_test.rb +32 -0
- data/test/unit/repository_test.rb +110 -0
- data/test/unit/server_test.rb +66 -0
- data/test/unit/svn_configuration_test.rb +90 -0
- metadata +134 -93
- data/Manifest.txt +0 -80
- data/db/migrations/001_command_histories.rb +0 -20
- data/db/migrations/002_module_events.rb +0 -24
- data/db/migrations/003_command_histories_add_logfile.rb +0 -19
- data/lib/build-tool/GUI.rb +0 -360
- data/lib/build-tool/commands/help.rb +0 -22
- data/lib/build-tool/commands/lsfeatures.rb +0 -76
- data/lib/build-tool/feature.rb +0 -47
data/.gitignore
CHANGED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.3-p0@0.6-dev
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--charset=utf-8
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
build-tool (0.6)
|
5
|
+
activerecord (>= 3.2.1)
|
6
|
+
ansi (>= 1.4.2)
|
7
|
+
grit (>= 2.4.1)
|
8
|
+
logging (>= 1.6.0)
|
9
|
+
sqlite3 (>= 1.3.5)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activemodel (3.2.1)
|
15
|
+
activesupport (= 3.2.1)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
activerecord (3.2.1)
|
18
|
+
activemodel (= 3.2.1)
|
19
|
+
activesupport (= 3.2.1)
|
20
|
+
arel (~> 3.0.0)
|
21
|
+
tzinfo (~> 0.3.29)
|
22
|
+
activesupport (3.2.1)
|
23
|
+
i18n (~> 0.6)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
ansi (1.4.2)
|
26
|
+
arel (3.0.0)
|
27
|
+
builder (3.0.0)
|
28
|
+
diff-lcs (1.1.3)
|
29
|
+
grit (2.4.1)
|
30
|
+
diff-lcs (~> 1.1)
|
31
|
+
mime-types (~> 1.15)
|
32
|
+
i18n (0.6.0)
|
33
|
+
little-plugger (1.1.3)
|
34
|
+
logging (1.7.0)
|
35
|
+
little-plugger (>= 1.1.3)
|
36
|
+
mime-types (1.17.2)
|
37
|
+
multi_json (1.1.0)
|
38
|
+
racc (1.4.7)
|
39
|
+
rake (0.9.2.2)
|
40
|
+
rexical (1.0.5)
|
41
|
+
sqlite3 (1.3.5)
|
42
|
+
turn (0.9.3)
|
43
|
+
ansi
|
44
|
+
tzinfo (0.3.31)
|
45
|
+
yard (0.7.5)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
build-tool!
|
52
|
+
racc (>= 1.4.7)
|
53
|
+
rake (>= 0.9.2)
|
54
|
+
rexical (>= 1.0.5)
|
55
|
+
turn (>= 0.9)
|
56
|
+
yard (>= 0.7.5)
|
data/History.txt
CHANGED
@@ -1,3 +1,67 @@
|
|
1
|
+
== 0.6.0 ==
|
2
|
+
|
3
|
+
- Features
|
4
|
+
- Add --ionice and --nice N options to set IO (idle) and CPU Priority.
|
5
|
+
> kde-build --ionice --nice 19 build ....
|
6
|
+
- When updating the source show the newly applied commits if -v is specified.
|
7
|
+
They will allways end up in the rebase logfile.
|
8
|
+
- Make it possible to specify all modules at once.
|
9
|
+
kde-build fetch :all
|
10
|
+
- New command 'recipe edit'
|
11
|
+
- Opens the recipe override file in a editor.
|
12
|
+
- --global will open the recipe itself.
|
13
|
+
- --browser will open a file browser instead.
|
14
|
+
- New command 'module cleanup'
|
15
|
+
- Can remove the src and build dir of a module. Handle with care.
|
16
|
+
- The enabled/disabled state of features has been moved to the database.
|
17
|
+
- On the first start the current state will be migrated to the database.
|
18
|
+
AFTER that remove all 'feature enable|disable' lines from the override
|
19
|
+
file.
|
20
|
+
- command 'feature enable FEATURE' enables a feature.
|
21
|
+
- command 'feature disable FEATURE' disables a feature.
|
22
|
+
- The enabled/disabled state of modules has been moved to the database.
|
23
|
+
- On the first start the current state will be migrated to the database.
|
24
|
+
AFTER that remove all 'modules enable|disable' lines from the override
|
25
|
+
file.
|
26
|
+
- command 'module enable MODULE' enables a module.
|
27
|
+
- command 'module disable MODULE' disables a module and has options to
|
28
|
+
remove src and bld directory in one step.
|
29
|
+
- The 'recipe fetch incoming' command now works against a branch that has the
|
30
|
+
build-tool version encoded. This makes it possible to make a recipe that is
|
31
|
+
compatible to more than one version.
|
32
|
+
- The configuration values have been moved into the command line. A migration
|
33
|
+
will be done automatically on first run.
|
34
|
+
- 'configuration list' Will show the configuration values.
|
35
|
+
- 'configuration edit' will edit them.
|
36
|
+
|
37
|
+
|
38
|
+
- Enhancements
|
39
|
+
- Most of the --help texts have been improved dramatically.
|
40
|
+
- Unit testing was reenabled again.
|
41
|
+
- Command: lsmod
|
42
|
+
- Sort output alphabetically by default
|
43
|
+
- With --broken only shows modules that failed.
|
44
|
+
- With --no-sort shows modules in order of declaration / build order.
|
45
|
+
- With --all shows disabled modules too.
|
46
|
+
- With --disabled shows only disabled modules.
|
47
|
+
- Command lsfeat
|
48
|
+
- Looks much more similar to the module list output.
|
49
|
+
- Shows only active features by default.
|
50
|
+
- With --all shows all features.
|
51
|
+
- The long description statement now accepts multiline string with """....""".
|
52
|
+
- Command: gc
|
53
|
+
- Cleanup the logfiles more thoroughly.
|
54
|
+
- Disabled modules are accepted when given explicit on the command line if
|
55
|
+
they are associated with a active feature. This makes it possible to build
|
56
|
+
disabled modules.
|
57
|
+
|
58
|
+
|
59
|
+
- Bugfixes
|
60
|
+
- Change current directory to $HOME on start. The current working directory
|
61
|
+
could be removed while the command runs.
|
62
|
+
|
63
|
+
|
64
|
+
|
1
65
|
== 0.5.7 ==
|
2
66
|
|
3
67
|
- Features
|
data/README.txt
CHANGED
@@ -46,13 +46,6 @@ Currently the following recipes are provided:
|
|
46
46
|
|
47
47
|
http://michael-jansen.biz/build-tool
|
48
48
|
|
49
|
-
== REQUIREMENTS:
|
50
|
-
|
51
|
-
* logging >= 1.4.3
|
52
|
-
* sequel >= 3.18.0
|
53
|
-
* sqlite3-ruby >= 1.3.1
|
54
|
-
* ansi >= 1.2.2
|
55
|
-
|
56
49
|
== INSTALL:
|
57
50
|
|
58
51
|
gem install build-tool
|
data/Rakefile
CHANGED
@@ -1,61 +1,13 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
require '
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'psych'
|
7
|
-
rescue ::LoadError
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'hoe'
|
11
|
-
require 'fileutils'
|
12
|
-
require './lib/build-tool'
|
13
|
-
|
14
|
-
Hoe.plugin :git
|
15
|
-
Hoe.plugin :doofus
|
16
|
-
Hoe.plugin :debugging
|
17
|
-
Hoe.plugin :racc
|
18
|
-
|
19
|
-
|
20
|
-
# Generate all the Rake tasks
|
21
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
22
|
-
Hoe.spec( 'build-tool' ) do
|
23
|
-
|
24
|
-
self.developer 'Michael Jansen', 'info@michael-jansen.biz'
|
25
|
-
|
26
|
-
self.version = BuildTool::VERSION
|
27
|
-
|
28
|
-
self.post_install_message = <<-EOS
|
29
|
-
To start with build-tool try the following commands:
|
30
|
-
> build-tool recipe add git://gitorious.org/build-tool/kde-trunk-recipe.git kde
|
31
|
-
> build-tool recipe list
|
32
|
-
> build-tool recipe install kde
|
33
|
-
|
34
|
-
For documentation see http://michael-jansen.biz/build-tool
|
35
|
-
|
36
|
-
EOS
|
37
|
-
self.rubyforge_name = self.name
|
38
|
-
|
39
|
-
self.extra_deps <<
|
40
|
-
['logging', ">= 1.4.3"] <<
|
41
|
-
['sequel', ">= 3.18.0"] <<
|
42
|
-
['sqlite3', ">= 1.3.3" ] <<
|
43
|
-
['ansi', '>= 1.2.2' ] <<
|
44
|
-
['grit', ">= 2.4.1" ]
|
45
|
-
|
46
|
-
self.extra_dev_deps <<
|
47
|
-
['hoe-debugging', ">= 1.0.1"] <<
|
48
|
-
['hoe-doofus', ">= 1.0.0"] <<
|
49
|
-
['hoe-git', ">= 1.3.0"] <<
|
50
|
-
['racc', ">= 1.4.6"] <<
|
51
|
-
['rexical', ">= 1.0.5"]
|
52
|
-
|
53
|
-
self.rex_flags = ""
|
4
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
54
5
|
|
6
|
+
# A task to build all generated files.
|
7
|
+
namespace :bt do
|
8
|
+
desc "Generate all needed files"
|
9
|
+
task :genall => [ :rexical, :racc ]
|
55
10
|
end
|
56
11
|
|
57
|
-
|
58
|
-
|
59
|
-
# Want other tests/tasks run by default
|
60
|
-
# remove_task :default
|
61
|
-
# task :default => [:spec, :features]
|
12
|
+
# Make sure all files are generated when building the pkg
|
13
|
+
task :build => 'bt:genall'
|
data/bin/build-tool
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
2
3
|
#
|
3
4
|
# Created by Michael Jansen on 2009-8-31.
|
4
5
|
# Copyright (c) 2009. All rights reserved.
|
5
6
|
|
7
|
+
# BEGIN { $VERBOSE = true }
|
8
|
+
|
6
9
|
require 'pathname'
|
7
10
|
require 'rubygems'
|
8
11
|
|
9
12
|
# libs relative to the link target
|
10
13
|
root_directory = Pathname.new(__FILE__).realpath.dirname.dirname
|
11
14
|
|
12
|
-
require root_directory.join( 'lib/build-tool')
|
15
|
+
require root_directory.join( 'lib/build-tool').to_s
|
13
16
|
require 'build-tool/application'
|
14
17
|
|
15
18
|
exit BuildTool.main( $0, ARGV, root_directory );
|
data/build-tool.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'build-tool/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'build-tool'
|
7
|
+
s.version = BuildTool::VERSION
|
8
|
+
s.authors = ['Michael Jansen']
|
9
|
+
s.email = ['info@michael-jansen.biz']
|
10
|
+
s.homepage = 'http://michael-jansen.biz'
|
11
|
+
s.summary = %q{A tool helping to download, configure and compile from sources.}
|
12
|
+
s.description = %q{
|
13
|
+
The tool helps
|
14
|
+
|
15
|
+
...
|
16
|
+
}
|
17
|
+
|
18
|
+
s.license = 'GPL-V2+'
|
19
|
+
|
20
|
+
# It only works with ruby 1.9
|
21
|
+
s.required_ruby_version = '>= 1.9.2'
|
22
|
+
|
23
|
+
# Additional requirements (verbose)
|
24
|
+
# s.requirements << ''
|
25
|
+
|
26
|
+
# Documentation
|
27
|
+
s.rubyforge_project = 'build-tool'
|
28
|
+
s.extra_rdoc_files = [ 'README.txt' ]
|
29
|
+
|
30
|
+
# Dependencies
|
31
|
+
s.add_dependency( 'logging', '>= 1.6.0' ) # Logging Support
|
32
|
+
s.add_dependency( 'activerecord', '>= 3.2.1' ) # Object Relation Model
|
33
|
+
s.add_dependency( 'sqlite3', '>= 1.3.5' ) # SQLite Database Support
|
34
|
+
s.add_dependency( 'ansi', '>= 1.4.2' ) # ANSI Codes at your Fingertips
|
35
|
+
s.add_dependency( 'grit', '>= 2.4.1' ) # Git Support
|
36
|
+
|
37
|
+
# Development Dependencies
|
38
|
+
s.add_development_dependency( 'racc', '>= 1.4.7' ) # A LALR(1) parser generator.
|
39
|
+
s.add_development_dependency( 'rexical', '>= 1.0.5') # A lexical scanner generator
|
40
|
+
s.add_development_dependency( 'rake', '>= 0.9.2' )
|
41
|
+
s.add_development_dependency( 'yard', '>= 0.7.5' )
|
42
|
+
s.add_development_dependency( 'turn', '>= 0.9' ) # Pretty test output
|
43
|
+
|
44
|
+
# Post installation message
|
45
|
+
s.post_install_message = <<-EOF
|
46
|
+
Thank you for using build-tool. For documentation see http://michael-jansen.biz/build-tool .
|
47
|
+
Report bugs to kde (at) michael-jansen.biz.
|
48
|
+
|
49
|
+
To start with build-tool try the following commands:
|
50
|
+
> build-tool recipe add git://gitorious.org/build-tool/kde-trunk-recipe.git kde
|
51
|
+
> build-tool recipe list
|
52
|
+
> build-tool recipe install kde
|
53
|
+
|
54
|
+
EOF
|
55
|
+
|
56
|
+
s.files = `git ls-files`.split("\n")
|
57
|
+
s.files += Dir.glob( 'lib/**/*.y' ).map { |p| p.sub( /.y$/, '.rb' ) }
|
58
|
+
s.files += Dir.glob( 'lib/**/*.rex' ).map { |p| p.sub( /.rex$/, '.rb' ) }
|
59
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
60
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
61
|
+
s.require_paths = ['lib']
|
62
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AddCommandLogs < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :command_logs do |t|
|
5
|
+
t.string :command, :null => false
|
6
|
+
t.string :logdir
|
7
|
+
t.datetime :started_at
|
8
|
+
t.datetime :finished_at
|
9
|
+
t.integer :state, :default => 0, :null => false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
drop_table :command_logs
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class AddModuleLogs < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :module_logs do |t|
|
5
|
+
t.integer :command_log_id, :null => false
|
6
|
+
t.string :module, :null => false
|
7
|
+
t.string :event, :size => 20, :null => false
|
8
|
+
t.string :logfile
|
9
|
+
t.datetime :started_at
|
10
|
+
t.datetime :finished_at
|
11
|
+
t.integer :state, :default => 0, :null => false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
drop_table :module_events
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AddFeatures < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :features do |t|
|
5
|
+
t.string :name, :null => false
|
6
|
+
t.integer :parent_id
|
7
|
+
t.boolean :active, :default => nil
|
8
|
+
end
|
9
|
+
add_index :features, [ :parent_id, :name ], :unique => true
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
remove_index :features, [ :parent_id, :name ]
|
14
|
+
drop_table :features
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AddModules < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :modules do |t|
|
5
|
+
t.string :name, :null => false
|
6
|
+
t.boolean :active, :default => nil
|
7
|
+
end
|
8
|
+
add_index :modules, [ :name ], :unique => true
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
remove_index :modules, [ :name ]
|
13
|
+
drop_table :modules
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class AddSettings < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
create_table :settings do |t|
|
5
|
+
t.string :name, :null => false
|
6
|
+
t.string :value
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :settings, :name
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
remove_index :settings, :name
|
14
|
+
drop_table :settings
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
data/lib/build-tool.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
1
2
|
|
2
3
|
require 'logging'
|
3
|
-
Logging.init :debug, :trace, :verbose, :info, :warn, :error
|
4
|
+
Logging.init :debug2, :debug, :trace, :verbose, :info, :warn, :error
|
4
5
|
include Logging.globally
|
5
6
|
|
6
7
|
require 'optparse'
|
7
8
|
require 'erb'
|
8
9
|
require 'yaml'
|
9
|
-
require 'sequel'
|
10
|
-
require 'sequel/extensions/migration'
|
11
10
|
|
12
11
|
require 'mj/logging'
|
13
12
|
|
14
13
|
require "build-tool/errors"
|
15
|
-
require 'build-tool/recipe'
|
16
14
|
require 'build-tool/singleton'
|
17
|
-
|
15
|
+
|
16
|
+
require 'active_record'
|
17
|
+
require 'sqlite3'
|
18
18
|
|
19
19
|
$noop = false
|
20
20
|
|
@@ -34,9 +34,8 @@ class Application < Singleton
|
|
34
34
|
attr_reader :name
|
35
35
|
|
36
36
|
def recipe
|
37
|
-
return @recipe if @
|
38
|
-
configuration
|
39
|
-
@recipe
|
37
|
+
return @configuration.recipe if @configuration
|
38
|
+
configuration.recipe
|
40
39
|
end
|
41
40
|
|
42
41
|
def initialize( name, application_root )
|
@@ -44,22 +43,107 @@ def initialize( name, application_root )
|
|
44
43
|
@application_root = Pathname.new( application_root ).expand_path
|
45
44
|
@database = nil
|
46
45
|
@name = File.basename( name ).sub( "-build", "" )
|
47
|
-
@recipe = nil
|
48
46
|
@local_settings_file_path = local_configuration_dir.join("#{@name}.yaml")
|
49
47
|
end
|
50
48
|
|
49
|
+
# Execute necessary migration steps
|
50
|
+
def migrate()
|
51
|
+
|
52
|
+
logger.debug( 'Checking for obsolete modules in db.' )
|
53
|
+
for mod in @configuration.modules do
|
54
|
+
if not mod.found_in_recipe
|
55
|
+
logger.info 'Module %s no longer supported by recipe. Removing it from db.' % [ mod.name ]
|
56
|
+
mod.destroy()
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
logger.debug( 'Checking for obsolete settings in db.' )
|
61
|
+
@configuration.settings.each do |n, s|
|
62
|
+
if not s.seen and not n.start_with? 'BUILD_TOOL.'
|
63
|
+
logger.info 'Setting %s no longer supported by recipe. Removing it from db.' % [ s.name ]
|
64
|
+
s.destroy()
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
51
70
|
# Load the configuration
|
52
71
|
def configuration
|
53
72
|
return @configuration if @configuration
|
54
|
-
|
73
|
+
|
74
|
+
require 'build-tool/configuration'
|
75
|
+
require 'build-tool/recipe'
|
76
|
+
|
77
|
+
# Read the configuration from the database
|
78
|
+
@configuration = Configuration.new()
|
79
|
+
@configuration.load()
|
80
|
+
|
81
|
+
#
|
82
|
+
### MIGRATION FROM 0.5 START
|
83
|
+
#
|
84
|
+
# First load the old settings file if it exists. For new style the settings are
|
85
|
+
# correctly loaded from the database already.
|
55
86
|
file = local_settings_file_path
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
87
|
+
if file.exist?
|
88
|
+
logger.info "Loading old style settings file #{file}."
|
89
|
+
YAML.load( File.open( file, 'r:UTF-8' ) ).each do |n, v|
|
90
|
+
case n
|
91
|
+
when 'RECIPE'
|
92
|
+
n = "BUILD_TOOL.RECIPE"
|
93
|
+
logger.debug( " %s='%s'" % [ n, v ] )
|
94
|
+
s = ( @configuration.settings[ n ] or Setting.new( :name => n ) )
|
95
|
+
s.value = v
|
96
|
+
@configuration.add_setting( s )
|
97
|
+
when 'SETTINGS'
|
98
|
+
v.each do |n, v|
|
99
|
+
logger.debug( " %s='%s'" % [ n, v ] )
|
100
|
+
s = ( @configuration.settings[ n ] or Setting.new( :name => n ) )
|
101
|
+
s.value = v
|
102
|
+
@configuration.add_setting( s )
|
103
|
+
end
|
104
|
+
else
|
105
|
+
logger.warn( 'Unknown setting %s found in %s' % [ n, file ] )
|
106
|
+
end
|
107
|
+
end
|
108
|
+
@configuration.save()
|
109
|
+
# Now rename the old file.
|
110
|
+
file.rename( file.to_s + '_0.5' )
|
111
|
+
logger.info( "Renamed old style settings file to #{file}_0.5. Please delete later!" )
|
112
|
+
end
|
113
|
+
#
|
114
|
+
### MIGRATION FROM 0.5 END
|
115
|
+
#
|
116
|
+
|
117
|
+
|
118
|
+
# Find the recipe. Will throw an exception if recipe is invalid.
|
119
|
+
recipe = BuildTool::Recipe.new( @configuration.settings['BUILD_TOOL.RECIPE'].value )
|
120
|
+
logger.debug( 'Determined associated recipe as %s ( %s )' % [ recipe.name, recipe.global_path ] )
|
121
|
+
@configuration.recipe = recipe
|
122
|
+
|
123
|
+
# Initialize the settings from the settings.yaml file from the recipe
|
124
|
+
logger.debug( 'Loading configuration values from recipe:settings.yaml' )
|
125
|
+
YAML.load( File.open( recipe.global_config_file_path( 'settings.yaml' ), 'r:UTF-8' ) ).each do |v|
|
126
|
+
name = v['name']
|
127
|
+
logger.debug2( ' - Setting %s' % name )
|
128
|
+
s = ( @configuration.settings[ name ] or Setting.new( :name => name ) )
|
129
|
+
s.description = v['description']
|
130
|
+
s.default = v['default']
|
131
|
+
s.seen = true
|
132
|
+
@configuration.add_setting( s )
|
133
|
+
end
|
134
|
+
|
135
|
+
# Load the recipe
|
136
|
+
logger.debug( 'Loading recipe %s' % recipe.name )
|
137
|
+
@configuration = recipe.load( name, @configuration )
|
138
|
+
|
139
|
+
# Save possible changes to the configuration.
|
140
|
+
@configuration.save
|
141
|
+
|
142
|
+
# Migrate the recipe (if necessary)
|
143
|
+
migrate()
|
144
|
+
|
145
|
+
# Finished.
|
146
|
+
@configuration
|
63
147
|
end
|
64
148
|
|
65
149
|
# Return the local configuration dir. Makes sure the directory exists
|
@@ -76,18 +160,19 @@ def local_configuration_dir
|
|
76
160
|
# Open the database
|
77
161
|
#
|
78
162
|
# @return [Object] The database handle
|
79
|
-
def open_database
|
163
|
+
def open_database( name )
|
80
164
|
path = local_configuration_dir.join( "#{name}.db" )
|
81
165
|
logger.debug "Opening the database #{path}."
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
166
|
+
ActiveRecord::Base.establish_connection(
|
167
|
+
:adapter => 'sqlite3',
|
168
|
+
:database => path.to_s )
|
169
|
+
ActiveRecord::Migrator.migrate(
|
170
|
+
[ application_root.join( 'db/migrations' ) ] )
|
86
171
|
end
|
87
172
|
|
88
173
|
# Close the database
|
89
174
|
def close_database
|
90
|
-
|
175
|
+
ActiveRecord::Base.remove_connection()
|
91
176
|
path = local_configuration_dir.join( "#{name}.db" )
|
92
177
|
logger.debug "Closing the database #{path}."
|
93
178
|
end
|
@@ -102,7 +187,7 @@ def main( args )
|
|
102
187
|
# don't need a configuration. Help for example.
|
103
188
|
|
104
189
|
# Initialize the database.
|
105
|
-
open_database()
|
190
|
+
open_database( name )
|
106
191
|
|
107
192
|
begin
|
108
193
|
|
@@ -110,14 +195,9 @@ def main( args )
|
|
110
195
|
require 'build-tool/commands'
|
111
196
|
@cli = Commands::Shell.new
|
112
197
|
|
113
|
-
# Load the commands. This has to be done AFTER the database is opened because
|
114
|
-
# sequel expects that there is a database before a Sequel::Model is created.
|
115
|
-
#
|
116
|
-
# And the commands require all that database related stuff.
|
117
|
-
@cli.load_commands( @application_root.join( "lib/build-tool/commands" ), BuildTool::Commands )
|
118
|
-
|
119
198
|
# Execute the given command (or start the cli)
|
120
199
|
@cli.execute( args )
|
200
|
+
|
121
201
|
ensure
|
122
202
|
# Make sure the database is closed correctly
|
123
203
|
close_database
|
@@ -135,15 +215,24 @@ def has_recipe?
|
|
135
215
|
|
136
216
|
def BuildTool.main(name, args, root_directory)
|
137
217
|
|
218
|
+
Dir.chdir( ENV["HOME"] )
|
219
|
+
|
138
220
|
begin
|
139
221
|
# Setup logging
|
140
|
-
Logging.logger.root.level = :
|
222
|
+
Logging.logger.root.level = :debug2
|
223
|
+
|
141
224
|
# Special case for the configurationParser. It is very verbose if active.
|
142
225
|
Logging.logger['BuildTool::Cfg::Parser'].level = :info
|
143
|
-
|
144
|
-
|
226
|
+
|
227
|
+
# Same goes for the activerecord logger, :info shows migrations
|
228
|
+
Logging.logger['ActiveRecord'].level = :warn
|
229
|
+
ActiveRecord::Base.logger = ::Logging::Logger['ActiveRecord']
|
230
|
+
|
231
|
+
# By default write only :info messages to stdout
|
232
|
+
Logging.logger['root'].add_appenders( Logging.appenders.stdout(
|
145
233
|
:layout => MJ::Logging::BasicLayout.new(),
|
146
|
-
:level => :info)
|
234
|
+
:level => :info) )
|
235
|
+
|
147
236
|
# Create the application
|
148
237
|
app = BuildTool::Application.new( name, root_directory )
|
149
238
|
# Execute the application
|
@@ -152,11 +241,12 @@ def BuildTool.main(name, args, root_directory)
|
|
152
241
|
logger.info "User interrupt!"
|
153
242
|
return 0
|
154
243
|
rescue BuildTool::Error => e
|
155
|
-
logger.error
|
156
|
-
logger.verbose e.backtrace.join("\n")
|
244
|
+
logger.error( e.message )
|
245
|
+
logger.verbose( e.backtrace.join("\n") )
|
157
246
|
return -1
|
158
247
|
rescue Exception => e
|
159
|
-
logger.error e
|
248
|
+
logger.error( e )
|
249
|
+
logger.verbose( e.backtrace.join("\n") )
|
160
250
|
return -1
|
161
251
|
end
|
162
252
|
|