autobuild 1.12.3 → 1.13.0.pre1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6623e40c3f107c71c1f9637be0c944a3ffe2a2d
4
- data.tar.gz: 7e3298cad9cb1215943573c57a0d70c29b36b676
3
+ metadata.gz: 221937ffc7554479e1190a3ebb88f288049bc56b
4
+ data.tar.gz: f2921614437608110ca0f9b5844df8e4f46e89a5
5
5
  SHA512:
6
- metadata.gz: 405285def822d6a26bc51bd7d336e76e20ba74d434dbb68c67b41b90d8cdbe13f2bbbd0512a81d3575a6f9283a2968d516d3f899eba2ef13dd74cd26a26d0211
7
- data.tar.gz: 20b5ebff2c2df256013c51e30064509ff7c99da00034de90816307cc163ca7af65d1593501b74e102b4f24252f5dc760a61520cb01622d09e7e4c1805f87b7e2
6
+ metadata.gz: 5a48c3e03b0ed90ac3557b8d02b511ce60b05afe25173695f29ffb0af154e6d3a9e387df3494aea55b12a2e11bcdff3ca1755f4a21754d08435d24708b9a42fd
7
+ data.tar.gz: 8418450a662dd4fc8f40bf9f515a750cf7cf95e0893f2bc215e767e05b1fa61556b8a673029a6b910a7923746598200b979c8e08bce64dbb8b19e70eb3a869fd
@@ -19,9 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.extensions = []
20
20
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
21
 
22
- s.add_runtime_dependency "rake", "~> 12.0", ">= 12.0.0", '< 12.1.0'
22
+ s.add_runtime_dependency "rake", "~> 12.0", ">= 12.3.0"
23
23
  s.add_runtime_dependency "utilrb", "~> 3.0", ">= 3.0"
24
- s.add_runtime_dependency 'tty-prompt', '~> 0.12.0', '>= 0.12.0'
24
+ s.add_runtime_dependency 'tty-prompt', '~> 0.15.0'
25
25
  s.add_runtime_dependency 'pastel', '~> 0.7.0', '>= 0.7.0'
26
26
  s.add_development_dependency "flexmock", '~> 2.0', ">= 2.0.0"
27
27
  s.add_development_dependency "minitest", "~> 5.0", ">= 5.0"
@@ -73,7 +73,7 @@ def create_utility(utility_name, package)
73
73
  else raise ArgumentError, "there is no utility called #{utility_name}, available utilities are #{utilities.keys.sort.join(", ")}"
74
74
  end
75
75
  end
76
- # The directory in which logs are saved. Defaults to PREFIX/log.
76
+ # The directory in which logs are saved. Defaults to PREFIX/log.
77
77
  attr_writer :logdir
78
78
 
79
79
  # True if we build and if the build is applied on all packages
@@ -116,45 +116,45 @@ def self.color(message, *style)
116
116
 
117
117
  @post_install_handlers = Array.new
118
118
  def self.post_install(*args, &block)
119
- if args.empty?
120
- @post_install_handlers << block
121
- elsif !block
122
- @post_install_handlers << args
123
- else
124
- raise ArgumentError, "cannot set both arguments and block"
125
- end
119
+ if args.empty?
120
+ @post_install_handlers << block
121
+ elsif !block
122
+ @post_install_handlers << args
123
+ else
124
+ raise ArgumentError, "cannot set both arguments and block"
125
+ end
126
126
  end
127
127
  class << self
128
128
  attr_reader :post_install_handlers
129
129
  end
130
130
 
131
131
  def self.apply_post_install(pkg, info)
132
- return unless info
133
-
134
- case info
135
- when Array
136
- args = info.dup
137
- tool = Autobuild.tool(args.shift)
138
- pkg.run 'post-install', tool, *args
139
- when Proc
132
+ return unless info
133
+
134
+ case info
135
+ when Array
136
+ args = info.dup
137
+ tool = Autobuild.tool(args.shift)
138
+ pkg.run 'post-install', tool, *args
139
+ when Proc
140
140
  if info.arity == 1
141
141
  info.call(pkg)
142
142
  else
143
143
  info.call
144
144
  end
145
- end
145
+ end
146
146
  end
147
147
 
148
148
  @mail = Hash.new
149
149
  class << self
150
- # Mailing configuration. It is a hash with the following keys (as symbols)
151
- # [:to] the mail destination. Defaults to USER@HOSTNAME, where USER is the username
152
- # of autobuild's caller, and HOSTNAME the hostname of the current machine.
153
- # [:from] the mail origin. Defaults to the same value than +:to+
154
- # [:smtp] the hostname of the SMTP server, defaults to localhost
155
- # [:port] the port of the SMTP server, defauts to 22
156
- # [:only_errors] mail only on errors. Defaults to false.
157
- attr_reader :mail
150
+ # Mailing configuration. It is a hash with the following keys (as symbols)
151
+ # [:to] the mail destination. Defaults to USER@HOSTNAME, where USER is the username
152
+ # of autobuild's caller, and HOSTNAME the hostname of the current machine.
153
+ # [:from] the mail origin. Defaults to the same value than +:to+
154
+ # [:smtp] the hostname of the SMTP server, defaults to localhost
155
+ # [:port] the port of the SMTP server, defauts to 22
156
+ # [:only_errors] mail only on errors. Defaults to false.
157
+ attr_reader :mail
158
158
 
159
159
  # call-seq:
160
160
  # post_success_message => string
@@ -178,18 +178,18 @@ def post_success_message(*args, &block)
178
178
  end
179
179
  end
180
180
 
181
- # The directory in which logs are saved
181
+ # The directory in which logs are saved
182
182
  def logdir; @logdir || "#{prefix}/log" end
183
183
 
184
- # Removes all log files
184
+ # Removes all log files
185
185
  def clean_log!
186
186
  Reporting.each_log do |file|
187
187
  FileUtils.rm_f file
188
188
  end
189
189
  end
190
190
 
191
- # Gets autobuild options from the command line and returns the
192
- # remaining elements
191
+ # Gets autobuild options from the command line and returns the
192
+ # remaining elements
193
193
  def commandline(args)
194
194
  parser = OptionParser.new do |opts|
195
195
  opts.separator "Path specification"
@@ -204,9 +204,9 @@ def commandline(args)
204
204
  puts opts
205
205
  exit
206
206
  end
207
- if defined? Daemons
208
- opts.on("--[no-]daemon", "go into daemon mode") do |v| Autobuild.daemonize = v end
209
- end
207
+ if defined? Daemons
208
+ opts.on("--[no-]daemon", "go into daemon mode") do |v| Autobuild.daemonize = v end
209
+ end
210
210
  opts.on("--no-update", "update already checked-out sources") do |v| Autobuild.do_update = v end
211
211
  opts.on("--no-build", "only prepare packages, do not build them") do |v| Autobuild.do_build = v end
212
212
  opts.on("--forced-build", "force the trigger of all the build commands") do |v| Autobuild.do_forced_build = v end
@@ -226,25 +226,25 @@ def commandline(args)
226
226
  end
227
227
 
228
228
  opts.separator ""
229
- opts.separator "Mail reports"
230
- opts.on("--mail-from EMAIL", String, "From: field of the sent mails") do |from_email|
231
- mail[:from] = from_email
232
- end
233
- opts.on("--mail-to EMAILS", String, "comma-separated list of emails to which the reports should be sent") do |emails|
234
- mail[:to] ||= []
235
- mail[:to] += emails.split(',')
236
- end
237
- opts.on("--mail-subject SUBJECT", String, "Subject: field of the sent mails") do |subject_email|
238
- mail[:subject] = subject_email
239
- end
240
- opts.on("--mail-smtp HOSTNAME", String, " address of the mail server written as hostname[:port]") do |smtp|
241
- raise "invalid SMTP specification #{smtp}" unless smtp =~ /^([^:]+)(?::(\d+))?$/
242
- mail[:smtp] = $1
243
- mail[:port] = Integer($2) if $2 && !$2.empty?
244
- end
245
- opts.on("--mail-only-errors", "send mail only on errors") do
246
- mail[:only_errors] = true
247
- end
229
+ opts.separator "Mail reports"
230
+ opts.on("--mail-from EMAIL", String, "From: field of the sent mails") do |from_email|
231
+ mail[:from] = from_email
232
+ end
233
+ opts.on("--mail-to EMAILS", String, "comma-separated list of emails to which the reports should be sent") do |emails|
234
+ mail[:to] ||= []
235
+ mail[:to] += emails.split(',')
236
+ end
237
+ opts.on("--mail-subject SUBJECT", String, "Subject: field of the sent mails") do |subject_email|
238
+ mail[:subject] = subject_email
239
+ end
240
+ opts.on("--mail-smtp HOSTNAME", String, " address of the mail server written as hostname[:port]") do |smtp|
241
+ raise "invalid SMTP specification #{smtp}" unless smtp =~ /^([^:]+)(?::(\d+))?$/
242
+ mail[:smtp] = $1
243
+ mail[:port] = Integer($2) if $2 && !$2.empty?
244
+ end
245
+ opts.on("--mail-only-errors", "send mail only on errors") do
246
+ mail[:only_errors] = true
247
+ end
248
248
 
249
249
  end
250
250
 
@@ -469,20 +469,15 @@ def source_after(file = nil)
469
469
  end
470
470
  end
471
471
 
472
- # Generates a shell script that sets the environment variable listed in
473
- # Autobuild.environment, following the inheritance setting listed in
474
- # Autobuild.inherited_environment.
475
- #
476
- # It also sources the files added by source_file
477
- def export_env_sh(io)
478
- source_before.each do |path|
479
- io.puts SHELL_SOURCE_SCRIPT % path
480
- end
472
+ ExportedEnvironment = Struct.new :set, :unset, :update
481
473
 
482
- unset_variables = Set.new
483
- variables = []
474
+ # Computes the set of environment modification operations that should
475
+ # be applied to load this environment
476
+ #
477
+ # This is for instance used to generate the env.sh
478
+ def exported_environment
479
+ export = ExportedEnvironment.new(Hash.new, Array.new, Hash.new)
484
480
  environment.each_key do |name|
485
- variables << name
486
481
  value_with_inheritance = value(name, inheritance_mode: :keep)
487
482
  value_without_inheritance = value(name, inheritance_mode: :ignore)
488
483
  if path_variable?(name)
@@ -492,25 +487,74 @@ def export_env_sh(io)
492
487
  end
493
488
 
494
489
  if !value_with_inheritance
495
- unset_variables << name
496
- shell_line = SHELL_UNSET_COMMAND % [name]
490
+ export.unset << name
497
491
  elsif value_with_inheritance == value_without_inheritance # no inheritance
498
- shell_line = SHELL_SET_COMMAND % [name, value_with_inheritance.join(File::PATH_SEPARATOR)]
492
+ export.set[name] = value_with_inheritance
499
493
  else
500
- shell_line = SHELL_CONDITIONAL_SET_COMMAND % [name, value_with_inheritance.join(File::PATH_SEPARATOR), value_without_inheritance.join(File::PATH_SEPARATOR)]
494
+ export.update[name] = [value_with_inheritance, value_without_inheritance]
501
495
  end
502
- io.puts shell_line
503
496
  end
504
- variables.each do |var|
505
- if !unset_variables.include?(var)
506
- io.puts SHELL_EXPORT_COMMAND % [var]
507
- end
497
+ export
498
+ end
499
+
500
+ # Generates a shell script that sets the environment variable listed in
501
+ # Autobuild.environment, following the inheritance setting listed in
502
+ # Autobuild.inherited_environment.
503
+ #
504
+ # It also sources the files added by source_file
505
+ def export_env_sh(io)
506
+ export = exported_environment
507
+ source_before.each do |path|
508
+ io.puts SHELL_SOURCE_SCRIPT % path
509
+ end
510
+ export.unset.each do |name|
511
+ io.puts SHELL_UNSET_COMMAND % [name]
512
+ end
513
+ export.set.each do |name, value|
514
+ io.puts SHELL_SET_COMMAND % [name, value.join(File::PATH_SEPARATOR)]
515
+ io.puts SHELL_EXPORT_COMMAND % [name]
516
+ end
517
+ export.update.each do |name, (with_inheritance, without_inheritance)|
518
+ io.puts SHELL_CONDITIONAL_SET_COMMAND % [name, with_inheritance.join(File::PATH_SEPARATOR), without_inheritance.join(File::PATH_SEPARATOR)]
519
+ io.puts SHELL_EXPORT_COMMAND % [name]
508
520
  end
509
521
  source_after.each do |path|
510
522
  io.puts SHELL_SOURCE_SCRIPT % [path]
511
523
  end
512
524
  end
513
525
 
526
+ # Build an environment hash from an environment export and some initial state
527
+ #
528
+ # This is basically the programmatic version of what {#export_env_sh}
529
+ # instructs the shell to do
530
+ def self.environment_from_export(export, base_env = ENV)
531
+ result = Hash.new
532
+ export.set.each do |name, value|
533
+ result[name] = value.join(File::PATH_SEPARATOR)
534
+ end
535
+ base_env.each do |name, value|
536
+ result[name] ||= value
537
+ end
538
+ export.unset.each do |name|
539
+ result.delete(name)
540
+ end
541
+ export.update.each do |name, (with_inheritance, without_inheritance)|
542
+ if result[name]
543
+ variable_expansion = "$#{name}"
544
+ with_inheritance = with_inheritance.map do |value|
545
+ if value == variable_expansion
546
+ base_env[name]
547
+ else value
548
+ end
549
+ end
550
+ result[name] = with_inheritance.join(File::PATH_SEPARATOR)
551
+ else
552
+ result[name] = without_inheritance.join(File::PATH_SEPARATOR)
553
+ end
554
+ end
555
+ result
556
+ end
557
+
514
558
  # DEPRECATED: use add_path instead
515
559
  def self.pathvar(path, varname)
516
560
  if File.directory?(path)
@@ -560,7 +604,7 @@ def arch_size
560
604
  end
561
605
  out = `#{cmdline.join(" ")}`.split
562
606
  arch = out.grep(/DEB_TARGET_ARCH_BITS/).first ||
563
- out.grep(/DEB_BUILD_ARCH_BITS/).first
607
+ out.grep(/DEB_BUILD_ARCH_BITS/).first
564
608
  if arch
565
609
  @arch_size = Integer(arch.chomp.split('=').last)
566
610
  end
@@ -596,7 +640,7 @@ def arch_names
596
640
  end
597
641
  out = `#{cmdline.join(" ")}`.split
598
642
  arch = out.grep(/DEB_TARGET_MULTIARCH/).first ||
599
- out.grep(/DEB_BUILD_MULTIARCH/).first
643
+ out.grep(/DEB_BUILD_MULTIARCH/).first
600
644
  if arch
601
645
  result << arch.chomp.split('=').last
602
646
  end
@@ -670,7 +714,11 @@ def add_prefix(newprefix, includes = nil)
670
714
  end
671
715
 
672
716
  def find_executable_in_path(file, path_var = 'PATH')
673
- (value(path_var) || Array.new).each do |dir|
717
+ self.class.find_executable_in_path(file, value(path_var) || Array.new)
718
+ end
719
+
720
+ def self.find_executable_in_path(file, entries)
721
+ entries.each do |dir|
674
722
  full = File.join(dir, file)
675
723
  begin
676
724
  stat = File.stat(full)
@@ -684,7 +732,11 @@ def find_executable_in_path(file, path_var = 'PATH')
684
732
  end
685
733
 
686
734
  def find_in_path(file, path_var = 'PATH')
687
- (value(path_var) || Array.new).each do |dir|
735
+ self.class.find_in_path(file, value(path_var) || Array.new)
736
+ end
737
+
738
+ def self.find_in_path(file, entries)
739
+ entries.each do |dir|
688
740
  full = File.join(dir, file)
689
741
  if File.file?(full)
690
742
  return full
@@ -122,5 +122,26 @@ def to_s
122
122
  class InteractionRequired < RuntimeError; end
123
123
 
124
124
  class AlreadyFailedError < RuntimeError; end
125
- end
126
125
 
126
+ # The exception type that is used to report multiple errors that occured
127
+ # when ignore_errors is set
128
+ class CompositeException < Autobuild::Exception
129
+ # The array of exception objects representing all the errors that
130
+ # occured during the build
131
+ attr_reader :original_errors
132
+
133
+ def initialize(original_errors)
134
+ @original_errors = original_errors
135
+ end
136
+
137
+ def mail?; true end
138
+
139
+ def to_s
140
+ result = ["#{original_errors.size} errors occured"]
141
+ original_errors.each_with_index do |e, i|
142
+ result << "(#{i}) #{e.to_s}"
143
+ end
144
+ result.join("\n")
145
+ end
146
+ end
147
+ end
@@ -5,20 +5,20 @@
5
5
 
6
6
  WINDOWS = RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
7
7
  if WINDOWS
8
- require 'net/http'
9
- require 'net/https'
10
- require 'rubygems/package'
11
- require 'zlib'
8
+ require 'net/http'
9
+ require 'net/https'
10
+ require 'rubygems/package'
11
+ require 'zlib'
12
12
  end
13
13
 
14
14
 
15
15
  module Autobuild
16
16
  class ArchiveImporter < Importer
17
- # The tarball is not compressed
17
+ # The tarball is not compressed
18
18
  Plain = 0
19
- # The tarball is compressed with gzip
19
+ # The tarball is compressed with gzip
20
20
  Gzip = 1
21
- # The tarball is compressed using bzip
21
+ # The tarball is compressed using bzip
22
22
  Bzip = 2
23
23
  # Not a tarball but a zip
24
24
  Zip = 3
@@ -29,7 +29,7 @@ class ArchiveImporter < Importer
29
29
  Bzip => 'j'
30
30
  }
31
31
 
32
- # Known URI schemes for +url+
32
+ # Known URI schemes for +url+
33
33
  VALID_URI_SCHEMES = [ 'file', 'http', 'https', 'ftp' ]
34
34
 
35
35
  class << self
@@ -67,7 +67,7 @@ def cachedir
67
67
  @timeout = 10
68
68
  @cachedir = nil
69
69
 
70
- # Returns the unpack mode from the file name
70
+ # Returns the unpack mode from the file name
71
71
  #
72
72
  # @return [Integer,nil] either one of the pack constants (Zip, Plain,
73
73
  # ...) or nil if it cannot be inferred
@@ -81,7 +81,7 @@ def self.find_mode_from_filename(filename)
81
81
  end
82
82
  end
83
83
 
84
- # Returns the unpack mode from the file name
84
+ # Returns the unpack mode from the file name
85
85
  def self.filename_to_mode(filename)
86
86
  if mode = find_mode_from_filename(filename)
87
87
  mode
@@ -104,9 +104,9 @@ def self.auto_update?
104
104
 
105
105
  def update_cached_file?; @options[:update_cached_file] end
106
106
 
107
-
108
- def get_url_on_windows(url, filename)
109
- uri = URI(url)
107
+
108
+ def get_url_on_windows(url, filename)
109
+ uri = URI(url)
110
110
 
111
111
  http = Net::HTTP.new(uri.host,uri.port)
112
112
  http.use_ssl = true if uri.port == 443
@@ -123,8 +123,8 @@ def get_url_on_windows(url, filename)
123
123
  file.write(resp.body)
124
124
  end
125
125
  end
126
- end
127
-
126
+ end
127
+
128
128
  def extract_tar_on_windows(filename,target)
129
129
  Gem::Package::TarReader.new(Zlib::GzipReader.open(filename)).each do |entry|
130
130
  newname = File.join(target,entry.full_name.slice(entry.full_name.index('/'),entry.full_name.size))
@@ -142,8 +142,8 @@ def extract_tar_on_windows(filename,target)
142
142
  end
143
143
  end
144
144
  end
145
-
146
- # Updates the downloaded file in cache only if it is needed
145
+
146
+ # Updates the downloaded file in cache only if it is needed
147
147
  def update_cache(package)
148
148
  do_update = false
149
149
 
@@ -206,18 +206,18 @@ def update_cache(package)
206
206
  do_update
207
207
  end
208
208
 
209
- # The source URL
209
+ # The source URL
210
210
  attr_reader :url
211
- # The local file (either a downloaded file if +url+ is not local, or +url+ itself)
212
- attr_reader :cachefile
211
+ # The local file (either a downloaded file if +url+ is not local, or +url+ itself)
212
+ attr_reader :cachefile
213
213
  # The SHA1 digest of the current cachefile. It is updated only once the
214
214
  # cachefile has been downloaded
215
215
  #
216
216
  # @return [String] hexadecimal SHA1 digest of the file
217
217
  attr_reader :cachefile_digest
218
- # The unpack mode. One of Zip, Bzip, Gzip or Plain
219
- attr_reader :mode
220
- # The directory in which remote files are cached
218
+ # The unpack mode. One of Zip, Bzip, Gzip or Plain
219
+ attr_reader :mode
220
+ # The directory in which remote files are cached
221
221
  #
222
222
  # Defaults to ArchiveImporter.cachedir
223
223
  attr_reader :cachedir
@@ -228,10 +228,10 @@ def cachedir=(dir)
228
228
  relocate(@url.to_s)
229
229
  end
230
230
 
231
- # The directory contained in the tar file
231
+ # The directory contained in the tar file
232
232
  #
233
233
  # DEPRECATED use #archive_dir instead
234
- def tardir; @options[:tardir] end
234
+ def tardir; @options[:tardir] end
235
235
  # The directory contained in the archive. If not set, we assume that it
236
236
  # is the same than the source dir
237
237
  def archive_dir; @options[:archive_dir] || tardir end
@@ -270,9 +270,9 @@ def has_subdirectory?
270
270
  !@options[:no_subdirectory]
271
271
  end
272
272
 
273
- # Creates a new importer which downloads +url+ in +cachedir+ and unpacks it. The following options
274
- # are allowed:
275
- # [:cachedir] the cache directory. Defaults to "#{Autobuild.prefix}/cache"
273
+ # Creates a new importer which downloads +url+ in +cachedir+ and unpacks it. The following options
274
+ # are allowed:
275
+ # [:cachedir] the cache directory. Defaults to "#{Autobuild.prefix}/cache"
276
276
  # [:archive_dir] the directory contained in the archive file. If set,
277
277
  # the importer will rename that directory to make it match
278
278
  # Package#srcdir
@@ -414,7 +414,7 @@ def checkout(package, options = Hash.new) # :nodoc:
414
414
  if !@options[:no_subdirectory]
415
415
  cmd << '--strip-components=1'
416
416
  end
417
-
417
+
418
418
  if(WINDOWS)
419
419
  extract_tar_on_windows(cachefile,package.srcdir)
420
420
  else
@@ -439,12 +439,12 @@ def checkout(package, options = Hash.new) # :nodoc:
439
439
  # Creates an importer which downloads a tarball from +source+ and unpacks
440
440
  # it. The allowed values in +options+ are described in ArchiveImporter.new.
441
441
  def self.archive(source, options = {})
442
- ArchiveImporter.new(source, options)
442
+ ArchiveImporter.new(source, options)
443
443
  end
444
444
 
445
445
  # DEPRECATED. Use Autobuild.archive instead.
446
446
  def self.tar(source, options = {})
447
- ArchiveImporter.new(source, options)
447
+ ArchiveImporter.new(source, options)
448
448
  end
449
449
  end
450
450