autobuild 1.10.0.b1 → 1.10.0.b2

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: e42c625c20b8bfbb4fc824fc40a9b2a41f5d6bb6
4
- data.tar.gz: c35720c6c894d3fb3337bafb17424b72c9b1e9e1
3
+ metadata.gz: 67c87629da5179c5b58f195daf8679f53bfc4054
4
+ data.tar.gz: af790ea0bf7210db55344839c79455b650d1e915
5
5
  SHA512:
6
- metadata.gz: 728e7d5f5a968767e5d5bea8368bfda85c2601b6d66647f8d2f52ae7fe26019f1ef361ce3b0d9cf43b49e4ee71eb6c794c7b146eeb72c01543b495f83caefa2a
7
- data.tar.gz: bc5181729cf2196ab580d175efcf411e0a79f9d3abc02e06280dda2bc15f595e0e8fa40b54cdcba1c11b6cec38ed316067f5de30d642049fdfb82785814ae340
6
+ metadata.gz: 504fec6fac6c095d815d7541ba6828dc55a62032ae8bfeea548e8c23ae3f29bb4dd2f945a80720fc8110ab0d3e3c2695e26fc3dd05729f94bf102c630cfd73ab
7
+ data.tar.gz: 20292807e5da7f402da75132e4ed808e1b89f05eda485b371b7b03c1156827d6886dc4cd31be4a6da46b079c01e7db941b5b74fe5f2ad2a67d37eecbff83bfde
@@ -531,6 +531,24 @@ module Autobuild
531
531
  add_prefix(newprefix, includes)
532
532
  end
533
533
 
534
+ # Returns the system-wide search path that is embedded in pkg-config
535
+ def default_pkgconfig_search_suffixes
536
+ found_path_rx = /Scanning directory '(.*\/)((?:lib|lib64|share)\/.*)'$/
537
+ nonexistent_path_rx = /Cannot open directory '.*\/((?:lib|lib64|share)\/.*)' in package search path:.*/
538
+
539
+ if !@default_pkgconfig_search_suffixes
540
+ output = `LANG=C PKG_CONFIG_PATH= #{Autobuild.tool("pkg-config")} --debug 2>&1`.split("\n")
541
+ found_paths = output.grep(found_path_rx).
542
+ map { |l| l.gsub(found_path_rx, '\2') }.
543
+ to_set
544
+ not_found = output.grep(nonexistent_path_rx).
545
+ map { |l| l.gsub(nonexistent_path_rx, '\1') }.
546
+ to_set
547
+ @default_pkgconfig_search_suffixes = found_paths | not_found
548
+ end
549
+ return @default_pkgconfig_search_suffixes
550
+ end
551
+
534
552
  # Updates the environment when a new prefix has been added
535
553
  def add_prefix(newprefix, includes = nil)
536
554
  if !includes || includes.include?('PATH')
@@ -540,8 +558,7 @@ module Autobuild
540
558
  end
541
559
 
542
560
  if !includes || includes.include?('PKG_CONFIG_PATH')
543
- pkg_config_search = ['lib/pkgconfig', 'lib/ARCH/pkgconfig', 'libARCHSIZE/pkgconfig']
544
- each_env_search_path(newprefix, pkg_config_search) do |path|
561
+ each_env_search_path(newprefix, default_pkgconfig_search_suffixes) do |path|
545
562
  add_path('PKG_CONFIG_PATH', path)
546
563
  end
547
564
  end
@@ -117,5 +117,12 @@ module Autobuild
117
117
  msg
118
118
  end
119
119
  end
120
+
121
+ # Exception raised in contexts where user interaction is forbidden but
122
+ # required by the import/build process
123
+ #
124
+ # This is for instance used during package import if the importer has to ask
125
+ # the user a question and allow_interactive is false
126
+ class InteractionRequired < RuntimeError; end
120
127
  end
121
128
 
@@ -288,7 +288,7 @@ module Autobuild
288
288
  # also used to infer the mode
289
289
  # [:mode] The unpack mode: one of Zip, Bzip, Gzip or Plain, this is
290
290
  # usually automatically inferred from the filename
291
- def initialize(url, options)
291
+ def initialize(url, options = Hash.new)
292
292
  sourceopts, options = Kernel.filter_options options,
293
293
  :source_id, :repository_id, :filename, :mode
294
294
  super(options)
@@ -304,13 +304,13 @@ module Autobuild
304
304
 
305
305
  # Changes the URL from which we should pick the archive
306
306
  def relocate(url, options = Hash.new)
307
- parsed_url = URI.parse(url)
307
+ parsed_url = URI.parse(url).normalize
308
308
  @url = parsed_url
309
309
  if !VALID_URI_SCHEMES.include?(@url.scheme)
310
310
  raise ConfigException, "invalid URL #{@url} (local files must be prefixed with file://)"
311
311
  end
312
- @repository_id = options[:repository_id] || parsed_url
313
- @source_id = options[:source_id] || parsed_url
312
+ @repository_id = options[:repository_id] || parsed_url.to_s
313
+ @source_id = options[:source_id] || parsed_url.to_s
314
314
 
315
315
  @filename = options[:filename] || @filename || File.basename(url).gsub(/\?.*/, '')
316
316
 
@@ -334,7 +334,7 @@ module Autobuild
334
334
  end
335
335
 
336
336
  if needs_update || archive_changed?(package)
337
- checkout(package)
337
+ checkout(package, allow_interactive: options[:allow_interactive])
338
338
  end
339
339
  rescue OpenURI::HTTPError
340
340
  raise Autobuild::Exception.new(package.name, :import)
@@ -357,7 +357,10 @@ module Autobuild
357
357
  checkout_digest != cachefile_digest
358
358
  end
359
359
 
360
- def checkout(package) # :nodoc:
360
+ def checkout(package, options = Hash.new) # :nodoc:
361
+ options = Kernel.validate_options options,
362
+ allow_interactive: true
363
+
361
364
  update_cache(package)
362
365
 
363
366
  # Check whether the archive file changed, and if that is the case
@@ -365,7 +368,7 @@ module Autobuild
365
368
  if File.file?(checkout_digest_stamp(package)) && archive_changed?(package)
366
369
  if ArchiveImporter.auto_update?
367
370
  response = 'yes'
368
- else
371
+ elsif options[:allow_interactive]
369
372
  package.progress_done
370
373
  package.message "The archive #{@url.to_s} is different from the one currently checked out at #{package.srcdir}", :bold
371
374
  package.message "I will have to delete the current folder to go on with the update"
@@ -375,6 +378,8 @@ module Autobuild
375
378
  q.default = 'yes'
376
379
  q.case = :downcase
377
380
  end
381
+ else
382
+ raise Autobuild::InteractionRequired, "importing #{package.name} would have required user interaction and allow_interactive is false"
378
383
  end
379
384
 
380
385
  if response == "no"
@@ -428,7 +433,9 @@ module Autobuild
428
433
  rescue OpenURI::HTTPError
429
434
  raise Autobuild::PackageException.new(package.name, :import)
430
435
  rescue SubcommandFailed
431
- FileUtils.rm_f cachefile
436
+ if cachefile != url.path
437
+ FileUtils.rm_f cachefile
438
+ end
432
439
  raise
433
440
  end
434
441
  end
@@ -61,7 +61,7 @@ module Autobuild
61
61
  retry: true, working_directory: package.importdir)
62
62
  end
63
63
 
64
- def checkout(package) # :nodoc:
64
+ def checkout(package, options = Hash.new) # :nodoc:
65
65
  head, tail = File.split(package.srcdir)
66
66
  cvsroot = @root
67
67
 
@@ -36,7 +36,7 @@ module Autobuild
36
36
  'pull', '--all', "--repodir=#{package.srcdir}", '--set-scripts-executable', @source, *@pull, retry: true)
37
37
  end
38
38
 
39
- def checkout(package) # :nodoc:
39
+ def checkout(package, options = Hash.new) # :nodoc:
40
40
  basedir = File.dirname(package.srcdir)
41
41
  unless File.directory?(basedir)
42
42
  FileUtils.mkdir_p(basedir)
@@ -652,7 +652,9 @@ module Autobuild
652
652
  # @param [String] fetch_commit the state of the remote branch. This is
653
653
  # used to avoid losing commits if HEAD is not included in
654
654
  # target_commit
655
- def reset_head_to_commit(package, target_commit, fetch_commit)
655
+ # @option options [Boolean] force (false) bypasses checks that verify
656
+ # that some commits won't be lost by resetting
657
+ def reset_head_to_commit(package, target_commit, fetch_commit, options = Hash.new)
656
658
  current_head = rev_parse(package, 'HEAD')
657
659
  head_to_target = merge_status(package, target_commit, current_head)
658
660
  status_to_target = head_to_target.status
@@ -661,7 +663,7 @@ module Autobuild
661
663
  return
662
664
  elsif status_to_target == Status::SIMPLE_UPDATE
663
665
  run_git(package, 'merge', target_commit)
664
- else
666
+ elsif !options[:force]
665
667
  # Check whether the current HEAD is present on the remote
666
668
  # repository. We'll refuse resetting if there are uncommitted
667
669
  # changes
@@ -745,7 +747,7 @@ module Autobuild
745
747
 
746
748
  fetch_commit ||= current_remote_commit(package, options[:only_local])
747
749
  if options[:reset]
748
- reset_head_to_commit(package, target_commit, fetch_commit)
750
+ reset_head_to_commit(package, target_commit, fetch_commit, force: (options[:reset] == :force))
749
751
  else
750
752
  merge_if_simple(package, target_commit)
751
753
  end
@@ -774,7 +776,7 @@ module Autobuild
774
776
  nil
775
777
  end
776
778
 
777
- def checkout(package)
779
+ def checkout(package, options = Hash.new)
778
780
  base_dir = File.expand_path('..', package.importdir)
779
781
  if !File.directory?(base_dir)
780
782
  FileUtils.mkdir_p base_dir
@@ -59,7 +59,7 @@ module Autobuild
59
59
  package.run(:import, Autobuild.tool('hg'), 'update', branch, working_directory: package.importdir)
60
60
  end
61
61
 
62
- def checkout(package)
62
+ def checkout(package, options = Hash.new)
63
63
  base_dir = File.expand_path('..', package.importdir)
64
64
  if !File.directory?(base_dir)
65
65
  FileUtils.mkdir_p base_dir
@@ -212,7 +212,7 @@ module Autobuild
212
212
  run_svn(package, 'up', "--non-interactive", *options_up)
213
213
  end
214
214
 
215
- def checkout(package) # :nodoc:
215
+ def checkout(package, options = Hash.new) # :nodoc:
216
216
  run_svn(package, 'co', "--non-interactive", *@options_co, svnroot, package.importdir,
217
217
  working_directory: nil)
218
218
  end
@@ -72,6 +72,7 @@ class Importer
72
72
  @options = options.dup
73
73
  @options[:retry_count] = Integer(@options[:retry_count] || 0)
74
74
  @repository_id = options[:repository_id] || "#{self.class.name}:#{object_id}"
75
+ @interactive = options[:interactive]
75
76
  @source_id = options[:source_id] || @repository_id
76
77
  end
77
78
 
@@ -82,6 +83,7 @@ class Importer
82
83
  # two git importers that point to the same repository but different branches
83
84
  # would have the same repository_id but different source_id
84
85
  #
86
+ # @return [String]
85
87
  # @see source_id
86
88
  attr_reader :repository_id
87
89
 
@@ -92,9 +94,14 @@ class Importer
92
94
  # point to the same repository but different branches would have the same
93
95
  # repository_id but different source_id
94
96
  #
97
+ # @return [String]
95
98
  # @see repository_id
96
99
  attr_reader :source_id
97
100
 
101
+ # Whether this importer will need interaction with the user, for instance to
102
+ # give credentials
103
+ def interactive?; !!@interactive end
104
+
98
105
  # The number of times update / checkout should be retried before giving up.
99
106
  # The default is 0 (do not retry)
100
107
  #
@@ -204,11 +211,11 @@ class Importer
204
211
  fallback(e, package, :import, package)
205
212
  end
206
213
 
207
- def perform_checkout(package)
214
+ def perform_checkout(package, options = Hash.new)
208
215
  package.progress_start "checking out %s", :done_message => 'checked out %s' do
209
216
  retry_count = 0
210
217
  begin
211
- checkout(package)
218
+ checkout(package, options)
212
219
  rescue Interrupt
213
220
  raise
214
221
  rescue ::Exception => original_error
@@ -268,7 +275,8 @@ class Importer
268
275
  only_local: false,
269
276
  reset: false,
270
277
  checkout_only: false,
271
- ignore_errors: false
278
+ ignore_errors: false,
279
+ allow_interactive: true
272
280
  ignore_errors = options.delete(:ignore_errors)
273
281
 
274
282
  importdir = package.importdir
@@ -288,7 +296,7 @@ class Importer
288
296
  raise ConfigException.new(package, 'import'), "#{importdir} exists but is not a directory"
289
297
  else
290
298
  package.isolate_errors(mark_as_failed: true, ignore_errors: ignore_errors) do
291
- perform_checkout(package)
299
+ perform_checkout(package, allow_interactive: options[:allow_interactive])
292
300
  end
293
301
  end
294
302
  end
@@ -229,6 +229,7 @@ module Autobuild
229
229
  end
230
230
 
231
231
  def resolve_cycle(tasks)
232
+ cycle = tasks.dup
232
233
  chain = []
233
234
  next_task = tasks.first
234
235
  while true
@@ -244,7 +245,7 @@ module Autobuild
244
245
  end
245
246
  end
246
247
  if !next_task
247
- raise "something fishy while resolving a cycle in #{tasks.map(&:name).join(", ")}. Some of these packages might have added new dependencies during the task resolution, which is forbidden"
248
+ raise "something fishy while resolving a cycle in #{cycle.map(&:name).join(", ")}. Some of these packages might have added new dependencies during the task resolution, which is forbidden"
248
249
  end
249
250
  end
250
251
  chain
@@ -298,7 +298,13 @@ module Autobuild
298
298
 
299
299
  rescue Autobuild::Exception => e
300
300
  error(e)
301
- exit(1) if e.fatal?
301
+ if e.fatal?
302
+ if Autobuild.debug
303
+ raise
304
+ else
305
+ exit 1
306
+ end
307
+ end
302
308
  end
303
309
  end
304
310
 
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.10.0.b1" unless defined? Autobuild::VERSION
2
+ VERSION = "1.10.0.b2" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
@@ -25,6 +25,25 @@ class TC_TarImporter < Minitest::Test
25
25
  assert_equal(TarImporter::Bzip, TarImporter.filename_to_mode('tarfile.tar.bz2'))
26
26
  end
27
27
 
28
+ def test_it_sets_the_repository_id_to_the_normalized_URL
29
+ importer = TarImporter.new "FILE://test/file"
30
+ assert_equal "file://test/file", importer.repository_id.to_str
31
+ end
32
+
33
+ def test_it_sets_the_source_id_to_the_normalized_URL
34
+ importer = TarImporter.new "FILE://test/file"
35
+ assert_equal "file://test/file", importer.source_id.to_str
36
+ end
37
+
38
+ def test_it_does_not_delete_a_locally_specified_archive_on_error
39
+ dummy_tar = File.join(@datadir, "dummy.tar")
40
+ FileUtils.touch dummy_tar
41
+ importer = TarImporter.new "file://#{dummy_tar}"
42
+ pkg = Package.new 'tarimport'
43
+ assert_raises(Autobuild::SubcommandFailed) { importer.checkout(pkg) }
44
+ assert File.file?(dummy_tar)
45
+ end
46
+
28
47
  def test_tar_valid_url
29
48
  assert_raises(ConfigException) {
30
49
  TarImporter.new 'ccc://localhost/files/tarimport.tar.gz', :cachedir => @cachedir
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0.b1
4
+ version: 1.10.0.b2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake