autoproj 1.13.7 → 2.0.0.b1

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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gemtest +0 -0
  3. data/Manifest.txt +27 -21
  4. data/Rakefile +4 -6
  5. data/bin/alocate +5 -1
  6. data/bin/amake +3 -53
  7. data/bin/aup +3 -50
  8. data/bin/autoproj +3 -264
  9. data/bin/autoproj_bootstrap +294 -349
  10. data/bin/autoproj_bootstrap.in +27 -3
  11. data/lib/autoproj.rb +23 -1
  12. data/lib/autoproj/autobuild.rb +51 -89
  13. data/lib/autoproj/base.rb +0 -9
  14. data/lib/autoproj/build_option.rb +1 -3
  15. data/lib/autoproj/cli.rb +1 -0
  16. data/lib/autoproj/cli/base.rb +155 -0
  17. data/lib/autoproj/cli/bootstrap.rb +119 -0
  18. data/lib/autoproj/cli/build.rb +72 -0
  19. data/lib/autoproj/cli/cache.rb +31 -0
  20. data/lib/autoproj/cli/clean.rb +37 -0
  21. data/lib/autoproj/cli/commit.rb +41 -0
  22. data/lib/autoproj/cli/doc.rb +22 -0
  23. data/lib/autoproj/cli/envsh.rb +22 -0
  24. data/lib/autoproj/cli/inspection_tool.rb +73 -0
  25. data/lib/autoproj/cli/locate.rb +96 -0
  26. data/lib/autoproj/cli/log.rb +26 -0
  27. data/lib/autoproj/cli/main.rb +249 -0
  28. data/lib/autoproj/cli/main_test.rb +57 -0
  29. data/lib/autoproj/cli/osdeps.rb +30 -0
  30. data/lib/autoproj/cli/query.rb +43 -0
  31. data/lib/autoproj/cli/reconfigure.rb +19 -0
  32. data/lib/autoproj/cli/reset.rb +7 -32
  33. data/lib/autoproj/cli/show.rb +219 -0
  34. data/lib/autoproj/cli/snapshot.rb +1 -1
  35. data/lib/autoproj/cli/status.rb +149 -0
  36. data/lib/autoproj/cli/switch_config.rb +28 -0
  37. data/lib/autoproj/cli/tag.rb +9 -35
  38. data/lib/autoproj/cli/test.rb +34 -55
  39. data/lib/autoproj/cli/update.rb +158 -0
  40. data/lib/autoproj/cli/versions.rb +32 -69
  41. data/lib/autoproj/configuration.rb +95 -34
  42. data/lib/autoproj/default.osdeps +25 -35
  43. data/lib/autoproj/environment.rb +85 -63
  44. data/lib/autoproj/exceptions.rb +50 -0
  45. data/lib/autoproj/gitorious.rb +11 -9
  46. data/lib/autoproj/manifest.rb +199 -231
  47. data/lib/autoproj/metapackage.rb +0 -8
  48. data/lib/autoproj/ops/build.rb +1 -17
  49. data/lib/autoproj/ops/configuration.rb +92 -90
  50. data/lib/autoproj/ops/import.rb +222 -0
  51. data/lib/autoproj/ops/loader.rb +18 -8
  52. data/lib/autoproj/ops/main_config_switcher.rb +45 -73
  53. data/lib/autoproj/ops/snapshot.rb +5 -10
  54. data/lib/autoproj/ops/tools.rb +10 -44
  55. data/lib/autoproj/options.rb +35 -6
  56. data/lib/autoproj/osdeps.rb +97 -68
  57. data/lib/autoproj/package_selection.rb +39 -20
  58. data/lib/autoproj/package_set.rb +26 -24
  59. data/lib/autoproj/reporter.rb +91 -0
  60. data/lib/autoproj/system.rb +50 -149
  61. data/lib/autoproj/variable_expansion.rb +32 -6
  62. data/lib/autoproj/vcs_definition.rb +57 -17
  63. data/lib/autoproj/version.rb +1 -1
  64. data/lib/autoproj/workspace.rb +550 -0
  65. data/test/ops/test_snapshot.rb +26 -0
  66. data/test/test_package.rb +30 -0
  67. data/test/test_vcs_definition.rb +46 -0
  68. metadata +55 -50
  69. data/bin/autolocate +0 -3
  70. data/bin/autoproj-bootstrap +0 -68
  71. data/bin/autoproj-cache +0 -18
  72. data/bin/autoproj-clean +0 -13
  73. data/bin/autoproj-commit +0 -10
  74. data/bin/autoproj-create-set +0 -118
  75. data/bin/autoproj-doc +0 -28
  76. data/bin/autoproj-envsh +0 -14
  77. data/bin/autoproj-list +0 -69
  78. data/bin/autoproj-locate +0 -85
  79. data/bin/autoproj-log +0 -5
  80. data/bin/autoproj-query +0 -82
  81. data/bin/autoproj-reset +0 -13
  82. data/bin/autoproj-show +0 -192
  83. data/bin/autoproj-snapshot +0 -27
  84. data/bin/autoproj-switch-config +0 -24
  85. data/bin/autoproj-tag +0 -13
  86. data/bin/autoproj-test +0 -31
  87. data/bin/autoproj-versions +0 -20
  88. data/bin/autoproj_stress_test +0 -40
  89. data/lib/autoproj/cmdline.rb +0 -1649
@@ -1,3 +1,4 @@
1
+ require 'autobuild'
1
2
  module Autoproj
2
3
  module CLI
3
4
  class InvalidArguments < Autobuild::Exception
@@ -0,0 +1,155 @@
1
+ require 'autoproj'
2
+ require 'autoproj/autobuild'
3
+
4
+ module Autoproj
5
+ module CLI
6
+ class Base
7
+ include Ops::Tools
8
+
9
+ attr_reader :ws
10
+
11
+ def initialize(ws = nil)
12
+ @ws = (ws || Workspace.from_environment)
13
+ end
14
+
15
+ # Normalizes the arguments given by the user on the command line
16
+ #
17
+ # This converts relative paths to full paths, and removes mentions
18
+ # of the configuration directory (as it is handled separately in
19
+ # autoproj)
20
+ #
21
+ # @return [(Array<String>,Boolean)] the normalized arguments that
22
+ # could e.g. be passed to {#resolve_selection}, as well as whether
23
+ # the config directory was selected or not
24
+ def normalize_command_line_package_selection(selection)
25
+ selection = selection.map do |name|
26
+ if File.directory?(name)
27
+ File.expand_path(name) + "/"
28
+ else
29
+ name
30
+ end
31
+ end
32
+
33
+ config_selected = false
34
+ selection.delete_if do |name|
35
+ if name =~ /^#{Regexp.quote(ws.config_dir)}(?:#{File::SEPARATOR}|$)/ ||
36
+ name =~ /^#{Regexp.quote(ws.remotes_dir)}(?:#{File::SEPARATOR}|$)/
37
+ config_selected = true
38
+ elsif (ws.config_dir + File::SEPARATOR) =~ /^#{Regexp.quote(name)}/
39
+ config_selected = true
40
+ false
41
+ end
42
+ end
43
+
44
+ return selection, config_selected
45
+ end
46
+
47
+ def resolve_user_selection(selected_packages, options = Hash.new)
48
+ if selected_packages.empty?
49
+ return ws.manifest.default_packages
50
+ end
51
+ selected_packages = selected_packages.to_set
52
+
53
+ selected_packages, nonresolved = ws.manifest.
54
+ expand_package_selection(selected_packages, options)
55
+
56
+ # Try to auto-add stuff if nonresolved
57
+ nonresolved.delete_if do |sel|
58
+ next if !File.directory?(sel)
59
+ while sel != '/'
60
+ handler, srcdir = Autoproj.package_handler_for(sel)
61
+ if handler
62
+ Autoproj.message " auto-adding #{srcdir} using the #{handler.gsub(/_package/, '')} package handler"
63
+ srcdir = File.expand_path(srcdir)
64
+ relative_to_root = Pathname.new(srcdir).relative_path_from(Pathname.new(ws.root_dir))
65
+ pkg = ws.in_package_set(ws.manifest.main_package_set, ws.manifest.file) do
66
+ send(handler, relative_to_root.to_s)
67
+ end
68
+ ws.setup_package_directories(pkg)
69
+ selected_packages.select(sel, pkg.name, weak: true)
70
+ break(true)
71
+ end
72
+
73
+ sel = File.dirname(sel)
74
+ end
75
+ end
76
+
77
+ if Autoproj.verbose
78
+ Autoproj.message "will install #{selected_packages.packages.to_a.sort.join(", ")}"
79
+ end
80
+ return selected_packages, nonresolved
81
+ end
82
+
83
+ def resolve_selection(manifest, user_selection, options = Hash.new)
84
+ options = Kernel.validate_options options,
85
+ checkout_only: true,
86
+ only_local: false,
87
+ recursive: true,
88
+ ignore_non_imported_packages: false
89
+
90
+ resolved_selection, _ = resolve_user_selection(user_selection, filter: false)
91
+ if options[:ignore_non_imported_packages]
92
+ manifest.each_autobuild_package do |pkg|
93
+ if !File.directory?(pkg.srcdir)
94
+ manifest.ignore_package(pkg.name)
95
+ end
96
+ end
97
+ end
98
+ resolved_selection.filter_excluded_and_ignored_packages(manifest)
99
+
100
+ ops = Ops::Import.new(ws)
101
+ source_packages, osdep_packages = ops.import_packages(
102
+ resolved_selection,
103
+ checkout_only: options[:checkout_only],
104
+ only_local: options[:only_local],
105
+ recursive: options[:recursive],
106
+ warn_about_ignored_packages: false)
107
+
108
+ return source_packages, osdep_packages, resolved_selection
109
+ end
110
+
111
+ def validate_user_selection(user_selection, resolved_selection)
112
+ not_matched = user_selection.find_all do |pkg_name|
113
+ !resolved_selection.has_match_for?(pkg_name)
114
+ end
115
+ if !not_matched.empty?
116
+ raise ConfigError.new, "autoproj: wrong package selection on command line, cannot find a match for #{not_matched.to_a.sort.join(", ")}"
117
+ end
118
+ end
119
+
120
+ def validate_options(args, options)
121
+ self.class.validate_options(args, options)
122
+ end
123
+
124
+ def self.validate_options(args, options)
125
+ options, remaining = filter_options options,
126
+ silent: false,
127
+ verbose: false,
128
+ debug: false,
129
+ color: true,
130
+ progress: true
131
+
132
+ Autoproj.silent = options[:silent]
133
+ if options[:verbose]
134
+ Autoproj.verbose = true
135
+ Autobuild.verbose = true
136
+ Rake.application.options.trace = false
137
+ Autobuild.debug = false
138
+ end
139
+
140
+ if options[:debug]
141
+ Autoproj.verbose = true
142
+ Autobuild.verbose = true
143
+ Rake.application.options.trace = true
144
+ Autobuild.debug = true
145
+ end
146
+
147
+ Autobuild.color = options[:color]
148
+
149
+ Autobuild.progress_display_enabled = options[:progress]
150
+ return args, remaining
151
+ end
152
+ end
153
+ end
154
+ end
155
+
@@ -0,0 +1,119 @@
1
+ require 'autoproj'
2
+ require 'autoproj/cli/base'
3
+ require 'autoproj/ops/tools'
4
+ require 'autoproj/ops/main_config_switcher'
5
+
6
+ module Autoproj
7
+ module CLI
8
+ class Bootstrap
9
+ include Ops::Tools
10
+
11
+ attr_reader :root_dir
12
+
13
+ def initialize(root_dir = Dir.pwd)
14
+ if File.exists?(File.join(root_dir, 'autoproj', "manifest"))
15
+ raise ConfigError, "this installation is already bootstrapped. Remove the autoproj directory if it is not the case"
16
+ end
17
+ @root_dir = root_dir
18
+ end
19
+
20
+ def validate_options(args, options)
21
+ args, options = Base.validate_options(args, options)
22
+ if path = options[:reuse]
23
+ if path == 'reuse'
24
+ path = ENV['AUTOPROJ_CURRENT_ROOT']
25
+ end
26
+
27
+ path = File.expand_path(path)
28
+ if !File.directory?(path) || !File.directory?(File.join(path, 'autoproj'))
29
+ raise ArgumentError, "#{path} does not look like an autoproj installation"
30
+ end
31
+ options[:reuse] = [path]
32
+ end
33
+ return args, options
34
+ end
35
+
36
+ def restart_if_needed
37
+ # Check if the .autoprojrc changed the PATH and therefore which autoproj script
38
+ # should be executed ... and restart if it did
39
+ autoproj_path = Autobuild.find_in_path('autoproj')
40
+ if $0 != autoproj_path
41
+ puts "your .autoprojrc file changed PATH in a way that requires the restart of autoproj"
42
+
43
+ if ENV['AUTOPROJ_RESTARTING']
44
+ puts "infinite loop detected, will not restart this time"
45
+ else
46
+ require 'rbconfig'
47
+ ws.config.save
48
+ exec(ws.config.ruby_executable, autoproj_path, *ARGV)
49
+ end
50
+ end
51
+ end
52
+
53
+ def install_autoproj_gem_in_new_root(ws)
54
+ # Install the autoproj/autobuild gem explicitely in the new
55
+ # root.
56
+ original_env =
57
+ Hash['GEM_HOME' => Gem.paths.home,
58
+ 'GEM_PATH' => Gem.paths.path]
59
+
60
+ begin
61
+ Gem.paths =
62
+ Hash['GEM_HOME' => File.join(root_dir, '.gems'),
63
+ 'GEM_PATH' => []]
64
+ PackageManagers::GemManager.with_prerelease(ws.config.use_prerelease?) do
65
+ ws.osdeps.install(%w{autobuild autoproj})
66
+ end
67
+ ensure
68
+ Gem.paths = original_env
69
+ end
70
+ end
71
+
72
+ def run(buildconf_info, options)
73
+ ws = Workspace.new(root_dir)
74
+ ws.setup
75
+ install_autoproj_gem_in_new_root(ws)
76
+ restart_if_needed
77
+
78
+ switcher = Ops::MainConfigSwitcher.new(ws)
79
+ begin
80
+ switcher.bootstrap(buildconf_info, options)
81
+
82
+ STDERR.puts <<-EOTEXT
83
+
84
+
85
+ #{Autoproj.color('autoproj bootstrap successfully finished', :green, :bold)}
86
+
87
+ #{Autoproj.color('To further use autoproj and the installed software', :bold)}, you
88
+ must add the following line at the bottom of your .bashrc:
89
+ source #{root_dir}/#{Autoproj::ENV_FILENAME}
90
+
91
+ WARNING: autoproj will not work until your restart all
92
+ your consoles, or run the following in them:
93
+ $ source #{root_dir}/#{Autoproj::ENV_FILENAME}
94
+
95
+ #{Autoproj.color('To import and build the packages', :bold)}, you can now run
96
+ aup
97
+ amake
98
+
99
+ The resulting software is installed in
100
+ #{root_dir}/install
101
+
102
+ EOTEXT
103
+
104
+ rescue RuntimeError
105
+ STDERR.puts <<-EOTEXT
106
+ #{Autoproj.color('autoproj bootstrap failed', :red, :bold)}
107
+ To retry, first source the #{Autoproj::ENV_FILENAME} script with
108
+ source #{root_dir}/#{Autoproj::ENV_FILENAME}
109
+ and then re-run autoproj bootstrap
110
+ autoproj bootstrap '#{ARGV.join("'")}'
111
+ EOTEXT
112
+
113
+ raise
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+
@@ -0,0 +1,72 @@
1
+ require 'autoproj/cli/update'
2
+ require 'autoproj/ops/build'
3
+
4
+ module Autoproj
5
+ module CLI
6
+ class Build < Update
7
+ def validate_options(selected_packages, options)
8
+ selected_packages, options = super
9
+ if options[:amake] && selected_packages.empty? && !options[:all]
10
+ selected_packages = ['.']
11
+ end
12
+
13
+ if !options.has_key?(:deps)
14
+ options[:deps] =
15
+ !(options[:rebuild] || options[:force])
16
+ end
17
+ return selected_packages, options
18
+ end
19
+
20
+ def run(selected_packages, options)
21
+ build_options, options = filter_options options,
22
+ force: false,
23
+ rebuild: false
24
+
25
+ Autobuild.ignore_errors = options[:keep_going]
26
+
27
+ command_line_selection, source_packages, osdep_packages =
28
+ super(selected_packages, options.merge(checkout_only: true))
29
+
30
+ ops = Ops::Build.new(ws.manifest)
31
+ if build_options[:rebuild] || build_options[:force]
32
+ packages_to_rebuild =
33
+ if options[:deps] || command_line_selection.empty?
34
+ source_packages
35
+ else command_line_selection
36
+ end
37
+
38
+ if command_line_selection.empty?
39
+ # If we don't have an explicit package selection, we want to
40
+ # make sure that the user really wants this
41
+ mode_name = if build_options[:rebuild] then 'rebuild'
42
+ else 'force-build'
43
+ end
44
+ opt = BuildOption.new("", "boolean", {:doc => "this is going to trigger a #{mode_name} of all packages. Is that really what you want ?"}, nil)
45
+ if !opt.ask(false)
46
+ raise Interrupt
47
+ end
48
+ if build_options[:rebuild]
49
+ if options[:osdeps]
50
+ ws.osdeps.reinstall
51
+ end
52
+ ops.rebuild_all
53
+ else
54
+ ops.force_build_all
55
+ end
56
+ elsif build_options[:rebuild]
57
+ ops.rebuild_packages(packages_to_rebuild, source_packages)
58
+ else
59
+ ops.force_build_packages(packages_to_rebuild, source_packages)
60
+ end
61
+ return
62
+ end
63
+
64
+ Autobuild.do_build = true
65
+ ops.build_packages(source_packages)
66
+ Autobuild.apply(source_packages, "autoproj-build", ['install'])
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+
@@ -0,0 +1,31 @@
1
+ require 'autoproj/cli/inspection_tool'
2
+ require 'autoproj/ops/cache'
3
+
4
+ module Autoproj
5
+ module CLI
6
+ class Cache < InspectionTool
7
+ def validate_options(argv, options = Hash.new)
8
+ argv, options = super
9
+
10
+ if argv.empty?
11
+ raise ArgumentError, "expected one cache directory as argument"
12
+ elsif argv.size > 1
13
+ raise ArgumentError, "expected one cache directory as argument"
14
+ end
15
+
16
+ return File.expand_path(argv.first, ws.root_dir), options
17
+ end
18
+
19
+ def run(cache_dir, options = Hash.new)
20
+ options = Kernel.validate_options options,
21
+ keep_going: false
22
+
23
+ initialize_and_load
24
+
25
+ cache_op = Autoproj::Ops::Cache.new(cache_dir, ws.manifest)
26
+ cache_op.create_or_update(options[:keep_going])
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,37 @@
1
+ require 'autoproj/cli/inspection_tool'
2
+
3
+ module Autoproj
4
+ module CLI
5
+ class Clean < InspectionTool
6
+ def validate_options(packages, options)
7
+ packages, options = super
8
+ if packages.empty? && !options[:all]
9
+ opt = BuildOption.new("", "boolean", {:doc => "this is going to clean all packages. Is that really what you want ?"}, nil)
10
+ if !opt.ask(false)
11
+ raise Interrupt
12
+ end
13
+ end
14
+ return packages, options
15
+ end
16
+
17
+ def run(selection, options = Hash.new)
18
+ initialize_and_load
19
+ packages, _ = normalize_command_line_package_selection(selection)
20
+ source_packages, * = resolve_selection(
21
+ ws.manifest,
22
+ selection,
23
+ recursive: false,
24
+ ignore_non_imported_packages: true)
25
+ if packages.empty?
26
+ raise ArgumentError, "no packages or OS packages match #{selection.join(" ")}"
27
+ end
28
+
29
+ source_packages.each do |pkg_name|
30
+ ws.manifest.find_autobuild_package(pkg_name).
31
+ prepare_for_rebuild
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,41 @@
1
+ require 'autoproj'
2
+ require 'autoproj/cli/versions'
3
+ require 'autoproj/ops/snapshot'
4
+ require 'autoproj/cli/base'
5
+
6
+ module Autoproj
7
+ module CLI
8
+ class Commit < InspectionTool
9
+ def run(*user_selection, options = Hash.new)
10
+ pkg = manifest.main_package_set.create_autobuild_package
11
+ importer = pkg.importer
12
+ if !importer || !importer.kind_of?(Autobuild::Git)
13
+ raise ConfigError, "cannot use autoproj tag if the main configuration is not managed by git"
14
+ end
15
+
16
+ versions_file = File.join(
17
+ ws.config_dir,
18
+ Workspace::OVERRIDES_DIR,
19
+ Versions::DEFAULT_VERSIONS_FILE_BASENAME)
20
+
21
+ initialize_and_load
22
+
23
+ versions = CLI::Versions.new(ws)
24
+ Autoproj.message "creating versions file, this may take a while"
25
+ versions.run(user_selection,
26
+ save: File.join(ws.config_dir, versions_file),
27
+ package_sets: options[:package_sets],
28
+ output_file: io.path,
29
+ replace: true,
30
+ keep_going: options[:keep_going])
31
+
32
+ importer.run_git(pkg, 'add', versions_file)
33
+ message = options[:message] ||
34
+ "autoproj created tag #{tag_name}"
35
+
36
+ importer.run_git(pkg, 'commit', '-m', message)
37
+ end
38
+ end
39
+ end
40
+ end
41
+