BuildMaster 1.1.9 → 1.1.12
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/lib/buildmaster/algorithms.rb +2 -2
- data/lib/buildmaster/auto.rb +27 -0
- data/lib/buildmaster/auto/classpath.rb +86 -0
- data/lib/buildmaster/auto/git.rb +38 -0
- data/lib/buildmaster/auto/java.rb +23 -0
- data/lib/buildmaster/auto/java_project.rb +185 -0
- data/lib/buildmaster/auto/javac_ant.rb +64 -0
- data/lib/buildmaster/auto/junit_ant.rb +226 -0
- data/lib/buildmaster/auto/mysql_server.rb +30 -0
- data/lib/buildmaster/auto/package_ant.rb +60 -0
- data/lib/buildmaster/auto/ruby_platform.rb +51 -0
- data/lib/buildmaster/common.rb +3 -3
- data/lib/buildmaster/cotta.rb +8 -3
- data/lib/buildmaster/cotta/command_runner.rb +19 -3
- data/lib/buildmaster/cotta/cotta.rb +42 -12
- data/lib/buildmaster/cotta/cotta_dir.rb +18 -14
- data/lib/buildmaster/cotta/cotta_file.rb +5 -8
- data/lib/buildmaster/cotta/in_memory_system.rb +15 -4
- data/lib/buildmaster/cotta/physical_system.rb +13 -7
- data/lib/buildmaster/project.rb +3 -9
- data/lib/buildmaster/project/ant_driver.rb +11 -7
- data/lib/buildmaster/project/ci.rb +2 -2
- data/lib/buildmaster/project/pscp_driver.rb +0 -4
- data/lib/buildmaster/project/ruby_forge_project.rb +0 -3
- data/lib/buildmaster/project/svn_admin_driver.rb +0 -4
- data/lib/buildmaster/project/svn_driver.rb +0 -6
- data/lib/buildmaster/project/svn_helper.rb +0 -6
- data/lib/buildmaster/project/svn_server_driver.rb +0 -5
- data/lib/buildmaster/project/windows/iis_driver.rb +0 -4
- data/lib/buildmaster/project/windows/sql_server_driver.rb +0 -1
- data/lib/buildmaster/site.rb +16 -4
- data/lib/buildmaster/site/about_handler.rb +0 -4
- data/lib/buildmaster/site/content_engine_repository.rb +0 -2
- data/lib/buildmaster/site/element_processor_by_name.rb +0 -4
- data/lib/buildmaster/site/file_processor.rb +0 -4
- data/lib/buildmaster/site/site.rb +0 -4
- data/lib/buildmaster/site/site_server.rb +1 -4
- data/lib/buildmaster/site/site_spec.rb +4 -15
- data/lib/buildmaster/site/source_file_handler.rb +0 -3
- data/lib/buildmaster/site/template_error.rb +0 -2
- data/lib/buildmaster/site/template_runner.rb +0 -4
- data/lib/buildmaster/site/templatelets.rb +9 -10
- data/lib/buildmaster/site/templatelets/href.rb +0 -5
- data/lib/buildmaster/site/templatelets/when.rb +0 -4
- data/lib/buildmaster/site/xtemplate.rb +0 -3
- data/lib/buildmaster/version +1 -1
- data/lib/buildmaster/win32/auto_it.rb +4 -0
- data/lib/buildmaster/win32/auto_it_driver.rb +45 -0
- data/lib/buildmaster/win32/auto_it_window.rb +82 -0
- data/lib/buildmaster/win32/autoit/AutoItX3.dll +0 -0
- data/lib/buildmaster/win32/autoit/README +1 -0
- data/lib/buildmaster/windows.rb +3 -3
- data/test/buildmaster/algorithms/tc_opn_compare.rb +2 -2
- data/test/buildmaster/auto/javac/src/org/rubyforge/buildmaster/javac/One.java +5 -0
- data/test/buildmaster/auto/javac/src/resource.txt +1 -0
- data/test/buildmaster/auto/javac/src2/org/rubyforge/buildmaster/javac/Two.java +9 -0
- data/test/buildmaster/auto/tc_classpath.rb +79 -0
- data/test/buildmaster/auto/tc_git.rb +32 -0
- data/test/buildmaster/auto/tc_java.rb +12 -0
- data/test/buildmaster/auto/tc_java_project.rb +78 -0
- data/test/buildmaster/auto/tc_java_project_slow.rb +89 -0
- data/test/buildmaster/auto/tc_javac_ant.rb +38 -0
- data/test/buildmaster/auto/tc_junit_ant.rb +187 -0
- data/test/buildmaster/auto/tc_package_ant.rb +29 -0
- data/test/buildmaster/auto/tc_ruby_platform.rb +10 -0
- data/test/buildmaster/common/tc_properties.rb +1 -3
- data/test/buildmaster/common/tc_tree_to_object.rb +1 -3
- data/test/buildmaster/cotta/cotta_dir_behaviors.rb +46 -8
- data/test/buildmaster/cotta/cotta_file_behaviors.rb +6 -6
- data/test/buildmaster/cotta/cotta_specifications.rb +1 -6
- data/test/buildmaster/cotta/file_system_behaviors.rb +1 -3
- data/test/buildmaster/cotta/physical_system_stub.rb +22 -3
- data/test/buildmaster/cotta/system_file_specifications.rb +1 -3
- data/test/buildmaster/cotta/tc_command_interface.rb +1 -3
- data/test/buildmaster/cotta/tc_command_runner.rb +1 -4
- data/test/buildmaster/cotta/tc_cotta.rb +5 -8
- data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +6 -9
- data/test/buildmaster/cotta/tc_cotta_dir_physical.rb +3 -6
- data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +3 -7
- data/test/buildmaster/cotta/tc_cotta_file_physical.rb +4 -4
- data/test/buildmaster/cotta/tc_cotta_zip_support.rb +1 -5
- data/test/buildmaster/cotta/tc_in_memory_system.rb +3 -7
- data/test/buildmaster/cotta/tc_io_chain.rb +3 -8
- data/test/buildmaster/cotta/tc_pathname.rb +1 -3
- data/test/buildmaster/cotta/tc_physical_system.rb +7 -8
- data/test/buildmaster/project/tc_ant_driver.rb +1 -4
- data/test/buildmaster/project/tc_build_number_file.rb +1 -6
- data/test/buildmaster/project/tc_cvs_driver.rb +1 -5
- data/test/buildmaster/project/tc_java_manifest.rb +1 -5
- data/test/buildmaster/project/tc_release.rb +1 -3
- data/test/buildmaster/project/tc_server_manager.rb +1 -4
- data/test/buildmaster/project/tc_svn_driver.rb +1 -5
- data/test/buildmaster/project/tc_svn_status_info.rb +1 -3
- data/test/buildmaster/project/tc_version_number_file.rb +1 -6
- data/test/buildmaster/project/windows/tc_iis_driver.rb +2 -3
- data/test/buildmaster/project/windows/tc_sql_server_driver.rb +2 -5
- data/test/buildmaster/site/content/tc_content_engine_repository.rb +1 -5
- data/test/buildmaster/site/tc_element_processor_by_name.rb +1 -4
- data/test/buildmaster/site/tc_file_processor.rb +1 -7
- data/test/buildmaster/site/tc_site.rb +1 -6
- data/test/buildmaster/site/tc_site_server.rb +2 -8
- data/test/buildmaster/site/tc_site_spec.rb +8 -5
- data/test/buildmaster/site/tc_source_file_handler.rb +1 -4
- data/test/buildmaster/site/tc_template_builder.rb +1 -4
- data/test/buildmaster/site/tc_template_error.rb +1 -3
- data/test/buildmaster/site/tc_template_runner.rb +2 -7
- data/test/buildmaster/site/tc_templatelets.rb +2 -6
- data/test/buildmaster/site/tc_xtemplate.rb +1 -5
- data/test/buildmaster/site/templatelets/common_templatelet_test.rb +1 -8
- data/test/buildmaster/site/templatelets/tc_attribute.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_code.rb +2 -2
- data/test/buildmaster/site/templatelets/tc_each.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_href.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_include.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_link.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_text.rb +3 -3
- data/test/buildmaster/site/templatelets/tc_when.rb +4 -4
- data/test/buildmaster/site/test.rb +1 -0
- data/test/buildmaster/test.rb +21 -0
- data/test/buildmaster/win32/tc_auto_it.rb +18 -0
- data/test/buildmaster/win32/tc_auto_it_window.rb +17 -0
- data/test/manual/bms.rb +2 -4
- data/test/tmp/svn_test/repository/conf/authz +14 -3
- data/test/tmp/svn_test/repository/conf/svnserve.conf +21 -4
- data/test/tmp/svn_test/repository/db/current +1 -1
- data/test/tmp/svn_test/repository/db/format +2 -1
- data/test/tmp/svn_test/repository/db/revprops/0/0 +5 -0
- data/test/tmp/svn_test/repository/db/revprops/{1 → 0/1} +1 -1
- data/test/tmp/svn_test/repository/db/revprops/{2 → 0/2} +1 -1
- data/test/tmp/svn_test/repository/db/revprops/{3 → 0/3} +1 -1
- data/test/tmp/svn_test/repository/db/revprops/{4 → 0/4} +1 -1
- data/test/tmp/svn_test/repository/db/revs/{0 → 0/0} +0 -0
- data/test/tmp/svn_test/repository/db/revs/0/1 +25 -0
- data/test/tmp/svn_test/repository/db/revs/{2 → 0/2} +9 -9
- data/test/tmp/svn_test/repository/db/revs/0/3 +33 -0
- data/test/tmp/svn_test/repository/db/revs/{4 → 0/4} +0 -0
- data/test/tmp/svn_test/repository/db/txn-current +1 -0
- data/{lib/buildmaster/project/java/class_path.rb → test/tmp/svn_test/repository/db/txn-current-lock} +0 -0
- data/test/tmp/svn_test/repository/db/uuid +1 -1
- data/test/tmp/svn_test/repository/hooks/post-revprop-change.tmpl +1 -1
- data/test/tmp/svn_test/repository/hooks/pre-unlock.tmpl +1 -0
- data/test/tmp/svn_test/repository/hooks/start-commit.tmpl +13 -2
- data/test/ts_buildmaster.rb +2 -2
- metadata +100 -46
- data/lib/buildmaster/project/java.rb +0 -4
- data/lib/buildmaster/project/java/javac.rb +0 -9
- data/test/tmp/svn_test/repository/db/revprops/0 +0 -5
- data/test/tmp/svn_test/repository/db/revs/1 +0 -25
- data/test/tmp/svn_test/repository/db/revs/3 +0 -33
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module BuildMaster
|
|
2
|
+
# MySQL server driver to manage the MySQL server
|
|
3
|
+
class MySqlServer
|
|
4
|
+
# Given a CottaDirectory to the mysql home directory, creates an instance
|
|
5
|
+
def initialize(home)
|
|
6
|
+
@home = home
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# starts the MySQL server
|
|
10
|
+
def start
|
|
11
|
+
['INT', 'TERM'].each { |signal|
|
|
12
|
+
trap(signal){ stop}
|
|
13
|
+
}
|
|
14
|
+
run('--console')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def stop(username = 'root', password = nil)
|
|
18
|
+
exe = RubyPlatform.locate_execution_file!(@home, 'bin/mysqladmin')
|
|
19
|
+
password_option = ' '
|
|
20
|
+
password_option = " -p #{password}" if password
|
|
21
|
+
@home.cotta.start("#{exe} -u #{username}#{password_option} shutdown")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# runs mysqld with provided argument
|
|
25
|
+
def run(*argv)
|
|
26
|
+
exe = RubyPlatform.locate_execution_file!(@home, 'bin/mysqld')
|
|
27
|
+
@home.cotta.start("#{exe} #{argv.join(' ')}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module BuildMaster
|
|
2
|
+
class PackageAnt
|
|
3
|
+
attr_accessor :manifest
|
|
4
|
+
|
|
5
|
+
def initialize(dir, name)
|
|
6
|
+
@jar = dir.file("#{name}.jar")
|
|
7
|
+
@zip = dir.file("#{name}-src.zip")
|
|
8
|
+
@classes = []
|
|
9
|
+
@sources = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def target
|
|
13
|
+
'package-ant'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add(class_root, source_root = nil)
|
|
17
|
+
@classes.push class_root
|
|
18
|
+
@sources.push source_root unless source_root.nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def build_file
|
|
22
|
+
file = @jar.parent.file('package-ant.xml')
|
|
23
|
+
file.write do |f|
|
|
24
|
+
f.puts <<CONTENT
|
|
25
|
+
<!-- ANT file generated by buildmaste PackageAnt -->
|
|
26
|
+
<project name="#{target}" default="#{target}">
|
|
27
|
+
<target name="#{target}">
|
|
28
|
+
<jar destfile="#{@jar}"#{manifest_attribute}>
|
|
29
|
+
#{fileset_elements(@classes)} </jar>
|
|
30
|
+
<zip destfile="#{@zip}">
|
|
31
|
+
#{fileset_elements(@sources)} </zip>
|
|
32
|
+
</target>
|
|
33
|
+
</project>
|
|
34
|
+
CONTENT
|
|
35
|
+
end
|
|
36
|
+
file
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def run
|
|
40
|
+
@jar.parent.mkdirs
|
|
41
|
+
AntDriver.from_file(build_file).target(target)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
def fileset_elements(dirs)
|
|
46
|
+
buffer = StringIO.new
|
|
47
|
+
dirs.each {|dir| buffer << " <fileset dir=\"#{dir}\"/>\n"}
|
|
48
|
+
buffer.string
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def manifest_attribute
|
|
52
|
+
if (manifest.nil?)
|
|
53
|
+
''
|
|
54
|
+
else
|
|
55
|
+
" manifest=\"#{manifest}\""
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module BuildMaster
|
|
2
|
+
# A utiliy class that helps figuring out the right file name
|
|
3
|
+
# by OS based on RUBY_PLATFORM
|
|
4
|
+
class RubyPlatform
|
|
5
|
+
# Returns the current OS, the values can be ':windows', ':unix'
|
|
6
|
+
# Note: linux, unix and mac are treated the same at this level, and cygwin is
|
|
7
|
+
# considered windows because the executables are still in windows naming convention
|
|
8
|
+
def self.os
|
|
9
|
+
value = nil
|
|
10
|
+
if RUBY_PLATFORM =~ /[^r]win/
|
|
11
|
+
value = :windows
|
|
12
|
+
else
|
|
13
|
+
value = :unix
|
|
14
|
+
end
|
|
15
|
+
value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the execution file name, for windows this will be
|
|
19
|
+
# with 'exe' extension or 'bat', for linux this will be with no extension
|
|
20
|
+
# or with 'sh' extension. If file is not found, this will return null
|
|
21
|
+
def self.locate_execution_file(dir, path)
|
|
22
|
+
file = dir.file(path)
|
|
23
|
+
if (not file.exists?)
|
|
24
|
+
os_value = os
|
|
25
|
+
if (:windows == os_value)
|
|
26
|
+
file = dir.file("#{path}.exe")
|
|
27
|
+
if (not file.exists?)
|
|
28
|
+
file = dir.file("#{path}.bat")
|
|
29
|
+
end
|
|
30
|
+
if (not file.exists?)
|
|
31
|
+
file = nil
|
|
32
|
+
end
|
|
33
|
+
else
|
|
34
|
+
file = dir.file("#{path}.sh")
|
|
35
|
+
if (not file.exists?)
|
|
36
|
+
file = nil
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
file
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Same as locate_execution_file except this will throw an error if
|
|
44
|
+
# file is not found
|
|
45
|
+
def self.locate_execution_file!(dir, path)
|
|
46
|
+
file = locate_execution_file(dir, path)
|
|
47
|
+
raise "No suitable execution file found under #{dir} using #{path}" unless file
|
|
48
|
+
file
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
data/lib/buildmaster/common.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
require 'properties'
|
|
3
|
-
require 'tree_to_object'
|
|
1
|
+
dir = File.dirname(__FILE__) + '/common'
|
|
2
|
+
require dir + '/properties'
|
|
3
|
+
require dir + '/tree_to_object'
|
data/lib/buildmaster/cotta.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
dir = File.dirname(__FILE__)
|
|
2
2
|
|
|
3
|
-
require 'cotta/cotta'
|
|
4
|
-
require 'cotta/
|
|
3
|
+
require dir + '/cotta/cotta'
|
|
4
|
+
require dir + '/cotta/in_memory_system'
|
|
5
|
+
require dir + '/cotta/io_chain'
|
|
6
|
+
require dir + '/cotta/file_not_found_error'
|
|
7
|
+
require dir + '/cotta/command_runner'
|
|
8
|
+
require dir + '/cotta/command_error'
|
|
9
|
+
require dir + '/cotta/command_interface'
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
=begin
|
|
2
|
+
if RUBY_PLATFORM =~ /mswin|mingw/
|
|
3
|
+
begin
|
|
4
|
+
require 'win32/open3'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
warn "You must 'gem install win32-open3' to use buildmaster on Windows"
|
|
7
|
+
exit 1
|
|
8
|
+
end
|
|
9
|
+
else
|
|
10
|
+
require 'open3'
|
|
11
|
+
end
|
|
12
|
+
=end
|
|
4
13
|
|
|
5
14
|
module BuildMaster
|
|
15
|
+
|
|
16
|
+
# Command runner
|
|
6
17
|
class CommandRunner
|
|
7
18
|
attr_reader :outputs
|
|
8
19
|
|
|
@@ -10,6 +21,11 @@ class CommandRunner
|
|
|
10
21
|
@command = command
|
|
11
22
|
end
|
|
12
23
|
|
|
24
|
+
# executs the command. If a closure is
|
|
25
|
+
# given, it will be called with the io to the process
|
|
26
|
+
# If not, it will print out the log pre-fixed with a random number for the process,
|
|
27
|
+
# collects the output and return the output when the process finishes.
|
|
28
|
+
# This method will also raise CommandError if the process fails.
|
|
13
29
|
def execute
|
|
14
30
|
id = rand(10000)
|
|
15
31
|
puts "[#{id}]$> #{@command}"
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
dir = File.dirname(__FILE__)
|
|
2
2
|
|
|
3
|
-
require 'physical_system'
|
|
4
|
-
require 'cotta_dir'
|
|
5
|
-
require 'cotta_file'
|
|
6
3
|
require 'pathname'
|
|
7
|
-
require '
|
|
8
|
-
require '
|
|
4
|
+
require dir + '/physical_system'
|
|
5
|
+
require dir + '/io_chain'
|
|
6
|
+
require dir + '/cotta_dir'
|
|
7
|
+
require dir + '/cotta_file'
|
|
8
|
+
require dir + '/cotta_pathname'
|
|
9
|
+
require dir + '/command_interface'
|
|
9
10
|
|
|
10
11
|
module BuildMaster
|
|
12
|
+
|
|
13
|
+
# The file factory of Cotta files that handles creation of the CottaFile and CottaDirectory
|
|
14
|
+
# instances. This class also can be used to start command lines
|
|
11
15
|
class Cotta
|
|
12
16
|
attr_accessor :command_interface
|
|
13
17
|
|
|
@@ -16,10 +20,30 @@ class Cotta
|
|
|
16
20
|
@command_interface = CommandInterface.new
|
|
17
21
|
end
|
|
18
22
|
|
|
23
|
+
# Invoke the command line through the backing system
|
|
19
24
|
def shell(command_line, &block)
|
|
20
25
|
@system.shell(command_line, &block)
|
|
21
26
|
end
|
|
22
27
|
|
|
28
|
+
def pwd
|
|
29
|
+
dir(@system.pwd)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Starts the process. Unlike shell method, this method does not
|
|
33
|
+
# collect the output, thus suitable for starting a server in Ruby
|
|
34
|
+
# and leave it running for a long time
|
|
35
|
+
def start(command_line)
|
|
36
|
+
@system.shell(command_line) do |io|
|
|
37
|
+
if (block_given?)
|
|
38
|
+
yield io
|
|
39
|
+
else
|
|
40
|
+
while (line = io.gets)
|
|
41
|
+
puts line
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
23
47
|
def command_interface=(value)
|
|
24
48
|
if (value)
|
|
25
49
|
@command_interface = value
|
|
@@ -33,11 +57,13 @@ class Cotta
|
|
|
33
57
|
return CottaDir.new(@system, Pathname.new(path))
|
|
34
58
|
end
|
|
35
59
|
|
|
36
|
-
|
|
60
|
+
# Creates a CottDirectory with the PhysicalSystem
|
|
61
|
+
def self::dir(path)
|
|
37
62
|
return nil unless path
|
|
38
63
|
return Cotta.new.dir(File.expand_path(path))
|
|
39
64
|
end
|
|
40
65
|
|
|
66
|
+
# Creates a CottaFile with the PhysicalSystem
|
|
41
67
|
def file(path)
|
|
42
68
|
return nil unless path
|
|
43
69
|
return CottaFile.new(@system, Pathname.new(path))
|
|
@@ -57,13 +83,17 @@ class Cotta
|
|
|
57
83
|
return Cotta.file(path).parent
|
|
58
84
|
end
|
|
59
85
|
|
|
86
|
+
# Creates the entry given a path. This will return either
|
|
87
|
+
# CottaFile or CottaDirectory depending by checking the path
|
|
88
|
+
# passed in, which means that if neither a directory nor a file
|
|
89
|
+
# exists with this name it will raise an error
|
|
60
90
|
def entry(path)
|
|
61
|
-
|
|
62
|
-
unless (
|
|
63
|
-
|
|
64
|
-
raise "#{path} exists as niether file nor directory" unless
|
|
91
|
+
entry_instance = file(path)
|
|
92
|
+
unless (entry_instance.exists?)
|
|
93
|
+
entry_instance = dir(path)
|
|
94
|
+
raise "#{path} exists as niether file nor directory" unless entry_instance.exists?
|
|
65
95
|
end
|
|
66
|
-
return
|
|
96
|
+
return entry_instance
|
|
67
97
|
end
|
|
68
98
|
|
|
69
99
|
def environment!(variable)
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
require 'rubygems/package'
|
|
2
|
-
|
|
3
|
-
$:.unshift File.dirname(__FILE__)
|
|
4
|
-
|
|
5
|
-
require 'cotta_file'
|
|
6
|
-
require 'io_chain'
|
|
7
|
-
|
|
8
1
|
module BuildMaster
|
|
9
2
|
class CottaDir
|
|
10
3
|
include IoChain
|
|
@@ -45,7 +38,11 @@ class CottaDir
|
|
|
45
38
|
def parent
|
|
46
39
|
parent_path = @path.cotta_parent
|
|
47
40
|
return nil unless parent_path
|
|
48
|
-
|
|
41
|
+
candidate = CottaDir.new(@system, parent_path)
|
|
42
|
+
if (block_given?)
|
|
43
|
+
candidate = candidate.parent until candidate.nil? or yield candidate
|
|
44
|
+
end
|
|
45
|
+
candidate
|
|
49
46
|
end
|
|
50
47
|
|
|
51
48
|
def relative_path_from(entry)
|
|
@@ -68,10 +65,12 @@ class CottaDir
|
|
|
68
65
|
end
|
|
69
66
|
|
|
70
67
|
def delete
|
|
71
|
-
|
|
72
|
-
children
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
if (exists?)
|
|
69
|
+
list.each {|children|
|
|
70
|
+
children.delete
|
|
71
|
+
}
|
|
72
|
+
@system.delete_dir(@path)
|
|
73
|
+
end
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
def move_to(target)
|
|
@@ -89,6 +88,7 @@ class CottaDir
|
|
|
89
88
|
end
|
|
90
89
|
|
|
91
90
|
def archive(target = nil, &block)
|
|
91
|
+
require 'rubygems/package'
|
|
92
92
|
unless target
|
|
93
93
|
target = parent.file("#{name}.tar")
|
|
94
94
|
end
|
|
@@ -135,6 +135,10 @@ class CottaDir
|
|
|
135
135
|
candidate
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
|
+
|
|
139
|
+
def chdir(&block)
|
|
140
|
+
@system.chdir(@path, &block)
|
|
141
|
+
end
|
|
138
142
|
|
|
139
143
|
def ==(other)
|
|
140
144
|
return @path == other.path && @system == other.system
|
|
@@ -145,8 +149,8 @@ class CottaDir
|
|
|
145
149
|
end
|
|
146
150
|
|
|
147
151
|
def to_s
|
|
148
|
-
@path
|
|
152
|
+
@path.to_s
|
|
149
153
|
end
|
|
150
154
|
|
|
151
155
|
end
|
|
152
|
-
end
|
|
156
|
+
end
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
-
require 'rubygems/package'
|
|
3
|
-
|
|
4
|
-
$:.unshift File.dirname(__FILE__)
|
|
5
|
-
require 'io_chain'
|
|
6
2
|
|
|
7
3
|
module BuildMaster
|
|
8
4
|
class CottaFile
|
|
@@ -159,16 +155,17 @@ windows system because it does no put the system on binary mode
|
|
|
159
155
|
end
|
|
160
156
|
|
|
161
157
|
def extract(directory = nil)
|
|
158
|
+
require 'rubygems/package'
|
|
162
159
|
directory = parent.dir(basename) unless directory
|
|
163
160
|
read_binary do |io|
|
|
164
161
|
reader = Gem::Package::TarReader.new(io)
|
|
165
162
|
reader.each do |entry|
|
|
166
163
|
full_name = entry.full_name
|
|
167
|
-
if (entry.
|
|
164
|
+
if (entry.file?)
|
|
168
165
|
directory.file(full_name).write_binary do |output|
|
|
169
166
|
copy_io(entry, output)
|
|
170
167
|
end
|
|
171
|
-
elsif (entry.
|
|
168
|
+
elsif (entry.directory?)
|
|
172
169
|
directory.dir(full_name).mkdirs
|
|
173
170
|
end
|
|
174
171
|
end
|
|
@@ -210,7 +207,7 @@ windows system because it does no put the system on binary mode
|
|
|
210
207
|
end
|
|
211
208
|
|
|
212
209
|
def to_s
|
|
213
|
-
@path
|
|
210
|
+
@path.to_s
|
|
214
211
|
end
|
|
215
212
|
|
|
216
213
|
def inspect
|
|
@@ -218,4 +215,4 @@ windows system because it does no put the system on binary mode
|
|
|
218
215
|
end
|
|
219
216
|
|
|
220
217
|
end
|
|
221
|
-
end
|
|
218
|
+
end
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
|
2
|
-
|
|
3
1
|
require 'stringio'
|
|
4
|
-
require 'file_not_found_error'
|
|
5
2
|
|
|
6
3
|
module BuildMaster
|
|
7
4
|
class InMemorySystem
|
|
8
5
|
|
|
9
|
-
attr_reader :executed_commands
|
|
6
|
+
attr_reader :executed_commands, :pwd
|
|
10
7
|
|
|
11
8
|
def initialize
|
|
12
9
|
@executed_commands = []
|
|
@@ -121,6 +118,20 @@ class InMemorySystem
|
|
|
121
118
|
return 'InMemorySystem'
|
|
122
119
|
end
|
|
123
120
|
|
|
121
|
+
def chdir(path)
|
|
122
|
+
last_pwd = @pwd
|
|
123
|
+
@pwd = path.to_s
|
|
124
|
+
result = 0
|
|
125
|
+
if (block_given?)
|
|
126
|
+
begin
|
|
127
|
+
result = yield
|
|
128
|
+
ensure
|
|
129
|
+
@pwd = last_pwd
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
result
|
|
133
|
+
end
|
|
134
|
+
|
|
124
135
|
private
|
|
125
136
|
def gather_paths_to_create(pathname)
|
|
126
137
|
paths = Array.new
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
|
2
|
-
|
|
3
|
-
require 'file_not_found_error'
|
|
4
|
-
require 'command_error'
|
|
5
|
-
require 'command_runner'
|
|
6
|
-
require 'fileutils'
|
|
7
|
-
|
|
8
1
|
module BuildMaster
|
|
9
2
|
class PhysicalSystem
|
|
10
3
|
def initialize
|
|
11
4
|
end
|
|
12
5
|
|
|
6
|
+
# Invoke the command passed in through the CommandRunner
|
|
7
|
+
# and pass in the closure.
|
|
13
8
|
def shell(command, &block)
|
|
14
9
|
runner = CommandRunner.new(command)
|
|
15
10
|
runner.execute(&block)
|
|
@@ -79,5 +74,16 @@ class PhysicalSystem
|
|
|
79
74
|
FileUtils.mv(source, target)
|
|
80
75
|
end
|
|
81
76
|
|
|
77
|
+
def chdir(target, &block)
|
|
78
|
+
Dir.chdir(target, &block)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def pwd
|
|
82
|
+
Dir.pwd
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def ==(other)
|
|
86
|
+
other.class == PhysicalSystem
|
|
87
|
+
end
|
|
82
88
|
end
|
|
83
89
|
end
|