autoproj 2.0.0.rc37 → 2.0.0.rc38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -2
  3. data/Rakefile +1 -1
  4. data/bin/autoproj_bootstrap +34 -2
  5. data/bin/autoproj_bootstrap.in +4 -2
  6. data/bin/autoproj_install +34 -2
  7. data/bin/autoproj_install.in +4 -2
  8. data/lib/autoproj.rb +9 -2
  9. data/lib/autoproj/autobuild.rb +13 -742
  10. data/lib/autoproj/autobuild_extensions/archive_importer.rb +44 -0
  11. data/lib/autoproj/autobuild_extensions/dsl.rb +439 -0
  12. data/lib/autoproj/autobuild_extensions/git.rb +116 -0
  13. data/lib/autoproj/autobuild_extensions/package.rb +159 -0
  14. data/lib/autoproj/autobuild_extensions/svn.rb +11 -0
  15. data/lib/autoproj/cli/base.rb +17 -18
  16. data/lib/autoproj/cli/clean.rb +1 -2
  17. data/lib/autoproj/cli/envsh.rb +1 -2
  18. data/lib/autoproj/cli/inspection_tool.rb +12 -21
  19. data/lib/autoproj/cli/locate.rb +130 -73
  20. data/lib/autoproj/cli/main.rb +31 -5
  21. data/lib/autoproj/cli/main_plugin.rb +79 -0
  22. data/lib/autoproj/cli/main_test.rb +19 -5
  23. data/lib/autoproj/cli/osdeps.rb +1 -2
  24. data/lib/autoproj/cli/patcher.rb +21 -0
  25. data/lib/autoproj/cli/query.rb +34 -41
  26. data/lib/autoproj/cli/show.rb +121 -52
  27. data/lib/autoproj/cli/status.rb +4 -5
  28. data/lib/autoproj/cli/tag.rb +1 -1
  29. data/lib/autoproj/cli/test.rb +7 -6
  30. data/lib/autoproj/cli/update.rb +8 -22
  31. data/lib/autoproj/cli/versions.rb +1 -2
  32. data/lib/autoproj/configuration.rb +1 -1
  33. data/lib/autoproj/environment.rb +2 -7
  34. data/lib/autoproj/exceptions.rb +10 -8
  35. data/lib/autoproj/find_workspace.rb +46 -12
  36. data/lib/autoproj/installation_manifest.rb +34 -25
  37. data/lib/autoproj/local_package_set.rb +86 -0
  38. data/lib/autoproj/manifest.rb +448 -503
  39. data/lib/autoproj/metapackage.rb +31 -5
  40. data/lib/autoproj/ops/configuration.rb +46 -45
  41. data/lib/autoproj/ops/import.rb +150 -60
  42. data/lib/autoproj/ops/install.rb +25 -1
  43. data/lib/autoproj/ops/loader.rb +4 -1
  44. data/lib/autoproj/ops/main_config_switcher.rb +4 -4
  45. data/lib/autoproj/ops/snapshot.rb +4 -3
  46. data/lib/autoproj/os_package_installer.rb +105 -46
  47. data/lib/autoproj/os_package_resolver.rb +63 -36
  48. data/lib/autoproj/package_definition.rb +1 -0
  49. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +30 -27
  50. data/lib/autoproj/package_managers/bundler_manager.rb +64 -18
  51. data/lib/autoproj/package_managers/gem_manager.rb +4 -2
  52. data/lib/autoproj/package_managers/manager.rb +26 -7
  53. data/lib/autoproj/package_managers/shell_script_manager.rb +4 -4
  54. data/lib/autoproj/package_managers/zypper_manager.rb +1 -1
  55. data/lib/autoproj/package_manifest.rb +154 -137
  56. data/lib/autoproj/package_selection.rb +16 -2
  57. data/lib/autoproj/package_set.rb +352 -309
  58. data/lib/autoproj/query.rb +13 -1
  59. data/lib/autoproj/system.rb +2 -2
  60. data/lib/autoproj/test.rb +164 -11
  61. data/lib/autoproj/variable_expansion.rb +15 -42
  62. data/lib/autoproj/vcs_definition.rb +93 -76
  63. data/lib/autoproj/version.rb +1 -1
  64. data/lib/autoproj/workspace.rb +116 -80
  65. metadata +10 -2
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "2.0.0.rc37"
2
+ VERSION = "2.0.0.rc38"
3
3
  end
@@ -15,20 +15,25 @@ class Workspace < Ops::Loader
15
15
 
16
16
  attr_reader :loader
17
17
 
18
- def os_package_resolver; manifest.os_package_resolver end
18
+ attr_reader :os_package_resolver
19
19
  attr_reader :os_package_installer
20
20
 
21
- def initialize(root_dir)
21
+ def initialize(root_dir,
22
+ os_package_resolver: OSPackageResolver.new,
23
+ package_managers: OSPackageInstaller::PACKAGE_MANAGERS)
22
24
  @root_dir = root_dir
23
25
 
24
26
  @loader = loader
25
27
  @env = Environment.new
28
+ env.prepare(root_dir)
26
29
  env.source_before(File.join(dot_autoproj_dir, 'env.sh'))
27
- @manifest = Manifest.new
28
- @config = Configuration.new
29
30
 
30
- @os_package_installer = OSPackageInstaller.new(self, os_package_resolver)
31
- env.prepare(root_dir)
31
+ @os_package_resolver = os_package_resolver
32
+ @manifest = Manifest.new(self, os_package_resolver: os_package_resolver)
33
+ @config = Configuration.new(config_file_path)
34
+
35
+ @os_package_installer = OSPackageInstaller.new(
36
+ self, os_package_resolver, package_managers: package_managers)
32
37
  super(root_dir)
33
38
  end
34
39
 
@@ -48,8 +53,8 @@ def self.autoproj_current_root
48
53
  #
49
54
  # @return [Workspace]
50
55
  # @raise (see from_dir)
51
- def self.from_pwd
52
- from_dir(Dir.pwd)
56
+ def self.from_pwd(**workspace_options)
57
+ from_dir(Dir.pwd, **workspace_options)
53
58
  end
54
59
 
55
60
  # Returns the workspace a directory is part of
@@ -58,9 +63,9 @@ def self.from_pwd
58
63
  # @raise [MismatchingWorkspace] if the currently loaded env.sh
59
64
  # and the one from +dir+ mismatch
60
65
  # @raise [NotWorkspace] if dir is not within an autoproj workspace
61
- def self.from_dir(dir)
66
+ def self.from_dir(dir, **workspace_options)
62
67
  if path = Autoproj.find_workspace_dir(dir)
63
- Workspace.new(path)
68
+ Workspace.new(path, **workspace_options)
64
69
  elsif Autoproj.find_v1_workspace_dir(dir)
65
70
  raise OutdatedWorkspace, "#{dir} looks like a v1 workspace, run autoproj upgrade before continuing"
66
71
  else
@@ -68,9 +73,9 @@ def self.from_dir(dir)
68
73
  end
69
74
  end
70
75
 
71
- def self.from_environment
76
+ def self.from_environment(**workspace_options)
72
77
  if path = Autoproj.find_workspace_dir
73
- from_dir(path)
78
+ from_dir(path, **workspace_options)
74
79
  elsif Autoproj.find_v1_workspace_dir(dir = Autoproj.default_find_base_dir)
75
80
  raise OutdatedWorkspace, "#{dir} looks like a v1 workspace, run autoproj upgrade before continuing"
76
81
  elsif envvar = ENV['AUTOPROJ_CURRENT_ROOT']
@@ -94,8 +99,8 @@ def self.in_autoproj_project?(path)
94
99
  # @raise MismatchingWorkspace if the workspace pointed by
95
100
  # AUTOPROJ_CURRENT_ROOT does not match the one containing the current
96
101
  # directory
97
- def self.default
98
- ws = from_environment
102
+ def self.default(**workspace_options)
103
+ ws = from_environment(**workspace_options)
99
104
  if (from_pwd = Autoproj.find_workspace_dir(Dir.pwd)) && (from_pwd != ws.root_dir)
100
105
  raise MismatchingWorkspace, "the current environment points to #{ws.root_dir}, but you are in #{from_pwd}, make sure you are loading the right #{ENV_FILENAME} script !"
101
106
  end
@@ -125,7 +130,7 @@ def dot_autoproj_dir
125
130
 
126
131
  # The installation manifest
127
132
  def installation_manifest_path
128
- InstallationManifest.path_for_root(root_dir)
133
+ InstallationManifest.path_for_workspace_root(root_dir)
129
134
  end
130
135
 
131
136
  # The path to the workspace configuration file
@@ -196,11 +201,15 @@ def load_config(reconfigure = false)
196
201
  type: 'local', url: config_dir)
197
202
  end
198
203
  os_package_resolver.prefer_indep_over_os_packages = config.prefer_indep_over_os_packages?
199
- OSPackageResolver.operating_system ||= config.get('operating_system', nil)
204
+ os_package_resolver.operating_system ||= config.get('operating_system', nil)
200
205
  end
201
206
  @config
202
207
  end
203
208
 
209
+ def save_config
210
+ config.save(config_file_path)
211
+ end
212
+
204
213
  def load_manifest
205
214
  if File.exist?(manifest_file_path)
206
215
  manifest.load(manifest_file_path)
@@ -213,7 +222,7 @@ def autodetect_operating_system(force: false)
213
222
  Autobuild.progress_start :operating_system_autodetection,
214
223
  "autodetecting the operating system"
215
224
  names, versions = OSPackageResolver.autodetect_operating_system
216
- OSPackageResolver.operating_system = [names, versions]
225
+ os_package_resolver.operating_system = [names, versions]
217
226
  Autobuild.progress :operating_system_autodetection,
218
227
  "operating system: #{(names - ['default']).join(",")} - #{(versions - ['default']).join(",")}"
219
228
  ensure
@@ -266,7 +275,6 @@ def setup
266
275
  if cache_dir = config.importer_cache_dir
267
276
  Autobuild::Importer.default_cache_dirs = cache_dir
268
277
  end
269
- env.prepare(root_dir)
270
278
  setup_os_package_installer
271
279
  install_ruby_shims
272
280
  end
@@ -317,20 +325,23 @@ def update_autoproj(restart_on_update: true)
317
325
 
318
326
  gemfile = File.join(dot_autoproj_dir, 'Gemfile')
319
327
  binstubs = File.join(dot_autoproj_dir, 'bin')
320
- old_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
321
- self, 'autoproj', gemfile: gemfile)
328
+ if restart_on_update
329
+ old_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
330
+ self, 'autoproj', gemfile: gemfile)
331
+ end
322
332
  begin
323
333
  PackageManagers::BundlerManager.run_bundler_install(
324
334
  self, gemfile, binstubs: binstubs)
325
335
  ensure
326
336
  Ops::Install.rewrite_shims(binstubs, config.ruby_executable, gemfile, config.gems_gem_home)
327
337
  end
328
- new_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
329
- self, 'autoproj', gemfile: gemfile)
330
-
338
+ if restart_on_update
339
+ new_autoproj_path = PackageManagers::BundlerManager.bundle_gem_path(
340
+ self, 'autoproj', gemfile: gemfile)
341
+ end
331
342
 
332
343
  # First things first, see if we need to update ourselves
333
- if (new_autoproj_path != old_autoproj_path) && restart_on_update
344
+ if new_autoproj_path != old_autoproj_path
334
345
  puts
335
346
  Autoproj.message "autoproj has been updated, restarting"
336
347
  puts
@@ -414,8 +425,11 @@ def load_autoprojrc
414
425
  #
415
426
  # @return [void]
416
427
  def load_osdeps_from_package_sets
417
- manifest.each_osdeps_file do |pkg_set, file|
418
- os_package_resolver.merge(pkg_set.load_osdeps(file))
428
+ manifest.each_package_set do |pkg_set|
429
+ pkg_set.each_osdeps_file do |file|
430
+ file_osdeps = pkg_set.load_osdeps(file, operating_system: os_package_resolver.operating_system)
431
+ os_package_resolver.merge(file_osdeps)
432
+ end
419
433
  end
420
434
  end
421
435
 
@@ -457,8 +471,10 @@ def load_package_sets(options = Hash.new)
457
471
  Autoproj.message("and use 'autoproj switch-config' to change the remote source for", :bold)
458
472
  Autoproj.message("autoproj's main build configuration", :bold)
459
473
  end
460
- manifest.each_autobuild_file do |source, name|
461
- import_autobuild_file source, name
474
+ manifest.each_package_set do |pkg_set|
475
+ pkg_set.each_autobuild_file do |path|
476
+ import_autobuild_file pkg_set, path
477
+ end
462
478
  end
463
479
 
464
480
  # Now, load the package's importer configurations (from the various
@@ -485,7 +501,7 @@ def load_package_sets(options = Hash.new)
485
501
  handler, _srcdir = Autoproj.package_handler_for(full_path)
486
502
  if handler
487
503
  Autoproj.message " auto-adding #{pkg_or_set} #{"in #{layout_level} " if layout_level != "/"}using the #{handler.gsub(/_package/, '')} package handler"
488
- in_package_set(manifest.local_package_set, manifest.file) do
504
+ in_package_set(manifest.main_package_set, manifest.file) do
489
505
  send(handler, pkg_or_set)
490
506
  end
491
507
  else
@@ -516,11 +532,11 @@ def mark_unavailable_osdeps_as_excluded
516
532
 
517
533
  case os_package_resolver.availability_of(osdep_name)
518
534
  when OSPackageResolver::UNKNOWN_OS
519
- manifest.add_exclusion(osdep_name, "this operating system is unknown to autoproj")
535
+ manifest.exclude_package(osdep_name, "this operating system is unknown to autoproj")
520
536
  when OSPackageResolver::WRONG_OS
521
- manifest.add_exclusion(osdep_name, "there are definitions for it, but not for this operating system")
537
+ manifest.exclude_package(osdep_name, "there are definitions for it, but not for this operating system")
522
538
  when OSPackageResolver::NONEXISTENT
523
- manifest.add_exclusion(osdep_name, "it is marked as unavailable for this operating system")
539
+ manifest.exclude_package(osdep_name, "it is marked as unavailable for this operating system")
524
540
  end
525
541
  end
526
542
  end
@@ -538,14 +554,14 @@ def setup_all_package_directories
538
554
  manifest.reused_installations.each do |imported_manifest|
539
555
  imported_manifest.each do |imported_pkg|
540
556
  imported_packages << imported_pkg.name
541
- if pkg = manifest.find_package(imported_pkg.name)
557
+ if pkg = manifest.find_package_definition(imported_pkg.name)
542
558
  pkg.autobuild.srcdir = imported_pkg.srcdir
543
559
  pkg.autobuild.prefix = imported_pkg.prefix
544
560
  end
545
561
  end
546
562
  end
547
563
 
548
- manifest.packages.each_value do |pkg_def|
564
+ manifest.each_package_definition do |pkg_def|
549
565
  pkg = pkg_def.autobuild
550
566
  next if imported_packages.include?(pkg_def.name)
551
567
  setup_package_directories(pkg)
@@ -604,7 +620,7 @@ def finalize_package_setup
604
620
  set_as_main_workspace
605
621
  # Now call the blocks that the user defined in the autobuild files. We do it
606
622
  # now so that the various package directories are properly setup
607
- manifest.packages.each_value do |pkg|
623
+ manifest.each_package_definition do |pkg|
608
624
  pkg.user_blocks.each do |blk|
609
625
  blk[pkg.autobuild]
610
626
  end
@@ -617,8 +633,9 @@ def finalize_package_setup
617
633
  end
618
634
  end
619
635
 
636
+ main_package_set = manifest.main_package_set
620
637
  Dir.glob(File.join( overrides_dir, "*.rb" ) ).sort.each do |file|
621
- load file
638
+ load main_package_set, file
622
639
  end
623
640
  end
624
641
 
@@ -628,13 +645,8 @@ def finalize_package_setup
628
645
  # have been properly set up (a.k.a. after package import)
629
646
  def finalize_setup
630
647
  # Finally, disable all ignored packages on the autobuild side
631
- manifest.each_ignored_package do |pkg_name|
632
- pkg = manifest.find_autobuild_package(pkg_name)
633
- if !pkg
634
- Autoproj.warn "ignore line #{pkg_name} does not match anything"
635
- else
636
- pkg.disable
637
- end
648
+ manifest.each_ignored_package do |pkg|
649
+ pkg.disable
638
650
  end
639
651
 
640
652
  # We now have processed the process setup blocks. All configuration
@@ -652,20 +664,18 @@ def all_present_packages
652
664
  #
653
665
  # @param [Array<String>] package_names the name of the packages that
654
666
  # should be updated
655
- def export_installation_manifest(package_names = all_present_packages)
667
+ def export_installation_manifest
668
+ selected_packages = manifest.all_selected_source_packages
656
669
  install_manifest = InstallationManifest.new(installation_manifest_path)
657
- if install_manifest.exist?
658
- install_manifest.load
659
- end
660
- # Delete obsolete entries
661
- install_manifest.delete_if do |pkg|
662
- !manifest.find_autobuild_package(pkg.name) ||
663
- !File.directory?(pkg.srcdir)
664
- end
670
+
665
671
  # Update the new entries
666
- package_names.each do |pkg_name|
667
- install_manifest[pkg_name] =
668
- manifest.find_autobuild_package(pkg_name)
672
+ manifest.each_package_set do |pkg_set|
673
+ next if pkg_set.main?
674
+ install_manifest.add_package_set(pkg_set)
675
+ end
676
+ selected_packages.each do |pkg_name|
677
+ pkg = manifest.package_definition_by_name(pkg_name)
678
+ install_manifest.add_package(pkg)
669
679
  end
670
680
  # And save
671
681
  install_manifest.save
@@ -674,9 +684,8 @@ def export_installation_manifest(package_names = all_present_packages)
674
684
  # Export the workspace's env.sh file
675
685
  def export_env_sh(package_names = all_present_packages, shell_helpers: true)
676
686
  env = self.env.dup
677
- manifest.all_selected_packages.each do |pkg_name|
678
- pkg = manifest.find_autobuild_package(pkg_name)
679
- pkg.apply_env(env)
687
+ manifest.all_selected_source_packages.each do |pkg|
688
+ pkg.autobuild.apply_env(env)
680
689
  end
681
690
  env.export_env_sh(shell_helpers: shell_helpers)
682
691
  end
@@ -685,33 +694,60 @@ def pristine_os_packages(packages, options = Hash.new)
685
694
  os_package_installer.pristine(packages, options)
686
695
  end
687
696
 
688
- # Restores the OS dependencies required by the given packages to
689
- # pristine conditions
697
+ # Returns the list of all OS packages required by the state of the
698
+ # workspace
690
699
  #
691
- # This is usually called as a rebuild step to make sure that all these
692
- # packages are updated to whatever required the rebuild
693
- def pristine_os_packages_for(packages)
694
- required_os_packages, package_os_deps =
695
- manifest.list_os_packages(packages)
696
- required_os_packages =
697
- manifest.filter_os_packages(required_os_packages, package_os_deps)
698
- pristine_os_packages(required_os_packages)
699
- end
700
-
701
- def install_os_packages(packages, options = Hash.new)
702
- os_package_installer.install(packages, options)
700
+ # @return [Array<String>] the list of OS packages that can be fed to
701
+ # {OSPackageManager#install}
702
+ def all_os_packages(import_missing: false, parallel: config.parallel_import_level)
703
+ if import_missing
704
+ ops = Autoproj::Ops::Import.new(self)
705
+ _, all_os_packages =
706
+ ops.import_packages(manifest.default_packages,
707
+ checkout_only: true, only_local: true, reset: false,
708
+ recursive: true, ignore_errors: true, parallel: parallel,
709
+ retry_count: 0)
710
+ all_os_packages
711
+ else
712
+ result = Set.new
713
+ manifest.all_selected_source_packages.each do |source_package|
714
+ result.merge(source_package.autobuild.os_packages)
715
+ end
716
+ result
717
+ end
703
718
  end
704
719
 
705
- # Installs the OS dependencies that are required by the given packages
706
- def install_os_packages_for(packages, options = Hash.new)
707
- required_os_packages, package_os_deps =
708
- manifest.list_os_packages(packages)
709
- required_os_packages =
710
- manifest.filter_os_packages(required_os_packages, package_os_deps)
711
- install_os_packages(required_os_packages, options)
720
+ def install_os_packages(packages, all: all_os_packages, **options)
721
+ os_package_installer.install(packages, all: all, **options)
712
722
  end
713
723
 
714
- # Register a package on this workspace
724
+ # Define and register an autobuild package on this workspace
725
+ #
726
+ # @param [Symbol] package_type a package-creation method on {Autobuild},
727
+ # e.g. :cmake
728
+ # @param [String] package_name the package name
729
+ # @param [PackageSet] package_set the package set into which this
730
+ # package is defined
731
+ # @param [String,nil] file the path to the file that defines this
732
+ # package (used for error reporting)
733
+ # @param [Proc,nil] block a setup block that should be called to
734
+ # configure the package
735
+ # @return [PackageDefinition]
736
+ def define_package(package_type, package_name, block = nil, package_set = manifest.main_package_set, file = nil)
737
+ autobuild_package = Autobuild.send(package_type, package_name)
738
+ register_package(autobuild_package, block, package_set, file)
739
+ end
740
+
741
+ # Register an autobuild package on this workspace
742
+ #
743
+ # @param [Autobuild::Package] package
744
+ # @param [PackageSet] package_set the package set into which this
745
+ # package is defined
746
+ # @param [String,nil] file the path to the file that defines this
747
+ # package (used for error reporting)
748
+ # @param [Proc,nil] block a setup block that should be called to
749
+ # configure the package
750
+ # @return [PackageDefinition]
715
751
  def register_package(package, block = nil, package_set = manifest.main_package_set, file = nil)
716
752
  pkg = manifest.register_package(package, block, package_set, file)
717
753
  pkg.autobuild.ws = self
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.rc37
4
+ version: 2.0.0.rc38
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-08-02 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,6 +198,11 @@ files:
198
198
  - bin/autoproj_install.in
199
199
  - lib/autoproj.rb
200
200
  - lib/autoproj/autobuild.rb
201
+ - lib/autoproj/autobuild_extensions/archive_importer.rb
202
+ - lib/autoproj/autobuild_extensions/dsl.rb
203
+ - lib/autoproj/autobuild_extensions/git.rb
204
+ - lib/autoproj/autobuild_extensions/package.rb
205
+ - lib/autoproj/autobuild_extensions/svn.rb
201
206
  - lib/autoproj/base.rb
202
207
  - lib/autoproj/build_option.rb
203
208
  - lib/autoproj/cli.rb
@@ -213,8 +218,10 @@ files:
213
218
  - lib/autoproj/cli/locate.rb
214
219
  - lib/autoproj/cli/log.rb
215
220
  - lib/autoproj/cli/main.rb
221
+ - lib/autoproj/cli/main_plugin.rb
216
222
  - lib/autoproj/cli/main_test.rb
217
223
  - lib/autoproj/cli/osdeps.rb
224
+ - lib/autoproj/cli/patcher.rb
218
225
  - lib/autoproj/cli/query.rb
219
226
  - lib/autoproj/cli/reconfigure.rb
220
227
  - lib/autoproj/cli/reset.rb
@@ -234,6 +241,7 @@ files:
234
241
  - lib/autoproj/git_server_configuration.rb
235
242
  - lib/autoproj/gitorious.rb
236
243
  - lib/autoproj/installation_manifest.rb
244
+ - lib/autoproj/local_package_set.rb
237
245
  - lib/autoproj/manifest.rb
238
246
  - lib/autoproj/metapackage.rb
239
247
  - lib/autoproj/ops/build.rb