autoproj 2.0.0.rc39 → 2.0.0.rc40

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: d50b298207a3006893877e6c968a46ec5614ed91
4
- data.tar.gz: f6e394d4adb73e2d0f4ed6f9d2e8113e041aede9
3
+ metadata.gz: 2a07dcff0dd83e7effa40c2e49cb6e7c787b8e91
4
+ data.tar.gz: 10d415d8951ffd95569ecdcceb6e57b21bc5f50d
5
5
  SHA512:
6
- metadata.gz: 267238c6a85992b631faaa5283558e5e90ad05d4cac54cedb4ed3a8cf480445b569536c324089b17a7f91d3f89965f6c93f1adfd27076b8750e5a317dd95036f
7
- data.tar.gz: 329ac2bb6222d965f9aa4121cfce725a9e4911301a606913a00b062f6f42c5ad3a037a3c327e773c9d9518b75f410185b3d5d973db31c6a712aa7704da79852a
6
+ metadata.gz: 9e5dbc3159967f110d135b2a698ddfac4832ad19c7c6155c80dd3a9d45d7118563bec8e7e035c75b39f5110a2d39242290f01eb9a0a64733a68e4b499fa55c83
7
+ data.tar.gz: ad22069f7b21df19a71daf6e0e9c6b1c58c875b8883645dd04e35fb3f5c6a13285ce9054de2dbc74f852f322877fc6808601513f0f0f88f5e3a70e4ad8c005d8
data/autoproj.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency "thor", '~> 0.19.0', '>= 0.19.1'
29
29
  s.add_runtime_dependency 'concurrent-ruby'
30
30
  s.add_runtime_dependency 'tty-color', '~> 0.3.0', '>= 0.3.0'
31
+ s.add_runtime_dependency 'tty-prompt'
31
32
  s.add_development_dependency "flexmock", ">= 2.0.0"
32
33
  s.add_development_dependency "minitest", ">= 5.0", "~> 5.0"
33
34
  s.add_development_dependency "fakefs"
@@ -46,7 +46,7 @@ def run(buildconf_info, options)
46
46
  FileUtils.cp seed_config, File.join(ws.config_dir, 'config.yml')
47
47
  end
48
48
 
49
- STDERR.puts <<-EOTEXT
49
+ STDOUT.puts <<-EOTEXT
50
50
 
51
51
 
52
52
  #{Autoproj.color('autoproj bootstrap successfully finished', :green, :bold)}
@@ -108,32 +108,68 @@ def initialize_from_workspace
108
108
  @package_sets = ws.manifest.each_package_set.to_a
109
109
  end
110
110
 
111
- def run(selections, cache: !!packages, build: false, prefix: false)
112
- if !cache
113
- initialize_from_workspace
111
+ def validate_options(selections, options = Hash.new)
112
+ selections, options = super
113
+ mode = if options.delete(:build)
114
+ :build_dir
115
+ elsif options.delete(:prefix)
116
+ :prefix_dir
117
+ elsif log_type = options[:log]
118
+ if log_type == 'log'
119
+ options.delete(:log)
120
+ end
121
+ :log
122
+ else
123
+ :source_dir
124
+ end
125
+ options[:mode] ||= mode
126
+ if selections.empty?
127
+ selections << ws.root_dir
114
128
  end
129
+ return selections, options
130
+ end
115
131
 
116
- if selections.empty?
117
- if prefix || build
118
- puts ws.prefix_dir
119
- else
120
- puts ws.root_dir
121
- end
132
+ RESOLUTION_MODES = [:source_dir, :build_dir, :prefix_dir, :log]
133
+
134
+ def run(selections, cache: !!packages, mode: :source_dir, log: nil)
135
+ if !RESOLUTION_MODES.include?(mode)
136
+ raise ArgumentError, "'#{mode}' was expected to be one of #{RESOLUTION_MODES}"
137
+ elsif !cache
138
+ initialize_from_workspace
122
139
  end
123
140
 
124
141
  selections.each do |string|
125
142
  if File.directory?(string)
126
143
  string = "#{File.expand_path(string)}/"
127
144
  end
128
- puts location_of(string, build: build, prefix: prefix)
145
+ if mode == :source_dir
146
+ puts source_dir_of(string)
147
+ elsif mode == :build_dir
148
+ puts build_dir_of(string)
149
+ elsif mode == :prefix_dir
150
+ puts prefix_dir_of(string)
151
+ elsif mode == :log
152
+ if all_logs = (log == 'all')
153
+ log = nil
154
+ end
155
+ result = logs_of(string, log: log)
156
+ if (result.size == 1) || all_logs
157
+ result.each { |p| puts p }
158
+ elsif result.size > 1
159
+ puts select_log_file(result)
160
+ elsif result.empty?
161
+ raise NotFound, "no logs found for #{string}"
162
+ end
163
+ end
129
164
  end
130
165
  end
131
166
 
132
- def location_of(selection, prefix: false, build: false)
133
- if pkg_set = find_package_set(selection)
134
- return pkg_set.user_local_dir
135
- end
136
-
167
+ # Resolve the package that matches a given selection
168
+ #
169
+ # @return [PackageDefinition]
170
+ # @raise [NotFound] if nothing matches
171
+ # @raise [AmbiguousSelection] if the selection is ambiguous
172
+ def resolve_package(selection)
137
173
  matching_packages = find_packages(selection)
138
174
  if matching_packages.empty?
139
175
  matching_packages = find_packages_with_directory_shortnames(selection)
@@ -153,19 +189,103 @@ def location_of(selection, prefix: false, build: false)
153
189
  elsif matching_packages.size > 1
154
190
  raise AmbiguousSelection, "multiple packages match '#{selection}' in the current autoproj installation: #{matching_packages.map(&:name).sort.join(", ")}"
155
191
  else
156
- pkg = matching_packages.first
157
- if prefix
158
- pkg.prefix
159
- elsif build
160
- if pkg.respond_to?(:builddir) && pkg.builddir
161
- pkg.builddir
162
- else
163
- raise ArgumentError, "#{pkg.name} does not have a build directory"
164
- end
192
+ return matching_packages.first
193
+ end
194
+ end
195
+
196
+ # Tests whether 'selection' points to one of the workspace's root
197
+ # directories
198
+ def workspace_dir?(selection)
199
+ selection == "#{ws.root_dir}/" || selection == "#{ws.prefix_dir}/"
200
+ end
201
+
202
+ # Returns the source directory for a given selection
203
+ def source_dir_of(selection)
204
+ if workspace_dir?(selection)
205
+ ws.root_dir
206
+ elsif pkg_set = find_package_set(selection)
207
+ pkg_set.user_local_dir
208
+ else
209
+ resolve_package(selection).srcdir
210
+ end
211
+ end
212
+
213
+ # Returns the prefix directory for a given selection
214
+ #
215
+ # @raise [ArgumentError] if the selection points to a package set
216
+ def prefix_dir_of(selection)
217
+ if workspace_dir?(selection)
218
+ ws.prefix_dir
219
+ elsif find_package_set(selection)
220
+ raise ArgumentError, "#{selection} is a package set, and package sets do not have prefixes"
221
+ else
222
+ resolve_package(selection).prefix
223
+ end
224
+ end
225
+
226
+ # Returns the build directory for a given selection
227
+ #
228
+ # @raise [ArgumentError] if the selection points to a package set,
229
+ # or to a package that has no build directory
230
+ def build_dir_of(selection)
231
+ if workspace_dir?(selection)
232
+ raise ArgumentError, "#{selection} points to the workspace itself, which has no build dir"
233
+ elsif find_package_set(selection)
234
+ raise ArgumentError, "#{selection} is a package set, and package sets do not have build directories"
235
+ else
236
+ pkg = resolve_package(selection)
237
+ if pkg.respond_to?(:builddir) && pkg.builddir
238
+ pkg.builddir
239
+ else
240
+ raise ArgumentError, "#{selection} resolves to the package #{pkg.name}, which does not have a build directory"
241
+ end
242
+ end
243
+ end
244
+
245
+ # Resolve logs available for what points to the given selection
246
+ #
247
+ # The workspace is resolved as the main configuration
248
+ #
249
+ # If 'log' is nil and multiple logs are available,
250
+ def logs_of(selection, log: nil)
251
+ if workspace_dir?(selection) || (pkg_set = find_package_set(selection))
252
+ if log && log != 'import'
253
+ return []
254
+ end
255
+ name = if pkg_set then pkg_set.name
256
+ else "autoproj main configuration"
257
+ end
258
+
259
+ import_log = File.join(ws.log_dir, "#{name}-import.log")
260
+ if File.file?(import_log)
261
+ return [import_log]
262
+ else return []
263
+ end
264
+ else
265
+ pkg = resolve_package(selection)
266
+ Dir.enum_for(:glob, File.join(pkg.logdir, "#{pkg.name}-#{log || '*'}.log")).to_a
267
+ end
268
+ end
269
+
270
+ # Interactively select a log file among a list
271
+ def select_log_file(log_files)
272
+ require 'tty/prompt'
273
+
274
+ log_files = log_files.map do |path|
275
+ [path, File.stat(path).mtime]
276
+ end.sort_by(&:last).reverse
277
+
278
+ choices = Hash.new
279
+ log_files.each do |path, mtime|
280
+ if path =~ /-(\w+)\.log/
281
+ choices["(#{mtime}) #{$1}"] = path
165
282
  else
166
- pkg.srcdir
283
+ choices["(#{mtime}) #{path}"] = path
167
284
  end
168
285
  end
286
+
287
+ prompt = TTY::Prompt.new
288
+ prompt.select("Select the log file", choices)
169
289
  end
170
290
  end
171
291
  end
@@ -173,6 +173,8 @@ def clean(*packages)
173
173
  desc: "outputs the package's prefix directory instead of its source directory"
174
174
  option :build, aliases: :b, type: :boolean,
175
175
  desc: "outputs the package's build directory instead of its source directory"
176
+ option :log, aliases: :l,
177
+ desc: "outputs the path to a package's log file"
176
178
  def locate(*packages)
177
179
  run_autoproj_cli(:locate, :Locate, Hash[], *packages)
178
180
  end
@@ -32,8 +32,6 @@ def export_env_sh(subdir = nil, options = Hash.new)
32
32
 
33
33
  shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__))
34
34
  if options[:shell_helpers]
35
- Autoproj.message "sourcing autoproj shell helpers"
36
- Autoproj.message "add \"Autoproj.config.shell_helpers = false\" in autoproj/init.rb to disable"
37
35
  source_after(File.join(shell_dir, "autoproj_sh"))
38
36
  end
39
37
 
@@ -127,12 +127,6 @@ def update_remote_package_set(vcs,
127
127
  return
128
128
  end
129
129
 
130
- # YUK. I am stopping there in the refactoring
131
- # TODO: figure out a better way
132
- if !@remote_update_message_displayed
133
- Autoproj.message("autoproj: updating remote definitions of package sets", :bold)
134
- @remote_update_message_displayed = true
135
- end
136
130
  ws.install_os_packages([vcs.type], all: nil)
137
131
  update_configuration_repository(
138
132
  vcs, name, raw_local_dir,
@@ -473,7 +467,6 @@ def load_package_set_information(mainline: nil)
473
467
  load_osdeps_from_package_sets
474
468
 
475
469
  # Load the required autobuild definitions
476
- Autoproj.message("autoproj: loading ...", :bold)
477
470
  manifest.each_package_set do |pkg_set|
478
471
  pkg_set.each_autobuild_file do |path|
479
472
  ws.import_autobuild_file pkg_set, path
@@ -607,12 +600,6 @@ def update_package_sets(only_local: false,
607
600
  package_sets.each do |pkg_set|
608
601
  ws.manifest.register_package_set(pkg_set)
609
602
  end
610
- # YUK. I am stopping there in the refactoring
611
- # TODO: figure out a better way
612
- if @remote_update_message_displayed
613
- Autoproj.message
614
- end
615
-
616
603
  failures
617
604
  end
618
605
  end
@@ -4,20 +4,7 @@
4
4
  module Autoproj
5
5
  # Manager for packages provided by external package managers
6
6
  class OSPackageResolver
7
- class << self
8
- # When requested to load a file called '$FILE', the osdeps code will
9
- # also look for files called '$FILE-suffix', where 'suffix' is an
10
- # element in +suffixes+
11
- #
12
- # A usage of this functionality is to make loading conditional to
13
- # the available version of certain tools, namely Ruby. Autoproj for
14
- # instance adds ruby18 when started on Ruby 1.8 and ruby19 when
15
- # started on Ruby 1.9
16
- attr_reader :suffixes
17
- end
18
- @suffixes = []
19
-
20
- def self.load(file, **options)
7
+ def self.load(file, suffixes: [], **options)
21
8
  if !File.file?(file)
22
9
  raise ArgumentError, "no such file or directory #{file}"
23
10
  end
@@ -45,22 +32,9 @@ def self.load(file, **options)
45
32
  result
46
33
  end
47
34
 
48
- class << self
49
- attr_reader :aliases
50
- end
51
- @aliases = Hash.new
52
-
53
35
  # The underlying workspace
54
36
  attr_reader :ws
55
37
 
56
- def self.alias(old_name, new_name)
57
- @aliases[new_name] = old_name
58
- end
59
-
60
- def self.ruby_version_keyword
61
- "ruby#{RUBY_VERSION.split('.')[0, 2].join("")}"
62
- end
63
-
64
38
  def self.autodetect_ruby_program
65
39
  ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
66
40
  ruby_bindir = RbConfig::CONFIG['bindir']
@@ -69,12 +43,6 @@ def self.autodetect_ruby_program
69
43
  ruby_executable
70
44
  end
71
45
 
72
- def self.autodetect_ruby
73
- self.alias(ruby_version_keyword, "ruby")
74
- end
75
- self.suffixes << ruby_version_keyword
76
- autodetect_ruby
77
-
78
46
  AUTOPROJ_OSDEPS = File.join(File.expand_path(File.dirname(__FILE__)), 'default.osdeps')
79
47
  def self.load_default
80
48
  file = ENV['AUTOPROJ_DEFAULT_OSDEPS'] || AUTOPROJ_OSDEPS
@@ -157,6 +125,9 @@ def os_package_manager
157
125
  # @return [Array<String>]
158
126
  attr_reader :package_managers
159
127
 
128
+ # Aliases for osdep packages
129
+ attr_reader :aliases
130
+
160
131
  # The Gem::SpecFetcher object that should be used to query RubyGems, and
161
132
  # install RubyGems packages
162
133
  def initialize(defs = Hash.new, file = nil,
@@ -170,6 +141,7 @@ def initialize(defs = Hash.new, file = nil,
170
141
  self.os_package_manager = os_package_manager
171
142
 
172
143
  @prefer_indep_over_os_packages = false
144
+ @aliases = Hash.new
173
145
 
174
146
  @sources = Hash.new
175
147
  @installed_packages = Set.new
@@ -188,6 +160,14 @@ def initialize(defs = Hash.new, file = nil,
188
160
  end
189
161
  end
190
162
 
163
+ # Register new aliases
164
+ #
165
+ # @param [String=>String] new_aliases mapping of the alias to the exact
166
+ # name
167
+ def add_aliases(new_aliases)
168
+ aliases.merge!(new_aliases)
169
+ end
170
+
191
171
  # Returns the name of all known OS packages
192
172
  #
193
173
  # It includes even the packages for which there are no definitions on
@@ -469,7 +449,7 @@ class InvalidRecursiveStatement < Autobuild::Exception; end
469
449
  #
470
450
  # returns an array contain the path starting with name and
471
451
  # ending at the resolved name
472
- def self.resolve_name(name)
452
+ def resolve_name(name)
473
453
  path = [ name ]
474
454
  while aliases.has_key?(name)
475
455
  name = aliases[name]
@@ -500,7 +480,7 @@ def resolve_package(name)
500
480
  return resolve_package_cache[name]
501
481
  end
502
482
 
503
- path = self.class.resolve_name(name)
483
+ path = resolve_name(name)
504
484
  name = path.last
505
485
 
506
486
  dep_def = definitions[name]
@@ -719,7 +699,7 @@ def resolve_os_packages(dependencies)
719
699
  dependencies.each do |name|
720
700
  result = resolve_package(name)
721
701
  if !result
722
- path = self.class.resolve_name(name)
702
+ path = resolve_name(name)
723
703
  raise MissingOSDep.new, "there is no osdeps definition for #{path.last} (search tree: #{path.join("->")})"
724
704
  end
725
705
 
@@ -166,7 +166,10 @@ def initialize(
166
166
 
167
167
  # Load a new osdeps file for this package set
168
168
  def load_osdeps(file, **options)
169
- new_osdeps = OSPackageResolver.load(file, **options)
169
+ new_osdeps = OSPackageResolver.load(
170
+ file,
171
+ suffixes: ws.osdep_suffixes,
172
+ **options)
170
173
  all_osdeps << new_osdeps
171
174
  os_package_resolver.merge(all_osdeps.last)
172
175
  new_osdeps
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "2.0.0.rc39"
2
+ VERSION = "2.0.0.rc40"
3
3
  end
@@ -18,10 +18,35 @@ class Workspace < Ops::Loader
18
18
  attr_reader :os_package_resolver
19
19
  attr_reader :os_package_installer
20
20
 
21
+ # The keyword used to represent the current ruby version.
22
+ #
23
+ # It is e.g. ruby21 for ruby 2.1.
24
+ #
25
+ # It is initialized to the local ruby version in {#initialize}. If one
26
+ # intends to override it, one must do it before {#setup} gets called
27
+ #
28
+ # This is aliased to 'ruby' in the osdep system, so one that depends on
29
+ # ruby should only refer to 'ruby' unless a specific version is
30
+ # requested.
31
+ #
32
+ # It is also used as an osdep suffix when loading osdep files (i.e. the
33
+ # osdep system will attempt to load `.osdep-ruby21` files on ruby 2.1 in
34
+ # addition to the plain .osdep files.
35
+ #
36
+ # @return [String]
37
+ attr_accessor :ruby_version_keyword
38
+
39
+ # Suffixes that should be considered when loading osdep files
40
+ #
41
+ # {#ruby_version_keyword} is automatically added there in {#setup}
42
+ attr_reader :osdep_suffixes
43
+
21
44
  def initialize(root_dir,
22
45
  os_package_resolver: OSPackageResolver.new,
23
46
  package_managers: OSPackageInstaller::PACKAGE_MANAGERS)
24
47
  @root_dir = root_dir
48
+ @ruby_version_keyword = "ruby#{RUBY_VERSION.split('.')[0, 2].join("")}"
49
+ @osdep_suffixes = Array.new
25
50
 
26
51
  @loader = loader
27
52
  @env = Environment.new
@@ -236,7 +261,13 @@ def setup_os_package_installer
236
261
  os_package_installer.osdeps_mode
237
262
  end
238
263
 
264
+ def setup_ruby_version_handling
265
+ os_package_resolver.add_aliases('ruby' => ruby_version_keyword)
266
+ osdep_suffixes << ruby_version_keyword
267
+ end
268
+
239
269
  def setup
270
+ setup_ruby_version_handling
240
271
  migrate_bundler_and_autoproj_gem_layout
241
272
  load_config
242
273
  rewrite_shims
@@ -318,6 +349,7 @@ def update_autoproj(restart_on_update: true)
318
349
  self, 'autoproj', gemfile: gemfile)
319
350
  end
320
351
  begin
352
+ Autoproj.message " updating autoproj"
321
353
  PackageManagers::BundlerManager.run_bundler_install(
322
354
  self, gemfile, binstubs: binstubs)
323
355
  ensure
@@ -431,11 +463,6 @@ def load_package_sets(only_local: false,
431
463
  return
432
464
  end
433
465
 
434
- if !reconfigure
435
- Autoproj.message("run 'autoproj reconfigure' to change configuration options", :bold)
436
- Autoproj.message("and use 'autoproj switch-config' to change the remote source for", :bold)
437
- Autoproj.message("autoproj's main build configuration", :bold)
438
- end
439
466
  Ops::Configuration.new(self).
440
467
  load_package_sets(only_local: only_local,
441
468
  checkout_only: checkout_only,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc39
4
+ version: 2.0.0.rc40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 0.3.0
109
+ - !ruby/object:Gem::Dependency
110
+ name: tty-prompt
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: flexmock
111
125
  requirement: !ruby/object:Gem::Requirement
@@ -321,4 +335,3 @@ signing_key:
321
335
  specification_version: 4
322
336
  summary: Easy installation and management of sets of software packages
323
337
  test_files: []
324
- has_rdoc: