build-tool 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/History.txt +28 -1
- data/Manifest.txt +91 -52
- data/README.txt +63 -0
- data/Rakefile +20 -23
- data/bin/build-tool +53 -0
- data/lib/build-tool.rb +7 -0
- data/lib/build-tool/GUI.rb +360 -0
- data/lib/build-tool/application.rb +84 -0
- data/lib/build-tool/build-system/autoconf.rb +60 -0
- data/lib/build-tool/build-system/base.rb +142 -0
- data/lib/build-tool/build-system/cmake.rb +119 -0
- data/lib/build-tool/build-system/custom.rb +115 -0
- data/lib/build-tool/build-system/qt.rb +113 -0
- data/lib/build-tool/cfg/lexer.rb +558 -0
- data/lib/build-tool/cfg/lexer.rex +248 -0
- data/lib/build-tool/cfg/lexer_base.rb +82 -0
- data/lib/build-tool/cfg/node.rb +94 -0
- data/lib/build-tool/cfg/parser.rb +871 -0
- data/lib/build-tool/cfg/parser.y +279 -0
- data/lib/build-tool/cfg/visitor.rb +471 -0
- data/lib/build-tool/commands.rb +639 -0
- data/lib/build-tool/commands/build.rb +120 -0
- data/lib/build-tool/commands/configure.rb +73 -0
- data/lib/build-tool/commands/ctags.rb +46 -0
- data/lib/build-tool/commands/environments.rb +29 -0
- data/lib/build-tool/commands/environments/list.rb +37 -0
- data/lib/build-tool/commands/environments/set.rb +33 -0
- data/lib/build-tool/commands/fetch.rb +50 -0
- data/lib/build-tool/commands/files.rb +73 -0
- data/lib/build-tool/commands/help.rb +22 -0
- data/lib/build-tool/commands/info.rb +48 -0
- data/lib/build-tool/commands/install.rb +56 -0
- data/lib/build-tool/commands/modules.rb +29 -0
- data/lib/build-tool/commands/modules/info.rb +75 -0
- data/lib/build-tool/commands/modules/list.rb +49 -0
- data/lib/build-tool/commands/modules/shell.rb +40 -0
- data/lib/build-tool/commands/rebase.rb +46 -0
- data/lib/build-tool/commands/recipes.rb +32 -0
- data/lib/build-tool/commands/recipes/info.rb +46 -0
- data/lib/build-tool/commands/recipes/install.rb +184 -0
- data/lib/build-tool/commands/recipes/list.rb +33 -0
- data/lib/build-tool/configuration.rb +115 -0
- data/lib/build-tool/environment.rb +119 -0
- data/lib/build-tool/errors.rb +9 -0
- data/lib/build-tool/module.rb +366 -0
- data/lib/build-tool/pluginbase.rb +43 -0
- data/lib/build-tool/recipe.rb +180 -0
- data/lib/build-tool/repository.rb +59 -0
- data/lib/build-tool/server.rb +43 -0
- data/lib/build-tool/singleton.rb +50 -0
- data/lib/build-tool/sshkey.rb +22 -0
- data/lib/build-tool/vcs/base.rb +105 -0
- data/lib/build-tool/vcs/git-svn.rb +154 -0
- data/lib/build-tool/vcs/git.rb +187 -0
- data/lib/build-tool/vcs/svn.rb +136 -0
- data/lib/mj/logging.rb +31 -0
- data/lib/mj/tools/ssh.rb +64 -0
- data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
- data/lib/mj/visitor.rb +21 -0
- data/recipes/kde/files/finish_installation.sh +16 -0
- data/recipes/kde/files/kde4.desktop +22 -0
- data/recipes/kde/files/xsession +89 -0
- data/recipes/kde/info.yaml +10 -0
- data/recipes/kde/recipe +585 -0
- data/recipes/kde/recipe-local +90 -0
- data/recipes/kde/settings.yaml +52 -0
- data/recipes/kde43/info.yaml +10 -0
- data/recipes/kde43/recipe +256 -0
- data/recipes/kde43/recipe-local +90 -0
- data/recipes/kde43/settings.yaml +32 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
- data/recipes/kdeqt4.6/info.yaml +7 -0
- data/recipes/kdeqt4.6/recipe +155 -0
- data/recipes/kdeqt4.6/recipe-local +30 -0
- data/recipes/kdeqt4.6/settings.yaml +27 -0
- data/tags +745 -0
- data/tasks/genfiles.rake +28 -0
- data/tasks/rdoc.rake +34 -0
- data/tasks/rspec.rake +21 -0
- data/test.rb +28 -0
- data/test/commands/test_build.rb +29 -0
- data/test/test_build_system.rb +98 -0
- data/test/test_cli.rb +61 -0
- data/test/test_command.rb +175 -0
- data/test/test_configuration_parser.rb +542 -0
- data/test/test_environment.rb +82 -0
- data/test/test_helper.rb +39 -7
- data/test/test_module.rb +158 -0
- data/test/test_repository.rb +75 -0
- data/test/test_singleton.rb +51 -0
- data/test/test_ssh_key.rb +14 -0
- data/test/test_svn_parser.rb +28 -0
- data/test/test_vcs.rb +33 -0
- metadata +139 -90
- metadata.gz.sig +0 -0
- data/PostInstall.txt +0 -3
- data/TODO +0 -2
- data/bin/kde-build.rb +0 -21
- data/config/website.yml +0 -2
- data/config/website.yml.sample +0 -2
- data/lib/kde-build.rb +0 -18
- data/lib/kde-build/application.rb +0 -270
- data/lib/kde-build/build_system.rb +0 -28
- data/lib/kde-build/build_system/autoconf.rb +0 -108
- data/lib/kde-build/build_system/base.rb +0 -139
- data/lib/kde-build/build_system/cmake.rb +0 -94
- data/lib/kde-build/build_system/qtcopy.rb +0 -127
- data/lib/kde-build/command.rb +0 -42
- data/lib/kde-build/command/build.rb +0 -106
- data/lib/kde-build/command/compile.rb +0 -39
- data/lib/kde-build/command/configure.rb +0 -48
- data/lib/kde-build/command/ctags.rb +0 -41
- data/lib/kde-build/command/fetch.rb +0 -33
- data/lib/kde-build/command/help.rb +0 -71
- data/lib/kde-build/command/info.rb +0 -45
- data/lib/kde-build/command/install.rb +0 -39
- data/lib/kde-build/command/module_based.rb +0 -44
- data/lib/kde-build/command/rebase.rb +0 -50
- data/lib/kde-build/command/version.rb +0 -43
- data/lib/kde-build/configuration.rb +0 -209
- data/lib/kde-build/exception.rb +0 -6
- data/lib/kde-build/metaaid.rb +0 -18
- data/lib/kde-build/module.rb +0 -227
- data/lib/kde-build/module_configuration.rb +0 -107
- data/lib/kde-build/moduleregistry.rb +0 -85
- data/lib/kde-build/tools/ctags.rb +0 -59
- data/lib/kde-build/tools/logging.rb +0 -49
- data/lib/kde-build/tools/make.rb +0 -58
- data/lib/kde-build/tools/ssh.rb +0 -47
- data/lib/kde-build/vcs.rb +0 -28
- data/lib/kde-build/vcs/base.rb +0 -85
- data/lib/kde-build/vcs/git-svn.rb +0 -139
- data/lib/kde-build/vcs/git.rb +0 -121
- data/lib/kde-build/vcs/svn.rb +0 -102
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -71
- data/test.yaml.tmpl +0 -632
- data/test/test_kde-build.rb +0 -11
- data/test/test_vcs_svn.rb +0 -44
- data/website/index.html +0 -84
- data/website/index.txt +0 -59
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -159
- data/website/template.html.erb +0 -50
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'build-tool/errors'
|
2
|
+
|
3
|
+
module BuildTool
|
4
|
+
|
5
|
+
# Encapsulates a source code repository.
|
6
|
+
class Repository
|
7
|
+
|
8
|
+
# Repository name
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
# The server this repository is hosted
|
12
|
+
attr_accessor :server
|
13
|
+
|
14
|
+
# The relative path on the server
|
15
|
+
attr_accessor :path
|
16
|
+
|
17
|
+
# The relative path on the server
|
18
|
+
attr_accessor :user
|
19
|
+
|
20
|
+
# The associated ssh-key
|
21
|
+
attr_accessor :sshkey
|
22
|
+
|
23
|
+
# Create a repository
|
24
|
+
def initialize(name)
|
25
|
+
if name.nil?
|
26
|
+
raise StandardError, "The repository name has to be set"
|
27
|
+
end
|
28
|
+
@name = name
|
29
|
+
@server = nil
|
30
|
+
@sshkey = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def url
|
34
|
+
if !server
|
35
|
+
raise ConfigurationError, "No server specified for repository #{name}"
|
36
|
+
end
|
37
|
+
if !server.host
|
38
|
+
raise ConfigurationError, "No host specified for rserver #{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
|
+
end # class Repository
|
58
|
+
|
59
|
+
end # module BuildTool
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BuildTool
|
2
|
+
|
3
|
+
class Server
|
4
|
+
|
5
|
+
# The host this repository is hosted
|
6
|
+
attr_accessor :host
|
7
|
+
|
8
|
+
# Repository name
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
# The relative path on the server
|
12
|
+
attr_accessor :path
|
13
|
+
|
14
|
+
# The protocol used to access the repository
|
15
|
+
attr_accessor :protocol
|
16
|
+
|
17
|
+
# Create a repository
|
18
|
+
def initialize(name)
|
19
|
+
if name.nil?
|
20
|
+
raise StandardError, "The server name has to be set"
|
21
|
+
end
|
22
|
+
@name = name
|
23
|
+
end
|
24
|
+
|
25
|
+
def url
|
26
|
+
if !host
|
27
|
+
raise ConfigurationError, "No host specified for server #{name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
url = host
|
31
|
+
if protocol
|
32
|
+
url = "#{protocol}://#{url}"
|
33
|
+
end
|
34
|
+
if path
|
35
|
+
url = "#{url}/#{path}"
|
36
|
+
end
|
37
|
+
url
|
38
|
+
end
|
39
|
+
|
40
|
+
end # class Server
|
41
|
+
|
42
|
+
|
43
|
+
end # module BuildTool
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module BuildTool
|
2
|
+
|
3
|
+
class Singleton
|
4
|
+
|
5
|
+
def self.inherited( child )
|
6
|
+
if child.superclass == Singleton
|
7
|
+
child.class_eval <<-EOS
|
8
|
+
def self.instance; instance_variable_get( "@instance" ); end
|
9
|
+
def self.instance=( x ); instance_variable_set( "@instance", x ); end
|
10
|
+
EOS
|
11
|
+
else
|
12
|
+
child.class_eval <<-EOS
|
13
|
+
def self.instance; superclass.instance; end
|
14
|
+
def self.instance=( x ); superclass.instance = x; end
|
15
|
+
EOS
|
16
|
+
end
|
17
|
+
child.instance_variable_set( "@instance", nil )
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
if !self.class.instance.nil?
|
22
|
+
raise StandardError, "More than one instance of #{self.class} created!"
|
23
|
+
end
|
24
|
+
self.class.instance = self
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def self.instance
|
29
|
+
raise StandardError, "No instance of #{self} created"
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
cls = self.class
|
34
|
+
while cls.superclass != Singleton
|
35
|
+
cls = cls.superclass
|
36
|
+
end
|
37
|
+
cls.instance = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def instance
|
41
|
+
cls = self.class
|
42
|
+
while cls.superclass != Singleton
|
43
|
+
cls = cls.superclass
|
44
|
+
end
|
45
|
+
cls.instance
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end # module BuildTool
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BuildTool
|
2
|
+
#
|
3
|
+
# Encapsulates a ssh key
|
4
|
+
#
|
5
|
+
class SshKey
|
6
|
+
|
7
|
+
def initialize(name, file = nil)
|
8
|
+
@name = name
|
9
|
+
@file = file
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
attr_accessor :file
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
@file
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class SshKey
|
21
|
+
|
22
|
+
end # module BuildTool
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'mj/tools/subprocess.rb'
|
2
|
+
|
3
|
+
require 'build-tool/errors'
|
4
|
+
|
5
|
+
module BuildTool; module VCS
|
6
|
+
|
7
|
+
class BaseConfiguration
|
8
|
+
|
9
|
+
attr_reader :module
|
10
|
+
|
11
|
+
def initialize( mod = nil )
|
12
|
+
@module = mod
|
13
|
+
end
|
14
|
+
|
15
|
+
def remote_path
|
16
|
+
@module.remote_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def repository
|
20
|
+
@module.repository
|
21
|
+
end
|
22
|
+
|
23
|
+
def local_path
|
24
|
+
@module.source_directory
|
25
|
+
end
|
26
|
+
|
27
|
+
def module
|
28
|
+
@module
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Base class for Version Control System implementations
|
35
|
+
#
|
36
|
+
class Base
|
37
|
+
|
38
|
+
class VcsError < BuildTool::Error; end
|
39
|
+
|
40
|
+
include MJ::Tools::SubProcess
|
41
|
+
|
42
|
+
# # Create a repository
|
43
|
+
def initialize( config )
|
44
|
+
@config = config
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
### ATTRIBUTES
|
49
|
+
#
|
50
|
+
attr_reader :config
|
51
|
+
|
52
|
+
def local_path
|
53
|
+
local_path = @config.local_path
|
54
|
+
raise ConfigurationError, "#{self.class}.local_path not set" if local_path.nil?
|
55
|
+
local_path
|
56
|
+
end
|
57
|
+
|
58
|
+
def remote_path
|
59
|
+
remote_path = @config.remote_path
|
60
|
+
raise ConfigurationError, "#{self.class}.remote_path not set" if remote_path.nil?
|
61
|
+
remote_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def repository
|
65
|
+
repository = @config.repository
|
66
|
+
raise ConfigurationError, "#{self.class}.repository not set" if repository.nil?
|
67
|
+
repository
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
### METHODS
|
72
|
+
#
|
73
|
+
|
74
|
+
# checks if path exists and is a directory
|
75
|
+
def local_path_exist?
|
76
|
+
!local_path.nil? and File.exist? local_path and File.directory? local_path
|
77
|
+
end
|
78
|
+
|
79
|
+
def configure
|
80
|
+
logger.debug "VCS #{name} did not implement configure!"
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
### VIRTUAL FUNCTIONS
|
85
|
+
#
|
86
|
+
for method in [
|
87
|
+
:checkedout?,
|
88
|
+
:clone,
|
89
|
+
:fetch,
|
90
|
+
:name ,
|
91
|
+
:rebase,
|
92
|
+
:fetching_supported?,
|
93
|
+
:[]=,
|
94
|
+
:[]
|
95
|
+
] do
|
96
|
+
class_eval <<-EOS
|
97
|
+
def #{method}
|
98
|
+
raise NotImplementedError, "Method #{method} is not implemented for class #{self}"
|
99
|
+
end
|
100
|
+
EOS
|
101
|
+
end
|
102
|
+
|
103
|
+
end # class Base
|
104
|
+
|
105
|
+
end; end # module BuildTool::VCS
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'build-tool/vcs/svn'
|
2
|
+
require 'build-tool/vcs/git'
|
3
|
+
|
4
|
+
module BuildTool; module VCS
|
5
|
+
|
6
|
+
|
7
|
+
class GitSvnConfiguration < GitConfiguration
|
8
|
+
|
9
|
+
def name
|
10
|
+
"git-svn"
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :externals
|
14
|
+
|
15
|
+
def initialize( mod = nil )
|
16
|
+
super( mod )
|
17
|
+
@externals = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def vcs( mod )
|
21
|
+
@module = mod
|
22
|
+
GitSvn.new( self )
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_external( local, target )
|
26
|
+
@externals[local] = target
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Implementation for the git-svn version control system.
|
33
|
+
#
|
34
|
+
class GitSvn < Base
|
35
|
+
|
36
|
+
class GitSvnError < BuildTool::Error; end
|
37
|
+
|
38
|
+
def initialize( *args )
|
39
|
+
super( *args )
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
### ATTRIBUTES
|
44
|
+
#
|
45
|
+
def name
|
46
|
+
"git-svn"
|
47
|
+
end
|
48
|
+
|
49
|
+
def fetching_supported?
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
### METHOD
|
55
|
+
#
|
56
|
+
|
57
|
+
def checkedout?
|
58
|
+
return false if !local_path_exist?
|
59
|
+
if !Pathname.new( local_path ).join( ".git" ).exist?
|
60
|
+
raise Base::VcsError, "Checkout path #{local_path} is not a git repo!"
|
61
|
+
end
|
62
|
+
return true
|
63
|
+
end
|
64
|
+
|
65
|
+
def clone
|
66
|
+
if local_path_exist?
|
67
|
+
raise GitSvnError, "Failed to create repository at '#{local_path}': Path exists"
|
68
|
+
end
|
69
|
+
# Create the directory
|
70
|
+
FileUtils.mkdir_p( local_path ) if !$noop
|
71
|
+
# Init the repository
|
72
|
+
if 0 != ( git_svn "init #{repository.url}/#{remote_path}" )
|
73
|
+
raise GitSvnError, "Error while initializing the repo `git svn init '#{repository}/#{remote_path}'`: #{$?}"
|
74
|
+
end
|
75
|
+
fetch( "HEAD" )
|
76
|
+
end
|
77
|
+
|
78
|
+
def configure
|
79
|
+
git.configure
|
80
|
+
end
|
81
|
+
|
82
|
+
# Fetch from +repository+
|
83
|
+
#
|
84
|
+
# Initializes the local clone if it does not exist.
|
85
|
+
def fetch( revision = nil )
|
86
|
+
if !checkedout? and !$noop # Beware of looping
|
87
|
+
clone
|
88
|
+
end
|
89
|
+
if revision
|
90
|
+
cmd = "fetch -r#{revision}"
|
91
|
+
else
|
92
|
+
cmd = "fetch"
|
93
|
+
end
|
94
|
+
if ( rc = git_svn( cmd ) ) != 0
|
95
|
+
raise GitSvnError, "Error while fetching: #{rc}"
|
96
|
+
end
|
97
|
+
update_externals
|
98
|
+
end
|
99
|
+
|
100
|
+
def git
|
101
|
+
if @git.nil?
|
102
|
+
@git = Git.new( config )
|
103
|
+
end
|
104
|
+
@git
|
105
|
+
end
|
106
|
+
|
107
|
+
# Call git-svn with command
|
108
|
+
def git_svn( command, wd = local_path, &block )
|
109
|
+
rc = self.class.execute( "git svn " + command, wd, &block )
|
110
|
+
if rc != 0
|
111
|
+
raise GitSvnError, "git svn #{command || "" } failed with error code #{rc}";
|
112
|
+
end
|
113
|
+
rc
|
114
|
+
end
|
115
|
+
|
116
|
+
def rebase
|
117
|
+
git.git( "rebase git-svn" )
|
118
|
+
end
|
119
|
+
|
120
|
+
def update_externals
|
121
|
+
config.externals.each do |local, remote|
|
122
|
+
VCS::Svn::svn( "checkout #{remote}@HEAD #{local}", wd = local_path )
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def[]( var )
|
127
|
+
case var
|
128
|
+
|
129
|
+
when 'external'
|
130
|
+
return @externals
|
131
|
+
|
132
|
+
else
|
133
|
+
# *TODO* raise correct exception
|
134
|
+
raise NotImplementedError, "#{var}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def[]=( var, val )
|
139
|
+
case var
|
140
|
+
|
141
|
+
when 'external'
|
142
|
+
tmp = val.split( /#/ )
|
143
|
+
@externals[tmp[0]] = tmp[1]
|
144
|
+
|
145
|
+
else
|
146
|
+
# *TODO* raise correct exception
|
147
|
+
raise NotImplementedError, "#{var}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end # class GitSvn
|
152
|
+
|
153
|
+
|
154
|
+
end; end # module BuildTool::VCS
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'build-tool/vcs/base'
|
2
|
+
require 'build-tool/errors'
|
3
|
+
|
4
|
+
module BuildTool; module VCS
|
5
|
+
|
6
|
+
class GitError < BuildTool::Error; end
|
7
|
+
|
8
|
+
class GitConfiguration < BaseConfiguration
|
9
|
+
|
10
|
+
def name
|
11
|
+
"git"
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :remote
|
15
|
+
|
16
|
+
def initialize( mod = nil )
|
17
|
+
super( mod )
|
18
|
+
@remote = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def vcs( mod )
|
22
|
+
@module = mod
|
23
|
+
Git.new( self )
|
24
|
+
end
|
25
|
+
|
26
|
+
def track_remote
|
27
|
+
rc = self.module.remote_path.split('/')
|
28
|
+
# If there is only one string we assume it is the branch name from
|
29
|
+
# origin
|
30
|
+
return "origin" if rc.length == 1
|
31
|
+
return rc[0]
|
32
|
+
end
|
33
|
+
|
34
|
+
def track_branch
|
35
|
+
rc = self.module.remote_path.split('/')
|
36
|
+
# If there is only one string we assume it is the branch name from
|
37
|
+
# origin
|
38
|
+
return rc[0] if rc.length == 1
|
39
|
+
return rc[1..-1].join( '/' )
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Implementation for the git version control system.
|
47
|
+
#
|
48
|
+
class Git < Base
|
49
|
+
|
50
|
+
def initialize( config )
|
51
|
+
super( config )
|
52
|
+
@remote = {}
|
53
|
+
@vcs = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
### ATTRIBUTES
|
58
|
+
#
|
59
|
+
def name
|
60
|
+
"git"
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetching_supported?
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
### METHODS
|
69
|
+
#
|
70
|
+
|
71
|
+
def checkedout?
|
72
|
+
return false if !local_path_exist?
|
73
|
+
if !Pathname.new( local_path ).join( ".git" ).exist?
|
74
|
+
raise Base::VcsError, "Checkout path #{local_path} is not a git repo!"
|
75
|
+
end
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Initialize the local repository
|
80
|
+
def clone
|
81
|
+
# Check if path exists
|
82
|
+
if local_path_exist?
|
83
|
+
raise GitError, "Failed to create repository at '#{local_path}': Path exists"
|
84
|
+
end
|
85
|
+
|
86
|
+
# Create the directory
|
87
|
+
FileUtils.mkdir_p( local_path ) if !$noop
|
88
|
+
|
89
|
+
# Initialize the repository
|
90
|
+
if git( "init", local_path ) != 0
|
91
|
+
raise GitError, "Error while initializing the repo `git init #{local_path}'`: #{$?}"
|
92
|
+
end
|
93
|
+
|
94
|
+
config.remote.each do |name, val|
|
95
|
+
if git( "remote add #{name} #{val.url}" ) != 0
|
96
|
+
raise GitError, "Error while initializing the repo `git remote add #{name} #{val.url}`: #{$?}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
cmd = "remote add origin #{repository.url}"
|
101
|
+
if git( cmd, local_path ) != 0
|
102
|
+
raise GitError, "Error while initializing the repo `#{cmd}`: #{$?}"
|
103
|
+
end
|
104
|
+
|
105
|
+
logger.info <<-EOS
|
106
|
+
The following command sometimes fails when issued from this script. Reason unknown. The
|
107
|
+
best chance you have is issuing the command manually!
|
108
|
+
#{local_path}: #{cmd}
|
109
|
+
#{local_path}: git checkout -b #{config.track_branch} #{config.track_remote}/#{config.track_branch}
|
110
|
+
EOS
|
111
|
+
|
112
|
+
fetch()
|
113
|
+
|
114
|
+
cmd = "checkout -b #{config.track_branch} #{config.track_remote}/#{config.track_branch}"
|
115
|
+
if git( cmd, local_path ) != 0
|
116
|
+
raise GitError, "Error while initializing the repo `#{cmd}`: #{$?}"
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
def remote?( name )
|
122
|
+
found = false
|
123
|
+
git( "remote" ) do |line|
|
124
|
+
found = true if line == name
|
125
|
+
end
|
126
|
+
return found
|
127
|
+
end
|
128
|
+
|
129
|
+
# Fetch from +repository+
|
130
|
+
#
|
131
|
+
# Initializes the local clone if it does not exist.
|
132
|
+
def fetch()
|
133
|
+
if !checkedout? and !$noop
|
134
|
+
clone
|
135
|
+
end
|
136
|
+
cmd = "fetch #{config.track_remote}"
|
137
|
+
if ( rc = git( cmd ) ) != 0
|
138
|
+
raise GitError, "Error while fetching: #{rc}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def git( command, wd = local_path, &block )
|
143
|
+
rc = self.class.execute "git #{command}", wd, &block
|
144
|
+
if rc != 0
|
145
|
+
raise GitError, "git #{command || "" } failed with error code #{rc}";
|
146
|
+
end
|
147
|
+
rc
|
148
|
+
end
|
149
|
+
|
150
|
+
def rebase
|
151
|
+
if 0 != ( git "rebase #{config.track_remote}/#{config.track_branch}" )
|
152
|
+
raise GitSvnError, "Error while rebasing the repo with `git rebase git-svn: #{$?}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end # class Git
|
157
|
+
|
158
|
+
class GitRemote
|
159
|
+
|
160
|
+
attr_accessor :server
|
161
|
+
attr_accessor :path
|
162
|
+
attr_reader :name
|
163
|
+
|
164
|
+
def initialize( name )
|
165
|
+
@name = name
|
166
|
+
@path = nil
|
167
|
+
end
|
168
|
+
|
169
|
+
def url
|
170
|
+
url = ""
|
171
|
+
if @server
|
172
|
+
url = @server.url
|
173
|
+
end
|
174
|
+
if @path
|
175
|
+
url = "#{url}/#{path}"
|
176
|
+
end
|
177
|
+
url
|
178
|
+
end
|
179
|
+
|
180
|
+
def to_s
|
181
|
+
"REMOTE: #{name} #{url}"
|
182
|
+
end
|
183
|
+
|
184
|
+
end # class Remote
|
185
|
+
|
186
|
+
end; end # module BuildTool::VCS
|
187
|
+
|