build-tool 0.4.6 → 0.5.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.
- data.tar.gz.sig +0 -0
- data/History.txt +0 -8
- data/Manifest.txt +0 -2
- data/lib/build-tool.rb +1 -1
- data/lib/build-tool/cfg/lexer.rex +47 -8
- data/lib/build-tool/cfg/node.rb +5 -2
- data/lib/build-tool/cfg/parser.y +27 -8
- data/lib/build-tool/cfg/visitor.rb +101 -37
- data/lib/build-tool/commands.rb +7 -1
- data/lib/build-tool/commands/modules/info.rb +16 -12
- data/lib/build-tool/module.rb +2 -30
- data/lib/build-tool/repository.rb +1 -1
- data/lib/build-tool/server.rb +4 -0
- data/lib/build-tool/vcs/base.rb +9 -20
- data/lib/build-tool/vcs/git-svn.rb +39 -3
- data/lib/build-tool/vcs/git.rb +118 -16
- data/lib/build-tool/vcs/svn.rb +42 -0
- data/lib/mj/visitor.rb +1 -1
- metadata +2 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -24,8 +24,6 @@ lib/build-tool/cfg/lexer_base.rb
|
|
24
24
|
lib/build-tool/cfg/node.rb
|
25
25
|
lib/build-tool/cfg/parser.y
|
26
26
|
lib/build-tool/cfg/visitor.rb
|
27
|
-
lib/build-tool/cfg/parser.rb
|
28
|
-
lib/build-tool/cfg/lexer.rb
|
29
27
|
lib/build-tool/command_actions.rb
|
30
28
|
lib/build-tool/commands.rb
|
31
29
|
lib/build-tool/commands/build.rb
|
data/lib/build-tool.rb
CHANGED
@@ -154,12 +154,34 @@ rule
|
|
154
154
|
:ENVIRONMENT {STRINGERROR} { [:GARBAGE, text]; }
|
155
155
|
:ENVIRONMENT . { [:GARBAGE, text]; }
|
156
156
|
|
157
|
+
#
|
158
|
+
### GIT_SVN
|
159
|
+
#
|
160
|
+
:GIT_SVN external\b { [:EXTERNAL, text]; }
|
161
|
+
:GIT_SVN use\b { @states.push @state; @state = :USE; [:USE, text]; }
|
162
|
+
:GIT_SVN track\b { [:TRACK, text]; }
|
163
|
+
:GIT_SVN ssh-key\b { @states.push @state; @state = :SSH_KEY; [:SSH_KEY, text]; }
|
164
|
+
:GIT_SVN repository\b { @states.push @state; @state = :REPOSITORY; [:REPOSITORY, text]; }
|
165
|
+
:GIT_SVN remote-path\b { [:REMOTE_PATH, text]; }
|
166
|
+
:GIT_SVN remote\b { @states.push @state; @state = :GIT_REMOTE; [:REMOTE, text]; }
|
167
|
+
:GIT_SVN end\b { @state = @states.pop; [ :END, text ]; }
|
168
|
+
# COMMON
|
169
|
+
:GIT_SVN {STRING} { [:STRING, @ss[1]]; }
|
170
|
+
:GIT_SVN {TOKEN} { [:TOKEN, text]; }
|
171
|
+
:GIT_SVN {COMMENT} { [:COMMENT, text]; }
|
172
|
+
:GIT_SVN {BLANK} { [:IGNORE, text]; }
|
173
|
+
:GIT_SVN {LF} { [:IGNORE, text]; }
|
174
|
+
:GIT_SVN {STRINGERROR} { [:GARBAGE, text]; }
|
175
|
+
:GIT_SVN . { [:GARBAGE, text]; }
|
176
|
+
|
157
177
|
#
|
158
178
|
### GIT
|
159
179
|
#
|
160
|
-
:GIT
|
161
|
-
:GIT track
|
162
|
-
:GIT
|
180
|
+
:GIT url\b { [:URL, text]; }
|
181
|
+
:GIT track\b { [:TRACK, text]; }
|
182
|
+
:GIT push\b { [:PUSH, text]; }
|
183
|
+
:GIT ssh-key\b { @states.push @state; @state = :SSH_KEY; [:SSH_KEY, text]; }
|
184
|
+
:GIT remote\b { @states.push @state; @state = :GIT_REMOTE; [:REMOTE, text]; }
|
163
185
|
:GIT end\b { @state = @states.pop; [ :END, text ]; }
|
164
186
|
# COMMON
|
165
187
|
:GIT {STRING} { [:STRING, @ss[1]]; }
|
@@ -170,6 +192,22 @@ rule
|
|
170
192
|
:GIT {STRINGERROR} { [:GARBAGE, text]; }
|
171
193
|
:GIT . { [:GARBAGE, text]; }
|
172
194
|
|
195
|
+
#
|
196
|
+
### GIT REMOTE
|
197
|
+
#
|
198
|
+
:GIT_REMOTE url\b { [:URL, text]; }
|
199
|
+
:GIT_REMOTE push\b { [:PUSH, text]; }
|
200
|
+
:GIT_REMOTE ssh-key\b { @states.push @state; @state = :SSH_KEY; [:SSH_KEY, text]; }
|
201
|
+
:GIT_REMOTE end\b { @state = @states.pop; [ :END, text ]; }
|
202
|
+
# COMMON
|
203
|
+
:GIT_REMOTE {STRING} { [:STRING, @ss[1]]; }
|
204
|
+
:GIT_REMOTE {TOKEN} { [:TOKEN, text]; }
|
205
|
+
:GIT_REMOTE {COMMENT} { [:COMMENT, text]; }
|
206
|
+
:GIT_REMOTE {BLANK} { [:IGNORE, text]; }
|
207
|
+
:GIT_REMOTE {LF} { [:IGNORE, text]; }
|
208
|
+
:GIT_REMOTE {STRINGERROR} { [:GARBAGE, text]; }
|
209
|
+
:GIT_REMOTE . { [:GARBAGE, text]; }
|
210
|
+
|
173
211
|
#
|
174
212
|
### MODULE
|
175
213
|
#
|
@@ -181,12 +219,10 @@ rule
|
|
181
219
|
:MODULE description\b { [:DESCRIPTION, text ]; }
|
182
220
|
:MODULE install-prefix\b { [:INSTALL_PREFIX, text]; }
|
183
221
|
:MODULE local-path\b { [:LOCAL_PATH, text]; }
|
184
|
-
:MODULE remote-path\b { [:REMOTE_PATH, text]; }
|
185
222
|
:MODULE TEMPLATE\b { [:TEMPLATE, text]; }
|
186
223
|
|
187
224
|
:MODULE build-system\b { @states.push @state; @state = :BUILD_SYSTEM; [:BUILD_SYSTEM, text]; }
|
188
225
|
:MODULE environment\b { @states.push @state; @state = :ENVIRONMENT; [:ENVIRONMENT, text]; }
|
189
|
-
:MODULE repository\b { @states.push @state; @state = :REPOSITORY; [:REPOSITORY, text]; }
|
190
226
|
:MODULE use\b { @states.push @state; @state = :USE; [:USE, text]; }
|
191
227
|
:MODULE vcs\b { @states.push @state; @state = :VCS; [:VCS, text]; }
|
192
228
|
|
@@ -253,8 +289,11 @@ rule
|
|
253
289
|
#
|
254
290
|
### SVN
|
255
291
|
#
|
256
|
-
:SVN only\b
|
257
|
-
:SVN end\b
|
292
|
+
:SVN only\b { [:ONLY, text]; }
|
293
|
+
:SVN end\b { @state = @states.pop; [ :END, text ]; }
|
294
|
+
:SVN repository\b { @states.push @state; @state = :REPOSITORY; [:REPOSITORY, text]; }
|
295
|
+
:SVN use\b { @states.push @state; @state = :USE; [:USE, text]; }
|
296
|
+
:SVN remote-path\b { [:REMOTE_PATH, text]; }
|
258
297
|
# COMMON
|
259
298
|
:SVN {STRING} { [:STRING, @ss[1]]; }
|
260
299
|
:SVN {TOKEN} { [:TOKEN, text]; }
|
@@ -285,7 +324,7 @@ rule
|
|
285
324
|
#
|
286
325
|
### VCS
|
287
326
|
#
|
288
|
-
:VCS git-svn\b { @state = :
|
327
|
+
:VCS git-svn\b { @state = :GIT_SVN; [:GIT_SVN, text]; }
|
289
328
|
:VCS git\b { @state = :GIT; [:GIT, text]; }
|
290
329
|
:VCS svn\b { @state = :SVN; [:SVN, text]; }
|
291
330
|
:VCS archive\b { @state = :ARCHIVE; [:ARCHIVE, text]; }
|
data/lib/build-tool/cfg/node.rb
CHANGED
@@ -44,6 +44,10 @@ def initialize(values = nil)
|
|
44
44
|
|
45
45
|
GitDeclaration
|
46
46
|
GitRemotePath
|
47
|
+
GitRemoteUrl
|
48
|
+
GitRemoteDeclaration
|
49
|
+
GitRemotePush
|
50
|
+
GitTrack
|
47
51
|
GitServer
|
48
52
|
|
49
53
|
GitSvnExternal
|
@@ -56,10 +60,8 @@ def initialize(values = nil)
|
|
56
60
|
ModuleDeclaration
|
57
61
|
ModuleInstallPrefix
|
58
62
|
ModuleLocalPath
|
59
|
-
ModuleRemotePath
|
60
63
|
ModuleTemplate
|
61
64
|
|
62
|
-
RemoteDeclaration
|
63
65
|
RepositoryDeclaration
|
64
66
|
RepositoryPath
|
65
67
|
RepositoryUser
|
@@ -74,6 +76,7 @@ def initialize(values = nil)
|
|
74
76
|
|
75
77
|
SvnDeclaration
|
76
78
|
SvnCheckoutOnly
|
79
|
+
SvnRemotePath
|
77
80
|
|
78
81
|
UseBuildSystem
|
79
82
|
UseEnvironment
|
data/lib/build-tool/cfg/parser.y
CHANGED
@@ -30,6 +30,7 @@ class BuildTool::Cfg::Parser < BuildTool::Cfg::Lexer
|
|
30
30
|
token PATH
|
31
31
|
token PREPEND
|
32
32
|
token PROTOCOL
|
33
|
+
token PUSH
|
33
34
|
token REMOTE
|
34
35
|
token REMOTE_PATH
|
35
36
|
token REPOSITORY
|
@@ -41,7 +42,8 @@ class BuildTool::Cfg::Parser < BuildTool::Cfg::Lexer
|
|
41
42
|
token SVN
|
42
43
|
token TEMPLATE
|
43
44
|
token TOKEN
|
44
|
-
token
|
45
|
+
token TRACK
|
46
|
+
token URL
|
45
47
|
token USE
|
46
48
|
token USER
|
47
49
|
token VAR
|
@@ -185,13 +187,27 @@ rule
|
|
185
187
|
: VCS GIT git_statements END { result = GitDeclarationNode.new( val[2] ); }
|
186
188
|
;
|
187
189
|
|
190
|
+
git_remote_statements
|
191
|
+
: /* empty */
|
192
|
+
| git_remote_statement git_remote_statements { result = val.flatten(); }
|
193
|
+
;
|
194
|
+
|
195
|
+
git_remote_statement
|
196
|
+
: URL STRING STRING { result = GitRemoteUrlNode.new( val[1..-1] ); }
|
197
|
+
| URL STRING { result = GitRemoteUrlNode.new( val[1..-1] ); }
|
198
|
+
| PUSH STRING STRING { result = GitRemotePushNode.new( val[1..-1] ); }
|
199
|
+
| PUSH STRING { result = GitRemotePushNode.new( val[1..-1] ); }
|
200
|
+
;
|
201
|
+
|
188
202
|
git_statements
|
189
203
|
: /* empty */
|
190
|
-
| git_statement git_statements
|
204
|
+
| git_statement git_statements { result = val.flatten; }
|
191
205
|
;
|
192
206
|
|
193
207
|
git_statement
|
194
|
-
: REMOTE STRING
|
208
|
+
: REMOTE STRING git_remote_statements END { result = GitRemoteDeclarationNode.new( val[1..-1]); }
|
209
|
+
| TRACK STRING { result = GitTrackNode.new( val[1] ); }
|
210
|
+
| git_remote_statement { result = val[0]; }
|
195
211
|
;
|
196
212
|
|
197
213
|
#
|
@@ -207,8 +223,11 @@ rule
|
|
207
223
|
;
|
208
224
|
|
209
225
|
git_svn_statement
|
210
|
-
: git_statement
|
211
|
-
|
|
226
|
+
: git_statement { result = val[0]; }
|
227
|
+
| USE REPOSITORY identifier { result = UseRepositoryNode.new( val[2] ); }
|
228
|
+
| EXTERNAL STRING { result = GitSvnExternalNode.new( val[1] ); }
|
229
|
+
| REMOTE_PATH STRING { result = SvnRemotePathNode.new( val[1] ); }
|
230
|
+
| repository_declaration { result = val[0]; }
|
212
231
|
;
|
213
232
|
|
214
233
|
#
|
@@ -234,17 +253,14 @@ rule
|
|
234
253
|
module_statement
|
235
254
|
: USE BUILD_SYSTEM identifier { result = UseBuildSystemNode.new( val[2] ); }
|
236
255
|
| USE ENVIRONMENT identifier { result = UseEnvironmentNode.new( val[2] ); }
|
237
|
-
| USE REPOSITORY identifier { result = UseRepositoryNode.new( val[2] ); }
|
238
256
|
| USE VCS identifier { result = UseVcsNode.new( val[2] ); }
|
239
257
|
| LONG DESCRIPTION multiline_string { result = LongDescriptionNode.new( val[2] ); }
|
240
258
|
| DESCRIPTION STRING { result = ShortDescriptionNode.new( val[1] ); }
|
241
259
|
| build_system_declaration { result = val[0]; }
|
242
260
|
| vcs_declaration { result = val[0]; }
|
243
|
-
| repository_declaration { result = val[0]; }
|
244
261
|
| environment_declaration { result = val[0]; }
|
245
262
|
| INSTALL_PREFIX STRING { result = ModuleInstallPrefixNode.new( val[1] ); }
|
246
263
|
| BUILD_PREFIX STRING { result = ModuleBuildPrefixNode.new( val[1] ); }
|
247
|
-
| REMOTE_PATH STRING { result = ModuleRemotePathNode.new( val[1] ); }
|
248
264
|
| LOCAL_PATH STRING { result = ModuleLocalPathNode.new( val[1] ); }
|
249
265
|
| TEMPLATE { result = ModuleTemplateNode.new(); }
|
250
266
|
| APPLY PATCH STRING { result = ApplyPatchesNode.new(val[2]); }
|
@@ -321,6 +337,9 @@ rule
|
|
321
337
|
|
322
338
|
svn_statement
|
323
339
|
: ONLY STRING { result = SvnCheckoutOnlyNode.new(val[1]); }
|
340
|
+
| USE REPOSITORY identifier { result = UseRepositoryNode.new( val[2] ); }
|
341
|
+
| REMOTE_PATH STRING { result = SvnRemotePathNode.new( val[1] ); }
|
342
|
+
| repository_declaration { result = val[0]; }
|
324
343
|
;
|
325
344
|
|
326
345
|
#
|
@@ -21,6 +21,10 @@ def initialize( configuration )
|
|
21
21
|
@configuration = configuration
|
22
22
|
end
|
23
23
|
|
24
|
+
def visit_Object( object )
|
25
|
+
raise "#{self.class}: Not a visitor for #{object.class}!"
|
26
|
+
end
|
27
|
+
|
24
28
|
end # class VisitorBase
|
25
29
|
|
26
30
|
|
@@ -297,22 +301,67 @@ def visit_ShortDescriptionNode( node )
|
|
297
301
|
end # class FeatureNodeVisitor
|
298
302
|
|
299
303
|
|
300
|
-
|
304
|
+
|
305
|
+
class GitRemoteDeclarationNodeVisitor < ListVisitor
|
306
|
+
|
307
|
+
def visit_GitRemoteDeclarationNode( node )
|
308
|
+
name = node.values[0]
|
309
|
+
@remote = BuildTool::VCS::GitRemote.new( name )
|
310
|
+
stmts = node.values[1]
|
311
|
+
visit_nodes( stmts )
|
312
|
+
return @remote
|
313
|
+
end
|
314
|
+
|
315
|
+
def visit_GitRemoteUrlNode( node )
|
316
|
+
if node.values.length == 2
|
317
|
+
@remote.server = configuration.server( node.values[0] )
|
318
|
+
if @remote.server.nil?
|
319
|
+
raise ConfigurationError, "Unknown server #{node.values[0]} configured."
|
320
|
+
end
|
321
|
+
@remote.path = node.values[1]
|
322
|
+
else
|
323
|
+
@remote.server = BuildTool::Server.new( "unnamed" )
|
324
|
+
@remote.server.host = node.values[0]
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def visit_GitRemotePushNode( node )
|
329
|
+
@remote.push_server = configuration.server( node.values[0] )
|
330
|
+
if @remote.push_server.nil?
|
331
|
+
raise ConfigurationError, "Unknown server #{node.values[0]} configured."
|
332
|
+
end
|
333
|
+
@remote.push_path = node.values[1]
|
334
|
+
end
|
335
|
+
|
336
|
+
end # class GitRemoteDeclarationNodeVisitor
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
class GitDeclarationNodeVisitor < GitRemoteDeclarationNodeVisitor
|
301
341
|
|
302
342
|
def initialize( configuration, vcs = BuildTool::VCS::GitConfiguration.new )
|
303
343
|
super( configuration )
|
344
|
+
@remote = BuildTool::VCS::GitRemote.new( "origin" )
|
304
345
|
@vcs = vcs
|
346
|
+
@vcs.remote[@remote.name] = @remote
|
305
347
|
end
|
306
348
|
|
307
349
|
def visit_GitDeclarationNode( node )
|
308
350
|
visit_nodes( node.values )
|
351
|
+
if @remote.server.nil? and @remote.path.nil?
|
352
|
+
@vcs.remote.delete( "origin" )
|
353
|
+
end
|
309
354
|
return @vcs
|
310
355
|
end
|
311
356
|
|
312
|
-
def
|
313
|
-
visitor =
|
314
|
-
|
315
|
-
@vcs.remote[
|
357
|
+
def visit_GitRemoteDeclarationNode( node )
|
358
|
+
visitor = GitRemoteDeclarationNodeVisitor.new( configuration )
|
359
|
+
remote = node.accept(visitor)
|
360
|
+
@vcs.remote[remote.name] = remote
|
361
|
+
end
|
362
|
+
|
363
|
+
def visit_GitTrackNode( node )
|
364
|
+
@vcs.track = node.values
|
316
365
|
end
|
317
366
|
|
318
367
|
end # class GitDeclarationNodeVisitor
|
@@ -326,6 +375,9 @@ def initialize( configuration, vcs )
|
|
326
375
|
|
327
376
|
def visit_GitSvnDeclarationNode( node )
|
328
377
|
visit_nodes( node.values )
|
378
|
+
if @remote.server.nil? and @remote.path.nil?
|
379
|
+
@vcs.remote.delete( "origin" )
|
380
|
+
end
|
329
381
|
return @vcs
|
330
382
|
end
|
331
383
|
|
@@ -334,6 +386,23 @@ def visit_GitSvnExternalNode( node )
|
|
334
386
|
@vcs.add_external( name, value )
|
335
387
|
end
|
336
388
|
|
389
|
+
def visit_RepositoryDeclarationNode( node )
|
390
|
+
visitor = RepositoryDeclarationNodeVisitor.new( configuration )
|
391
|
+
@vcs.repository = node.accept( visitor )
|
392
|
+
end
|
393
|
+
|
394
|
+
def visit_UseRepositoryNode( node )
|
395
|
+
repo = configuration.repository( node.value )
|
396
|
+
if repo.nil?
|
397
|
+
raise ConfigurationError, "Unknown repository #{node.value}!"
|
398
|
+
end
|
399
|
+
@vcs.repository = repo
|
400
|
+
end
|
401
|
+
|
402
|
+
def visit_SvnRemotePathNode( node )
|
403
|
+
@vcs.remote_path = node.value
|
404
|
+
end
|
405
|
+
|
337
406
|
end # class GitSvnDeclarationNodeVisitor
|
338
407
|
|
339
408
|
|
@@ -410,12 +479,8 @@ def visit_GitDeclarationNode( node )
|
|
410
479
|
# vcs.copy_configuration( @module.vcs_configuration )
|
411
480
|
# end
|
412
481
|
@module.vcs_configuration = vcs
|
413
|
-
|
414
|
-
|
415
|
-
node.accept( visitor )
|
416
|
-
rescue ConfigurationError => e
|
417
|
-
raise ConfigurationError, "Module #{@module.name}: #{e.to_s}"
|
418
|
-
end
|
482
|
+
visitor = GitDeclarationNodeVisitor.new( configuration, vcs )
|
483
|
+
node.accept( visitor )
|
419
484
|
end
|
420
485
|
|
421
486
|
def visit_GitSvnDeclarationNode( node )
|
@@ -465,7 +530,11 @@ def visit_ModuleDeclarationNode( node )
|
|
465
530
|
configuration.active_feature.modules << @module
|
466
531
|
end
|
467
532
|
end
|
468
|
-
|
533
|
+
begin
|
534
|
+
self.visit_nodes( stmts )
|
535
|
+
rescue ConfigurationError => e
|
536
|
+
raise ConfigurationError, "Module #{@module.name}: #{e.to_s}"
|
537
|
+
end
|
469
538
|
end
|
470
539
|
|
471
540
|
def visit_ModuleInstallPrefixNode( node )
|
@@ -476,19 +545,10 @@ def visit_ModuleLocalPathNode( node )
|
|
476
545
|
@module.local_path = node.value
|
477
546
|
end
|
478
547
|
|
479
|
-
def visit_ModuleRemotePathNode( node )
|
480
|
-
@module.remote_path = node.value
|
481
|
-
end
|
482
|
-
|
483
548
|
def visit_ModuleTemplateNode( node )
|
484
549
|
@module.is_template = true
|
485
550
|
end
|
486
551
|
|
487
|
-
def visit_RepositoryDeclarationNode( node )
|
488
|
-
visitor = RepositoryDeclarationNodeVisitor.new( configuration )
|
489
|
-
@module.repository = node.accept( visitor )
|
490
|
-
end
|
491
|
-
|
492
552
|
def visit_ShortDescriptionNode( node )
|
493
553
|
if !@module.description.nil?
|
494
554
|
logger.warn "Overwriting short description for module #{@module.name}"
|
@@ -521,13 +581,6 @@ def visit_UseEnvironmentNode( node )
|
|
521
581
|
end
|
522
582
|
end
|
523
583
|
|
524
|
-
def visit_UseRepositoryNode( node )
|
525
|
-
@module.repository = configuration.repository( node.value )
|
526
|
-
if @module.repository.nil?
|
527
|
-
raise ConfigurationError, "Unknown repository #{node.value} configured for module #{@module.name}!"
|
528
|
-
end
|
529
|
-
end
|
530
|
-
|
531
584
|
def visit_UseVcsNode( node )
|
532
585
|
@module.vcs_configuration = configuration.vcs(node.value)
|
533
586
|
end
|
@@ -549,14 +602,6 @@ def visit_RepositoryDeclarationNode( node )
|
|
549
602
|
return @repository
|
550
603
|
end
|
551
604
|
|
552
|
-
def visit_RemoteDeclarationNode( node )
|
553
|
-
name = node.values[0]
|
554
|
-
@repository = BuildTool::Repository.new( name )
|
555
|
-
stmts = node.values[1]
|
556
|
-
visit_nodes( stmts )
|
557
|
-
return @repository
|
558
|
-
end
|
559
|
-
|
560
605
|
def visit_RepositoryPathNode( node )
|
561
606
|
@repository.path = node.value
|
562
607
|
end
|
@@ -663,7 +708,8 @@ def visit_SshKeyFileNode( node )
|
|
663
708
|
class SvnDeclarationNodeVisitor < ListVisitor
|
664
709
|
|
665
710
|
def initialize( configuration, vcs )
|
666
|
-
super( configuration
|
711
|
+
super( configuration )
|
712
|
+
@vcs = vcs
|
667
713
|
end
|
668
714
|
|
669
715
|
def visit_SvnDeclarationNode( node )
|
@@ -675,6 +721,24 @@ def visit_SvnCheckoutOnlyNode( node )
|
|
675
721
|
@vcs.only = node.value.split( / +/ )
|
676
722
|
end
|
677
723
|
|
724
|
+
def visit_RepositoryDeclarationNode( node )
|
725
|
+
visitor = RepositoryDeclarationNodeVisitor.new( configuration )
|
726
|
+
@vcs.repository = node.accept( visitor )
|
727
|
+
end
|
728
|
+
|
729
|
+
def visit_UseRepositoryNode( node )
|
730
|
+
repo = configuration.repository( node.value )
|
731
|
+
if repo.nil?
|
732
|
+
raise ConfigurationError, "Unknown repository #{node.value}!"
|
733
|
+
end
|
734
|
+
@vcs.repository = repo
|
735
|
+
end
|
736
|
+
|
737
|
+
def visit_SvnRemotePathNode( node )
|
738
|
+
@vcs.remote_path = node.value
|
739
|
+
end
|
740
|
+
|
741
|
+
|
678
742
|
end # class SvnDeclarationNodeVisitor
|
679
743
|
|
680
744
|
end; end
|
data/lib/build-tool/commands.rb
CHANGED
@@ -521,7 +521,13 @@ def do_execute( args )
|
|
521
521
|
# 2. Check prerequisites
|
522
522
|
isready = true
|
523
523
|
modules.each do |mod|
|
524
|
-
|
524
|
+
begin
|
525
|
+
isready &= is_module_ready?( mod )
|
526
|
+
rescue Exception => e
|
527
|
+
logger.error "#{mod.name}: #{e.message}"
|
528
|
+
logger.verbose e.backtrace.join("\n")
|
529
|
+
isready = false
|
530
|
+
end
|
525
531
|
end
|
526
532
|
|
527
533
|
if !isready
|
@@ -22,15 +22,15 @@ def do_execute_module( mod )
|
|
22
22
|
|
23
23
|
say "Active: #{mod.active?}"
|
24
24
|
|
25
|
-
if mod.repository
|
26
|
-
say "Repository: #{mod.repository.url}/#{mod.remote_path}"
|
27
|
-
if mod.repository.sshkey
|
28
|
-
say " SSH Key: '#{mod.repository.sshkey.name}' (#{mod.repository.sshkey.file})"
|
29
|
-
end
|
30
|
-
say "Apply Patches: #{mod.patches.join(", ")}"
|
31
|
-
else
|
32
|
-
say "Repository: not configured"
|
33
|
-
end
|
25
|
+
# if mod.repository
|
26
|
+
# say "Repository: #{mod.repository.url}/#{mod.remote_path}"
|
27
|
+
# if mod.repository.sshkey
|
28
|
+
# say " SSH Key: '#{mod.repository.sshkey.name}' (#{mod.repository.sshkey.file})"
|
29
|
+
# end
|
30
|
+
# say "Apply Patches: #{mod.patches.join(", ")}"
|
31
|
+
# else
|
32
|
+
# say "Repository: not configured"
|
33
|
+
# end
|
34
34
|
|
35
35
|
if mod.build_prefix
|
36
36
|
say "Local Checkout: #{mod.vcs.local_path} #{mod.checkedout? ? '(EXISTS)' : '(TODO)' }"
|
@@ -53,15 +53,19 @@ def do_execute_module( mod )
|
|
53
53
|
if mod.vcs_configuration
|
54
54
|
case mod.vcs_configuration.name
|
55
55
|
when 'svn'
|
56
|
+
say " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ]
|
56
57
|
when 'archive'
|
57
58
|
when 'git'
|
58
|
-
say " Remote: %s -> %s" % [ "origin", mod.vcs_configuration.repository.url ]
|
59
59
|
mod.vcs_configuration.remote.each do |key, val|
|
60
|
-
|
60
|
+
if val.push_url
|
61
|
+
say " Remote: %s -> %s (push to %s)" % [ key, val.url, val.push_url ]
|
62
|
+
else
|
63
|
+
say " Remote: %s -> %s" % [ key, val.url ]
|
64
|
+
end
|
61
65
|
end
|
62
66
|
say " Track branch: #{mod.vcs_configuration.track_remote}/#{mod.vcs_configuration.track_branch}"
|
63
67
|
when 'git-svn'
|
64
|
-
say "
|
68
|
+
say " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ]
|
65
69
|
mod.vcs_configuration.remote.each do |key, val|
|
66
70
|
say " Remote: %s -> %s" % [ key, val.url ]
|
67
71
|
end
|
data/lib/build-tool/module.rb
CHANGED
@@ -23,7 +23,6 @@ def initialize( name, parent = nil )
|
|
23
23
|
@remote_path = nil
|
24
24
|
@environment = nil
|
25
25
|
@build_system = nil
|
26
|
-
@repository = nil
|
27
26
|
@install_prefix = nil
|
28
27
|
@is_template = false
|
29
28
|
@vcs_configuration = nil
|
@@ -205,22 +204,6 @@ def remote_path
|
|
205
204
|
@remote_path || @name
|
206
205
|
end
|
207
206
|
|
208
|
-
# Repository
|
209
|
-
def repository=( repository )
|
210
|
-
@repository = repository
|
211
|
-
end
|
212
|
-
|
213
|
-
def repository
|
214
|
-
return @repository if @repository
|
215
|
-
return @parent.repository if @parent && @parent.repository
|
216
|
-
end
|
217
|
-
|
218
|
-
def repository_required
|
219
|
-
repo = self.repository
|
220
|
-
return repo if repo
|
221
|
-
raise ConfigurationError, "No repository configured for #{name}!"
|
222
|
-
end
|
223
|
-
|
224
207
|
def source_directory
|
225
208
|
build_prefix_required.join("src", local_path)
|
226
209
|
end
|
@@ -253,12 +236,6 @@ def vcs_configuration_required
|
|
253
236
|
end
|
254
237
|
|
255
238
|
def vcs_required
|
256
|
-
if repository.nil?
|
257
|
-
raise ConfigurationError, "No repository specified for module #{name}."
|
258
|
-
end
|
259
|
-
if remote_path.nil?
|
260
|
-
raise ConfigurationError, "No remote path specified for module #{name}."
|
261
|
-
end
|
262
239
|
if source_directory.nil?
|
263
240
|
raise ConfigurationError, "No source directory specified for module #{name}."
|
264
241
|
end
|
@@ -340,14 +317,9 @@ def cleanup_after_vcs_access
|
|
340
317
|
|
341
318
|
# Check if an ssh-key is required and active it if necessary
|
342
319
|
def prepare_for_vcs_access
|
343
|
-
if
|
344
|
-
|
345
|
-
logger.info ""
|
346
|
-
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
|
347
|
-
MJ::Tools::SSH::add_key key.file
|
348
|
-
end
|
320
|
+
if vcs
|
321
|
+
return vcs.prepare_for_access
|
349
322
|
end
|
350
|
-
return true
|
351
323
|
end
|
352
324
|
|
353
325
|
def prepare_for_installation
|
data/lib/build-tool/server.rb
CHANGED
data/lib/build-tool/vcs/base.rb
CHANGED
@@ -12,14 +12,6 @@ def initialize
|
|
12
12
|
@module = nil
|
13
13
|
end
|
14
14
|
|
15
|
-
def remote_path
|
16
|
-
@module.remote_path
|
17
|
-
end
|
18
|
-
|
19
|
-
def repository
|
20
|
-
@module.repository
|
21
|
-
end
|
22
|
-
|
23
15
|
def local_path
|
24
16
|
@module.source_directory
|
25
17
|
end
|
@@ -69,18 +61,6 @@ def local_path
|
|
69
61
|
local_path
|
70
62
|
end
|
71
63
|
|
72
|
-
def remote_path
|
73
|
-
remote_path = @config.remote_path
|
74
|
-
raise ConfigurationError, "#{self.class}.remote_path not set" if remote_path.nil?
|
75
|
-
remote_path
|
76
|
-
end
|
77
|
-
|
78
|
-
def repository
|
79
|
-
repository = @config.repository
|
80
|
-
raise ConfigurationError, "#{self.class}.repository not set" if repository.nil?
|
81
|
-
repository
|
82
|
-
end
|
83
|
-
|
84
64
|
#
|
85
65
|
### METHODS
|
86
66
|
#
|
@@ -94,6 +74,15 @@ def configure
|
|
94
74
|
logger.debug "VCS #{name} did not implement configure!"
|
95
75
|
end
|
96
76
|
|
77
|
+
def prepare_for_vcs_access
|
78
|
+
if key = repository.ssh_key and !MJ::Tools::SSH::has_key? key.file
|
79
|
+
logger.info ""
|
80
|
+
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
|
81
|
+
MJ::Tools::SSH::add_key key.file
|
82
|
+
end
|
83
|
+
return true
|
84
|
+
end
|
85
|
+
|
97
86
|
def recipe
|
98
87
|
Application::instance.recipe
|
99
88
|
end
|
@@ -32,6 +32,25 @@ def copy_configuration( other )
|
|
32
32
|
@externals = {} # Do not copy the externals
|
33
33
|
end
|
34
34
|
|
35
|
+
attr_writer :repository
|
36
|
+
def repository
|
37
|
+
if @repository.nil?
|
38
|
+
raise ConfigurationError, "No repository configured for module #{self.module.name}."
|
39
|
+
end
|
40
|
+
@repository
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_writer :remote_path
|
44
|
+
def remote_path
|
45
|
+
if @remote_path.nil?
|
46
|
+
return @module.name
|
47
|
+
end
|
48
|
+
@remote_path
|
49
|
+
end
|
50
|
+
|
51
|
+
def track_branch
|
52
|
+
"git-svn"
|
53
|
+
end
|
35
54
|
end
|
36
55
|
|
37
56
|
#
|
@@ -75,8 +94,8 @@ def clone
|
|
75
94
|
# Create the directory
|
76
95
|
FileUtils.mkdir_p( local_path ) if !$noop
|
77
96
|
# Init the repository
|
78
|
-
if 0 != ( git_svn "init #{repository.url}/#{remote_path}" )
|
79
|
-
raise GitSvnError, "Error while initializing the repo `git svn init '#{repository}/#{remote_path}'`: #{$?}"
|
97
|
+
if 0 != ( git_svn "init #{config.repository.url}/#{remote_path}" )
|
98
|
+
raise GitSvnError, "Error while initializing the repo `git svn init '#{config.repository}/#{remote_path}'`: #{$?}"
|
80
99
|
end
|
81
100
|
fetch( "HEAD" )
|
82
101
|
end
|
@@ -123,8 +142,25 @@ def git_svn( command, wd = local_path, &block )
|
|
123
142
|
rc
|
124
143
|
end
|
125
144
|
|
145
|
+
def prepare_for_access
|
146
|
+
# If our server has an associated ssh-key, add it to the ssh-agent.
|
147
|
+
if config.repository.sshkey
|
148
|
+
key = config.repository.sshkey
|
149
|
+
logger.info ""
|
150
|
+
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
|
151
|
+
MJ::Tools::SSH::add_key key.file
|
152
|
+
end
|
153
|
+
true
|
154
|
+
end
|
155
|
+
|
126
156
|
def rebase
|
127
|
-
git.git
|
157
|
+
if 0 != ( git.git "rebase #{config.track_branch}" )
|
158
|
+
raise GitSvnError, "Error while rebasing the repo with `#{config.track_branch}': #{$?}"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def remote_path
|
163
|
+
@config.remote_path
|
128
164
|
end
|
129
165
|
|
130
166
|
def update_externals
|
data/lib/build-tool/vcs/git.rb
CHANGED
@@ -1,10 +1,88 @@
|
|
1
1
|
require 'build-tool/vcs/base'
|
2
2
|
require 'build-tool/errors'
|
3
|
+
require 'grit'
|
3
4
|
|
4
5
|
module BuildTool; module VCS
|
5
6
|
|
6
7
|
class GitError < BuildTool::Error; end
|
7
8
|
|
9
|
+
class GitRemote
|
10
|
+
|
11
|
+
# The name for the remote
|
12
|
+
attr_accessor :name
|
13
|
+
|
14
|
+
# The hostname for the remote
|
15
|
+
attr_accessor :server
|
16
|
+
|
17
|
+
# The path for the remote
|
18
|
+
attr_accessor :path
|
19
|
+
|
20
|
+
# The hostname to push to for the remote
|
21
|
+
attr_accessor :push_server
|
22
|
+
|
23
|
+
# The path to push to for the remote
|
24
|
+
attr_accessor :push_path
|
25
|
+
|
26
|
+
attr_reader :user
|
27
|
+
|
28
|
+
def initialize( name )
|
29
|
+
self.name = name
|
30
|
+
@user = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def url
|
34
|
+
if !server
|
35
|
+
raise ConfigurationError, "No server specified for remote #{name}"
|
36
|
+
end
|
37
|
+
if !server.host
|
38
|
+
raise ConfigurationError, "No host specified for server #{server.name}"
|
39
|
+
end
|
40
|
+
|
41
|
+
url = server.host
|
42
|
+
if server.path
|
43
|
+
url = "#{url}/#{server.path}"
|
44
|
+
end
|
45
|
+
if user
|
46
|
+
url = "#{user}@#{url}"
|
47
|
+
end
|
48
|
+
if server.protocol
|
49
|
+
url = "#{server.protocol}://#{url}"
|
50
|
+
end
|
51
|
+
if path
|
52
|
+
url = "#{url}/#{path}"
|
53
|
+
end
|
54
|
+
url
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the pushUrl configured or nil if not configured.
|
58
|
+
def push_url
|
59
|
+
if !push_server
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
if !push_server.host
|
63
|
+
raise ConfigurationError, "No host specified for server #{push_server.name}"
|
64
|
+
end
|
65
|
+
|
66
|
+
url = push_server.host
|
67
|
+
if push_server.path
|
68
|
+
url = "#{url}/#{push_server.path}"
|
69
|
+
end
|
70
|
+
if user
|
71
|
+
url = "#{user}@#{url}"
|
72
|
+
end
|
73
|
+
if push_server.protocol
|
74
|
+
url = "#{push_server.protocol}://#{url}"
|
75
|
+
end
|
76
|
+
if path
|
77
|
+
url = "#{url}/#{path}"
|
78
|
+
end
|
79
|
+
url
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
8
86
|
class GitConfiguration < BaseConfiguration
|
9
87
|
|
10
88
|
def name
|
@@ -16,6 +94,7 @@ def name
|
|
16
94
|
def initialize
|
17
95
|
super
|
18
96
|
@remote = {}
|
97
|
+
@track = "origin/master"
|
19
98
|
end
|
20
99
|
|
21
100
|
def vcs( mod )
|
@@ -24,8 +103,11 @@ def vcs( mod )
|
|
24
103
|
Git.new( self )
|
25
104
|
end
|
26
105
|
|
106
|
+
# The branch to track
|
107
|
+
attr_accessor :track
|
108
|
+
|
27
109
|
def track_remote
|
28
|
-
rc =
|
110
|
+
rc = track.split('/')
|
29
111
|
# If there is only one string we assume it is the branch name from
|
30
112
|
# origin
|
31
113
|
return "origin" if rc.length == 1
|
@@ -33,7 +115,7 @@ def track_remote
|
|
33
115
|
end
|
34
116
|
|
35
117
|
def track_branch
|
36
|
-
rc =
|
118
|
+
rc = track.split('/')
|
37
119
|
# If there is only one string we assume it is the branch name from
|
38
120
|
# origin
|
39
121
|
return rc[0] if rc.length == 1
|
@@ -69,6 +151,11 @@ def fetching_supported?
|
|
69
151
|
true
|
70
152
|
end
|
71
153
|
|
154
|
+
def repo
|
155
|
+
return @repo if @repo
|
156
|
+
@repo = Grit::Repo.new( local_path )
|
157
|
+
@repo
|
158
|
+
end
|
72
159
|
#
|
73
160
|
### METHODS
|
74
161
|
#
|
@@ -100,11 +187,9 @@ def clone
|
|
100
187
|
if git( "remote add #{name} #{val.url}" ) != 0
|
101
188
|
raise GitError, "Error while initializing the repo `git remote add #{name} #{val.url}`: #{$?}"
|
102
189
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
if git( cmd, local_path ) != 0
|
107
|
-
raise GitError, "Error while initializing the repo `#{cmd}`: #{$?}"
|
190
|
+
if val.push_url and git( "remote set-url --push #{name} #{val.push_url}" ) != 0
|
191
|
+
raise GitError, "Error while initializing the repo `git remote add #{name} #{val.url}`: #{$?}"
|
192
|
+
end
|
108
193
|
end
|
109
194
|
|
110
195
|
logger.info <<-EOS
|
@@ -127,14 +212,6 @@ def gc
|
|
127
212
|
git( "gc" )
|
128
213
|
end
|
129
214
|
|
130
|
-
def remote?( name )
|
131
|
-
found = false
|
132
|
-
git( "remote" ) do |line|
|
133
|
-
found = true if line == name
|
134
|
-
end
|
135
|
-
return found
|
136
|
-
end
|
137
|
-
|
138
215
|
# Fetch from +repository+
|
139
216
|
#
|
140
217
|
# Initializes the local clone if it does not exist.
|
@@ -156,9 +233,34 @@ def git( command, wd = local_path, &block )
|
|
156
233
|
rc
|
157
234
|
end
|
158
235
|
|
236
|
+
def prepare_for_access
|
237
|
+
# If our server has an associated ssh-key, add it to the ssh-agent.
|
238
|
+
if config.remote[ config.track_remote ].server.sshkey
|
239
|
+
logger.info ""
|
240
|
+
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
|
241
|
+
MJ::Tools::SSH::add_key key.file
|
242
|
+
end
|
243
|
+
|
244
|
+
# Check that the remotes are the same as configured.
|
245
|
+
if checkedout?
|
246
|
+
gitconfig = repo.config
|
247
|
+
config.remote.each do |name, val|
|
248
|
+
if val.url and val.url != gitconfig["remote.#{name}.url"]
|
249
|
+
logger.info "#{config.module.name}: Setting remote.origin.url to #{val.url}"
|
250
|
+
gitconfig["remote.#{name}.url"] = val.url
|
251
|
+
end
|
252
|
+
if val.push_server and val.push_url != gitconfig["remote.#{name}.pushurl"]
|
253
|
+
logger.info "#{config.module.name}: Setting remote.origin.pushurl to #{val.push_url}"
|
254
|
+
gitconfig["remote.#{name}.pushurl"] = val.push_url
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
return true
|
259
|
+
end
|
260
|
+
|
159
261
|
def rebase
|
160
262
|
if 0 != ( git "rebase #{config.track_remote}/#{config.track_branch}" )
|
161
|
-
raise GitSvnError, "Error while rebasing the repo with
|
263
|
+
raise GitSvnError, "Error while rebasing the repo with `#{config.track_remote}/#{config.track_branch}': #{$?}"
|
162
264
|
end
|
163
265
|
end
|
164
266
|
|
data/lib/build-tool/vcs/svn.rb
CHANGED
@@ -4,9 +4,14 @@ module BuildTool; module VCS
|
|
4
4
|
|
5
5
|
class SvnConfiguration < BaseConfiguration
|
6
6
|
|
7
|
+
# The repository
|
8
|
+
attr_accessor :repository
|
9
|
+
|
7
10
|
def initialize
|
8
11
|
super
|
9
12
|
@only = nil
|
13
|
+
@repository = nil
|
14
|
+
@remote_path = nil
|
10
15
|
end
|
11
16
|
|
12
17
|
def name
|
@@ -29,6 +34,23 @@ def copy_configuration( other )
|
|
29
34
|
super
|
30
35
|
@only = nil # Do not copy nil
|
31
36
|
end
|
37
|
+
|
38
|
+
attr_writer :repository
|
39
|
+
def repository
|
40
|
+
if @repository.nil?
|
41
|
+
raise ConfigurationError, "No repository configured for module #{mod.name}."
|
42
|
+
end
|
43
|
+
@repository
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_writer :remote_path
|
47
|
+
def remote_path
|
48
|
+
if @remote_path.nil?
|
49
|
+
return @module.name
|
50
|
+
end
|
51
|
+
@remote_path
|
52
|
+
end
|
53
|
+
|
32
54
|
end
|
33
55
|
|
34
56
|
#
|
@@ -112,6 +134,26 @@ def last_changed_rev
|
|
112
134
|
return version
|
113
135
|
end
|
114
136
|
|
137
|
+
def prepare_for_access
|
138
|
+
# If our server has an associated ssh-key, add it to the ssh-agent.
|
139
|
+
if config.repository.sshkey
|
140
|
+
key = config.repository.sshkey
|
141
|
+
logger.info ""
|
142
|
+
logger.info "#### Adding required ssh-key #{key.file} to ssh-agent."
|
143
|
+
MJ::Tools::SSH::add_key key.file
|
144
|
+
end
|
145
|
+
true
|
146
|
+
end
|
147
|
+
|
148
|
+
def remote_path
|
149
|
+
@config.remote_path
|
150
|
+
end
|
151
|
+
|
152
|
+
def repository
|
153
|
+
config.repository
|
154
|
+
end
|
155
|
+
|
156
|
+
|
115
157
|
# Call svn with command
|
116
158
|
def svn( command, wd = local_path, &block )
|
117
159
|
self.class.svn( command, wd, &block )
|
data/lib/mj/visitor.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: build-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Jansen
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
M3zOaQdtTmiQPBqNIsE=
|
32
32
|
-----END CERTIFICATE-----
|
33
33
|
|
34
|
-
date: 2011-02-
|
34
|
+
date: 2011-02-07 00:00:00 +01:00
|
35
35
|
default_executable:
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -197,8 +197,6 @@ files:
|
|
197
197
|
- lib/build-tool/cfg/node.rb
|
198
198
|
- lib/build-tool/cfg/parser.y
|
199
199
|
- lib/build-tool/cfg/visitor.rb
|
200
|
-
- lib/build-tool/cfg/parser.rb
|
201
|
-
- lib/build-tool/cfg/lexer.rb
|
202
200
|
- lib/build-tool/command_actions.rb
|
203
201
|
- lib/build-tool/commands.rb
|
204
202
|
- lib/build-tool/commands/build.rb
|
metadata.gz.sig
CHANGED
Binary file
|