autoproj 2.8.8 → 2.9.0

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
  SHA256:
3
- metadata.gz: 52887a2af332210cca2a14090350718f88ca070be1a5ab7493cc82af38f7ba59
4
- data.tar.gz: b3d84d28e9a283f0cd9efd2cf0cd254382caffabbd7144aff55633e917466c9e
3
+ metadata.gz: a79f0dc8faf8c992dedb96e65c997ab35f41d62107845dd9dd20bc260630f0a2
4
+ data.tar.gz: 2e3db38917f2cefa9defa70fa248ced0c05ad909817003b135d9b7f6179ca8bc
5
5
  SHA512:
6
- metadata.gz: 03c32ce93aed3de8fad8bf3dfcbfe5529703315b83e0a8afe70bd1b54c3f0c91257a42f838e67866aca8beff348f4766b37eec82e70dfa04b243bc6d41df2747
7
- data.tar.gz: 8fe58af39dd943a8841eadce3222cf32124d3befe1e909e683b34481d5211da660c1ba8d1ab25ee8fad6fbe5aca209cfe1d9927a1248fa8cf74bab99cd2e0198
6
+ metadata.gz: 346bdce3bf52c42187143908ef04767a03e1e71b24738b0c333591bd73d113355a871ccdf67bec9b69018d30e3302e6a53946e007922a4a3e01fb82fa371eae8
7
+ data.tar.gz: 470faaa51b2d58609f70e794173d07d41003feee472c3c9e3dd9bb8024e66746403a480becad1dc0222066084e76c0205104465e138afc714d8555fc32d60d55
data/bin/alog CHANGED
@@ -24,10 +24,12 @@ Autoproj.report(silent: true) do
24
24
  if log_files.size == 1
25
25
  logfile = log_files.first
26
26
  elsif log_files.size > 1
27
- logfile = cli.select_log_file(log_files)
27
+ begin
28
+ logfile = cli.select_log_file(log_files)
29
+ puts File.read(logfile)
30
+ rescue Interrupt
31
+ end
28
32
  elsif log_files.empty?
29
33
  raise "no logs found for #{string}"
30
34
  end
31
-
32
- puts File.read(logfile)
33
35
  end
@@ -30,6 +30,8 @@
30
30
  require 'autoproj/installation_manifest'
31
31
  require 'autoproj/os_package_installer'
32
32
  require 'autoproj/os_package_resolver'
33
+ require 'autoproj/os_repository_resolver'
34
+ require 'autoproj/os_repository_installer'
33
35
  require 'autoproj/system'
34
36
  require 'autoproj/build_option'
35
37
  require 'autoproj/configuration'
@@ -206,7 +206,14 @@ def self.validate_options(args, options)
206
206
  end
207
207
 
208
208
  def export_env_sh(shell_helpers: ws.config.shell_helpers?)
209
- @env_sh_updated = ws.export_env_sh(shell_helpers: shell_helpers)
209
+ # @env_sh_updated == nil means "did not even export".
210
+ # make sure that it is set to 'true' or 'false'
211
+ @env_sh_updated =
212
+ if ws.export_env_sh(shell_helpers: shell_helpers)
213
+ true
214
+ else
215
+ false
216
+ end
210
217
  end
211
218
 
212
219
  def notify_env_sh_updated
@@ -27,7 +27,10 @@ def run(selected_packages, options)
27
27
  confirm: true
28
28
 
29
29
  command_line_selection, source_packages, _osdep_packages =
30
- super(selected_packages, options.merge(checkout_only: true))
30
+ super(selected_packages,
31
+ ignore_errors: options[:keep_going],
32
+ checkout_only: true,
33
+ **options)
31
34
 
32
35
  parallel = build_options[:parallel] || ws.config.parallel_build_level
33
36
 
@@ -41,7 +44,7 @@ def run(selected_packages, options)
41
44
 
42
45
  Autobuild.ignore_errors = options[:keep_going]
43
46
 
44
- ops = Ops::Build.new(ws.manifest)
47
+ ops = Ops::Build.new(ws.manifest, report_dir: ws.log_dir)
45
48
  if build_options[:rebuild] || build_options[:force]
46
49
  packages_to_rebuild =
47
50
  if options[:deps] || command_line_selection.empty?
@@ -77,7 +80,6 @@ def run(selected_packages, options)
77
80
 
78
81
  Autobuild.do_build = true
79
82
  ops.build_packages(source_packages, parallel: parallel)
80
- Autobuild.apply(source_packages, "autoproj-build", ['install'])
81
83
  Main.run_post_command_hook(:build, ws, source_packages: source_packages)
82
84
  ensure
83
85
  export_env_sh
@@ -285,7 +285,11 @@ def select_log_file(log_files)
285
285
  end
286
286
 
287
287
  prompt = TTY::Prompt.new
288
- prompt.select("Select the log file", choices)
288
+ begin
289
+ prompt.select("Select the log file", choices)
290
+ rescue TTY::Reader::InputInterrupt
291
+ raise Interrupt
292
+ end
289
293
  end
290
294
  end
291
295
  end
@@ -24,6 +24,7 @@ def run(user_selection, update: true, **options)
24
24
 
25
25
  shell_helpers = options.fetch(:shell_helpers, ws.config.shell_helpers?)
26
26
 
27
+ ws.install_os_repositories
27
28
  ws.install_os_packages(
28
29
  osdep_packages,
29
30
  run_package_managers_without_packages: true,
@@ -73,6 +73,15 @@ def snapshot_overrides_vcs?(importer, vcs, snapshot)
73
73
  end
74
74
  end
75
75
 
76
+ def report_exception(package_status, msg, e)
77
+ package_status.msg << Autoproj.color(" #{msg} (#{e})", :red)
78
+ if Autobuild.debug
79
+ package_status.msg.concat(e.backtrace.map do |line|
80
+ Autoproj.color(" #{line}", :red)
81
+ end)
82
+ end
83
+ end
84
+
76
85
  PackageStatus = Struct.new :msg, :sync, :uncommitted, :local, :remote
77
86
  def status_of_package(package_description, only_local: false, snapshot: false)
78
87
  pkg = package_description.autobuild
@@ -85,9 +94,9 @@ def status_of_package(package_description, only_local: false, snapshot: false)
85
94
  elsif !File.directory?(pkg.srcdir)
86
95
  package_status.msg << Autoproj.color(" is not imported yet", :magenta)
87
96
  else
88
- begin status = importer.status(pkg, only_local)
97
+ begin status = importer.status(pkg, only_local: only_local)
89
98
  rescue StandardError => e
90
- package_status.msg << Autoproj.color(" failed to fetch status information (#{e})", :red)
99
+ report_exception(package_status, "failed to fetch status information", e)
91
100
  return package_status
92
101
  end
93
102
 
@@ -99,7 +108,7 @@ def status_of_package(package_description, only_local: false, snapshot: false)
99
108
  rescue Autobuild::PackageException
100
109
  Hash.new
101
110
  rescue StandardError => e
102
- package_status.msg << Autoproj.color(" failed to fetch snapshotting information (#{e})", :red)
111
+ report_exception(package_status, "failed to fetch snapshotting information", e)
103
112
  return package_status
104
113
  end
105
114
  if snapshot_overrides_vcs?(importer, package_description.vcs, snapshot_version)
@@ -227,7 +236,7 @@ def display_status(packages, parallel: ws.config.parallel_import_level, snapshot
227
236
  end
228
237
  end
229
238
 
230
- result = each_package_status(packages, parallel: parallel, progress: progress) do |pkg, status|
239
+ result = each_package_status(packages, only_local: only_local, parallel: parallel, progress: progress) do |pkg, status|
231
240
  if spinner
232
241
  spinner.stop
233
242
  spinner = nil
@@ -44,7 +44,7 @@ def validate_options(selection, options)
44
44
  (options[:autoproj] || (
45
45
  options[:autoproj] != false &&
46
46
  !has_explicit_selection &&
47
- !options[:config] &&
47
+ !options[:config] &&
48
48
  !options[:checkout_only])
49
49
  )
50
50
 
@@ -97,6 +97,8 @@ def run(selected_packages, run_hook: false, **options)
97
97
  command_line_selection, selected_packages =
98
98
  finish_loading_configuration(selected_packages)
99
99
  else
100
+ ws.setup_all_package_directories
101
+ ws.finalize_package_setup
100
102
  command_line_selection, selected_packages = [], PackageSelection.new
101
103
  end
102
104
 
@@ -106,10 +108,11 @@ def run(selected_packages, run_hook: false, **options)
106
108
  osdeps: options[:osdeps],
107
109
  osdeps_filter_uptodate: options[:osdeps_filter_uptodate])
108
110
 
109
- source_packages, osdep_packages, import_failure =
111
+ source_packages, osdep_packages, import_failure =
110
112
  update_packages(
111
113
  selected_packages,
112
- osdeps: options[:osdeps], osdeps_options: osdeps_options,
114
+ osdeps: options[:osdeps],
115
+ osdeps_options: osdeps_options,
113
116
  from: options[:from],
114
117
  checkout_only: options[:checkout_only],
115
118
  only_local: options[:only_local],
@@ -124,6 +127,7 @@ def run(selected_packages, run_hook: false, **options)
124
127
  ws.export_installation_manifest
125
128
 
126
129
  if options[:osdeps] && !osdep_packages.empty?
130
+ ws.install_os_repositories
127
131
  ws.install_os_packages(osdep_packages, **osdeps_options)
128
132
  end
129
133
 
@@ -141,7 +145,7 @@ def run(selected_packages, run_hook: false, **options)
141
145
 
142
146
  export_env_sh
143
147
 
144
- if !options[:auto_exclude]
148
+ if !options[:auto_exclude] && !options[:ignore_errors]
145
149
  if import_failure && configuration_import_failure
146
150
  raise ImportFailed.new(configuration_import_failure.original_errors + import_failure.original_errors)
147
151
  elsif import_failure
@@ -198,7 +202,7 @@ def update_packages(selected_packages,
198
202
  end
199
203
 
200
204
  ops = Autoproj::Ops::Import.new(ws)
201
- source_packages, osdep_packages =
205
+ source_packages, osdep_packages =
202
206
  ops.import_packages(selected_packages,
203
207
  checkout_only: checkout_only,
204
208
  only_local: only_local,
@@ -160,9 +160,23 @@ pip:
160
160
  opensuse: python-pip
161
161
  fedora: python-pip
162
162
  freebsd: pip
163
+ default: ignore # assume pip will be installed by the user
163
164
 
164
165
  sudo:
165
166
  macos-brew: ignore
166
167
  default: sudo
167
168
 
169
+ archive-keyring:
170
+ ubuntu: ubuntu-keyring
171
+ debian: debian-archive-keyring
172
+ default: ignore
173
+
174
+ gnupg:
175
+ ubuntu,debian: gnupg
176
+ default: ignore
177
+
178
+ apt-transport-https:
179
+ ubuntu,debian: apt-transport-https
180
+ default: ignore
181
+
168
182
  # vim: expandtab
@@ -892,16 +892,14 @@ def package_selected?(name, validate = true)
892
892
  #
893
893
  # @return [Array<PackageDefinition>]
894
894
  def all_selected_source_packages(validate = true)
895
- result = Set.new
896
- selection = default_packages(validate)
895
+ default_packages(validate).all_selected_source_packages(self)
896
+ end
897
897
 
898
- root_sources = selection.each_source_package_name.to_set
899
- root_sources.each do |pkg_name|
900
- find_autobuild_package(pkg_name).all_dependencies(result)
901
- end
902
- result.merge(root_sources).map do |pkg_name|
903
- find_package_definition(pkg_name)
904
- end
898
+ # Returns the set of osdep packages that are selected by the layout
899
+ #
900
+ # @return [Array<String>]
901
+ def all_selected_osdep_packages(validate = true)
902
+ default_packages(validate).all_selected_osdep_packages(self)
905
903
  end
906
904
 
907
905
  # Returns the set of packages that are selected by the layout
@@ -1,3 +1,4 @@
1
+ require 'erb'
1
2
  module Autoproj
2
3
  module Ops
3
4
  # Operations related to building packages
@@ -10,8 +11,11 @@ class Build
10
11
  # @return [Manifest]
11
12
  attr_reader :manifest
12
13
 
13
- def initialize(manifest)
14
+ # @param [String] report_dir the log directory in which to build
15
+ # the build report. If left to nil, no report will be generated
16
+ def initialize(manifest, report_dir: nil)
14
17
  @manifest = manifest
18
+ @report_dir = report_dir
15
19
  end
16
20
 
17
21
  # Triggers a rebuild of all packages
@@ -73,6 +77,7 @@ def force_build_packages(selected_packages, all_enabled_packages)
73
77
  build_packages(all_enabled_packages)
74
78
  end
75
79
 
80
+
76
81
  # Builds the listed packages
77
82
  #
78
83
  # Only build steps that are actually needed will be performed. See
@@ -84,7 +89,48 @@ def force_build_packages(selected_packages, all_enabled_packages)
84
89
  def build_packages(all_enabled_packages, options = Hash.new)
85
90
  Autobuild.do_rebuild = false
86
91
  Autobuild.do_forced_build = false
87
- Autobuild.apply(all_enabled_packages, "autoproj-build", ['build'], options)
92
+ begin
93
+ Autobuild.apply(all_enabled_packages, "autoproj-build", ['build'], options)
94
+ ensure
95
+ build_report(all_enabled_packages) if @report_dir
96
+ end
97
+ end
98
+
99
+ REPORT_BASENAME = "build_report.json"
100
+
101
+ # The path to the report file
102
+ #
103
+ # @return [String,nil] the path, or nil if the report should not
104
+ # be generated
105
+ def report_path
106
+ File.join(@report_dir, REPORT_BASENAME) if @report_dir
107
+ end
108
+
109
+ def build_report(package_list)
110
+ FileUtils.mkdir_p @report_dir
111
+
112
+ packages = package_list.map do |pkg_name|
113
+ pkg = manifest.find_autobuild_package(pkg_name)
114
+
115
+ {
116
+ name: pkg.name,
117
+ import_invoked: pkg.import_invoked?,
118
+ prepare_invoked: pkg.prepare_invoked?,
119
+ build_invoked: pkg.build_invoked?,
120
+ failed: pkg.failed?,
121
+ imported: pkg.imported?,
122
+ prepared: pkg.prepared?,
123
+ built: pkg.built?
124
+ }
125
+ end
126
+
127
+ build_report = JSON.pretty_generate({
128
+ build_report: {
129
+ timestamp: Time.now,
130
+ packages: packages
131
+ }
132
+ })
133
+ IO.write(report_path, build_report)
88
134
  end
89
135
  end
90
136
  end
@@ -464,6 +464,9 @@ def load_package_set_information(mainline: nil)
464
464
  end
465
465
  end
466
466
 
467
+ # Loads OS repository definitions once and for all
468
+ load_osrepos_from_package_sets
469
+
467
470
  # Loads OS package definitions once and for all
468
471
  load_osdeps_from_package_sets
469
472
 
@@ -580,6 +583,21 @@ def load_osdeps_from_package_sets
580
583
  end
581
584
  end
582
585
 
586
+ # Load OS repository information contained in our registered package
587
+ # sets into the provided osrepo object
588
+ #
589
+ # This is included in {load_package_sets}
590
+ #
591
+ # @return [void]
592
+ def load_osrepos_from_package_sets
593
+ ws.manifest.each_package_set do |pkg_set|
594
+ pkg_set.each_osrepos_file do |file|
595
+ file_osrepos = pkg_set.load_osrepos(file)
596
+ ws.os_repository_resolver.merge(file_osrepos)
597
+ end
598
+ end
599
+ end
600
+
583
601
  def update_package_sets(only_local: false,
584
602
  checkout_only: !Autobuild.do_update,
585
603
  keep_going: false,
@@ -188,6 +188,10 @@ def osdeps_mode_string_to_value(string)
188
188
  modes
189
189
  end
190
190
 
191
+ def configure_manager
192
+ os_package_manager.configure_manager if osdeps_mode.include?('os')
193
+ end
194
+
191
195
  # If set to true (the default), #install will try to remove the list of
192
196
  # already uptodate packages from the installed packages. Set to false to
193
197
  # install all packages regardless of their status
@@ -380,6 +384,29 @@ def resolve_and_partition_osdep_packages(osdep_packages, all_osdep_packages = ni
380
384
 
381
385
  partitioned_packages[manager] = manager_packages
382
386
  end
387
+ resolve_managers_dependencies(partitioned_packages)
388
+ end
389
+
390
+ def resolve_managers_dependencies(partitioned_packages)
391
+ partitioned_packages.clone.each do |manager, packages|
392
+ # Skip if the manager is not being used
393
+ next if packages&.empty?
394
+
395
+ manager_dependencies = os_package_resolver.resolve_os_packages(manager.os_dependencies)
396
+ manager_dependencies = resolve_package_managers_in_mapping(manager_dependencies)
397
+ manager_dependencies.each_key do |nested_manager|
398
+ deps = manager_dependencies.fetch(nested_manager, Set.new).to_set
399
+ next if deps.empty?
400
+
401
+ unless partitioned_packages[nested_manager]
402
+ partitioned_packages[nested_manager] = Set.new
403
+ enable_recursion = true
404
+ end
405
+
406
+ partitioned_packages[nested_manager] += deps
407
+ partitioned_packages = resolve_managers_dependencies(partitioned_packages) if enable_recursion
408
+ end
409
+ end
383
410
  partitioned_packages
384
411
  end
385
412
 
@@ -0,0 +1,53 @@
1
+ require 'autoproj/repository_managers/manager'
2
+ require 'autoproj/repository_managers/unknown_os_manager'
3
+ require 'autoproj/repository_managers/apt'
4
+
5
+ module Autoproj
6
+ class OSRepositoryInstaller
7
+ # The workspace object
8
+ attr_reader :ws
9
+
10
+ # Returns the set of repository managers
11
+ attr_reader :repository_managers
12
+
13
+ OS_REPOSITORY_MANAGERS = {
14
+ 'debian' => RepositoryManagers::APT
15
+ }.freeze
16
+
17
+ def initialize(ws)
18
+ @ws = ws
19
+ @repository_managers = {}
20
+ OS_REPOSITORY_MANAGERS.each do |name, klass|
21
+ @repository_managers[name] = klass.new(ws)
22
+ end
23
+ end
24
+
25
+ def os_repository_resolver
26
+ ws.os_repository_resolver
27
+ end
28
+
29
+ # Returns the repository manager object for the current OS
30
+ def os_repository_manager
31
+ return @os_repository_manager if @os_repository_manager
32
+
33
+ os_names, = os_repository_resolver.operating_system
34
+ os_name = os_names.find { |name| OS_REPOSITORY_MANAGERS[name] }
35
+
36
+ @os_repository_manager =
37
+ repository_managers[os_name] ||
38
+ RepositoryManagers::UnknownOSManager.new(ws)
39
+ end
40
+
41
+ def each_manager(&block)
42
+ repository_managers.each_value(&block)
43
+ end
44
+
45
+ def install_os_repositories
46
+ return if os_repository_resolver.resolved_entries.empty?
47
+
48
+ deps = os_repository_manager.os_dependencies
49
+ ws.install_os_packages(deps, all: nil) unless deps.empty?
50
+ os_repository_manager.install(os_repository_resolver.resolved_entries)
51
+ end
52
+ end
53
+ end