autoproj 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -10,10 +10,8 @@ bin/autoproj
10
10
  bin/autoproj-clean
11
11
  bin/autoproj-create-set
12
12
  bin/autoproj-envsh
13
- bin/autoproj-list
14
13
  bin/autoproj-locate
15
14
  bin/autoproj-query
16
- bin/autoproj-show
17
15
  bin/autoproj_bootstrap
18
16
  bin/autoproj_bootstrap.in
19
17
  bin/autoproj_stress_test
data/bin/autoproj CHANGED
@@ -18,33 +18,6 @@ def color(*args)
18
18
  Autoproj.color(*args)
19
19
  end
20
20
 
21
- def report
22
- Autobuild::Reporting.report do
23
- yield
24
- end
25
- Autobuild::Reporting.success
26
-
27
- rescue ConfigError => e
28
- STDERR.puts
29
- STDERR.puts color(e.message, :red, :bold)
30
- if Autoproj.in_autoproj_installation?(Dir.pwd)
31
- root_dir = /^#{Regexp.quote(Autoproj.root_dir)}(?!\/\.gems)/
32
- e.backtrace.find_all { |path| path =~ root_dir }.
33
- each do |path|
34
- STDERR.puts color(" in #{path}", :red, :bold)
35
- end
36
- end
37
- if Autobuild.debug then raise
38
- else exit 1
39
- end
40
- rescue Interrupt
41
- STDERR.puts
42
- STDERR.puts color("Interrupted by user", :red, :bold)
43
- if Autobuild.debug then raise
44
- else exit 1
45
- end
46
- end
47
-
48
21
  Autoproj::OSDependencies.autodetect_ruby
49
22
 
50
23
  # Check the first element of ARGV. If a tool called autoproj-VALUE exists, just
@@ -65,7 +38,7 @@ if File.file?("#{prefix}-#{ARGV.first}")
65
38
  end
66
39
 
67
40
  # Find the autoproj root dir
68
- report do
41
+ Autoproj::CmdLine.report do
69
42
  selected_packages =
70
43
  begin Autoproj::CmdLine.parse_arguments(ARGV.dup)
71
44
  rescue RuntimeError => e
@@ -150,12 +123,21 @@ EOTEXT
150
123
  # First do the resolution to get auto-add, finalize the package
151
124
  # configuration, and then re-resolve
152
125
  Autoproj.silent do
153
- Autoproj::CmdLine.resolve_user_selection(selected_packages)
126
+ begin
127
+ Autoproj::CmdLine.resolve_user_selection(selected_packages)
128
+ rescue Autoproj::Manifest::ExcludedSelection => e
129
+ raise e, "#{e.selection}, which is selected on the command line, cannot be built: #{e.message}"
130
+ end
154
131
  end
155
132
  # Now load the rest of the configuration
156
133
  Autoproj::CmdLine.finalize_package_setup
157
134
  # Finally, filter out exclusions
158
- resolved_selected_packages = Autoproj::CmdLine.resolve_user_selection(selected_packages)
135
+ resolved_selected_packages =
136
+ begin
137
+ Autoproj::CmdLine.resolve_user_selection(selected_packages)
138
+ rescue Autoproj::Manifest::ExcludedSelection => e
139
+ raise e, "#{e.sel}, which is selected on the command line, cannot be built: #{e.message}"
140
+ end
159
141
  Autoproj::CmdLine.validate_user_selection(selected_packages, resolved_selected_packages)
160
142
 
161
143
  if !selected_packages.empty?
@@ -258,6 +240,7 @@ EOTEXT
258
240
  # line.
259
241
  all_enabled_packages = Autoproj::CmdLine.import_packages(selected_packages)
260
242
  Autoproj::CmdLine.load_all_available_package_manifests
243
+ Autoproj::CmdLine.export_installation_manifest
261
244
 
262
245
  if Autoproj::CmdLine.update_os_dependencies? && !all_enabled_packages.empty?
263
246
  begin
data/bin/autoproj-envsh CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  require 'autoproj'
4
4
  require 'autoproj/cmdline'
5
- Autoproj.silent do
6
- Autoproj::CmdLine.initialize_root_directory
7
- Autoproj::CmdLine.initialize_and_load(ARGV)
5
+ Autoproj::CmdLine.report do
6
+ Autoproj.silent do
7
+ Autoproj::CmdLine.initialize_root_directory
8
+ Autoproj::CmdLine.initialize_and_load(ARGV)
9
+ end
10
+ Autoproj.export_env_sh
11
+ Autoproj::CmdLine.export_installation_manifest
12
+ Autoproj.message "autoproj: updated #{Autoproj.root_dir}/#{Autoproj::ENV_FILENAME}", :green
8
13
  end
9
- Autoproj.export_env_sh
10
- Autoproj.message "autoproj: updated #{Autoproj.root_dir}/#{Autoproj::ENV_FILENAME}", :green
11
14
 
@@ -5,6 +5,24 @@ if RUBY_VERSION < "1.8.7"
5
5
  exit 1
6
6
  end
7
7
 
8
+ if defined? Encoding # This is a 1.9-only thing
9
+ Encoding.default_internal = Encoding::UTF_8
10
+ Encoding.default_external = Encoding::UTF_8
11
+ end
12
+
13
+ require 'rbconfig'
14
+ module Autobuild
15
+ @windows = RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
16
+ def self.windows?
17
+ @windows
18
+ end
19
+
20
+ @macos = RbConfig::CONFIG["host_os"] = ~%r!([Dd]arwin)!
21
+ def self.macos?
22
+ @macos
23
+ end
24
+ end
25
+
8
26
  require 'set'
9
27
  curdir_entries = Dir.entries('.').to_set - [".", "..", "autoproj_bootstrap", ".gems", 'env.sh'].to_set
10
28
  if !curdir_entries.empty? && ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] != '1'
@@ -841,13 +859,13 @@ fi
841
859
  end
842
860
  else
843
861
  Autoproj.message " autodetecting the operating system"
844
- name, versions = os_from_lsb
845
- if name
846
- if name != "debian"
862
+ lsb_name, lsb_versions = os_from_lsb
863
+ if lsb_name
864
+ if lsb_name != "debian"
847
865
  if File.exists?("/etc/debian_version")
848
- @operating_system = [[name, "debian"], versions]
866
+ @operating_system = [[lsb_name, "debian"], lsb_versions]
849
867
  else
850
- @operating_system = [[name], versions]
868
+ @operating_system = [[lsb_name], lsb_versions]
851
869
  end
852
870
  end
853
871
  end
@@ -861,6 +879,9 @@ fi
861
879
  if versions.first =~ /sid/
862
880
  versions = ["unstable", "sid"]
863
881
  end
882
+ if lsb_versions
883
+ lsb_versions.each { |v| versions << v if !versions.include?(v) }
884
+ end
864
885
  [['debian'], versions]
865
886
  elsif File.exists?('/etc/fedora-release')
866
887
  release_string = File.read('/etc/fedora-release').strip
@@ -1808,9 +1829,7 @@ module Autoproj
1808
1829
  def self.export_env_sh(subdir = nil)
1809
1830
  # Make sure that we have the environment of all selected packages
1810
1831
  if Autoproj.manifest # we don't have a manifest if we are bootstrapping
1811
- Autoproj.manifest.all_selected_packages(false).each do |pkg_name|
1812
- Autobuild::Package[pkg_name].update_environment
1813
- end
1832
+ Autoproj::CmdLine.update_environment
1814
1833
  end
1815
1834
 
1816
1835
  filename = if subdir
@@ -5,6 +5,24 @@ if RUBY_VERSION < "1.8.7"
5
5
  exit 1
6
6
  end
7
7
 
8
+ if defined? Encoding # This is a 1.9-only thing
9
+ Encoding.default_internal = Encoding::UTF_8
10
+ Encoding.default_external = Encoding::UTF_8
11
+ end
12
+
13
+ require 'rbconfig'
14
+ module Autobuild
15
+ @windows = RbConfig::CONFIG["host_os"] =~%r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
16
+ def self.windows?
17
+ @windows
18
+ end
19
+
20
+ @macos = RbConfig::CONFIG["host_os"] = ~%r!([Dd]arwin)!
21
+ def self.macos?
22
+ @macos
23
+ end
24
+ end
25
+
8
26
  require 'set'
9
27
  curdir_entries = Dir.entries('.').to_set - [".", "..", "autoproj_bootstrap", ".gems", 'env.sh'].to_set
10
28
  if !curdir_entries.empty? && ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] != '1'
@@ -299,9 +299,8 @@ module Autoproj
299
299
  dir ||= find_topmost_directory_containing(full_path, 'CMakeLists.txt')
300
300
 
301
301
  return "cmake_package", dir
302
- elsif !Dir.glob('*.rb').empty?
303
- dir = find_topmost_directory_containing(full_path, "Rakefile") ||
304
- find_topmost_directory_containing(full_path, "lib/*.rb")
302
+ elsif dir = find_topmost_directory_containing(full_path, "Rakefile") ||
303
+ find_topmost_directory_containing(full_path, "lib/*.rb")
305
304
 
306
305
  return "ruby_package", dir
307
306
  end
@@ -42,6 +42,46 @@ module Autoproj
42
42
  end
43
43
 
44
44
  module CmdLine
45
+ def self.handle_ruby_version
46
+ ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
47
+ ruby_bindir = RbConfig::CONFIG['bindir']
48
+
49
+ ruby_executable = File.join(ruby_bindir, ruby)
50
+ if Autoproj.has_config_key?('ruby_executable')
51
+ expected = Autoproj.user_config('ruby_executable')
52
+ if expected != ruby_executable
53
+ raise ConfigError.new, "this autoproj installation was bootstrapped using #{expected}, but you are currently running under #{ruby_executable}. This is usually caused by calling a wrong gem program (for instance, gem1.8 instead of gem1.9.1)"
54
+ end
55
+ end
56
+ Autoproj.change_option('ruby_executable', ruby_executable, true)
57
+
58
+ install_suffix = ""
59
+ if match = /ruby(.*)$/.match(ruby)
60
+ install_suffix = match[1]
61
+ end
62
+
63
+ bindir = File.join(Autoproj.build_dir, 'bin')
64
+ FileUtils.mkdir_p bindir
65
+ Autoproj.env_add 'PATH', bindir
66
+
67
+ File.open(File.join(bindir, 'ruby'), 'w') do |io|
68
+ io.puts "#! /bin/sh"
69
+ io.puts "exec #{File.join(ruby_bindir, ruby)} \"$@\""
70
+ end
71
+ FileUtils.chmod 0755, File.join(bindir, 'ruby')
72
+
73
+ subprograms = ['gem', 'irb'].each do |name|
74
+ # Look for the corresponding gem program
75
+ prg_name = "#{name}#{install_suffix}"
76
+ if File.file?(prg_path = File.join(ruby_bindir, prg_name))
77
+ File.open(File.join(bindir, name), 'w') do |io|
78
+ io.puts "#! /bin/sh"
79
+ io.puts "exec #{prg_path} \"$@\""
80
+ end
81
+ end
82
+ end
83
+ end
84
+
45
85
  def self.initialize
46
86
  if defined? Encoding # This is a 1.9-only thing
47
87
  Encoding.default_internal = Encoding::UTF_8
@@ -59,14 +99,7 @@ module Autoproj
59
99
  Autoproj.loaded_autobuild_files.clear
60
100
  Autoproj.load_config
61
101
 
62
- ruby_executable = Autoproj.find_in_path(RbConfig::CONFIG['RUBY_INSTALL_NAME'])
63
- if Autoproj.has_config_key?('ruby_executable')
64
- expected = Autoproj.user_config('ruby_executable')
65
- if expected != ruby_executable
66
- raise ConfigError.new, "this autoproj installation was bootstrapped using #{expected}, but you are currently running under #{ruby_executable}. This is usually caused by calling a wrong gem program (for instance, gem1.8 instead of gem1.9.1)"
67
- end
68
- end
69
- Autoproj.change_option('ruby_executable', ruby_executable, true)
102
+ handle_ruby_version
70
103
 
71
104
  if Autoproj.has_config_key?('autobuild')
72
105
  params = Autoproj.user_config('autobuild')
@@ -102,19 +135,6 @@ module Autoproj
102
135
  Autobuild.srcdir = Autoproj.root_dir
103
136
  Autobuild.logdir = File.join(Autobuild.prefix, 'log')
104
137
 
105
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
106
- if ruby != 'ruby'
107
- bindir = File.join(Autoproj.build_dir, 'bin')
108
- FileUtils.mkdir_p bindir
109
- File.open(File.join(bindir, 'ruby'), 'w') do |io|
110
- io.puts "#! /bin/sh"
111
- io.puts "exec #{ruby} \"$@\""
112
- end
113
- FileUtils.chmod 0755, File.join(bindir, 'ruby')
114
-
115
- Autoproj.env_add 'PATH', bindir
116
- end
117
-
118
138
  Autoproj.manifest = Manifest.new
119
139
 
120
140
  local_source = LocalPackageSet.new(Autoproj.manifest)
@@ -332,16 +352,20 @@ module Autoproj
332
352
 
333
353
 
334
354
  def self.setup_all_package_directories
335
- manifest = Autoproj.manifest
355
+ # Override the package directories from our reused installations
356
+ imported_packages = Set.new
357
+ Autoproj.manifest.reused_installations.each do |manifest|
358
+ manifest.each do |pkg|
359
+ imported_packages << pkg.name
360
+ Autobuild::Package[pkg.name].srcdir = pkg.srcdir
361
+ Autobuild::Package[pkg.name].prefix = pkg.prefix
362
+ end
363
+ end
336
364
 
337
- # Now starts a different stage of the whole build. Until now, we were
338
- # working on the whole package set. Starting from now, we need to build the
339
- # package sets based on the layout file
340
- #
341
- # First, we allow to user to specify packages based on disk paths, so
342
- # resolve those
365
+ manifest = Autoproj.manifest
343
366
  manifest.packages.each_value do |pkg_def|
344
367
  pkg = pkg_def.autobuild
368
+ next if imported_packages.include?(pkg_def.name)
345
369
  setup_package_directories(pkg)
346
370
  end
347
371
  end
@@ -371,10 +395,7 @@ module Autoproj
371
395
  Autobuild::Package[pkg_name].disable
372
396
  end
373
397
 
374
- # Make sure that we have the environment of all selected packages
375
- manifest.all_selected_packages.each do |pkg_name|
376
- Autobuild::Package[pkg_name].update_environment
377
- end
398
+ update_environment
378
399
 
379
400
  # We now have processed the process setup blocks. All configuration
380
401
  # should be done and we can save the configuration data.
@@ -392,6 +413,8 @@ module Autoproj
392
413
  if File.directory?(pkg.autobuild.srcdir)
393
414
  begin
394
415
  manifest.load_package_manifest(pkg.autobuild.name)
416
+ rescue Interrupt
417
+ raise
395
418
  rescue Exception => e
396
419
  Autoproj.warn "cannot load package manifest for #{pkg.autobuild.name}: #{e.message}"
397
420
  end
@@ -399,6 +422,19 @@ module Autoproj
399
422
  end
400
423
  end
401
424
 
425
+ def self.update_environment
426
+ Autoproj.manifest.reused_installations.each do |manifest|
427
+ manifest.each do |pkg|
428
+ Autobuild::Package[pkg.name].update_environment
429
+ end
430
+ end
431
+
432
+ # Make sure that we have the environment of all selected packages
433
+ manifest.all_selected_packages(false).each do |pkg_name|
434
+ Autobuild::Package[pkg_name].update_environment
435
+ end
436
+ end
437
+
402
438
  def self.display_configuration(manifest, package_list = nil)
403
439
  # Load the manifest for packages that are already present on the
404
440
  # file system
@@ -670,6 +706,7 @@ module Autoproj
670
706
  Autoproj.each_post_import_block(pkg) do |block|
671
707
  block.call(pkg)
672
708
  end
709
+ pkg.update_environment
673
710
 
674
711
  # Verify that its dependencies are there, and add
675
712
  # them to the selected_packages set so that they get
@@ -1527,6 +1564,7 @@ where 'mode' is one of:
1527
1564
  do_switch_config(false, type, url, *options)
1528
1565
  end
1529
1566
 
1567
+ handle_ruby_version
1530
1568
  Autoproj.save_config
1531
1569
 
1532
1570
  Autobuild.env_set 'RUBYOPT', '-rubygems'
@@ -1783,6 +1821,7 @@ where 'mode' is one of:
1783
1821
  Autoproj::CmdLine.finalize_package_setup
1784
1822
 
1785
1823
  load_all_available_package_manifests
1824
+ update_environment
1786
1825
  remaining_arguments
1787
1826
  end
1788
1827
 
@@ -1841,6 +1880,42 @@ where 'mode' is one of:
1841
1880
  puts " #{Pathname.new(dir).relative_path_from(root)}"
1842
1881
  end
1843
1882
  end
1883
+
1884
+ def self.export_installation_manifest
1885
+ File.open(File.join(Autoproj.root_dir, ".autoproj-installation-manifest"), 'w') do |io|
1886
+ Autoproj.manifest.all_selected_packages.each do |pkg_name|
1887
+ pkg = Autobuild::Package[pkg_name]
1888
+ io.puts "#{pkg_name},#{pkg.srcdir},#{pkg.prefix}"
1889
+ end
1890
+ end
1891
+ end
1892
+
1893
+ def self.report
1894
+ Autobuild::Reporting.report do
1895
+ yield
1896
+ end
1897
+ Autobuild::Reporting.success
1898
+
1899
+ rescue ConfigError => e
1900
+ STDERR.puts
1901
+ STDERR.puts color(e.message, :red, :bold)
1902
+ if Autoproj.in_autoproj_installation?(Dir.pwd)
1903
+ root_dir = /^#{Regexp.quote(Autoproj.root_dir)}(?!\/\.gems)/
1904
+ e.backtrace.find_all { |path| path =~ root_dir }.
1905
+ each do |path|
1906
+ STDERR.puts color(" in #{path}", :red, :bold)
1907
+ end
1908
+ end
1909
+ if Autobuild.debug then raise
1910
+ else exit 1
1911
+ end
1912
+ rescue Interrupt
1913
+ STDERR.puts
1914
+ STDERR.puts color("Interrupted by user", :red, :bold)
1915
+ if Autobuild.debug then raise
1916
+ else exit 1
1917
+ end
1918
+ end
1844
1919
  end
1845
1920
  end
1846
1921
 
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'csv'
2
3
  require 'utilrb/kernel/options'
3
4
  require 'set'
4
5
  require 'rexml/document'
@@ -966,7 +967,6 @@ module Autoproj
966
967
  # The Manifest class represents the information included in the main
967
968
  # manifest file, and allows to manipulate it
968
969
  class Manifest
969
-
970
970
  # Data structure used to use autobuild importers without a package, to
971
971
  # import configuration data.
972
972
  #
@@ -1023,7 +1023,7 @@ module Autoproj
1023
1023
 
1024
1024
  @file = file
1025
1025
  @data = data
1026
- data['ignore_packages'] ||= Set.new
1026
+ @ignored_packages |= (data['ignored_packages'] || Set.new)
1027
1027
  data['exclude_packages'] ||= Set.new
1028
1028
 
1029
1029
  if data['constants']
@@ -1044,6 +1044,12 @@ module Autoproj
1044
1044
  # The path to the manifest file that has been loaded
1045
1045
  attr_reader :file
1046
1046
 
1047
+ # The set of package names for packages that should be ignored
1048
+ attr_reader :ignored_packages
1049
+
1050
+ # A set of other autoproj installations that are being reused
1051
+ attr_reader :reused_installations
1052
+
1047
1053
  # True if osdeps should be handled in update and build, or left to the
1048
1054
  # osdeps command
1049
1055
  def auto_osdeps?
@@ -1075,6 +1081,8 @@ module Autoproj
1075
1081
  @osdeps_overrides = Hash.new
1076
1082
  @metapackages = Hash.new
1077
1083
  @ignored_os_dependencies = Set.new
1084
+ @reused_installations = Array.new
1085
+ @ignored_packages = Set.new
1078
1086
 
1079
1087
  @constant_definitions = Hash.new
1080
1088
  if Autoproj.has_config_key?('manifest_source')
@@ -1086,7 +1094,7 @@ module Autoproj
1086
1094
  # Call this method to ignore a specific package. It must not be used in
1087
1095
  # init.rb, as the manifest is not yet loaded then
1088
1096
  def ignore_package(package_name)
1089
- data['ignore_packages'] << package_name
1097
+ @ignored_packages << package_name
1090
1098
  end
1091
1099
 
1092
1100
  # True if the given package should not be built, with the packages that
@@ -1094,7 +1102,7 @@ module Autoproj
1094
1102
  #
1095
1103
  # This is useful if the packages are already installed on this system.
1096
1104
  def ignored?(package_name)
1097
- data['ignore_packages'].any? do |l|
1105
+ ignored_packages.any? do |l|
1098
1106
  if package_name == l
1099
1107
  true
1100
1108
  elsif (pkg_set = metapackages[l]) && pkg_set.include?(package_name)
@@ -1107,7 +1115,7 @@ module Autoproj
1107
1115
 
1108
1116
  # Enumerates the package names of all ignored packages
1109
1117
  def each_ignored_package
1110
- data['ignore_packages'].each do |l|
1118
+ ignored_packages.each do |l|
1111
1119
  if pkg_set = metapackages[l]
1112
1120
  pkg_set.each_package do |pkg|
1113
1121
  yield(pkg.name)
@@ -1126,7 +1134,7 @@ module Autoproj
1126
1134
 
1127
1135
  # Removes all registered ignored packages
1128
1136
  def clear_ignored
1129
- data['ignore_packages'].clear
1137
+ ignored_packages.clear
1130
1138
  end
1131
1139
 
1132
1140
  # The set of package names that are listed in the excluded_packages
@@ -1767,7 +1775,7 @@ module Autoproj
1767
1775
  else
1768
1776
  pkg_set = find_metapackage(name)
1769
1777
  if !pkg_set
1770
- raise ConfigError.new, "#{name} is neither a package nor a package set name. Packages in autoproj must be declared in an autobuild file."
1778
+ raise UnknownPackage.new(name), "#{name} is neither a package nor a package set name. Packages in autoproj must be declared in an autobuild file."
1771
1779
  end
1772
1780
  pkg_set.each_package.
1773
1781
  map(&:name).
@@ -1813,22 +1821,27 @@ module Autoproj
1813
1821
  metapackages.each_value(&block)
1814
1822
  end
1815
1823
 
1816
- # Returns the packages contained in the provided layout definition
1824
+ # Returns the packages selected in this manifest's layout
1817
1825
  #
1818
- # If recursive is false, yields only the packages at this level.
1819
- # Otherwise, return all packages.
1826
+ # @return [PackageSelection]
1820
1827
  def layout_packages(validate)
1821
1828
  result = PackageSelection.new
1822
1829
  Autoproj.in_file(self.file) do
1823
1830
  normalized_layout.each_key do |pkg_or_set|
1824
- result.select(pkg_or_set, resolve_package_set(pkg_or_set))
1831
+ begin
1832
+ result.select(pkg_or_set, resolve_package_set(pkg_or_set))
1833
+ rescue UnknownPackage => e
1834
+ raise e, "#{e.name}, which is selected in the layout, is unknown: #{e.message}", e.backtrace
1835
+ end
1825
1836
  end
1826
1837
  end
1827
1838
 
1828
1839
  begin
1829
1840
  result.filter_excluded_and_ignored_packages(self)
1830
- rescue ConfigError
1831
- raise if validate
1841
+ rescue ExcludedSelection => e
1842
+ if validate
1843
+ raise e, "#{e.sel}, which is selected in the layout, cannot be built: #{e.message}", e.backtrace
1844
+ end
1832
1845
  end
1833
1846
  result
1834
1847
  end
@@ -2086,6 +2099,24 @@ module Autoproj
2086
2099
  @osdeps_overrides.delete(osdeps_name.to_s)
2087
2100
  end
2088
2101
 
2102
+ # Exception raised by
2103
+ # PackageSelection#filter_excluded_and_ignored_packages when a given
2104
+ # selection is completely excluded
2105
+ class ExcludedSelection < ConfigError
2106
+ attr_reader :selection
2107
+ def initialize(selection)
2108
+ @selection = selection
2109
+ end
2110
+ end
2111
+
2112
+ # Exception raised when an unknown package is encountered
2113
+ class UnknownPackage < ConfigError
2114
+ attr_reader :name
2115
+ def initialize(name)
2116
+ @name = name
2117
+ end
2118
+ end
2119
+
2089
2120
  # Class holding information about which packages have been selected, and
2090
2121
  # why. It is used to decide whether some non-availability of packages
2091
2122
  # are errors or simply warnings (i.e. if the user really wants a given
@@ -2162,12 +2193,12 @@ module Autoproj
2162
2193
  if exclusions.size == 1
2163
2194
  reason = exclusions[0][1]
2164
2195
  if sel == exclusions[0][0]
2165
- raise ConfigError.new, "#{sel} is excluded from the build: #{reason}"
2196
+ raise ExcludedSelection.new(sel), "it is excluded from the build: #{reason}"
2166
2197
  else
2167
- raise ConfigError.new, "#{sel} expands to #{exclusions.map(&:first).join(", ")}, which is excluded from the build: #{reason}"
2198
+ raise ExcludedSelection.new(sel), "it expands to #{exclusions.map(&:first).join(", ")}, which is excluded from the build: #{reason}"
2168
2199
  end
2169
2200
  else
2170
- raise ConfigError.new, "#{sel} expands to #{exclusions.map(&:first).join(", ")}, and all these packages are excluded from the build:\n #{exclusions.map { |name, reason| "#{name}: #{reason}" }.join("\n ")}"
2201
+ raise ExcludedSelection.new(sel), "it expands to #{exclusions.map(&:first).join(", ")}, and all these packages are excluded from the build:\n #{exclusions.map { |name, reason| "#{name}: #{reason}" }.join("\n ")}"
2171
2202
  end
2172
2203
  elsif !ignored.empty?
2173
2204
  ignored.each do |pkg_name|
@@ -2300,6 +2331,21 @@ module Autoproj
2300
2331
  end
2301
2332
  result
2302
2333
  end
2334
+
2335
+ def reuse(*dir)
2336
+ dir = File.expand_path(File.join(*dir), Autoproj.root_dir)
2337
+ if reused_installations.any? { |mnf| mnf.path == dir }
2338
+ return
2339
+ end
2340
+
2341
+ manifest = InstallationManifest.new(dir)
2342
+ manifest.load(File.join(dir, ".autoproj-installation-manifest"))
2343
+ @reused_installations << manifest
2344
+ manifest.each do |pkg|
2345
+ puts pkg.name
2346
+ ignore_package pkg.name
2347
+ end
2348
+ end
2303
2349
  end
2304
2350
 
2305
2351
  class << self
@@ -2317,6 +2363,27 @@ module Autoproj
2317
2363
  osdeps
2318
2364
  end
2319
2365
 
2366
+ # Manifest of installed packages imported from another autoproj installation
2367
+ class InstallationManifest
2368
+ Package = Struct.new :name, :srcdir, :prefix
2369
+
2370
+ attr_reader :path
2371
+ attr_reader :packages
2372
+ def initialize(path)
2373
+ @path = path
2374
+ end
2375
+
2376
+ def load(path)
2377
+ @packages = CSV.read(path).map do |row|
2378
+ Package.new(*row)
2379
+ end
2380
+ end
2381
+
2382
+ def each(&block)
2383
+ packages.each(&block)
2384
+ end
2385
+ end
2386
+
2320
2387
  # Access to the information contained in a package's manifest.xml file
2321
2388
  #
2322
2389
  # Use PackageManifest.load to create
@@ -742,13 +742,13 @@ fi
742
742
  end
743
743
  else
744
744
  Autoproj.message " autodetecting the operating system"
745
- name, versions = os_from_lsb
746
- if name
747
- if name != "debian"
745
+ lsb_name, lsb_versions = os_from_lsb
746
+ if lsb_name
747
+ if lsb_name != "debian"
748
748
  if File.exists?("/etc/debian_version")
749
- @operating_system = [[name, "debian"], versions]
749
+ @operating_system = [[lsb_name, "debian"], lsb_versions]
750
750
  else
751
- @operating_system = [[name], versions]
751
+ @operating_system = [[lsb_name], lsb_versions]
752
752
  end
753
753
  end
754
754
  end
@@ -762,6 +762,9 @@ fi
762
762
  if versions.first =~ /sid/
763
763
  versions = ["unstable", "sid"]
764
764
  end
765
+ if lsb_versions
766
+ lsb_versions.each { |v| versions << v if !versions.include?(v) }
767
+ end
765
768
  [['debian'], versions]
766
769
  elsif File.exists?('/etc/fedora-release')
767
770
  release_string = File.read('/etc/fedora-release').strip
@@ -148,9 +148,7 @@ module Autoproj
148
148
  def self.export_env_sh(subdir = nil)
149
149
  # Make sure that we have the environment of all selected packages
150
150
  if Autoproj.manifest # we don't have a manifest if we are bootstrapping
151
- Autoproj.manifest.all_selected_packages(false).each do |pkg_name|
152
- Autobuild::Package[pkg_name].update_environment
153
- end
151
+ Autoproj::CmdLine.update_environment
154
152
  end
155
153
 
156
154
  filename = if subdir
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.9.0"
2
+ VERSION = "1.9.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autobuild
16
- requirement: &24040760 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.7.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *24040760
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: utilrb
27
- requirement: &24040300 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 1.6.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *24040300
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: highline
38
- requirement: &24039840 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 1.5.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *24039840
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rdoc
49
- requirement: &24039380 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,18 +69,28 @@ dependencies:
54
69
  version: '3.10'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *24039380
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.10'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: hoe
60
- requirement: &24038940 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
64
84
  - !ruby/object:Gem::Version
65
- version: '3.3'
85
+ version: '3.4'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *24038940
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.4'
69
94
  description: autoproj is a manager for sets of software packages. It allows the user
70
95
  to import and build packages from source, still using the underlying distribution's
71
96
  native package manager for software that is available on it.
@@ -79,10 +104,8 @@ executables:
79
104
  - autoproj-clean
80
105
  - autoproj-create-set
81
106
  - autoproj-envsh
82
- - autoproj-list
83
107
  - autoproj-locate
84
108
  - autoproj-query
85
- - autoproj-show
86
109
  - autoproj_bootstrap
87
110
  - autoproj_bootstrap.in
88
111
  - autoproj_stress_test
@@ -105,10 +128,8 @@ files:
105
128
  - bin/autoproj-clean
106
129
  - bin/autoproj-create-set
107
130
  - bin/autoproj-envsh
108
- - bin/autoproj-list
109
131
  - bin/autoproj-locate
110
132
  - bin/autoproj-query
111
- - bin/autoproj-show
112
133
  - bin/autoproj_bootstrap
113
134
  - bin/autoproj_bootstrap.in
114
135
  - bin/autoproj_stress_test
@@ -172,14 +193,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
193
  version: '0'
173
194
  requirements: []
174
195
  rubyforge_project: autobuild
175
- rubygems_version: 1.8.11
196
+ rubygems_version: 1.8.23
176
197
  signing_key:
177
198
  specification_version: 3
178
199
  summary: Easy installation and management of sets of software packages
179
200
  test_files:
180
- - test/test_manifest.rb
181
- - test/test_package_manifest.rb
182
201
  - test/test_os_dependencies.rb
183
202
  - test/test_debian.rb
203
+ - test/test_manifest.rb
184
204
  - test/package_managers/test_apt_dpkg_manager.rb
185
205
  - test/package_managers/test_gem.rb
206
+ - test/test_package_manifest.rb
data/bin/autoproj-list DELETED
@@ -1,68 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- require 'autoproj'
4
- require 'autoproj/cmdline'
5
-
6
- Autoproj.silent do
7
- Autoproj::CmdLine.initialize_root_directory
8
- Autoproj::CmdLine.initialize_and_load(ARGV)
9
- end
10
- manifest = Autoproj.manifest
11
-
12
- # Load the manifest for packages that are already present on the
13
- # file system
14
- manifest.packages.each_value do |pkg|
15
- if File.directory?(pkg.autobuild.srcdir)
16
- manifest.load_package_manifest(pkg.autobuild.name)
17
- end
18
- end
19
-
20
- all_packages = Hash.new
21
- package_sets = manifest.each_package_set.to_a
22
- package_sets.each do |pkg_set|
23
- pkg_set.each_package.each do |pkg|
24
- all_packages[pkg.name] = [pkg, pkg_set.name]
25
- end
26
- end
27
-
28
- metapackages = manifest.metapackages.values
29
-
30
- if package_sets.empty?
31
- Autoproj.message("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
32
- exit(0)
33
- end
34
-
35
- Autoproj.message
36
- Autoproj.message("autoproj: package sets", :bold)
37
- package_sets.sort_by(&:name).each do |pkg_set|
38
- next if pkg_set.empty?
39
- if pkg_set.imported_from
40
- Autoproj.message " #{pkg_set.name} (imported by #{pkg_set.imported_from.name})"
41
- else
42
- Autoproj.message " #{pkg_set.name} (listed in manifest)"
43
- end
44
- end
45
-
46
- Autoproj.message
47
- Autoproj.message("autoproj: metapackages", :bold)
48
- metapackages.sort_by(&:name).each do |metap|
49
- Autoproj.message " #{metap.name}"
50
- end
51
-
52
- packages_not_present = []
53
-
54
- Autoproj.message
55
- Autoproj.message("autoproj: packages", :bold)
56
- all_packages.to_a.sort_by(&:first).map(&:last).each do |pkg, pkg_set|
57
- if File.exists?(File.join(pkg.srcdir, "manifest.xml"))
58
- manifest.load_package_manifest(pkg.name)
59
- manifest.resolve_optional_dependencies
60
- end
61
-
62
- pkg_manifest = pkg.description
63
- if File.directory?(pkg.srcdir)
64
- Autoproj.message " #{pkg.name}#{": #{pkg_manifest.short_documentation}" if pkg_manifest && pkg_manifest.short_documentation}"
65
- else
66
- Autoproj.message " #{pkg.name}: not yet checked out", :magenta
67
- end
68
- end
data/bin/autoproj-show DELETED
@@ -1,102 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- require 'autoproj'
4
- require 'autoproj/cmdline'
5
- Autoproj.silent = true
6
- Autoproj::CmdLine.initialize_root_directory
7
- Autoproj::CmdLine.initialize_and_load(ARGV)
8
-
9
- require 'pp'
10
- default_packages = Autoproj.manifest.default_packages
11
- revdeps = Autoproj.manifest.compute_revdeps
12
-
13
- user_selection = ARGV.map do |arg|
14
- if File.directory?(arg)
15
- File.expand_path(arg)
16
- else arg
17
- end
18
- end
19
- resolved_selection = Autoproj::CmdLine.resolve_user_selection(user_selection, :filter => false)
20
- packages = resolved_selection.selection.keys
21
-
22
- def find_selection_path(from, to)
23
- path = [from]
24
- if from == to
25
- return path
26
- end
27
-
28
- Autobuild::Package[from].dependencies.each do |dep_pkg_name|
29
- if result = find_selection_path(dep_pkg_name, to)
30
- return path + result
31
- end
32
- end
33
- nil
34
- end
35
-
36
- packages.each do |name|
37
- result = Autoproj.manifest.resolve_package_name(name, :filter => false)
38
- packages, osdeps = result.partition { |type, name| type == :package }
39
- packages = packages.map(&:last)
40
- osdeps = osdeps.map(&:last)
41
-
42
- packages.each do |pkg_name|
43
- puts "source package #{pkg_name}"
44
- if default_packages.include?(pkg_name)
45
- selection = default_packages.selection[pkg_name]
46
- if selection.include?(pkg_name) && selection.size == 1
47
- puts " is directly selected by the manifest"
48
- else
49
- selection = selection.dup
50
- selection.delete(pkg_name)
51
- puts " is directly selected by the manifest via #{selection.to_a.join(", ")}"
52
- end
53
- else
54
- puts " is not directly selected by the manifest"
55
- end
56
- if Autoproj.manifest.ignored?(pkg_name)
57
- puts " is ignored"
58
- end
59
- if Autoproj.manifest.excluded?(pkg_name)
60
- puts " is excluded: #{Autoproj.manifest.exclusion_reason(pkg_name)}"
61
- end
62
-
63
- all_reverse_dependencies = Set.new
64
- pkg_revdeps = revdeps[pkg_name].dup.to_a
65
- while !pkg_revdeps.empty?
66
- parent_name = pkg_revdeps.shift
67
- next if all_reverse_dependencies.include?(parent_name)
68
- all_reverse_dependencies << parent_name
69
- pkg_revdeps.concat(revdeps[parent_name].to_a)
70
- end
71
- if all_reverse_dependencies.empty?
72
- puts " no reverse dependencies"
73
- else
74
- puts " reverse dependencies: #{all_reverse_dependencies.sort.join(", ")}"
75
- end
76
-
77
- selections = Set.new
78
- all_reverse_dependencies = all_reverse_dependencies.to_a.sort
79
- all_reverse_dependencies.each do |parent_name|
80
- if default_packages.include?(parent_name)
81
- selections |= default_packages.selection[parent_name]
82
- end
83
- end
84
-
85
- if !selections.empty?
86
- puts " selected by way of"
87
- selections.each do |root_pkg|
88
- path = find_selection_path(root_pkg, pkg_name)
89
- puts " #{path.join(">")}"
90
- end
91
- end
92
- puts " directly depends on: #{Autobuild::Package[pkg_name].dependencies.sort.join(", ")}"
93
- end
94
-
95
- osdeps.each do |pkg_name|
96
- puts "the osdep '#{pkg_name}'"
97
- Autoproj.osdeps.resolve_os_dependencies(pkg_name).each do |manager, packages|
98
- puts " #{manager.names.first}: #{packages.map { |*subnames| subnames.join(" ") }.join(", ")}"
99
- end
100
- end
101
- end
102
-