autobuild 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes.txt +5 -0
- data/Rakefile +1 -1
- data/bin/autobuild +4 -0
- data/lib/autobuild.rb +1 -1
- data/lib/autobuild/config.rb +41 -9
- data/lib/autobuild/import/cvs.rb +16 -7
- data/lib/autobuild/import/darcs.rb +13 -3
- data/lib/autobuild/import/svn.rb +12 -2
- data/lib/autobuild/import/tar.rb +27 -11
- data/lib/autobuild/importer.rb +11 -5
- metadata +2 -2
data/Changes.txt
CHANGED
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ Hoe.new('autobuild', Autobuild::VERSION) do |p|
|
|
8
8
|
p.summary = 'Rake-based utility to build and install multiple packages with dependencies'
|
9
9
|
p.description = p.paragraphs_of('README.txt', 3..5).join("\n\n")
|
10
10
|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
11
|
-
p.changes = p.paragraphs_of('Changes.txt', 0..
|
11
|
+
p.changes = p.paragraphs_of('Changes.txt', 0..1).join("\n\n")
|
12
12
|
|
13
13
|
p.extra_deps << ['rake', '>= 0.7.0']
|
14
14
|
p.extra_deps << 'rmail'
|
data/bin/autobuild
CHANGED
@@ -9,6 +9,7 @@ DEFAULT_HTTP_PORT = 2000
|
|
9
9
|
|
10
10
|
# Load the command line options
|
11
11
|
conffile, *packages = Autobuild.commandline(ARGV)
|
12
|
+
Autobuild.packages = packages
|
12
13
|
|
13
14
|
# make conffile an absolute path since daemonize mode makes
|
14
15
|
# / the current directory
|
@@ -30,6 +31,9 @@ begin
|
|
30
31
|
targets = ['import']
|
31
32
|
targets += ['prepare', 'build'] if Autobuild.do_build
|
32
33
|
targets.each do |phase|
|
34
|
+
packages = Autobuild.packages
|
35
|
+
packages = Autobuild.default_packages if packages.empty?
|
36
|
+
|
33
37
|
if packages.empty?
|
34
38
|
Rake::Task[phase].invoke
|
35
39
|
else
|
data/lib/autobuild.rb
CHANGED
data/lib/autobuild/config.rb
CHANGED
@@ -2,25 +2,44 @@ require 'optparse'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'singleton'
|
4
4
|
|
5
|
+
# Evaluates +script+ in autobuild context
|
5
6
|
def Autobuild(&script)
|
6
7
|
Autobuild.send(:module_eval, &script)
|
7
8
|
end
|
8
9
|
|
10
|
+
# Main Autobuild module. This module includes the build configuration options
|
11
|
+
# (see Autobuild::DEFAULT_OPTIONS) for the default values)
|
12
|
+
# nice:: the nice value at which we should spawn subprocesses
|
13
|
+
# srcdir:: the base source directory. If a package defines a relative srcdir, then
|
14
|
+
# it is defined relatively to Autobuild.srcdir
|
15
|
+
# prefix:: the base install directory. If a package defines a relative prefix, then
|
16
|
+
# it is defined relatively to Autobuild.prefix.
|
17
|
+
# verbose:: if true, displays all subprocesses output
|
18
|
+
# debug:: more verbose than 'verbose': displays Rake's debugging output
|
19
|
+
# do_update:: if we should update the packages
|
20
|
+
# do_build:: if we should build the packages
|
21
|
+
# daemonize:: if the build should go into daemon mode
|
22
|
+
# clean_log:: remove all logs before starting the build
|
23
|
+
# packages:: a list of packages to build specifically
|
24
|
+
# default_packages:: the list of packages to build if Autobuild.packages is empty.
|
25
|
+
# It this array is empty too, build all defined packages.
|
9
26
|
module Autobuild
|
10
27
|
class << self
|
11
28
|
%w{ nice srcdir prefix
|
12
29
|
verbose debug do_update do_build
|
13
|
-
daemonize clean_log }.each do |name|
|
30
|
+
daemonize clean_log packages default_packages }.each do |name|
|
14
31
|
attr_accessor name
|
15
32
|
end
|
16
33
|
|
34
|
+
# Configure the programs used by different packages
|
17
35
|
attr_reader :programs
|
36
|
+
# The directory in which logs are saved. Defaults to PREFIX/log.
|
18
37
|
attr_writer :logdir
|
19
38
|
end
|
20
39
|
DEFAULT_OPTIONS = { :nice => 0,
|
21
40
|
:srcdir => nil, :prefix => nil, :logdir => nil,
|
22
41
|
:verbose => false, :debug => false, :do_build => true, :do_update => true,
|
23
|
-
:daemonize => false }
|
42
|
+
:daemonize => false, :packages => [], :default_packages => [] }
|
24
43
|
|
25
44
|
@programs = Hash.new
|
26
45
|
DEFAULT_OPTIONS.each do |name, value|
|
@@ -29,29 +48,42 @@ module Autobuild
|
|
29
48
|
|
30
49
|
@mail = Hash.new
|
31
50
|
class << self
|
51
|
+
# Mailing configuration. It is a hash with the following keys (as symbols)
|
52
|
+
# [:to] the mail destination. Defaults to USER@HOSTNAME, where USER is the username
|
53
|
+
# of autobuild's caller, and HOSTNAME the hostname of the current machine.
|
54
|
+
# [:from] the mail origin. Defaults to the same value than +:to+
|
55
|
+
# [:smtp] the hostname of the SMTP server, defaults to localhost
|
56
|
+
# [:port] the port of the SMTP server, defauts to 22
|
57
|
+
# [:only_errors] mail only on errors. Defaults to false.
|
32
58
|
attr_reader :mail
|
59
|
+
|
60
|
+
# The directory in which logs are saved
|
33
61
|
def logdir; @logdir || "#{prefix}/log" end
|
34
62
|
|
63
|
+
# Removes all log files
|
35
64
|
def clean_log!
|
36
65
|
Reporting.each_log do |file|
|
37
66
|
FileUtils.rm_f file
|
38
67
|
end
|
39
68
|
end
|
40
69
|
|
41
|
-
# Get a given program, using its name as default value
|
70
|
+
# Get a given program, using its name as default value. For
|
71
|
+
# instance
|
72
|
+
# tool('automake')
|
73
|
+
# will return 'automake' unless the autobuild script defined
|
74
|
+
# another automake program in Autobuild.programs by doing
|
75
|
+
# Autobuild.programs['automake'] = 'automake1.9'
|
42
76
|
def tool(name)
|
43
77
|
programs[name.to_sym] || programs[name.to_s] || name.to_s
|
44
78
|
end
|
45
79
|
|
46
|
-
|
47
|
-
|
80
|
+
# Gets autobuild options from the command line and returns the
|
81
|
+
# remaining elements
|
48
82
|
def commandline(args)
|
49
83
|
parser = OptionParser.new do |opts|
|
50
84
|
opts.separator "Path specification"
|
51
85
|
opts.on("--srcdir PATH", "sources are installed in PATH") do |@srcdir| end
|
52
|
-
opts.on("--prefix PATH", "built packages are installed in PATH") do |@prefix|
|
53
|
-
logdir = "#{prefix}/autobuild"
|
54
|
-
end
|
86
|
+
opts.on("--prefix PATH", "built packages are installed in PATH") do |@prefix| end
|
55
87
|
opts.on("--logdir PATH", "logs are saved in PATH (default: <prefix>/autobuild)") do |@logdir| end
|
56
88
|
|
57
89
|
opts.separator ""
|
@@ -68,7 +100,7 @@ module Autobuild
|
|
68
100
|
opts.separator ""
|
69
101
|
opts.separator "Program output"
|
70
102
|
opts.on("--[no-]verbose", "display output of commands on stdout") do |@verbose| end
|
71
|
-
opts.on("--[no-]debug", "
|
103
|
+
opts.on("--[no-]debug", "debug information (for debugging purposes)") do |@debug| end
|
72
104
|
|
73
105
|
opts.separator ""
|
74
106
|
opts.separator "Mail reports"
|
data/lib/autobuild/import/cvs.rb
CHANGED
@@ -4,6 +4,14 @@ require 'autobuild/importer'
|
|
4
4
|
|
5
5
|
module Autobuild
|
6
6
|
class CVSImporter < Importer
|
7
|
+
# Creates a new importer which gets the module +name+ from the
|
8
|
+
# repository in +root+. The following values are allowed in +options+:
|
9
|
+
# [:cvsup] options to give to 'cvs up'. Default: -dP.
|
10
|
+
# [:cvsco] options to give to 'cvs co'. Default: -P.
|
11
|
+
#
|
12
|
+
# This importer uses the 'cvs' tool to perform the import. It defaults
|
13
|
+
# to 'cvs' and can be configured by doing
|
14
|
+
# Autobuild.programs['cvs'] = 'my_cvs_tool'
|
7
15
|
def initialize(root, name, options = {})
|
8
16
|
@root = root
|
9
17
|
@module = name
|
@@ -16,13 +24,12 @@ module Autobuild
|
|
16
24
|
super(options)
|
17
25
|
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
end
|
27
|
+
# Returns the module to get
|
28
|
+
def modulename; @module end
|
22
29
|
|
23
30
|
private
|
24
31
|
|
25
|
-
def update(package)
|
32
|
+
def update(package) # :nodoc:
|
26
33
|
Dir.chdir(package.srcdir) do
|
27
34
|
if !File.exists?("#{package.srcdir}/CVS/Root")
|
28
35
|
raise ConfigException, "#{package.srcdir} is not a CVS working copy"
|
@@ -38,7 +45,7 @@ module Autobuild
|
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
41
|
-
def checkout(package)
|
48
|
+
def checkout(package) # :nodoc:
|
42
49
|
head, tail = File.split(package.srcdir)
|
43
50
|
cvsroot = @root
|
44
51
|
|
@@ -50,8 +57,10 @@ module Autobuild
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
53
|
-
|
54
|
-
|
60
|
+
# Returns the CVS importer which will get the +name+ module in repository
|
61
|
+
# +repo+. The allowed values in +options+ are described in CVSImporter.new.
|
62
|
+
def self.cvs(repo, name, options = {})
|
63
|
+
CVSImporter.new(repo, name, options)
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
@@ -4,17 +4,25 @@ require 'autobuild/importer'
|
|
4
4
|
|
5
5
|
module Autobuild
|
6
6
|
class DarcsImporter < Importer
|
7
|
+
# Creates a new importer which gets the source from the Darcs repository
|
8
|
+
# +source+ # The following values are allowed in +options+:
|
9
|
+
# [:get] options to give to 'darcs get'.
|
10
|
+
# [:pull] options to give to 'darcs pull'.
|
11
|
+
#
|
12
|
+
# This importer uses the 'darcs' tool to perform the import. It defaults
|
13
|
+
# to 'darcs' and can be configured by doing
|
14
|
+
# Autobuild.programs['darcs'] = 'my_darcs_tool'
|
7
15
|
def initialize(source, options = {})
|
8
16
|
@source = source
|
9
17
|
@program = Autobuild.tool('darcs')
|
10
18
|
super(options)
|
11
19
|
@pull = [*options[:pull]]
|
12
|
-
@get
|
20
|
+
@get = [*options[:get]]
|
13
21
|
end
|
14
22
|
|
15
23
|
private
|
16
24
|
|
17
|
-
def update(package)
|
25
|
+
def update(package) # :nodoc:
|
18
26
|
if !File.directory?( File.join(package.srcdir, '_darcs') )
|
19
27
|
raise ConfigException, "#{package.srcdir} is not a Darcs repository"
|
20
28
|
end
|
@@ -23,12 +31,14 @@ module Autobuild
|
|
23
31
|
'pull', '--all', "--repodir=#{package.srcdir}", '--set-scripts-executable', @source, *@pull)
|
24
32
|
end
|
25
33
|
|
26
|
-
def checkout(package)
|
34
|
+
def checkout(package) # :nodoc:
|
27
35
|
Subprocess.run(package.name, :import, @program,
|
28
36
|
'get', '--set-scripts-executable', @source, package.srcdir, *@get)
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
40
|
+
# Returns the Darcs importer which will get the source from the Darcs repository
|
41
|
+
# +source+. The allowed values in +options+ are described in DarcsImporter.new.
|
32
42
|
def self.darcs(source, options = {})
|
33
43
|
DarcsImporter.new(source, options)
|
34
44
|
end
|
data/lib/autobuild/import/svn.rb
CHANGED
@@ -3,6 +3,14 @@ require 'autobuild/importer'
|
|
3
3
|
|
4
4
|
module Autobuild
|
5
5
|
class SVN < Importer
|
6
|
+
# Creates an importer which gets the source for the Subversion URL +source+.
|
7
|
+
# The following options are allowed:
|
8
|
+
# [:svnup] options to give to 'svn up'
|
9
|
+
# [:svnco] options to give to 'svn co'
|
10
|
+
#
|
11
|
+
# This importer uses the 'svn' tool to perform the import. It defaults
|
12
|
+
# to 'svn' and can be configured by doing
|
13
|
+
# Autobuild.programs['svn'] = 'my_svn_tool'
|
6
14
|
def initialize(source, options = {})
|
7
15
|
@source = [*source].join("/")
|
8
16
|
@program = Autobuild.tool('svn')
|
@@ -13,7 +21,7 @@ module Autobuild
|
|
13
21
|
|
14
22
|
private
|
15
23
|
|
16
|
-
def update(package)
|
24
|
+
def update(package) # :nodoc:
|
17
25
|
Dir.chdir(package.srcdir) {
|
18
26
|
old_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C'
|
19
27
|
svninfo = IO.popen("svn info") { |io| io.readlines }
|
@@ -34,12 +42,14 @@ module Autobuild
|
|
34
42
|
}
|
35
43
|
end
|
36
44
|
|
37
|
-
def checkout(package)
|
45
|
+
def checkout(package) # :nodoc:
|
38
46
|
options = [ @program, 'co' ] + @options_co + [ @source, package.srcdir ]
|
39
47
|
Subprocess.run(package.name, :import, *options)
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
51
|
+
# Creates a subversion importer which import the source for the Subversion
|
52
|
+
# URL +source+. The allowed values in +options+ are described in SVN.new.
|
43
53
|
def self.svn(source, options = {})
|
44
54
|
SVN.new(source, options)
|
45
55
|
end
|
data/lib/autobuild/import/tar.rb
CHANGED
@@ -2,8 +2,11 @@ require 'open-uri'
|
|
2
2
|
|
3
3
|
module Autobuild
|
4
4
|
class TarImporter < Importer
|
5
|
+
# The tarball is not compressed
|
5
6
|
Plain = 0
|
7
|
+
# The tarball is compressed with gzip
|
6
8
|
Gzip = 1
|
9
|
+
# The tarball is compressed using bzip
|
7
10
|
Bzip = 2
|
8
11
|
|
9
12
|
TAR_OPTION = {
|
@@ -12,22 +15,25 @@ module Autobuild
|
|
12
15
|
Bzip => 'j'
|
13
16
|
}
|
14
17
|
|
18
|
+
# Known URI schemes for +url+
|
15
19
|
VALID_URI_SCHEMES = [ 'file', 'http', 'ftp' ]
|
16
20
|
|
21
|
+
# Returns the unpack mode from the file name
|
17
22
|
def self.url_to_mode(url)
|
18
23
|
ext = File.extname(url)
|
24
|
+
unless ext == '.tar'
|
25
|
+
raise "Invalid file type in #{url}" unless File.basename(url, ext) != '.tar'
|
26
|
+
end
|
19
27
|
mode = case ext
|
20
28
|
when '.tar'; Plain
|
21
29
|
when '.gz'; Gzip
|
22
30
|
when '.bz2'; Bzip
|
23
31
|
end
|
24
32
|
|
25
|
-
unless ext == '.tar'
|
26
|
-
raise "Invalid file type in #{url}" unless File.basename(url, ext) != '.tar'
|
27
|
-
end
|
28
33
|
mode
|
29
34
|
end
|
30
35
|
|
36
|
+
# Updates the downloaded file in cache only if it is needed
|
31
37
|
def update_cache
|
32
38
|
do_update = true
|
33
39
|
|
@@ -67,6 +73,7 @@ module Autobuild
|
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
76
|
+
# Sets the source URL and update +cachefile+ and +mode+ attributes accordingly.
|
70
77
|
def url=(url)
|
71
78
|
@url = URI.parse(url)
|
72
79
|
raise ConfigException, "invalid URL #{url}" unless VALID_URI_SCHEMES.include?(@url.scheme)
|
@@ -79,22 +86,31 @@ module Autobuild
|
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
82
|
-
|
89
|
+
# The source URL
|
90
|
+
attr_reader :url
|
91
|
+
# The local file (either a downloaded file if +url+ is not local, or +url+ itself)
|
92
|
+
attr_reader :cachefile
|
93
|
+
# The unpack mode. One of Bzip, Gzip or Plain
|
94
|
+
attr_reader :mode
|
95
|
+
# The directory in which remote files are cached
|
83
96
|
def cachedir; @options[:cachedir] end
|
84
97
|
|
98
|
+
# Creates a new importer which downloads +url+ in +cachedir+ and unpacks it. The following options
|
99
|
+
# are allowed:
|
100
|
+
# [:cachedir] the cache directory. Defaults to "#{Autobuild.prefix}/cache"
|
85
101
|
def initialize(url, options)
|
86
102
|
@options = options.dup
|
87
|
-
@options[:cachedir] ||=
|
103
|
+
@options[:cachedir] ||= "#{Autobuild.prefix}/cache"
|
88
104
|
self.url = url
|
89
105
|
end
|
90
106
|
|
91
|
-
def update(package)
|
107
|
+
def update(package) # :nodoc:
|
92
108
|
checkout if update_cache
|
93
109
|
rescue OpenURI::HTTPError
|
94
110
|
raise Autobuild::Exception.new(package.name, :import)
|
95
111
|
end
|
96
112
|
|
97
|
-
def checkout(package)
|
113
|
+
def checkout(package) # :nodoc:
|
98
114
|
update_cache
|
99
115
|
|
100
116
|
base_dir = File.dirname(package.srcdir)
|
@@ -111,10 +127,10 @@ module Autobuild
|
|
111
127
|
end
|
112
128
|
end
|
113
129
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
130
|
+
# Creates an importer which downloads a tarball from +source+ and unpacks
|
131
|
+
# it. The allowed values in +options+ are described in TarImporter.new.
|
132
|
+
def self.tar(source, options)
|
133
|
+
TarImporter.new(source, options)
|
118
134
|
end
|
119
135
|
end
|
120
136
|
|
data/lib/autobuild/importer.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
require 'autobuild/config'
|
2
2
|
require 'autobuild/exceptions'
|
3
3
|
|
4
|
+
# This class is the base class for objects that are used to get the source from
|
5
|
+
# various RCS into the package source directory. A list of patches to apply
|
6
|
+
# after the import can be given in the +:patches+ option.
|
4
7
|
class Autobuild::Importer
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
# Creates a new Importer object. The options known to Importer are:
|
9
|
+
# [:patches] a list of patch to apply after import
|
10
|
+
#
|
11
|
+
# More options are specific to each importer type.
|
12
|
+
def initialize(options); @options = options end
|
8
13
|
|
14
|
+
# Performs the import of +package+
|
9
15
|
def import(package)
|
10
16
|
srcdir = package.srcdir
|
11
17
|
if File.directory?(srcdir)
|
@@ -32,8 +38,8 @@ class Autobuild::Importer
|
|
32
38
|
|
33
39
|
private
|
34
40
|
|
35
|
-
# We assume that package.srcdir already exists (checkout
|
36
|
-
#
|
41
|
+
# We assume that package.srcdir already exists (checkout is supposed to
|
42
|
+
# have been called)
|
37
43
|
def patchlist(package)
|
38
44
|
"#{package.srcdir}/patches-autobuild-stamp"
|
39
45
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: autobuild
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.6.
|
7
|
-
date: 2007-02-
|
6
|
+
version: 0.6.5
|
7
|
+
date: 2007-02-14 00:00:00 +01:00
|
8
8
|
summary: Rake-based utility to build and install multiple packages with dependencies
|
9
9
|
require_paths:
|
10
10
|
- lib
|