autoproj 2.12.1 → 2.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +24 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +6 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +225 -200
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +224 -199
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +9 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +66 -36
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/python.rb +18 -0
  25. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  26. data/lib/autoproj/base.rb +1 -1
  27. data/lib/autoproj/bash_completion.rb +5 -6
  28. data/lib/autoproj/build_option.rb +22 -24
  29. data/lib/autoproj/cli/base.rb +26 -26
  30. data/lib/autoproj/cli/bootstrap.rb +14 -16
  31. data/lib/autoproj/cli/build.rb +10 -7
  32. data/lib/autoproj/cli/cache.rb +11 -11
  33. data/lib/autoproj/cli/clean.rb +10 -10
  34. data/lib/autoproj/cli/commit.rb +7 -8
  35. data/lib/autoproj/cli/doc.rb +2 -2
  36. data/lib/autoproj/cli/envsh.rb +1 -2
  37. data/lib/autoproj/cli/exec.rb +60 -20
  38. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  39. data/lib/autoproj/cli/locate.rb +30 -41
  40. data/lib/autoproj/cli/log.rb +7 -7
  41. data/lib/autoproj/cli/main.rb +217 -205
  42. data/lib/autoproj/cli/main_doc.rb +22 -21
  43. data/lib/autoproj/cli/main_global.rb +44 -19
  44. data/lib/autoproj/cli/main_plugin.rb +18 -18
  45. data/lib/autoproj/cli/main_test.rb +28 -27
  46. data/lib/autoproj/cli/manifest.rb +7 -7
  47. data/lib/autoproj/cli/osdeps.rb +12 -11
  48. data/lib/autoproj/cli/patcher.rb +2 -3
  49. data/lib/autoproj/cli/query.rb +17 -18
  50. data/lib/autoproj/cli/reconfigure.rb +1 -2
  51. data/lib/autoproj/cli/reset.rb +9 -12
  52. data/lib/autoproj/cli/show.rb +38 -39
  53. data/lib/autoproj/cli/status.rb +56 -44
  54. data/lib/autoproj/cli/switch_config.rb +5 -6
  55. data/lib/autoproj/cli/tag.rb +12 -11
  56. data/lib/autoproj/cli/test.rb +7 -7
  57. data/lib/autoproj/cli/update.rb +97 -43
  58. data/lib/autoproj/cli/utility.rb +14 -12
  59. data/lib/autoproj/cli/version.rb +42 -40
  60. data/lib/autoproj/cli/versions.rb +14 -15
  61. data/lib/autoproj/cli/watch.rb +33 -37
  62. data/lib/autoproj/cli/which.rb +16 -20
  63. data/lib/autoproj/cli.rb +4 -2
  64. data/lib/autoproj/configuration.rb +78 -86
  65. data/lib/autoproj/default.osdeps +29 -3
  66. data/lib/autoproj/environment.rb +42 -23
  67. data/lib/autoproj/exceptions.rb +9 -3
  68. data/lib/autoproj/find_workspace.rb +20 -25
  69. data/lib/autoproj/git_server_configuration.rb +40 -44
  70. data/lib/autoproj/gitorious.rb +1 -1
  71. data/lib/autoproj/installation_manifest.rb +64 -29
  72. data/lib/autoproj/local_package_set.rb +13 -11
  73. data/lib/autoproj/manifest.rb +139 -132
  74. data/lib/autoproj/metapackage.rb +2 -6
  75. data/lib/autoproj/ops/atomic_write.rb +7 -6
  76. data/lib/autoproj/ops/build.rb +4 -6
  77. data/lib/autoproj/ops/cache.rb +41 -43
  78. data/lib/autoproj/ops/cached_env.rb +5 -4
  79. data/lib/autoproj/ops/configuration.rb +519 -507
  80. data/lib/autoproj/ops/import.rb +88 -63
  81. data/lib/autoproj/ops/install.rb +218 -192
  82. data/lib/autoproj/ops/loader.rb +77 -76
  83. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  84. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  85. data/lib/autoproj/ops/snapshot.rb +250 -247
  86. data/lib/autoproj/ops/tools.rb +76 -78
  87. data/lib/autoproj/ops/watch.rb +6 -6
  88. data/lib/autoproj/ops/which.rb +17 -14
  89. data/lib/autoproj/options.rb +13 -2
  90. data/lib/autoproj/os_package_installer.rb +102 -92
  91. data/lib/autoproj/os_package_query.rb +7 -13
  92. data/lib/autoproj/os_package_resolver.rb +189 -140
  93. data/lib/autoproj/os_repository_installer.rb +4 -4
  94. data/lib/autoproj/os_repository_resolver.rb +8 -6
  95. data/lib/autoproj/package_definition.rb +12 -13
  96. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +19 -11
  97. data/lib/autoproj/package_managers/bundler_manager.rb +186 -129
  98. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  99. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  100. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  101. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  102. data/lib/autoproj/package_managers/manager.rb +8 -3
  103. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  104. data/lib/autoproj/package_managers/pip_manager.rb +30 -28
  105. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  106. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  107. data/lib/autoproj/package_managers/shell_script_manager.rb +47 -25
  108. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  109. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  110. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  111. data/lib/autoproj/package_manifest.rb +28 -74
  112. data/lib/autoproj/package_selection.rb +187 -187
  113. data/lib/autoproj/package_set.rb +145 -114
  114. data/lib/autoproj/python.rb +297 -0
  115. data/lib/autoproj/query_base.rb +20 -14
  116. data/lib/autoproj/reporter.rb +19 -19
  117. data/lib/autoproj/repository_managers/apt.rb +102 -68
  118. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  119. data/lib/autoproj/ros_condition_parser.rb +84 -0
  120. data/lib/autoproj/ros_package_manifest.rb +125 -0
  121. data/lib/autoproj/shell_completion.rb +16 -13
  122. data/lib/autoproj/source_package_query.rb +29 -36
  123. data/lib/autoproj/system.rb +32 -21
  124. data/lib/autoproj/test.rb +131 -106
  125. data/lib/autoproj/variable_expansion.rb +10 -10
  126. data/lib/autoproj/vcs_definition.rb +53 -37
  127. data/lib/autoproj/version.rb +1 -1
  128. data/lib/autoproj/workspace.rb +143 -108
  129. data/lib/autoproj/zsh_completion.rb +8 -9
  130. data/lib/autoproj.rb +55 -53
  131. data/samples/autoproj/init.rb +1 -2
  132. metadata +86 -65
  133. data/.travis.yml +0 -22
@@ -1,627 +1,639 @@
1
+ require "rgl/adjacency"
2
+ require "rgl/dot"
3
+ require "rgl/topsort"
4
+
1
5
  module Autoproj
2
6
  module Ops
3
- #--
4
- # NOTE: indentation is wrong to let git track the history properly
5
- #+++
6
-
7
- # Implementation of the operations to manage the configuration
8
- class Configuration
9
- attr_reader :ws
10
-
11
- # The autoproj install we should update from (if any)
12
- #
13
- # @return [nil,InstallationManifest]
14
- attr_reader :update_from
15
-
16
- # The path in which remote package sets should be exposed to the
17
- # user
18
- #
19
- # @return [String]
20
- def remotes_dir
21
- ws.remotes_dir
22
- end
7
+ #--
8
+ # NOTE: indentation is wrong to let git track the history properly
9
+ #+++
10
+
11
+ # PackageSetHierachy be used to build the hierarchy of package set
12
+ # imports, as directed acyclic graph (DAG)
13
+ # so that they can be (topologically) sorted according to their
14
+ # dependencies
15
+ class PackageSetHierarchy
16
+ attr_reader :dag
17
+
18
+ def initialize(package_sets, root_pkg_set)
19
+ @dag = RGL::DirectedAdjacencyGraph.new
20
+
21
+ package_sets.each do |p|
22
+ p.imports.each do |dep|
23
+ @dag.add_edge dep, p
24
+ end
25
+ end
23
26
 
24
- # The path in which remote package sets should be exposed to the
25
- # user
26
- #
27
- # @return [String]
28
- def remotes_user_dir
29
- File.join(ws.config_dir, "remotes")
30
- end
27
+ @dag.add_vertex root_pkg_set
28
+ import_order = root_pkg_set.imports.to_a
29
+ import_order.each_with_index do |p, index|
30
+ if index + 1 < import_order.size
31
+ @dag.add_edge p, import_order[index + 1]
32
+ @dag.add_edge p, root_pkg_set
33
+ end
34
+ end
31
35
 
32
- # The path to the main manifest file
33
- #
34
- # @return [String]
35
- def manifest_path
36
- ws.manifest_file_path
37
- end
36
+ unless @dag.acyclic?
37
+ raise "The package set hierarchy contains cycles: #{@dag.cycles}"
38
+ end
39
+ end
38
40
 
39
- # @param [Manifest] manifest
40
- # @param [Loader] loader
41
- # @option options [InstallationManifest] :update_from
42
- # another autoproj installation from which we
43
- # should update (instead of the normal VCS)
44
- def initialize(workspace, update_from: nil)
45
- @ws = workspace
46
- @update_from = update_from
47
- @remote_update_message_displayed = false
41
+ # Flatten the hierarchy, a establish a sorting
42
+ def flatten
43
+ @dag.topsort_iterator.to_a
44
+ end
45
+
46
+ # Write the hierarchy to an image (png) file
47
+ def to_png(path)
48
+ @dag.write_to_graphic_file("png", path.gsub(".png", ""))
49
+ end
48
50
  end
49
51
 
50
- # Imports or updates a source (remote or otherwise).
51
- #
52
- # See create_autobuild_package for informations about the arguments.
53
- def update_configuration_repository(vcs, name, into,
52
+ # Implementation of the operations to manage the configuration
53
+ class Configuration
54
+ attr_reader :ws
55
+
56
+ # The autoproj install we should update from (if any)
57
+ #
58
+ # @return [nil,InstallationManifest]
59
+ attr_reader :update_from
60
+
61
+ # The path in which remote package sets should be exposed to the
62
+ # user
63
+ #
64
+ # @return [String]
65
+ def remotes_dir
66
+ ws.remotes_dir
67
+ end
68
+
69
+ # The path in which remote package sets should be exposed to the
70
+ # user
71
+ #
72
+ # @return [String]
73
+ def remotes_user_dir
74
+ File.join(ws.config_dir, "remotes")
75
+ end
76
+
77
+ # The path to the main manifest file
78
+ #
79
+ # @return [String]
80
+ def manifest_path
81
+ ws.manifest_file_path
82
+ end
83
+
84
+ # @param [Manifest] manifest
85
+ # @param [Loader] loader
86
+ # @option options [InstallationManifest] :update_from
87
+ # another autoproj installation from which we
88
+ # should update (instead of the normal VCS)
89
+ def initialize(workspace, update_from: nil)
90
+ @ws = workspace
91
+ @update_from = update_from
92
+ @remote_update_message_displayed = false
93
+ end
94
+
95
+ # Imports or updates a source (remote or otherwise).
96
+ #
97
+ # See create_autobuild_package for informations about the arguments.
98
+ def update_configuration_repository(vcs, name, into,
54
99
  only_local: false,
55
100
  reset: false,
56
101
  retry_count: nil)
57
102
 
58
- fake_package = Tools.create_autobuild_package(vcs, name, into)
59
- if update_from
60
- # Define a package in the installation manifest that points to
61
- # the desired folder in other_root
62
- relative_path = Pathname.new(into).
63
- relative_path_from(Pathname.new(ws.root_dir)).to_s
64
- other_dir = File.join(update_from.path, relative_path)
65
- if File.directory?(other_dir)
66
- update_from.packages.unshift(
67
- InstallationManifest::Package.new(fake_package.name, other_dir, File.join(other_dir, 'install')))
68
- end
103
+ fake_package = Tools.create_autobuild_package(vcs, name, into)
104
+ if update_from
105
+ # Define a package in the installation manifest that points to
106
+ # the desired folder in other_root
107
+ relative_path = Pathname.new(into)
108
+ .relative_path_from(Pathname.new(ws.root_dir)).to_s
109
+ other_dir = File.join(update_from.path, relative_path)
110
+ if File.directory?(other_dir)
111
+ update_from.packages.unshift(
112
+ InstallationManifest::Package.new(fake_package.name, other_dir, File.join(other_dir, "install"))
113
+ )
114
+ end
69
115
 
70
- # Then move the importer there if possible
71
- if fake_package.importer.respond_to?(:pick_from_autoproj_root)
72
- if !fake_package.importer.pick_from_autoproj_root(fake_package, update_from)
116
+ # Then move the importer there if possible
117
+ if fake_package.importer.respond_to?(:pick_from_autoproj_root)
118
+ unless fake_package.importer.pick_from_autoproj_root(fake_package, update_from)
119
+ fake_package.update = false
120
+ end
121
+ else
73
122
  fake_package.update = false
74
123
  end
75
- else
76
- fake_package.update = false
77
124
  end
78
- end
79
- if retry_count
80
- fake_package.importer.retry_count = retry_count
81
- end
82
- fake_package.import(only_local: only_local, reset: reset)
83
-
84
- rescue Autobuild::ConfigException => e
85
- raise ConfigError.new, "cannot import #{name}: #{e.message}", e.backtrace
86
- end
87
-
88
- # Update the main configuration repository
89
- #
90
- # @return [Boolean] true if something got updated or checked out,
91
- # and false otherwise
92
- def update_main_configuration(keep_going: false, checkout_only: !Autobuild.do_update, only_local: false, reset: false, retry_count: nil)
93
- if checkout_only && File.exist?(ws.config_dir)
94
- return []
125
+ fake_package.importer.retry_count = retry_count if retry_count
126
+ fake_package.import(only_local: only_local, reset: reset)
127
+ rescue Autobuild::ConfigException => e
128
+ raise ConfigError.new, "cannot import #{name}: #{e.message}", e.backtrace
95
129
  end
96
130
 
97
- update_configuration_repository(
98
- ws.manifest.vcs, "autoproj main configuration", ws.config_dir,
99
- only_local: only_local, reset: reset, retry_count: retry_count
100
- )
101
- []
102
- rescue Interrupt
103
- raise
104
- rescue Exception => e
105
- if keep_going
106
- [e]
107
- else
108
- raise e
131
+ # Update the main configuration repository
132
+ #
133
+ # @return [Boolean] true if something got updated or checked out,
134
+ # and false otherwise
135
+ def update_main_configuration(keep_going: false, checkout_only: !Autobuild.do_update, only_local: false, reset: false, retry_count: nil)
136
+ return [] if checkout_only && File.exist?(ws.config_dir)
137
+
138
+ update_configuration_repository(
139
+ ws.manifest.vcs, "autoproj main configuration", ws.config_dir,
140
+ only_local: only_local, reset: reset, retry_count: retry_count
141
+ )
142
+ []
143
+ rescue Interrupt
144
+ raise
145
+ rescue Exception => e
146
+ if keep_going
147
+ [e]
148
+ else
149
+ raise e
150
+ end
109
151
  end
110
- end
111
152
 
112
- # Update or checkout a remote package set, based on its VCS definition
113
- #
114
- # @param [VCSDefinition] vcs the package set VCS
115
- # @return [Boolean] true if something got updated or checked out,
116
- # and false otherwise
117
- def update_remote_package_set(vcs,
153
+ # Update or checkout a remote package set, based on its VCS definition
154
+ #
155
+ # @param [VCSDefinition] vcs the package set VCS
156
+ # @return [Boolean] true if something got updated or checked out,
157
+ # and false otherwise
158
+ def update_remote_package_set(vcs,
118
159
  checkout_only: !Autobuild.do_update,
119
160
  only_local: false,
120
161
  reset: false,
121
162
  retry_count: nil)
122
163
 
123
- raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
124
- if checkout_only && File.exist?(raw_local_dir)
125
- return
126
- end
164
+ raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
165
+ return if checkout_only && File.exist?(raw_local_dir)
127
166
 
128
- # name_of does minimal validation of source.yml, so do it here
129
- # even though we don't really need it
130
- name = PackageSet.name_of(ws, vcs, ignore_load_errors: true)
131
- ws.install_os_packages([vcs.type], all: nil)
132
- update_configuration_repository(
133
- vcs, name, raw_local_dir,
134
- only_local: only_local,
135
- reset: reset,
136
- retry_count: retry_count)
137
- end
167
+ # name_of does minimal validation of source.yml, so do it here
168
+ # even though we don't really need it
169
+ name = PackageSet.name_of(ws, vcs, ignore_load_errors: true)
170
+ ws.install_os_packages([vcs.type], all: nil)
171
+ update_configuration_repository(
172
+ vcs, name, raw_local_dir,
173
+ only_local: only_local,
174
+ reset: reset,
175
+ retry_count: retry_count
176
+ )
177
+ end
138
178
 
139
- # Create the user-visible directory for a remote package set
140
- #
141
- # @param [VCSDefinition] vcs the package set VCS
142
- # @return [String] the full path to the created user dir
143
- def create_remote_set_user_dir(vcs)
144
- name = PackageSet.name_of(ws, vcs)
145
- raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
146
- FileUtils.mkdir_p(remotes_user_dir)
147
- symlink_dest = File.join(remotes_user_dir, name)
148
-
149
- # Check if the current symlink is valid, and recreate it if it
150
- # is not
151
- if File.symlink?(symlink_dest)
152
- dest = File.readlink(symlink_dest)
153
- if dest != raw_local_dir
179
+ # Create the user-visible directory for a remote package set
180
+ #
181
+ # @param [VCSDefinition] vcs the package set VCS
182
+ # @return [String] the full path to the created user dir
183
+ def create_remote_set_user_dir(vcs)
184
+ name = PackageSet.name_of(ws, vcs)
185
+ raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
186
+ FileUtils.mkdir_p(remotes_user_dir)
187
+ symlink_dest = File.join(remotes_user_dir, name)
188
+
189
+ # Check if the current symlink is valid, and recreate it if it
190
+ # is not
191
+ if File.symlink?(symlink_dest)
192
+ dest = File.readlink(symlink_dest)
193
+ if dest != raw_local_dir
194
+ FileUtils.rm_f symlink_dest
195
+ Autoproj.create_symlink(raw_local_dir, symlink_dest)
196
+ end
197
+ else
154
198
  FileUtils.rm_f symlink_dest
155
199
  Autoproj.create_symlink(raw_local_dir, symlink_dest)
156
200
  end
157
- else
158
- FileUtils.rm_f symlink_dest
159
- Autoproj.create_symlink(raw_local_dir, symlink_dest)
160
- end
161
-
162
- symlink_dest
163
- end
164
201
 
165
- def load_package_set(vcs, options, imported_from)
166
- pkg_set = PackageSet.new(ws, vcs)
167
- pkg_set.auto_imports = options[:auto_imports]
168
- ws.load_if_present(pkg_set, pkg_set.local_dir, 'init.rb')
169
- pkg_set.load_description_file
170
- if imported_from
171
- pkg_set.imported_from << imported_from
172
- imported_from.imports << pkg_set
202
+ symlink_dest
173
203
  end
174
- pkg_set
175
- end
176
204
 
177
- def queue_auto_imports_if_needed(queue, pkg_set, root_set)
178
- if pkg_set.auto_imports?
179
- pkg_set.each_raw_imported_set do |import_vcs, import_options|
180
- vcs_overrides_key = import_vcs.overrides_key
181
- import_vcs = root_set.resolve_overrides("pkg_set:#{vcs_overrides_key}", import_vcs)
182
- queue << [import_vcs, import_options, pkg_set]
205
+ def load_package_set(vcs, options, imported_from)
206
+ pkg_set = PackageSet.new(ws, vcs)
207
+ pkg_set.auto_imports = options[:auto_imports]
208
+ pkg_set.load_description_file
209
+ if imported_from
210
+ pkg_set.imported_from << imported_from
211
+ imported_from.imports << pkg_set
183
212
  end
213
+ pkg_set
184
214
  end
185
- queue
186
- end
187
215
 
188
- # Load the package set information
189
- #
190
- # It loads the package set information as required by {manifest} and
191
- # makes sure that they are either updated (if Autobuild.do_update is
192
- # true), or at least checked out.
193
- #
194
- # @yieldparam [String] osdep the name of an osdep required to import the
195
- # package sets
196
- def load_and_update_package_sets(root_pkg_set,
197
- only_local: false,
198
- checkout_only: !Autobuild.do_update,
199
- keep_going: false,
200
- reset: false,
201
- retry_count: nil)
202
- package_sets = [root_pkg_set]
203
- by_repository_id = Hash.new
204
- by_name = Hash.new
205
- failures = Array.new
206
-
207
- required_remotes_dirs = Array.new
208
-
209
- queue = queue_auto_imports_if_needed(Array.new, root_pkg_set, root_pkg_set)
210
- while !queue.empty?
211
- vcs, import_options, imported_from = queue.shift
212
- repository_id = vcs.overrides_key
213
- if already_processed = by_repository_id[repository_id]
214
- already_processed_vcs, already_processed_from, pkg_set = *already_processed
215
- if (already_processed_from != root_pkg_set) && (already_processed_vcs != vcs)
216
- Autoproj.warn "already loaded the package set from #{already_processed_vcs} from #{already_processed_from.name}, this overrides different settings (#{vcs}) found in #{imported_from.name}"
216
+ def queue_auto_imports_if_needed(queue, pkg_set, root_set)
217
+ if pkg_set.auto_imports?
218
+ pkg_set.each_raw_imported_set do |import_vcs, import_options|
219
+ vcs_overrides_key = import_vcs.overrides_key
220
+ import_vcs = root_set.resolve_overrides("pkg_set:#{vcs_overrides_key}", import_vcs)
221
+ queue << [import_vcs, import_options, pkg_set]
217
222
  end
218
-
219
- if imported_from
220
- pkg_set.imported_from << imported_from
221
- imported_from.imports << pkg_set
222
- end
223
- next
224
223
  end
225
- by_repository_id[repository_id] = [vcs, imported_from]
226
-
227
- # Make sure the package set has been already checked out to
228
- # retrieve the actual name of the package set
229
- if !vcs.local?
230
- failed = handle_keep_going(keep_going, vcs, failures) do
231
- update_remote_package_set(
232
- vcs, checkout_only: checkout_only,
233
- only_local: only_local, reset: reset,
234
- retry_count: retry_count)
235
- end
236
- raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
224
+ queue
225
+ end
237
226
 
238
- # We really can't continue if the VCS was being checked out
239
- # and that failed
240
- if failed && !File.directory?(raw_local_dir)
241
- raise failures.last
227
+ # Load the package set information
228
+ #
229
+ # It loads the package set information as required by {manifest} and
230
+ # makes sure that they are either updated (if Autobuild.do_update is
231
+ # true), or at least checked out.
232
+ #
233
+ # @yieldparam [String] osdep the name of an osdep required to import the
234
+ # package sets
235
+ def load_and_update_package_sets(root_pkg_set,
236
+ only_local: false,
237
+ checkout_only: !Autobuild.do_update,
238
+ keep_going: false,
239
+ reset: false,
240
+ retry_count: nil)
241
+ package_sets = [root_pkg_set]
242
+ by_repository_id = Hash.new
243
+ by_name = Hash.new
244
+ failures = Array.new
245
+
246
+ required_remotes_dirs = Array.new
247
+
248
+ queue = queue_auto_imports_if_needed(Array.new, root_pkg_set, root_pkg_set)
249
+ until queue.empty?
250
+ vcs, import_options, imported_from = queue.shift
251
+ repository_id = vcs.overrides_key
252
+ if (already_processed = by_repository_id[repository_id])
253
+ already_processed_vcs, already_processed_from, pkg_set = *already_processed
254
+ if (already_processed_from != root_pkg_set) && (already_processed_vcs != vcs)
255
+ Autoproj.warn "already loaded the package set from #{already_processed_vcs} from #{already_processed_from.name}, this overrides different settings (#{vcs}) found in #{imported_from.name}"
256
+ end
257
+
258
+ if imported_from
259
+ pkg_set.imported_from << imported_from
260
+ imported_from.imports << pkg_set
261
+ end
262
+ next
242
263
  end
264
+ by_repository_id[repository_id] = [vcs, imported_from]
265
+
266
+ # Make sure the package set has been already checked out to
267
+ # retrieve the actual name of the package set
268
+ unless vcs.local?
269
+ failed = handle_keep_going(keep_going, vcs, failures) do
270
+ update_remote_package_set(
271
+ vcs, checkout_only: checkout_only,
272
+ only_local: only_local, reset: reset,
273
+ retry_count: retry_count
274
+ )
275
+ end
276
+ raw_local_dir = PackageSet.raw_local_dir_of(ws, vcs)
243
277
 
244
- required_remotes_dirs << raw_local_dir
245
- end
278
+ # We really can't continue if the VCS was being checked out
279
+ # and that failed
280
+ raise failures.last if failed && !File.directory?(raw_local_dir)
246
281
 
247
- name = PackageSet.name_of(ws, vcs)
282
+ required_remotes_dirs << raw_local_dir
283
+ end
248
284
 
249
- required_user_dirs = by_name.collect { |k,v| k }
250
- Autoproj.debug "Trying to load package_set: #{name} from definition #{repository_id}"
251
- Autoproj.debug "Already loaded package_sets are: #{required_user_dirs}"
285
+ name = PackageSet.name_of(ws, vcs)
286
+
287
+ required_user_dirs = by_name.collect { |k, v| k }
288
+ Autoproj.debug "Trying to load package_set: #{name} from definition #{repository_id}"
289
+ Autoproj.debug "Already loaded package_sets are: #{required_user_dirs}"
290
+
291
+ if (already_loaded = by_name[name])
292
+ already_loaded_pkg_set, already_loaded_vcs = *already_loaded
293
+ if already_loaded_vcs != vcs
294
+ if imported_from
295
+ Autoproj.warn "redundant auto-import of package set '#{name}' by package set '#{imported_from.name}'"
296
+ Autoproj.warn " A package set with the same name has already been imported from"
297
+ Autoproj.warn " #{already_loaded_vcs}"
298
+ Autoproj.warn " Skipping the following one: "
299
+ Autoproj.warn " #{vcs}"
300
+ else
301
+ Autoproj.warn "the manifest refers to a package set from #{vcs}, but a package set with the same name (#{name}) has already been imported from #{already_loaded_vcs}, I am skipping this one"
302
+ end
303
+ end
252
304
 
253
- if already_loaded = by_name[name]
254
- already_loaded_pkg_set, already_loaded_vcs = *already_loaded
255
- if already_loaded_vcs != vcs
256
305
  if imported_from
257
- Autoproj.warn "redundant auto-import of package set '#{name}' by package set '#{imported_from.name}'"
258
- Autoproj.warn " A package set with the same name has already been imported from"
259
- Autoproj.warn " #{already_loaded_vcs}"
260
- Autoproj.warn " Skipping the following one: "
261
- Autoproj.warn " #{vcs}"
262
- else
263
- Autoproj.warn "the manifest refers to a package set from #{vcs}, but a package set with the same name (#{name}) has already been imported from #{already_loaded_vcs}, I am skipping this one"
306
+ already_loaded_pkg_set.imported_from << imported_from
307
+ imported_from.imports << already_loaded_pkg_set
308
+ by_repository_id[repository_id][2] = already_loaded_pkg_set
264
309
  end
310
+ next
265
311
  end
266
312
 
267
- if imported_from
268
- already_loaded_pkg_set.imported_from << imported_from
269
- imported_from.imports << already_loaded_pkg_set
270
- by_repository_id[repository_id][2] = already_loaded_pkg_set
271
- end
272
- next
273
- end
313
+ create_remote_set_user_dir(vcs) unless vcs.local?
314
+ pkg_set = load_package_set(vcs, import_options, imported_from)
315
+ by_repository_id[repository_id][2] = pkg_set
316
+ package_sets << pkg_set
317
+
318
+ by_name[pkg_set.name] = [pkg_set, vcs, import_options, imported_from]
274
319
 
275
- if !vcs.local?
276
- create_remote_set_user_dir(vcs)
320
+ # Finally, queue the imports
321
+ queue_auto_imports_if_needed(queue, pkg_set, root_pkg_set)
277
322
  end
278
- pkg_set = load_package_set(vcs, import_options, imported_from)
279
- by_repository_id[repository_id][2] = pkg_set
280
- package_sets << pkg_set
281
323
 
282
- by_name[pkg_set.name] = [pkg_set, vcs, import_options, imported_from]
324
+ required_user_dirs = by_name.collect { |k, v| k }
325
+ cleanup_remotes_dir(package_sets, required_remotes_dirs)
326
+ cleanup_remotes_user_dir(package_sets, required_user_dirs)
283
327
 
284
- # Finally, queue the imports
285
- queue_auto_imports_if_needed(queue, pkg_set, root_pkg_set)
328
+ [package_sets, failures]
286
329
  end
287
330
 
288
- required_user_dirs = by_name.collect { |k,v| k }
289
- cleanup_remotes_dir(package_sets, required_remotes_dirs)
290
- cleanup_remotes_user_dir(package_sets, required_user_dirs)
291
-
292
- return package_sets, failures
293
- end
294
-
295
- # Removes from {remotes_dir} the directories that do not match a package
296
- # set
297
- def cleanup_remotes_dir(package_sets = ws.manifest.package_sets, required_remotes_dirs = Array.new)
298
- # Cleanup the .remotes and remotes_symlinks_dir directories
299
- Dir.glob(File.join(remotes_dir, '*')).each do |dir|
300
- dir = File.expand_path(dir)
301
- # Once a package set has been checked out during the process,
302
- # keep it -- so that it won't be checked out again
303
- if File.directory?(dir) && !required_remotes_dirs.include?(dir)
304
- FileUtils.rm_rf dir
331
+ # Removes from {remotes_dir} the directories that do not match a package
332
+ # set
333
+ def cleanup_remotes_dir(package_sets = ws.manifest.package_sets, required_remotes_dirs = Array.new)
334
+ # Cleanup the .remotes and remotes_symlinks_dir directories
335
+ Dir.glob(File.join(remotes_dir, "*")).each do |dir|
336
+ dir = File.expand_path(dir)
337
+ # Once a package set has been checked out during the process,
338
+ # keep it -- so that it won't be checked out again
339
+ if File.directory?(dir) && !required_remotes_dirs.include?(dir)
340
+ FileUtils.rm_rf dir
341
+ end
305
342
  end
306
343
  end
307
- end
308
344
 
309
- # Removes from {remotes_user_dir} the directories that do not match a
310
- # package set
311
- def cleanup_remotes_user_dir(package_sets = ws.manifest.package_sets, required_user_dirs = Array.new)
312
- Dir.glob(File.join(remotes_user_dir, '*')).each do |file|
313
- file = File.expand_path(file)
314
- user_dir = File.basename(file)
315
- if File.symlink?(file) && !required_user_dirs.include?(user_dir)
316
- FileUtils.rm_f file
345
+ # Removes from {remotes_user_dir} the directories that do not match a
346
+ # package set
347
+ def cleanup_remotes_user_dir(package_sets = ws.manifest.package_sets, required_user_dirs = Array.new)
348
+ Dir.glob(File.join(remotes_user_dir, "*")).each do |file|
349
+ file = File.expand_path(file)
350
+ user_dir = File.basename(file)
351
+ if File.symlink?(file) && !required_user_dirs.include?(user_dir)
352
+ FileUtils.rm_f file
353
+ end
317
354
  end
318
355
  end
319
- end
320
356
 
321
- def inspect; to_s end
322
-
323
- def sort_package_sets_by_import_order(package_sets, root_pkg_set)
324
- # The sorting is done in two steps:
325
- # - first, we build a topological order of the package sets
326
- # - then, we insert the auto-imported packages, following this
327
- # topological order, in the user-provided order. Each package is
328
- # considered in turn, and added at the earliest place that fits
329
- # the dependencies
330
- topological = Array.new
331
- queue = (package_sets.to_a + [root_pkg_set]).uniq
332
- while !queue.empty?
333
- last_size = queue.size
334
- pending = queue.dup
335
- queue = Array.new
336
- while !pending.empty?
337
- pkg_set = pending.shift
338
- if pkg_set.imports.any? { |imported_set| !topological.include?(imported_set) }
339
- queue.push(pkg_set)
340
- else
341
- topological << pkg_set
342
- end
343
- end
344
- if queue.size == last_size
345
- raise ArgumentError, "cannot resolve the dependencies between package sets. There seem to be a cycle amongst #{queue.map(&:name).sort.join(", ")}"
346
- end
357
+ def inspect
358
+ to_s
347
359
  end
348
360
 
349
- result = root_pkg_set.imports.to_a.dup
350
- to_insert = topological.dup.
351
- find_all { |p| !result.include?(p) }
352
- while !to_insert.empty?
353
- pkg_set = to_insert.shift
354
- dependencies = pkg_set.imports.dup
355
- if dependencies.empty?
356
- result.unshift(pkg_set)
357
- else
358
- i = result.find_index do |p|
359
- dependencies.delete(p)
360
- dependencies.empty?
361
- end
362
- result.insert(i + 1, pkg_set)
361
+ # Sort the package sets by dependency order
362
+ # Package sets that have no dependencies come first,
363
+ # the local package set (by main configuration) last
364
+ def sort_package_sets_by_import_order(package_sets, root_pkg_set)
365
+ c = PackageSetHierarchy.new(package_sets, root_pkg_set)
366
+ sorted_pkg_sets = c.flatten
367
+
368
+ if sorted_pkg_sets.last != root_pkg_set
369
+ raise InternalError, "Failed to sort the package sets: the " \
370
+ "root package set should be last, but is not #{sorted_pkg_sets.map(&:name)}"
363
371
  end
364
- end
365
372
 
366
- # Sanity check related to the root package set
367
- # - it should be last
368
- # - it should be present only once
369
- if result.last != root_pkg_set
370
- raise InternalError, "failed to sort the package sets: the root package set should be last, but is not"
373
+ sorted_pkg_sets
371
374
  end
372
- result
373
- end
374
375
 
375
- def load_package_sets(
376
+ def load_package_sets(
376
377
  only_local: false,
377
378
  checkout_only: true,
378
379
  keep_going: false,
379
380
  reset: false,
380
381
  retry_count: nil,
381
- mainline: nil)
382
- update_configuration(
383
- only_local: only_local,
384
- checkout_only: checkout_only,
385
- keep_going: keep_going,
386
- reset: reset,
387
- retry_count: retry_count,
388
- mainline: mainline)
389
- end
382
+ mainline: nil
383
+ )
384
+ update_configuration(
385
+ only_local: only_local,
386
+ checkout_only: checkout_only,
387
+ keep_going: keep_going,
388
+ reset: reset,
389
+ retry_count: retry_count,
390
+ mainline: mainline
391
+ )
392
+ end
390
393
 
391
- def report_import_failure(what, reason)
392
- if !reason.kind_of?(Interrupt)
393
- Autoproj.message "import of #{what} failed", :red
394
- Autoproj.message reason.to_s, :red
394
+ def report_import_failure(what, reason)
395
+ unless reason.kind_of?(Interrupt)
396
+ Autoproj.message "import of #{what} failed", :red
397
+ Autoproj.message reason.to_s, :red
398
+ end
395
399
  end
396
- end
397
400
 
398
- def handle_keep_going(keep_going, vcs, failures)
399
- yield
400
- false
401
- rescue Interrupt
402
- raise
403
- rescue Exception => failure_reason
404
- if keep_going
405
- report_import_failure(vcs, failure_reason)
406
- failures << failure_reason
407
- true
408
- else
401
+ def handle_keep_going(keep_going, vcs, failures)
402
+ yield
403
+ false
404
+ rescue Interrupt
409
405
  raise
406
+ rescue Exception => failure_reason
407
+ if keep_going
408
+ report_import_failure(vcs, failure_reason)
409
+ failures << failure_reason
410
+ true
411
+ else
412
+ raise
413
+ end
410
414
  end
411
- end
412
415
 
413
- def update_configuration(
416
+ def update_configuration(
414
417
  only_local: false,
415
418
  checkout_only: !Autobuild.do_update,
416
419
  keep_going: false,
417
420
  reset: false,
418
421
  retry_count: nil,
419
- mainline: nil)
422
+ mainline: nil
423
+ )
420
424
 
421
- if ws.manifest.vcs.needs_import?
422
- main_configuration_failure = update_main_configuration(
423
- keep_going: keep_going,
424
- checkout_only: checkout_only,
425
+ if ws.manifest.vcs.needs_import?
426
+ main_configuration_failure = update_main_configuration(
427
+ keep_going: keep_going,
428
+ checkout_only: checkout_only,
429
+ only_local: only_local,
430
+ reset: reset,
431
+ retry_count: retry_count
432
+ )
433
+
434
+ main_configuration_failure.each do |e|
435
+ report_import_failure("main configuration", e)
436
+ end
437
+ else
438
+ main_configuration_failure = []
439
+ end
440
+ ws.load_main_initrb
441
+ ws.manifest.load(manifest_path)
442
+ root_pkg_set = ws.manifest.main_package_set
443
+ root_pkg_set.load_description_file
444
+ root_pkg_set.explicit = true
445
+
446
+ package_sets_failure = update_package_sets(
425
447
  only_local: only_local,
448
+ checkout_only: checkout_only,
449
+ keep_going: keep_going,
426
450
  reset: reset,
427
- retry_count: retry_count)
451
+ retry_count: retry_count
452
+ )
428
453
 
429
- main_configuration_failure.each do |e|
430
- report_import_failure("main configuration", e)
454
+ load_package_set_information(mainline: mainline)
455
+
456
+ if !main_configuration_failure.empty? && !package_sets_failure.empty?
457
+ raise ImportFailed.new(main_configuration_failure + package_sets_failure)
458
+ elsif !main_configuration_failure.empty?
459
+ raise ImportFailed.new(main_configuration_failure)
460
+ elsif !package_sets_failure.empty?
461
+ raise ImportFailed.new(package_sets_failure)
431
462
  end
432
- else
433
- main_configuration_failure = []
434
- end
435
- ws.load_main_initrb
436
- ws.manifest.load(manifest_path)
437
- root_pkg_set = ws.manifest.main_package_set
438
- root_pkg_set.load_description_file
439
- root_pkg_set.explicit = true
440
-
441
- package_sets_failure = update_package_sets(
442
- only_local: only_local,
443
- checkout_only: checkout_only,
444
- keep_going: keep_going,
445
- reset: reset,
446
- retry_count: retry_count)
447
-
448
- load_package_set_information(mainline: mainline)
449
-
450
- if !main_configuration_failure.empty? && !package_sets_failure.empty?
451
- raise ImportFailed.new(main_configuration_failure + package_sets_failure)
452
- elsif !main_configuration_failure.empty?
453
- raise ImportFailed.new(main_configuration_failure)
454
- elsif !package_sets_failure.empty?
455
- raise ImportFailed.new(package_sets_failure)
456
463
  end
457
- end
458
464
 
459
- def load_package_set_information(mainline: nil)
460
- manifest = ws.manifest
461
- manifest.each_package_set do |pkg_set|
462
- if Gem::Version.new(pkg_set.required_autoproj_version) > Gem::Version.new(Autoproj::VERSION)
463
- raise ConfigError.new(pkg_set.source_file), "the #{pkg_set.name} package set requires autoproj v#{pkg_set.required_autoproj_version} but this is v#{Autoproj::VERSION}"
465
+ def load_package_set_information(mainline: nil)
466
+ manifest = ws.manifest
467
+ manifest.each_package_set do |pkg_set|
468
+ if Gem::Version.new(pkg_set.required_autoproj_version) > Gem::Version.new(Autoproj::VERSION)
469
+ raise ConfigError.new(pkg_set.source_file), "the #{pkg_set.name} package set requires autoproj v#{pkg_set.required_autoproj_version} but this is v#{Autoproj::VERSION}"
470
+ end
464
471
  end
465
- end
466
472
 
467
- # Loads OS repository definitions once and for all
468
- load_osrepos_from_package_sets
473
+ # Loads OS repository definitions once and for all
474
+ load_osrepos_from_package_sets
469
475
 
470
- # Loads OS package definitions once and for all
471
- load_osdeps_from_package_sets
476
+ # Loads OS package definitions once and for all
477
+ load_osdeps_from_package_sets
472
478
 
473
- # Load the required autobuild definitions
474
- manifest.each_package_set do |pkg_set|
475
- pkg_set.each_autobuild_file do |path|
476
- ws.import_autobuild_file pkg_set, path
479
+ # Load the required autobuild definitions
480
+ manifest.each_package_set do |pkg_set|
481
+ pkg_set.each_autobuild_file do |path|
482
+ ws.import_autobuild_file pkg_set, path
483
+ end
477
484
  end
478
- end
479
485
 
480
- # Now, load the package's importer configurations (from the various
481
- # source.yml files)
482
- if mainline.respond_to?(:to_str)
483
- mainline = manifest.package_set(mainline)
484
- end
485
- manifest.load_importers(mainline: mainline)
486
+ # Now, load the package's importer configurations (from the various
487
+ # source.yml files)
488
+ mainline = manifest.package_set(mainline) if mainline.respond_to?(:to_str)
489
+ manifest.load_importers(mainline: mainline)
486
490
 
487
- auto_add_packages_from_layout
491
+ auto_add_packages_from_layout
488
492
 
489
- manifest.each_autobuild_package do |pkg|
490
- Autobuild.each_utility do |uname, _|
491
- pkg.utility(uname).enabled =
492
- ws.config.utility_enabled_for?(uname, pkg.name)
493
+ manifest.each_autobuild_package do |pkg|
494
+ Autobuild.each_utility do |uname, _|
495
+ pkg.utility(uname).enabled =
496
+ ws.config.utility_enabled_for?(uname, pkg.name)
497
+ end
493
498
  end
494
- end
495
499
 
496
- mark_unavailable_osdeps_as_excluded
497
- end
500
+ mark_unavailable_osdeps_as_excluded
501
+ end
498
502
 
499
- # @api private
500
- #
501
- # Attempts to find packages mentioned in the layout but that are not
502
- # defined, and auto-define them if they can be found on disk
503
- #
504
- # It only warns about packages that can't be defined that way are on
505
- def auto_add_packages_from_layout
506
- manifest = ws.manifest
507
-
508
- # Auto-add packages that are
509
- # * present on disk
510
- # * listed in the layout part of the manifest
511
- # * but have no definition
512
- explicit = manifest.normalized_layout
513
- explicit.each do |pkg_or_set, layout_level|
514
- next if manifest.find_autobuild_package(pkg_or_set)
515
- next if manifest.has_package_set?(pkg_or_set)
516
- full_path = File.expand_path(File.join(ws.source_dir, layout_level, pkg_or_set))
517
- next if !File.directory?(full_path)
518
-
519
- if handler = auto_add_package(pkg_or_set, full_path)
520
- Autoproj.message " auto-added #{pkg_or_set} #{"in #{layout_level} " if layout_level != "/"}using the #{handler.gsub(/_package/, '')} package handler"
521
- else
522
- Autoproj.warn "cannot auto-add #{pkg_or_set}: unknown package type"
503
+ # @api private
504
+ #
505
+ # Attempts to find packages mentioned in the layout but that are not
506
+ # defined, and auto-define them if they can be found on disk
507
+ #
508
+ # It only warns about packages that can't be defined that way are on
509
+ def auto_add_packages_from_layout
510
+ manifest = ws.manifest
511
+
512
+ # Auto-add packages that are
513
+ # * present on disk
514
+ # * listed in the layout part of the manifest
515
+ # * but have no definition
516
+ explicit = manifest.normalized_layout
517
+ explicit.each do |pkg_or_set, layout_level|
518
+ next if manifest.find_autobuild_package(pkg_or_set)
519
+ next if manifest.has_package_set?(pkg_or_set)
520
+
521
+ full_path = File.expand_path(
522
+ File.join(ws.source_dir, layout_level, pkg_or_set)
523
+ )
524
+ next unless File.directory?(full_path)
525
+
526
+ if (handler = auto_add_package(pkg_or_set, full_path))
527
+ handler_name = handler.gsub(/_package/, "")
528
+ layout_level_msg = "in #{layout_level} " if layout_level != "/"
529
+ Autoproj.message " auto-added #{pkg_or_set} #{layout_level_msg}"\
530
+ "using the #{handler_name} package handler"
531
+ else
532
+ Autoproj.warn "cannot auto-add #{pkg_or_set}: "\
533
+ "unknown package type"
534
+ end
523
535
  end
524
-
525
536
  end
526
- end
527
537
 
528
- # @api private
529
- #
530
- # Attempts to auto-add the package checked out at the given path
531
- #
532
- # @param [String] full_path
533
- # @return [String,nil] either the name of the package handler used to
534
- # define the package, or nil if no handler could be found
535
- def auto_add_package(name, full_path)
536
- manifest = ws.manifest
537
- handler, _srcdir = Autoproj.package_handler_for(full_path)
538
- if handler
539
- ws.set_as_main_workspace do
540
- ws.in_package_set(manifest.main_package_set, manifest.file) do
541
- send(handler, name)
538
+ # @api private
539
+ #
540
+ # Attempts to auto-add the package checked out at the given path
541
+ #
542
+ # @param [String] full_path
543
+ # @return [String,nil] either the name of the package handler used to
544
+ # define the package, or nil if no handler could be found
545
+ def auto_add_package(name, full_path)
546
+ manifest = ws.manifest
547
+ handler, _srcdir = Autoproj.package_handler_for(full_path)
548
+ if handler
549
+ ws.set_as_main_workspace do
550
+ ws.in_package_set(manifest.main_package_set, manifest.file) do
551
+ send(handler, name)
552
+ end
542
553
  end
554
+ handler
543
555
  end
544
- handler
545
556
  end
546
- end
547
557
 
548
- def mark_unavailable_osdeps_as_excluded
549
- os_package_resolver = ws.os_package_resolver
550
- manifest = ws.manifest
551
- os_package_resolver.all_package_names.each do |osdep_name|
552
- # If the osdep can be replaced by source packages, there's
553
- # nothing to do really. The exclusions of the source packages
554
- # will work as expected
555
- if manifest.osdeps_overrides[osdep_name] || manifest.find_autobuild_package(osdep_name)
556
- next
557
- end
558
+ def mark_unavailable_osdeps_as_excluded
559
+ os_package_resolver = ws.os_package_resolver
560
+ manifest = ws.manifest
561
+ os_package_resolver.all_package_names.each do |osdep_name|
562
+ # If the osdep can be replaced by source packages, there's
563
+ # nothing to do really. The exclusions of the source packages
564
+ # will work as expected
565
+ if manifest.osdeps_overrides[osdep_name] || manifest.find_autobuild_package(osdep_name)
566
+ next
567
+ end
558
568
 
559
- case os_package_resolver.availability_of(osdep_name)
560
- when OSPackageResolver::UNKNOWN_OS
561
- manifest.exclude_package(osdep_name, "the current operating system is unknown to autoproj")
562
- when OSPackageResolver::WRONG_OS
563
- manifest.exclude_package(osdep_name, "#{osdep_name} is defined, but not for this operating system")
564
- when OSPackageResolver::NONEXISTENT
565
- manifest.exclude_package(osdep_name, "#{osdep_name} is marked as unavailable for this operating system")
569
+ case os_package_resolver.availability_of(osdep_name)
570
+ when OSPackageResolver::UNKNOWN_OS
571
+ manifest.exclude_package(osdep_name, "the current operating system is unknown to autoproj")
572
+ when OSPackageResolver::WRONG_OS
573
+ manifest.exclude_package(osdep_name, "#{osdep_name} is defined, but not for this operating system")
574
+ when OSPackageResolver::NONEXISTENT
575
+ manifest.exclude_package(osdep_name, "#{osdep_name} is marked as unavailable for this operating system")
576
+ end
566
577
  end
567
578
  end
568
- end
569
579
 
570
- # Load OS dependency information contained in our registered package
571
- # sets into the provided osdep object
572
- #
573
- # This is included in {load_package_sets}
574
- #
575
- # @return [void]
576
- def load_osdeps_from_package_sets
577
- ws.manifest.each_package_set do |pkg_set|
578
- pkg_set.each_osdeps_file do |file|
579
- file_osdeps = pkg_set.load_osdeps(
580
- file, operating_system: ws.operating_system)
581
- ws.os_package_resolver.merge(file_osdeps)
580
+ # Load OS dependency information contained in our registered package
581
+ # sets into the provided osdep object
582
+ #
583
+ # This is included in {load_package_sets}
584
+ #
585
+ # @return [void]
586
+ def load_osdeps_from_package_sets
587
+ ws.manifest.each_package_set do |pkg_set|
588
+ pkg_set.each_osdeps_file do |file|
589
+ file_osdeps = pkg_set.load_osdeps(
590
+ file, operating_system: ws.operating_system
591
+ )
592
+ ws.os_package_resolver.merge(file_osdeps)
593
+ end
582
594
  end
583
595
  end
584
- end
585
596
 
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
+ # Load OS repository information contained in our registered package
598
+ # sets into the provided osrepo object
599
+ #
600
+ # This is included in {load_package_sets}
601
+ #
602
+ # @return [void]
603
+ def load_osrepos_from_package_sets
604
+ ws.manifest.each_package_set do |pkg_set|
605
+ pkg_set.each_osrepos_file do |file|
606
+ file_osrepos = pkg_set.load_osrepos(file)
607
+ ws.os_repository_resolver.merge(file_osrepos)
608
+ end
597
609
  end
598
610
  end
599
- end
600
611
 
601
- def update_package_sets(only_local: false,
602
- checkout_only: !Autobuild.do_update,
603
- keep_going: false,
604
- reset: false,
605
- retry_count: nil)
606
- root_pkg_set = ws.manifest.main_package_set
607
- package_sets, failures = load_and_update_package_sets(
608
- root_pkg_set,
609
- only_local: only_local,
610
- checkout_only: checkout_only,
611
- keep_going: keep_going,
612
- reset: reset,
613
- retry_count: retry_count)
614
- root_pkg_set.imports.each do |pkg_set|
615
- pkg_set.explicit = true
616
- end
617
- package_sets = sort_package_sets_by_import_order(package_sets, root_pkg_set)
618
- ws.manifest.reset_package_sets
619
- package_sets.each do |pkg_set|
620
- ws.manifest.register_package_set(pkg_set)
612
+ def update_package_sets(only_local: false,
613
+ checkout_only: !Autobuild.do_update,
614
+ keep_going: false,
615
+ reset: false,
616
+ retry_count: nil)
617
+ root_pkg_set = ws.manifest.main_package_set
618
+ package_sets, failures = load_and_update_package_sets(
619
+ root_pkg_set,
620
+ only_local: only_local,
621
+ checkout_only: checkout_only,
622
+ keep_going: keep_going,
623
+ reset: reset,
624
+ retry_count: retry_count
625
+ )
626
+ root_pkg_set.imports.each do |pkg_set|
627
+ pkg_set.explicit = true
628
+ end
629
+ package_sets = sort_package_sets_by_import_order(package_sets, root_pkg_set)
630
+ ws.manifest.reset_package_sets
631
+ package_sets.each do |pkg_set|
632
+ ws.load_if_present(pkg_set, pkg_set.local_dir, "init.rb")
633
+ ws.manifest.register_package_set(pkg_set)
634
+ end
635
+ failures
621
636
  end
622
- failures
623
637
  end
624
638
  end
625
- end
626
639
  end
627
-