autobuild 1.10.0.b4 → 1.10.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 337600547fed308e00ef0dbcfbedcdd02664d3d3
4
- data.tar.gz: 5d051d09d63bcf0e82463b099d4a9e690893a516
3
+ metadata.gz: 8e471e6766c9f499c7afbc82edda72bf1abfc8fa
4
+ data.tar.gz: 25268f055e8dd9d2018b9630b2b48fe3183b8972
5
5
  SHA512:
6
- metadata.gz: b996cbdfa5a35e5b23da4ded4e8da3258ebb9f06fadfd1ec0472b0958777d76771eebb7708c2959ca8d532b10485192d8f54de1071a205332a8d25fc964075d6
7
- data.tar.gz: 54336977873b4150cea50d3356295b491ae154769c22cdf8660c2def2b9ca50a70709fa6291cf0898bbca475d450d47ad2843b6816476a2807868744150904d9
6
+ metadata.gz: ad1ec6b44e38d3761dab2a223b4d0ec9a8ed1f64d26441d3049a96e5c5ed0e92be1047d002e76605770d3452e9f3b7eef150ab05cf0789c9a61806fc807e9ce3
7
+ data.tar.gz: 2aeb1d2b702ceb8d1e3d1ed71342ef937411c12a78c3b0a1b10fda27e0a9c598c1bfa25fe69eabc6e143609c14a095b44f6734b74a65ccd11163c832ed088161
@@ -0,0 +1 @@
1
+ *.rb diff=ruby
@@ -0,0 +1,5 @@
1
+ *.swp
2
+ pkg/
3
+ doc/
4
+ vendor/
5
+ .bundle
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.6
5
+ - 2.2.2
@@ -1,3 +1,11 @@
1
+ == Version 1.10.0
2
+
3
+ Apart from a bunch of extensions to the Git importer API, and a host of
4
+ bugfixes, the main change is a modularized environment handling. Environment can
5
+ now be declared on a per-package basis, and commands executed through
6
+ Package#run will get the environment as stored in their package and its
7
+ dependencies, instead of always using a global environment.
8
+
1
9
  == Version 1.7.1
2
10
  * fix problems with encoding of subcommand output
3
11
 
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,54 @@
1
+ [![Build Status](https://travis-ci.org/rock-core/autobuild.svg?branch=autoproj-2.0)](https://travis-ci.org/rock-core/autobuild)
2
+ [![Gem Version](https://badge.fury.io/rb/autobuild.svg)](http://badge.fury.io/rb/autobuild)
3
+ [![Documentation](http://b.repl.ca/v1/yard-docs-blue.png)](http://rubydoc.info/gems/autobuild/frames)
4
+
5
+ ## What's autobuild ?
6
+
7
+ Autobuild is a collection of classes to interface with build systems (e.g.
8
+ autotools, CMake) and import mechanisms (git, svn, ...). It is used to build the
9
+ [autoproj](http://rock-robotics.org/documentation/autoproj) higher-level tool
10
+ that provides mechanisms to manage a whole workspace.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'autobuild'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install autobuild
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bundle install` to install dependencies. Then,
31
+ run `bundle exec rake test` to run the tests.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To
34
+ release a new version, update the version number in `version.rb`, and then run
35
+ `bundle exec rake release`, which will create a git tag for the version, push
36
+ git commits and tags, and push the `.gem` file to
37
+ [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at
42
+ https://github.com/rock-core/autobuild
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the GPL license v2 or
47
+ later.
48
+
49
+ Copyright and license
50
+ =====================
51
+ Author:: Sylvain Joyeux <sylvain.joyeux@m4x.org>
52
+ Copyright:: Copyright (c) 2005-2015 Sylvain Joyeux
53
+ License:: GPL
54
+
data/Rakefile CHANGED
@@ -1,28 +1,13 @@
1
1
  require 'utilrb/rake_common'
2
2
 
3
- Utilrb::Rake.hoe do
4
- Hoe.spec 'autobuild' do
5
- developer "Sylvain Joyeux", "sylvain.joyeux@m4x.org"
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
6
5
 
7
- self.urls = ["http://rock-robotics.org/stable/documentation/autoproj"]
8
- self.summary = 'Library to handle build systems and import mechanisms'
9
- self.description = "Collection of classes to handle build systems (CMake, autotools, ...) and import mechanisms (tarballs, CVS, SVN, git, ...). It also offers a Rake integration to import and build such software packages. It is the backbone of the autoproj (http://rock-robotics.org/autoproj) integrated software project management tool."
10
- self.email = %q{rock-dev@dfki.de}
6
+ task 'default'
7
+ task 'gem' => 'build'
11
8
 
12
- license 'BSD'
13
-
14
- self.spec_extras[:required_ruby_version] = ">= 1.9.2"
15
-
16
- self.extra_deps <<
17
- ['rake', '>= 0.9.0'] <<
18
- ['utilrb', '>= 1.6.0'] <<
19
- ['pastel', '>= 0.4.0'] <<
20
- ['tty', '>= 0.2.0']
21
-
22
- self.test_globs = ['test/suite.rb']
23
- end
24
- Rake.clear_tasks(/publish_docs/, /default/)
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << "lib" << Dir.pwd
11
+ t.test_files = ['test/suite.rb']
25
12
  end
26
13
 
27
- task "default"
28
-
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'autobuild/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "autobuild"
8
+ s.version = Autobuild::VERSION
9
+ s.authors = ["Sylvain Joyeux"]
10
+ s.email = "sylvain.joyeux@m4x.org"
11
+ s.summary = "Library to handle build systems and import mechanisms"
12
+ s.description = "Collection of classes to handle build systems (CMake, autotools, ...) and import mechanisms (tarballs, CVS, SVN, git, ...). It also offers a Rake integration to import and build such software packages. It is the backbone of the autoproj (http://rock-robotics.org/autoproj) integrated software project management tool."
13
+ s.homepage = "http://rock-robotics.org"
14
+ s.licenses = ["BSD"]
15
+
16
+ s.required_ruby_version = ">= 1.9.3"
17
+ s.require_paths = ["lib"]
18
+ s.extensions = []
19
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+
21
+ s.add_runtime_dependency "rake", ">= 0.9.0"
22
+ s.add_runtime_dependency "utilrb", ">= 2.0"
23
+ s.add_runtime_dependency "tty", '>= 0.2.1'
24
+ s.add_runtime_dependency 'pastel', '>= 0.5.0'
25
+ s.add_development_dependency "flexmock", ">= 2.0.0"
26
+ s.add_development_dependency "minitest", ">= 5.0", "~> 5.0"
27
+ s.add_development_dependency "fakefs"
28
+ s.add_development_dependency "simplecov"
29
+ end
30
+
@@ -171,6 +171,14 @@ def set(name, *values)
171
171
  add(name, *values)
172
172
  end
173
173
 
174
+ # Unset the given environment variable
175
+ #
176
+ # It is different from {#delete} in that it will lead to the environment
177
+ # variable being actively unset, while 'delete' will leave it to its
178
+ # original value
179
+ def unset(name)
180
+ environment[name] = nil
181
+ end
174
182
 
175
183
  # Returns true if the given environment variable must not be reset by the
176
184
  # env.sh script, but that new values should simply be prepended to it.
@@ -303,7 +311,9 @@ def value(name, options = Hash.new)
303
311
  inheritance_mode: :expand
304
312
  inheritance_mode = options[:inheritance_mode]
305
313
 
306
- if !environment[name] && !inherited_environment[name] && !system_env[name]
314
+ if !include?(name)
315
+ nil
316
+ elsif !environment[name]
307
317
  nil
308
318
  else
309
319
  inherited =
@@ -327,9 +337,18 @@ def value(name, options = Hash.new)
327
337
  end
328
338
  end
329
339
 
340
+ # Whether this object manages the given environment variable
341
+ def include?(name)
342
+ environment.has_key?(name)
343
+ end
344
+
330
345
  def update_var(name)
331
- if value = value(name)
332
- resolved_env[name] = value.join(File::PATH_SEPARATOR)
346
+ if include?(name)
347
+ if value = value(name)
348
+ resolved_env[name] = value.join(File::PATH_SEPARATOR)
349
+ else
350
+ resolved_env[name] = nil
351
+ end
333
352
  else
334
353
  resolved_env.delete(name)
335
354
  end
@@ -413,6 +432,7 @@ def export_env_sh(io)
413
432
  io.puts SHELL_SOURCE_SCRIPT % path
414
433
  end
415
434
 
435
+ unset_variables = Set.new
416
436
  variables = []
417
437
  environment.each do |name, _|
418
438
  variables << name
@@ -420,6 +440,7 @@ def export_env_sh(io)
420
440
  value_without_inheritance = value(name, inheritance_mode: :ignore)
421
441
 
422
442
  if !value_with_inheritance
443
+ unset_variables << name
423
444
  shell_line = SHELL_UNSET_COMMAND % [name]
424
445
  elsif value_with_inheritance == value_without_inheritance # no inheritance
425
446
  shell_line = SHELL_SET_COMMAND % [name, value_with_inheritance.join(File::PATH_SEPARATOR)]
@@ -429,7 +450,9 @@ def export_env_sh(io)
429
450
  io.puts shell_line
430
451
  end
431
452
  variables.each do |var|
432
- io.puts SHELL_EXPORT_COMMAND % [var]
453
+ if !unset_variables.include?(var)
454
+ io.puts SHELL_EXPORT_COMMAND % [var]
455
+ end
433
456
  end
434
457
  @source_after.each do |path|
435
458
  io.puts SHELL_SOURCE_SCRIPT % [path]
@@ -35,18 +35,14 @@ class ArchiveImporter < Importer
35
35
  class << self
36
36
  # The directory in which downloaded files are saved
37
37
  #
38
- # It defaults, by order of priority, to the archives/ subdirectory
39
- # of the environment variable AUTOBUILD_CACHE_DIR (if set), to the
40
- # AUTOBUILD_ARCHIVES_CACHE_DIR (if set) environment variable and to
41
- # #{prefix}/cache
38
+ # It defaults, if set, to the value returned by
39
+ # {Importer.cache_dirs} and falls back #{prefix}/cache
42
40
  def cachedir
43
41
  if @cachedir then @cachedir
44
- elsif dir = ENV['AUTOBUILD_ARCHIVES_CACHE_DIR']
45
- @cachedir = File.expand_path(dir)
46
- elsif dir = ENV['AUTOBUILD_CACHE_DIR']
47
- @cachedir = File.join(File.expand_path(dir), 'archives')
42
+ elsif cache_dirs = Importer.cache_dirs('archives')
43
+ @cachedir = cache_dirs.first
48
44
  else
49
- @cachedir = "#{Autobuild.prefix}/cache"
45
+ "#{Autobuild.prefix}/cache"
50
46
  end
51
47
  end
52
48
 
@@ -26,10 +26,8 @@ class << self
26
26
  # @see default_alternates=, Git#alternates
27
27
  def default_alternates
28
28
  if @default_alternates then @default_alternates
29
- elsif cache_dir = ENV['AUTOBUILD_GIT_CACHE_DIR']
30
- @default_alternates = cache_dir.split(':').map { |path| File.expand_path(path) }
31
- elsif cache_dir = ENV['AUTOBUILD_CACHE_DIR']
32
- @default_alternates = cache_dir.split(':').map { |path| File.join(File.expand_path(path), 'git', '%s') }
29
+ elsif cache_dirs = Importer.cache_dirs('git')
30
+ @default_alternates = cache_dirs.map { |path| File.join(File.expand_path(path), '%s') }
33
31
  else Array.new
34
32
  end
35
33
  end
@@ -584,7 +582,7 @@ def rev_parse(package, name, object_type = "commit")
584
582
  if object_type
585
583
  name = "#{name}^{#{object_type}}"
586
584
  end
587
- run_git_bare(package, 'rev-parse', name).first
585
+ run_git_bare(package, 'rev-parse', '-q', '--verify', name).first
588
586
  rescue Autobuild::SubcommandFailed
589
587
  raise PackageException.new(package, 'import'), "failed to resolve #{name}. Are you sure this commit, branch or tag exists ?"
590
588
  end
@@ -731,7 +729,7 @@ def update_alternates(package)
731
729
  File.join(path, 'objects')
732
730
  end
733
731
 
734
- if current_alternates.sort != alternates.sort
732
+ if !(current_alternates.sort - alternates.sort).empty?
735
733
  # Warn that something is fishy, but assume that the user knows
736
734
  # what he is doing
737
735
  package.warn "%s: the list of git alternates listed in the repository differs from the one set up in autobuild."
@@ -911,9 +909,9 @@ def relocate(repository, options = Hash.new)
911
909
  options = Hash[options.map { |k, v| [k.to_sym, v] }]
912
910
 
913
911
  @push_to = options[:push_to] || @push_to
912
+ local_branch = options[:local_branch] || options[:branch] || self.local_branch || 'master'
913
+ remote_branch = options[:remote_branch] || options[:branch] || self.remote_branch || 'master'
914
914
  @branch = @local_branch = @remote_branch = nil
915
- local_branch = options[:local_branch] || options[:branch] || local_branch || 'master'
916
- remote_branch = options[:remote_branch] || options[:branch] || remote_branch || 'master'
917
915
  if local_branch == remote_branch
918
916
  @branch = local_branch
919
917
  else
@@ -70,6 +70,73 @@ def initialize(status = -1)
70
70
  end
71
71
  end
72
72
 
73
+ # The cache directories for the given importer type.
74
+ #
75
+ # This is used by some importers to save disk space and/or avoid downloading
76
+ # the same things over and over again
77
+ #
78
+ # The default global cache directory is initialized from the
79
+ # AUTOBUILD_CACHE_DIR environment variable. Per-importer cache directories
80
+ # can be overriden by setting AUTOBUILD_{TYPE}_CACHE_DIR (e.g.
81
+ # AUTOBUILD_GIT_CACHE_DIR)
82
+ #
83
+ # The following importers use caches:
84
+ # - the archive importer saves downloaded files in the cache. They are
85
+ # saved under an archives/ subdirectory of the default cache if set, or to
86
+ # the value of AUTOBUILD_ARCHIVES_CACHE_DIR
87
+ # - the git importer uses the cache directories as alternates for the git
88
+ # checkouts
89
+ #
90
+ # @param [String] type the importer type. If set, it Given a root cache
91
+ # directory X, and importer specific cache is setup as a subdirectory of X
92
+ # with e.g. X/git or X/archives. The subdirectory name is defined by this
93
+ # argument
94
+ # @return [nil,Array<String>]
95
+ #
96
+ # @see .set_cache_dirs .default_cache_dirs .default_cache_dirs=
97
+ def self.cache_dirs(type)
98
+ if @cache_dirs[type] || (env = ENV["AUTOBUILD_#{type.upcase}_CACHE_DIR"])
99
+ @cache_dirs[type] ||= env.split(":")
100
+ elsif dirs = default_cache_dirs
101
+ dirs.map { |d| File.join(d, type) }
102
+ end
103
+ end
104
+
105
+ # Returns the default cache directory if there is one
106
+ #
107
+ # @return [Array<String>,nil]
108
+ # @see .cache_dirs
109
+ def self.default_cache_dirs
110
+ if @default_cache_dirs ||= ENV['AUTOBUILD_CACHE_DIR']
111
+ [@default_cache_dirs]
112
+ end
113
+ end
114
+
115
+ # Sets the cache directory for a given importer type
116
+ #
117
+ # @param [String] type the importer type
118
+ # @param [String] dir the cache directory
119
+ # @see .cache_dirs
120
+ def self.set_cache_dirs(type, *dirs)
121
+ @cache_dirs[type] = dirs
122
+ end
123
+
124
+ # Sets the default cache directory
125
+ #
126
+ # @param [Array<String>,String] the directories
127
+ # @see .cache_dirs
128
+ def self.default_cache_dirs=(dirs)
129
+ @default_cache_dirs = Array(dirs)
130
+ end
131
+
132
+ # Unset all cache directories
133
+ def self.unset_cache_dirs
134
+ @cache_dirs = Hash.new
135
+ @default_cache_dirs = nil
136
+ end
137
+
138
+ unset_cache_dirs
139
+
73
140
  # @return [Hash] the original option hash as given to #initialize
74
141
  attr_reader :options
75
142
 
@@ -288,9 +288,7 @@ def self.report
288
288
  # it
289
289
  errors = []
290
290
  Autobuild::Package.each do |name, pkg|
291
- if pkg.failed?
292
- errors.concat(pkg.failures)
293
- end
291
+ errors.concat(pkg.failures)
294
292
  end
295
293
 
296
294
  if !errors.empty?
@@ -311,12 +309,12 @@ def self.report
311
309
 
312
310
  ## Reports a successful build to the user
313
311
  def self.success
314
- @@reporters.each do |rep| rep.success end
312
+ each_reporter { |rep| rep.success }
315
313
  end
316
314
 
317
315
  ## Reports that the build failed to the user
318
316
  def self.error(error)
319
- @@reporters.each do |rep| rep.error(error) end
317
+ each_reporter { |rep| rep.error(error) }
320
318
  end
321
319
 
322
320
  ## Add a new reporter
@@ -324,6 +322,10 @@ def self.<<(reporter)
324
322
  @@reporters << reporter
325
323
  end
326
324
 
325
+ def self.remove(reporter)
326
+ @@reporters.delete(reporter)
327
+ end
328
+
327
329
  def self.clear_reporters
328
330
  @@reporters.clear
329
331
  end
@@ -18,8 +18,7 @@
18
18
  require 'tmpdir'
19
19
  require 'erb'
20
20
  require 'fileutils'
21
- ## Uncomment this to enable flexmock
22
- require 'flexmock/test_unit'
21
+ require 'flexmock/minitest'
23
22
  require 'minitest/spec'
24
23
 
25
24
  if ENV['TEST_ENABLE_PRY'] != '0'
@@ -41,11 +40,6 @@ module Autobuild
41
40
  # end
42
41
  #
43
42
  module SelfTest
44
- if defined? FlexMock
45
- include FlexMock::ArgumentTypes
46
- include FlexMock::MockContainer
47
- end
48
-
49
43
  def setup
50
44
  @tempdir = File.join(Dir.tmpdir, "/autobuild-test-#{Process.uid}")
51
45
  FileUtils.mkdir_p(@tempdir, :mode => 0700)
@@ -57,9 +51,6 @@ def setup
57
51
 
58
52
  def teardown
59
53
  Autobuild.silent = false
60
- if defined? FlexMock
61
- flexmock_teardown
62
- end
63
54
  super
64
55
 
65
56
  Autobuild::Package.clear
@@ -98,7 +89,4 @@ def untar(file)
98
89
  end
99
90
  end
100
91
 
101
- class Minitest::Test
102
- include Autobuild::SelfTest
103
- end
104
-
92
+ Minitest::Test.include Autobuild::SelfTest