build-tool 0.1.4 → 0.2
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.tar.gz.sig +2 -3
- data/History.txt +29 -0
- data/Manifest.txt +39 -10
- data/README.txt +5 -8
- data/Rakefile +14 -6
- data/bin/build-tool +3 -35
- data/db/migrations/001_command_histories.rb +20 -0
- data/db/migrations/002_module_events.rb +24 -0
- data/db/migrations/003_command_histories_add_logfile.rb +19 -0
- data/lib/build-tool.rb +1 -1
- data/lib/build-tool/application.rb +103 -30
- data/lib/build-tool/build-system/autoconf.rb +69 -6
- data/lib/build-tool/build-system/base.rb +2 -25
- data/lib/build-tool/build-system/custom.rb +6 -19
- data/lib/build-tool/build-system/kdel10n.rb +39 -0
- data/lib/build-tool/build-system/none.rb +82 -0
- data/lib/build-tool/cfg/lexer.rb +133 -7
- data/lib/build-tool/cfg/lexer.rex +58 -6
- data/lib/build-tool/cfg/node.rb +13 -1
- data/lib/build-tool/cfg/parser.rb +519 -333
- data/lib/build-tool/cfg/parser.y +74 -11
- data/lib/build-tool/cfg/visitor.rb +182 -20
- data/lib/build-tool/command_actions.rb +202 -0
- data/lib/build-tool/commands.rb +193 -49
- data/lib/build-tool/commands/build.rb +13 -8
- data/lib/build-tool/commands/configure.rb +8 -3
- data/lib/build-tool/commands/environments.rb +4 -8
- data/lib/build-tool/commands/environments/list.rb +8 -0
- data/lib/build-tool/commands/fetch.rb +7 -2
- data/lib/build-tool/commands/gc.rb +53 -0
- data/lib/build-tool/commands/history.rb +111 -0
- data/lib/build-tool/commands/install.rb +6 -1
- data/lib/build-tool/commands/lsfeatures.rb +73 -0
- data/lib/build-tool/commands/modules.rb +3 -7
- data/lib/build-tool/commands/modules/info.rb +15 -6
- data/lib/build-tool/commands/modules/list.rb +10 -5
- data/lib/build-tool/commands/rebase.rb +6 -1
- data/lib/build-tool/commands/recipes.rb +3 -7
- data/lib/build-tool/configuration.rb +24 -1
- data/lib/build-tool/environment.rb +17 -3
- data/lib/build-tool/feature.rb +47 -0
- data/lib/build-tool/history.rb +173 -0
- data/lib/build-tool/module.rb +49 -90
- data/lib/build-tool/recipe.rb +5 -0
- data/lib/build-tool/vcs/archive.rb +140 -0
- data/lib/build-tool/vcs/base.rb +5 -5
- data/lib/build-tool/vcs/git-svn.rb +4 -0
- data/lib/build-tool/vcs/git.rb +4 -0
- data/lib/mj/logging.rb +11 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/compile.sh +0 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/configure.sh +0 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/install.sh +0 -0
- data/recipes/kde/custom/scripting/pyqt4/compile.sh +10 -0
- data/recipes/kde/custom/scripting/pyqt4/configure.sh +14 -0
- data/recipes/kde/custom/scripting/pyqt4/install.sh +10 -0
- data/recipes/kde/custom/scripting/sip/compile.sh +10 -0
- data/recipes/kde/custom/scripting/sip/configure.sh +13 -0
- data/recipes/kde/custom/scripting/sip/install.sh +10 -0
- data/recipes/kde/files/xsession +8 -4
- data/recipes/kde/kde-bindings.recipe +22 -0
- data/recipes/kde/kde-core.recipe +104 -0
- data/recipes/kde/kde-devel.recipe +38 -0
- data/recipes/kde/kde-finance.recipe +17 -0
- data/recipes/kde/kde-graphics.recipe +27 -0
- data/recipes/kde/kde-kdevelop.recipe +116 -0
- data/recipes/kde/kde-l10n.recipe +14 -0
- data/recipes/kde/kde-multimedia.recipe +31 -0
- data/recipes/kde/kde-network.recipe +55 -0
- data/recipes/kde/kde-office.recipe +28 -0
- data/recipes/kde/kde-plasma.recipe +117 -0
- data/recipes/{kdeqt4.6/recipe → kde/kde-qt.recipe} +25 -57
- data/recipes/kde/kde-scripting.recipe +63 -0
- data/recipes/kde/kde-support.recipe +73 -0
- data/recipes/kde/kde-utils.recipe +22 -0
- data/recipes/kde/kde-webdev.recipe +41 -0
- data/recipes/kde/recipe +92 -532
- data/recipes/kde/recipe-local +58 -2
- data/recipes/kde/settings.yaml +17 -0
- data/recipes/kde43/recipe-local +58 -2
- data/test/test_configuration_parser.rb +76 -21
- data/test/test_feature.rb +34 -0
- data/test/test_history.rb +149 -0
- metadata +185 -30
- metadata.gz.sig +0 -0
- data/lib/build-tool/pluginbase.rb +0 -43
- data/recipes/kdeqt4.6/info.yaml +0 -7
- data/recipes/kdeqt4.6/recipe-local +0 -30
- data/recipes/kdeqt4.6/settings.yaml +0 -27
- data/tasks/rdoc.rake +0 -34
- data/test.rb +0 -28
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
夤m�~�9�xT:�q�1����=��/Z�M.?3ʽv��N�!�"�d�6����`�q�)X�8O`�n�f6
|
1
|
+
e�̾�Rگe�8���d*��qI�%)�0����9�s�^����[H����� �9n�������0��#�"<�.������Z�7������2c������w
|
2
|
+
�}��
|
data/History.txt
CHANGED
@@ -1,6 +1,35 @@
|
|
1
|
+
== 0.2
|
2
|
+
- Features
|
3
|
+
* Implement include directive.
|
4
|
+
* Implement feature directive.
|
5
|
+
* Group modules into features.
|
6
|
+
* Enable/Disable features.
|
7
|
+
* Implement "gc" command.
|
8
|
+
* execute "git gc" for all git repositories.
|
9
|
+
* Implement build-system "None".
|
10
|
+
* Implement vcs "archive".
|
11
|
+
- Download an archive.
|
12
|
+
- Unpack it.
|
13
|
+
* Add a database
|
14
|
+
- Keep record of executed commands and results
|
15
|
+
- Command "history" to query the commands.
|
16
|
+
- no argument -> show last 50 commands
|
17
|
+
- number -> show detailed info about that command
|
18
|
+
- +number -> show detailed info about number last command
|
19
|
+
+0 = last
|
20
|
+
+1 = next to last
|
21
|
+
...
|
22
|
+
- <module> -> show the last 3 commands affecting the module.
|
23
|
+
- Fixes
|
24
|
+
* Sort command listing on "help".
|
25
|
+
* Fixed autoconf support.
|
26
|
+
* Many changes to the kde recipe.
|
27
|
+
|
28
|
+
|
1
29
|
== 0.1.4 2009-12-10
|
2
30
|
* konversation moved to git
|
3
31
|
|
32
|
+
|
4
33
|
== 0.1.3 2009-11-28
|
5
34
|
* Add some links to the homepage with documentation
|
6
35
|
* kdevelop/kdevplatform moved to extragear for the kde recipe
|
data/Manifest.txt
CHANGED
@@ -3,6 +3,9 @@ Manifest.txt
|
|
3
3
|
README.txt
|
4
4
|
Rakefile
|
5
5
|
bin/build-tool
|
6
|
+
db/migrations/001_command_histories.rb
|
7
|
+
db/migrations/002_module_events.rb
|
8
|
+
db/migrations/003_command_histories_add_logfile.rb
|
6
9
|
lib/build-tool.rb
|
7
10
|
lib/build-tool/GUI.rb
|
8
11
|
lib/build-tool/application.rb
|
@@ -10,6 +13,8 @@ lib/build-tool/build-system/autoconf.rb
|
|
10
13
|
lib/build-tool/build-system/base.rb
|
11
14
|
lib/build-tool/build-system/cmake.rb
|
12
15
|
lib/build-tool/build-system/custom.rb
|
16
|
+
lib/build-tool/build-system/kdel10n.rb
|
17
|
+
lib/build-tool/build-system/none.rb
|
13
18
|
lib/build-tool/build-system/qt.rb
|
14
19
|
lib/build-tool/cfg/lexer.rb
|
15
20
|
lib/build-tool/cfg/lexer.rex
|
@@ -18,6 +23,7 @@ lib/build-tool/cfg/node.rb
|
|
18
23
|
lib/build-tool/cfg/parser.rb
|
19
24
|
lib/build-tool/cfg/parser.y
|
20
25
|
lib/build-tool/cfg/visitor.rb
|
26
|
+
lib/build-tool/command_actions.rb
|
21
27
|
lib/build-tool/commands.rb
|
22
28
|
lib/build-tool/commands/build.rb
|
23
29
|
lib/build-tool/commands/configure.rb
|
@@ -27,9 +33,12 @@ lib/build-tool/commands/environments/list.rb
|
|
27
33
|
lib/build-tool/commands/environments/set.rb
|
28
34
|
lib/build-tool/commands/fetch.rb
|
29
35
|
lib/build-tool/commands/files.rb
|
36
|
+
lib/build-tool/commands/gc.rb
|
30
37
|
lib/build-tool/commands/help.rb
|
38
|
+
lib/build-tool/commands/history.rb
|
31
39
|
lib/build-tool/commands/info.rb
|
32
40
|
lib/build-tool/commands/install.rb
|
41
|
+
lib/build-tool/commands/lsfeatures.rb
|
33
42
|
lib/build-tool/commands/modules.rb
|
34
43
|
lib/build-tool/commands/modules/info.rb
|
35
44
|
lib/build-tool/commands/modules/list.rb
|
@@ -42,13 +51,15 @@ lib/build-tool/commands/recipes/list.rb
|
|
42
51
|
lib/build-tool/configuration.rb
|
43
52
|
lib/build-tool/environment.rb
|
44
53
|
lib/build-tool/errors.rb
|
54
|
+
lib/build-tool/feature.rb
|
55
|
+
lib/build-tool/history.rb
|
45
56
|
lib/build-tool/module.rb
|
46
|
-
lib/build-tool/pluginbase.rb
|
47
57
|
lib/build-tool/recipe.rb
|
48
58
|
lib/build-tool/repository.rb
|
49
59
|
lib/build-tool/server.rb
|
50
60
|
lib/build-tool/singleton.rb
|
51
61
|
lib/build-tool/sshkey.rb
|
62
|
+
lib/build-tool/vcs/archive.rb
|
52
63
|
lib/build-tool/vcs/base.rb
|
53
64
|
lib/build-tool/vcs/git-svn.rb
|
54
65
|
lib/build-tool/vcs/git.rb
|
@@ -57,10 +68,35 @@ lib/mj/logging.rb
|
|
57
68
|
lib/mj/tools/ssh.rb
|
58
69
|
lib/mj/tools/subprocess.rb
|
59
70
|
lib/mj/visitor.rb
|
71
|
+
recipes/kde/custom/qt/qtscriptgenerator/compile.sh
|
72
|
+
recipes/kde/custom/qt/qtscriptgenerator/configure.sh
|
73
|
+
recipes/kde/custom/qt/qtscriptgenerator/install.sh
|
74
|
+
recipes/kde/custom/scripting/pyqt4/compile.sh
|
75
|
+
recipes/kde/custom/scripting/pyqt4/configure.sh
|
76
|
+
recipes/kde/custom/scripting/pyqt4/install.sh
|
77
|
+
recipes/kde/custom/scripting/sip/compile.sh
|
78
|
+
recipes/kde/custom/scripting/sip/configure.sh
|
79
|
+
recipes/kde/custom/scripting/sip/install.sh
|
60
80
|
recipes/kde/files/finish_installation.sh
|
61
81
|
recipes/kde/files/kde4.desktop
|
62
82
|
recipes/kde/files/xsession
|
63
83
|
recipes/kde/info.yaml
|
84
|
+
recipes/kde/kde-bindings.recipe
|
85
|
+
recipes/kde/kde-core.recipe
|
86
|
+
recipes/kde/kde-devel.recipe
|
87
|
+
recipes/kde/kde-finance.recipe
|
88
|
+
recipes/kde/kde-graphics.recipe
|
89
|
+
recipes/kde/kde-kdevelop.recipe
|
90
|
+
recipes/kde/kde-l10n.recipe
|
91
|
+
recipes/kde/kde-multimedia.recipe
|
92
|
+
recipes/kde/kde-network.recipe
|
93
|
+
recipes/kde/kde-office.recipe
|
94
|
+
recipes/kde/kde-plasma.recipe
|
95
|
+
recipes/kde/kde-qt.recipe
|
96
|
+
recipes/kde/kde-scripting.recipe
|
97
|
+
recipes/kde/kde-support.recipe
|
98
|
+
recipes/kde/kde-utils.recipe
|
99
|
+
recipes/kde/kde-webdev.recipe
|
64
100
|
recipes/kde/recipe
|
65
101
|
recipes/kde/recipe-local
|
66
102
|
recipes/kde/settings.yaml
|
@@ -68,24 +104,17 @@ recipes/kde43/info.yaml
|
|
68
104
|
recipes/kde43/recipe
|
69
105
|
recipes/kde43/recipe-local
|
70
106
|
recipes/kde43/settings.yaml
|
71
|
-
recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh
|
72
|
-
recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh
|
73
|
-
recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh
|
74
|
-
recipes/kdeqt4.6/info.yaml
|
75
|
-
recipes/kdeqt4.6/recipe
|
76
|
-
recipes/kdeqt4.6/recipe-local
|
77
|
-
recipes/kdeqt4.6/settings.yaml
|
78
107
|
tasks/genfiles.rake
|
79
|
-
tasks/rdoc.rake
|
80
108
|
tasks/rspec.rake
|
81
|
-
test.rb
|
82
109
|
test/commands/test_build.rb
|
83
110
|
test/test_build_system.rb
|
84
111
|
test/test_cli.rb
|
85
112
|
test/test_command.rb
|
86
113
|
test/test_configuration_parser.rb
|
87
114
|
test/test_environment.rb
|
115
|
+
test/test_feature.rb
|
88
116
|
test/test_helper.rb
|
117
|
+
test/test_history.rb
|
89
118
|
test/test_module.rb
|
90
119
|
test/test_repository.rb
|
91
120
|
test/test_singleton.rb
|
data/README.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= build-tool
|
2
2
|
|
3
|
-
* http://build-tool
|
3
|
+
* http://michael-jansen.biz/build-tool
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
@@ -11,8 +11,6 @@ and configures sources and updates them later.
|
|
11
11
|
|
12
12
|
== FEATURES/PROBLEMS:
|
13
13
|
|
14
|
-
* This is major rewrite version. Use at your own risk.
|
15
|
-
|
16
14
|
The tool uses recipes to build software from scratch. It does
|
17
15
|
- Check out the sources from the repository (git, git-svn, svn).
|
18
16
|
- Update the sources.
|
@@ -21,10 +19,10 @@ The tool uses recipes to build software from scratch. It does
|
|
21
19
|
- Build
|
22
20
|
- Install
|
23
21
|
|
24
|
-
It's main purpose is supporting me developing kde while having a
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
It's main purpose is supporting me in developing kde while having a complete
|
23
|
+
kde workspace from trunk. I would like to have reliable and reproducable
|
24
|
+
builds so i'm sure the code is the problem and not my environment if something
|
25
|
+
fails to build.
|
28
26
|
|
29
27
|
Additional features are:
|
30
28
|
- Open a shell with the environment used to build the sources.
|
@@ -53,7 +51,6 @@ http://michael-jansen.biz/build-tool
|
|
53
51
|
== REQUIREMENTS:
|
54
52
|
|
55
53
|
* logging > 1.2.2
|
56
|
-
* hoe > 2.3.3
|
57
54
|
|
58
55
|
== INSTALL:
|
59
56
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
|
3
2
|
require 'rubygems'
|
4
3
|
require 'hoe'
|
5
4
|
require 'fileutils'
|
6
5
|
require './lib/build-tool'
|
7
6
|
|
7
|
+
Hoe.plugin :git
|
8
|
+
Hoe.plugin :doofus
|
9
|
+
Hoe.plugin :debugging
|
10
|
+
|
8
11
|
# Generate all the Rake tasks
|
9
12
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
10
13
|
Hoe.spec( 'build-tool' ) do |build_tool|
|
@@ -20,14 +23,19 @@ Hoe.spec( 'build-tool' ) do |build_tool|
|
|
20
23
|
build_tool.rubyforge_name = build_tool.name
|
21
24
|
|
22
25
|
build_tool.extra_deps = [
|
23
|
-
['logging',
|
24
|
-
['
|
26
|
+
['logging', ">= 1.2.2"],
|
27
|
+
['sequel', ">= 3.8.0"],
|
28
|
+
['sqlite3-ruby', ">= 1.2" ]
|
25
29
|
]
|
26
30
|
|
27
|
-
|
31
|
+
build_tool.extra_dev_deps = [
|
32
|
+
['hoe-debugging', ">= 1.0.1"],
|
33
|
+
['hoe-doofus', ">= 1.0.0"],
|
34
|
+
['hoe-git', ">= 1.3.0"],
|
35
|
+
['racc', ">= 1.4.6"],
|
36
|
+
['rexical', ">= 1.0.4"]
|
37
|
+
]
|
28
38
|
|
29
|
-
# Does not work
|
30
|
-
# build_tool.local_rdoc_dir = "html_docs"
|
31
39
|
end
|
32
40
|
|
33
41
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
data/bin/build-tool
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
|
6
6
|
require 'pathname'
|
7
7
|
require 'rubygems'
|
8
|
-
require 'logging'
|
9
8
|
|
10
9
|
# libs relative to the link target
|
11
10
|
if File.symlink?(__FILE__)
|
@@ -13,41 +12,10 @@ if File.symlink?(__FILE__)
|
|
13
12
|
else
|
14
13
|
root_directory = File.dirname(__FILE__)
|
15
14
|
end
|
15
|
+
|
16
16
|
root_directory = Pathname.new( root_directory ).join( '..' )
|
17
17
|
require File.expand_path( root_directory + "lib/build-tool")
|
18
|
-
require 'mj/logging'
|
19
|
-
|
20
|
-
#
|
21
|
-
# CONFIGURE LOGGING
|
22
|
-
#
|
23
|
-
Logging.init :debug, :trace, :verbose, :info, :warn, :error
|
24
|
-
include Logging.globally
|
25
|
-
Logging.logger.root.level = :debug
|
26
|
-
# Special case for the configurationParser. It is very verbose if active.
|
27
|
-
Logging.logger['BuildTool::Cfg::Parser'].level = :info
|
28
|
-
Logging.logger.root.appenders = Logging.appenders.stdout(
|
29
|
-
:layout => MJ::Logging::BasicLayout.new(),
|
30
|
-
:level => :info)
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
require "build-tool/application"
|
36
|
-
require "build-tool/errors"
|
37
|
-
|
38
|
-
begin
|
39
|
-
app = BuildTool::Application.new( $0, root_directory )
|
40
|
-
rc = app.execute( ARGV )
|
41
|
-
rescue Interrupt => e
|
42
|
-
logger.info "User interrupt!"
|
43
|
-
rc = 0
|
44
|
-
rescue BuildTool::Error => e
|
45
|
-
logger.error e.message
|
46
|
-
logger.verbose e.backtrace.join("\n")
|
47
|
-
rc = -1
|
48
|
-
rescue Exception => e
|
49
|
-
logger.error e
|
50
|
-
rc = -1
|
51
|
-
end
|
19
|
+
require 'build-tool/application'
|
52
20
|
|
53
|
-
exit
|
21
|
+
exit BuildTool.main( $0, ARGV, root_directory );
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sequel/extensions/migration'
|
3
|
+
|
4
|
+
Class.new( Sequel::Migration ) do
|
5
|
+
|
6
|
+
def up
|
7
|
+
create_table :command_logs do
|
8
|
+
primary_key :id, :null => false
|
9
|
+
String :command, :null => false
|
10
|
+
DateTime :started_at
|
11
|
+
DateTime :finished_at
|
12
|
+
Integer :state, :default => 0, :null => false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
drop_table :command_logs
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sequel/extensions/migration'
|
3
|
+
|
4
|
+
Class.new( Sequel::Migration ) do
|
5
|
+
|
6
|
+
def up
|
7
|
+
create_table :module_logs do
|
8
|
+
primary_key :id
|
9
|
+
foreign_key :command_log_id, :command_log, :null => false
|
10
|
+
String :module, :null => false
|
11
|
+
String :event, :size => 20, :null => false
|
12
|
+
String :logfile
|
13
|
+
DateTime :started_at
|
14
|
+
DateTime :finished_at
|
15
|
+
Integer :state, :default => 0, :null => false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def down
|
20
|
+
drop_table :module_events
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sequel/extensions/migration'
|
3
|
+
|
4
|
+
Class.new( Sequel::Migration ) do
|
5
|
+
|
6
|
+
def up
|
7
|
+
alter_table :command_logs do
|
8
|
+
add_column :logdir, String
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
alter_table :command_logs do
|
14
|
+
remove_column :logdir
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
data/lib/build-tool.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
+
|
2
|
+
require 'logging'
|
3
|
+
Logging.init :debug, :trace, :verbose, :info, :warn, :error
|
4
|
+
include Logging.globally
|
5
|
+
|
1
6
|
require 'optparse'
|
2
7
|
require 'erb'
|
3
8
|
require 'yaml'
|
9
|
+
require 'sequel'
|
10
|
+
require 'sequel/extensions/migration'
|
4
11
|
|
5
|
-
require '
|
12
|
+
require 'mj/logging'
|
13
|
+
|
14
|
+
require "build-tool/errors"
|
6
15
|
require 'build-tool/recipe'
|
7
16
|
require 'build-tool/singleton'
|
8
17
|
require 'build-tool/cfg/parser'
|
@@ -16,9 +25,11 @@ module BuildTool
|
|
16
25
|
#
|
17
26
|
class Application < Singleton
|
18
27
|
|
19
|
-
attr_reader :name
|
20
28
|
attr_reader :application_root
|
21
29
|
attr_reader :cli
|
30
|
+
attr_reader :database
|
31
|
+
attr_reader :local_settings_file_path
|
32
|
+
attr_reader :name
|
22
33
|
|
23
34
|
def recipe
|
24
35
|
return @recipe if @recipe
|
@@ -29,40 +40,26 @@ module BuildTool
|
|
29
40
|
def initialize( name, application_root )
|
30
41
|
super()
|
31
42
|
@application_root = Pathname.new( application_root ).expand_path
|
43
|
+
@database = nil
|
44
|
+
@name = File.basename( name ).sub( "-build", "" )
|
32
45
|
@recipe = nil
|
33
|
-
|
34
|
-
# Determine the recipe name
|
35
|
-
@name = File.basename( name )
|
36
|
-
@name.sub!( "-build", "" )
|
37
|
-
|
38
|
-
# Create the shell
|
39
|
-
@cli = Commands::Shell.new
|
40
|
-
@cli.load_commands( @application_root.join( "lib/build-tool/commands" ), "Commands" )
|
46
|
+
@local_settings_file_path = local_configuration_dir.join("#{@name}.yaml")
|
41
47
|
end
|
42
48
|
|
49
|
+
# Load the configuration
|
43
50
|
def configuration
|
44
|
-
return
|
51
|
+
return @configuration if @configuration
|
52
|
+
# First load the settings file
|
53
|
+
file = local_settings_file_path
|
54
|
+
logger.debug "Loading settings file #{file}"
|
55
|
+
raise ConfigurationError, "Configuration File #{file} does not exists!" if !file.exist?
|
56
|
+
@settings = YAML.load_file( file )
|
57
|
+
# Then load the recipe
|
45
58
|
logger.debug "Loading configuration for #{name}"
|
46
|
-
load_settings
|
47
59
|
@recipe = BuildTool::Recipe.new( @settings['RECIPE'] || name )
|
48
60
|
@configuration = @recipe.load( name, @settings['SETTINGS'] )
|
49
61
|
end
|
50
62
|
|
51
|
-
def load_settings
|
52
|
-
file = local_settings_file_path
|
53
|
-
if file.exist?
|
54
|
-
@settings = YAML.load_file( file )
|
55
|
-
else
|
56
|
-
raise ConfigurationError, "Configuration File #{file} does not exists!"
|
57
|
-
end
|
58
|
-
@settings
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def local_settings_file_path
|
63
|
-
local_configuration_dir.join("#{name}.yaml")
|
64
|
-
end
|
65
|
-
|
66
63
|
# Return the local configuration dir. Makes sure the directory exists
|
67
64
|
# before returning it
|
68
65
|
def local_configuration_dir
|
@@ -74,11 +71,87 @@ module BuildTool
|
|
74
71
|
@local_configuration_dir
|
75
72
|
end
|
76
73
|
|
77
|
-
|
78
|
-
|
74
|
+
# Open the database
|
75
|
+
#
|
76
|
+
# @return [Object] The database handle
|
77
|
+
def open_database
|
78
|
+
path = local_configuration_dir.join( "#{name}.db" )
|
79
|
+
logger.debug "Opening the database #{path}."
|
80
|
+
@database = Sequel.connect( "sqlite:///#{path.to_s}" )
|
81
|
+
@database.logger= MJ::Logging::LoggerAdapter.new( 'db' )
|
82
|
+
# Try to upgrade the database if necessary
|
83
|
+
Sequel::Migrator.apply( @database, application_root.join( 'db/migrations' ) )
|
84
|
+
end
|
85
|
+
|
86
|
+
# Close the database
|
87
|
+
def close_database
|
88
|
+
@database.disconnect
|
89
|
+
path = local_configuration_dir.join( "#{name}.db" )
|
90
|
+
logger.debug "Closing the database #{path}."
|
91
|
+
end
|
92
|
+
|
93
|
+
# Get the database handle
|
94
|
+
def database
|
95
|
+
@database
|
96
|
+
end
|
97
|
+
|
98
|
+
def main( args )
|
99
|
+
# The configuration is loaded on demand to make it possible to execute command that
|
100
|
+
# don't need a configuration. Help for example.
|
101
|
+
|
102
|
+
# Initialize the database.
|
103
|
+
open_database()
|
104
|
+
|
105
|
+
begin
|
106
|
+
|
107
|
+
# Initialize the shell
|
108
|
+
require 'build-tool/commands'
|
109
|
+
@cli = Commands::Shell.new
|
110
|
+
|
111
|
+
# Load the commands. This has to be done AFTER the database is opened because
|
112
|
+
# sequel expects that there is a database before a Sequel::Model is created.
|
113
|
+
#
|
114
|
+
# And the commands require all that database related stuff.
|
115
|
+
@cli.load_commands( @application_root.join( "lib/build-tool/commands" ), BuildTool::Commands )
|
116
|
+
|
117
|
+
# Execute the given command (or start the cli)
|
118
|
+
@cli.execute( args )
|
119
|
+
ensure
|
120
|
+
# Make sure the database is closed correctly
|
121
|
+
close_database
|
122
|
+
end
|
79
123
|
end
|
80
124
|
|
81
125
|
end # class Application
|
82
126
|
|
83
|
-
end
|
127
|
+
end # module BuildTool
|
128
|
+
|
129
|
+
|
130
|
+
def BuildTool.main(name, args, root_directory)
|
131
|
+
|
132
|
+
begin
|
133
|
+
# Setup logging
|
134
|
+
Logging.logger.root.level = :debug
|
135
|
+
# Special case for the configurationParser. It is very verbose if active.
|
136
|
+
Logging.logger['BuildTool::Cfg::Parser'].level = :info
|
137
|
+
Logging.logger.root.appenders = Logging.appenders.stdout(
|
138
|
+
:layout => MJ::Logging::BasicLayout.new(),
|
139
|
+
:level => :info)
|
140
|
+
# Create the application
|
141
|
+
app = BuildTool::Application.new( name, root_directory )
|
142
|
+
# Execute the application
|
143
|
+
return app.main( args )
|
144
|
+
rescue Interrupt => e
|
145
|
+
logger.info "User interrupt!"
|
146
|
+
return 0
|
147
|
+
rescue BuildTool::Error => e
|
148
|
+
logger.error e.message
|
149
|
+
logger.verbose e.backtrace.join("\n")
|
150
|
+
return -1
|
151
|
+
rescue Exception => e
|
152
|
+
logger.error e
|
153
|
+
return -1
|
154
|
+
end
|
155
|
+
|
156
|
+
end # main()
|
84
157
|
|