autoproj 1.5.7 → 1.5.8

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.
@@ -1,3 +1,13 @@
1
+ = Version 1.5.8
2
+ * add a way to add some ignore regexp to the dependency tracking. Updated user
3
+ guide about that.
4
+ * small cosmetic fixes
5
+ * warn if an osdeps file overrides information present in other osdeps files
6
+ * performance improvement at initialization: we now cache the result of OS
7
+ autodetection in config.yml. That removes a few seconds due to calling
8
+ lsb_release
9
+ * better error reporting in some cases related to OS dependencies
10
+
1
11
  = Version 1.5.7
2
12
  * allow using options and constants in the manifest as well
3
13
  This is so that we can use variables in the VCS definition for package sets.
@@ -33,6 +33,7 @@ doc/guide/src/toc.page
33
33
  doc/guide/src/writing_manifest.page
34
34
  lib/autoproj.rb
35
35
  lib/autoproj/autobuild.rb
36
+ lib/autoproj/base.rb
36
37
  lib/autoproj/cmdline.rb
37
38
  lib/autoproj/default.osdeps
38
39
  lib/autoproj/manifest.rb
@@ -10,20 +10,9 @@ require 'autoproj/autobuild'
10
10
  require 'open-uri'
11
11
  require 'autoproj/cmdline'
12
12
 
13
- require 'highline'
14
13
  include Autoproj
15
14
 
16
15
  InputError = Autoproj::InputError
17
- module Autoproj
18
- @verbose = false
19
- @console = HighLine.new
20
-
21
- class << self
22
- attr_accessor :verbose
23
- attr_reader :console
24
- end
25
- end
26
-
27
16
  selected_packages = Autoproj::CmdLine.parse_arguments(ARGV.dup)
28
17
 
29
18
  def color(*args)
@@ -39,6 +28,11 @@ def report(debug)
39
28
  rescue ConfigError => e
40
29
  STDERR.puts
41
30
  STDERR.puts color(e.message, :red, :bold)
31
+ root_dir = /^#{Regexp.quote(Autoproj.root_dir)}/
32
+ e.backtrace.find_all { |path| path =~ root_dir }.
33
+ each do |path|
34
+ STDERR.puts color(" in #{path}", :red, :bold)
35
+ end
42
36
  if debug then raise
43
37
  else exit 1
44
38
  end
@@ -122,8 +116,7 @@ report(Autobuild.debug) do
122
116
  # Install prepackaged dependencies needed to import and build the packages.
123
117
  # The required information is in the package sets configuration.
124
118
  if Autoproj::CmdLine.update_os_dependencies?
125
- osdeps = manifest.known_os_packages
126
- osdeps.install(Autoproj.build_system_dependencies)
119
+ Autoproj.osdeps.install(Autoproj.build_system_dependencies)
127
120
  end
128
121
 
129
122
  begin
@@ -28,6 +28,14 @@ module Autoproj
28
28
  class << self
29
29
  attr_reader :verbose
30
30
  end
31
+
32
+ # Fake option management for the OSdeps class
33
+ def self.has_config_key?(*args)
34
+ false
35
+ end
36
+ def self.change_option(*args)
37
+ false
38
+ end
31
39
  end
32
40
 
33
41
  module Autobuild
@@ -69,14 +77,15 @@ require 'tempfile'
69
77
  module Autoproj
70
78
  class OSDependencies
71
79
  def self.load(file)
80
+ file = File.expand_path(file)
72
81
  begin
73
- data = YAML.load(File.read(file))
82
+ data = YAML.load(File.read(file)) || Hash.new
74
83
  verify_definitions(data)
75
84
  rescue ArgumentError => e
76
85
  raise ConfigError, "error in #{file}: #{e.message}"
77
86
  end
78
87
 
79
- OSDependencies.new(data)
88
+ OSDependencies.new(data, file)
80
89
  end
81
90
 
82
91
  class << self
@@ -98,33 +107,62 @@ module Autoproj
98
107
 
99
108
  AUTOPROJ_OSDEPS = File.join(File.expand_path(File.dirname(__FILE__)), 'default.osdeps')
100
109
  def self.load_default
101
- if @default_osdeps
102
- @default_osdeps
103
- else
104
- file = ENV['AUTOPROJ_DEFAULT_OSDEPS'] || AUTOPROJ_OSDEPS
105
- if !File.file?(file)
106
- STDERR.puts "WARN: #{file} (from AUTOPROJ_DEFAULT_OSDEPS) is not a file, falling back to #{AUTOPROJ_OSDEPS}"
107
- file = AUTOPROJ_OSDEPS
108
- end
109
- @default_osdeps = OSDependencies.load(file)
110
+ file = ENV['AUTOPROJ_DEFAULT_OSDEPS'] || AUTOPROJ_OSDEPS
111
+ if !File.file?(file)
112
+ Autoproj.progress "WARN: #{file} (from AUTOPROJ_DEFAULT_OSDEPS) is not a file, falling back to #{AUTOPROJ_OSDEPS}"
113
+ file = AUTOPROJ_OSDEPS
110
114
  end
115
+ OSDependencies.load(file)
111
116
  end
112
117
 
118
+ # The information contained in the OSdeps files, as a hash
113
119
  attr_reader :definitions
120
+ # The information as to from which osdeps file the current package
121
+ # information in +definitions+ originates. It is a mapping from the
122
+ # package name to the osdeps file' full path
123
+ attr_reader :sources
124
+
125
+ # The Gem::SpecFetcher object that should be used to query RubyGems, and
126
+ # install RubyGems packages
114
127
  def gem_fetcher
115
128
  @gem_fetcher ||= Gem::SpecFetcher.fetcher
116
129
  end
117
130
 
118
- def initialize(defs = Hash.new)
131
+ def initialize(defs = Hash.new, file = nil)
119
132
  @definitions = defs.to_hash
133
+ @sources = Hash.new
134
+ if file
135
+ defs.each_key do |package_name|
136
+ sources[package_name] = file
137
+ end
138
+ end
139
+ end
140
+
141
+ # Returns the full path to the osdeps file from which the package
142
+ # definition for +package_name+ has been taken
143
+ def source_of(package_name)
144
+ sources[package_name]
120
145
  end
121
146
 
147
+ # Merges the osdeps information of +info+ into +self+. If packages are
148
+ # defined in both OSDependencies objects, the information in +info+
149
+ # takes precedence
122
150
  def merge(info)
123
- @definitions = definitions.merge(info.definitions)
151
+ root_dir = nil
152
+ @definitions = definitions.merge(info.definitions) do |h, v1, v2|
153
+ if v1 != v2
154
+ root_dir ||= "#{Autoproj.root_dir}/"
155
+ old = source_of(h).gsub(root_dir, '')
156
+ new = info.source_of(h).gsub(root_dir, '')
157
+ Autoproj.warn("osdeps definition for #{h}, previously defined in #{old} overriden by #{new}")
158
+ end
159
+ v2
160
+ end
161
+ @sources = sources.merge(info.sources)
124
162
  end
125
163
 
126
- def self.verify_definitions(hash = nil)
127
- hash ||= definitions
164
+ # Perform some sanity checks on the given osdeps definitions
165
+ def self.verify_definitions(hash)
128
166
  hash.each do |key, value|
129
167
  if !key.kind_of?(String)
130
168
  raise ArgumentError, "invalid osdeps definition: found an #{key.class}. Don't forget to put quotes around numbers"
@@ -153,6 +191,8 @@ module Autoproj
153
191
  def self.operating_system
154
192
  if @operating_system
155
193
  return @operating_system
194
+ elsif Autoproj.has_config_key?('operating_system')
195
+ @operating_system = Autoproj.user_config('operating_system')
156
196
  elsif data = os_from_lsb
157
197
  if data[0] != "debian"
158
198
  # Fall back to reading debian_version, as
@@ -186,6 +226,8 @@ module Autoproj
186
226
  @operating_system =
187
227
  [@operating_system[0].downcase,
188
228
  @operating_system[1].map(&:downcase)]
229
+ Autoproj.change_option('operating_system', @operating_system, true)
230
+ @operating_system
189
231
  end
190
232
 
191
233
  def self.os_from_lsb
@@ -209,8 +251,8 @@ module Autoproj
209
251
  EOSCRIPT
210
252
 
211
253
  OS_PACKAGE_INSTALL = {
212
- 'debian' => 'apt-get install -y %s',
213
- 'ubuntu' => 'apt-get install -y %s',
254
+ 'debian' => 'export DEBIAN_FRONTEND=noninteractive; apt-get install -y %s',
255
+ 'ubuntu' => 'export DEBIAN_FRONTEND=noninteractive; apt-get install -y %s',
214
256
  'gentoo' => 'emerge --noreplace %s',
215
257
  'arch' => 'pacman -Sy --noconfirm %s'
216
258
  }
@@ -376,8 +418,8 @@ module Autoproj
376
418
  if !osdeps.empty?
377
419
  shell_script = generate_os_script(osdeps)
378
420
  if Autoproj.verbose
379
- STDERR.puts "Installing non-ruby OS dependencies with"
380
- STDERR.puts shell_script
421
+ Autoproj.progress "Installing non-ruby OS dependencies with"
422
+ Autoproj.progress shell_script
381
423
  end
382
424
 
383
425
  File.open('osdeps.sh', 'w') do |file|
@@ -393,6 +435,7 @@ module Autoproj
393
435
  end
394
436
 
395
437
  if !gems.empty?
438
+ Autobuild.progress "looking for RubyGems updates"
396
439
  # Don't install gems that are already there ...
397
440
  gems.delete_if do |name|
398
441
  version_requirements = Gem::Requirement.default
@@ -416,8 +459,8 @@ module Autoproj
416
459
  guess_gem_program
417
460
 
418
461
  if Autoproj.verbose
419
- STDERR.puts "Installing rubygems dependencies with"
420
- STDERR.puts "gem install #{gems.join(" ")}"
462
+ Autoproj.progress "Installing rubygems dependencies with"
463
+ Autoproj.progress "gem install #{gems.join(" ")}"
421
464
  end
422
465
  Autobuild.progress "installing/updating RubyGems dependencies: #{gems.join(", ")}"
423
466
  Autobuild::Subprocess.run 'autoproj', 'osdeps', Autobuild.tool('gem'), 'install', *gems
@@ -433,16 +476,50 @@ end
433
476
 
434
477
  DEFS = <<EODEFS
435
478
  ---
479
+ svn:
480
+ arch: subversion
481
+ gentoo: dev-util/subversion
482
+ debian,ubuntu: subversion
483
+ autobuild: gem
484
+ zlib:
485
+ debian,ubuntu: zlib1g-dev
486
+ libxml2:
487
+ arch: libxml2
488
+ gentoo: dev-libs/libxml2
489
+ debian,ubuntu: libxml2-dev
436
490
  none: ignore
491
+ autotools:
492
+ arch: automake autoconf
493
+ gentoo:
494
+ - sys-devel/automake:1.9
495
+ - sys-devel/autoconf
496
+ debian,ubuntu:
497
+ - automake1.9
498
+ - autoconf
499
+ autoproj: gem
500
+ archive:
501
+ arch:
502
+ - tar
503
+ - unzip
504
+ gentoo:
505
+ - app-arch/tar
506
+ - app-arch/unzip
507
+ debian,ubuntu:
508
+ - tar
509
+ - unzip
510
+ lsb_release:
511
+ arch:
512
+ gentoo: sys-apps/lsb-release
513
+ debian,ubuntu: lsb-release
437
514
  ruby18:
515
+ gentoo:
516
+ - dev-lang/ruby:1.8
438
517
  debian,ubuntu:
439
518
  - ruby1.8-dev
440
519
  - ruby1.8
441
520
  - rubygems1.8
442
521
  - ri1.8
443
522
  - libopenssl-ruby1.8
444
- gentoo:
445
- - dev-lang/ruby:1.8
446
523
  ruby19:
447
524
  debian:
448
525
  squeeze,sid:
@@ -453,65 +530,33 @@ ruby19:
453
530
  - ruby1.9.1
454
531
  - ruby1.9.1-dev
455
532
  - rubygems1.9.1
533
+ arch:
534
+ - ruby
535
+ gentoo:
536
+ - dev-lang/ruby:1.9
456
537
  ubuntu:
457
538
  - ruby1.9.1
458
539
  - ruby1.9.1-dev
459
540
  - rubygems1.9.1
460
541
  - ri1.9.1
461
542
  - libopenssl-ruby1.9.1
462
- gentoo:
463
- - dev-lang/ruby:1.9
464
- arch:
465
- - ruby
466
- rdoc: gem
467
- build-essential:
468
- debian,ubuntu: build-essential
469
- gentoo:
470
- arch:
471
- libxml2:
472
- debian,ubuntu: libxml2-dev
473
- gentoo: dev-libs/libxml2
474
- arch: libxml2
475
- libxslt:
476
- debian,ubuntu: libxslt1-dev
477
- gentoo: dev-libs/libxslt
478
- arch: libxslt
479
- autobuild: gem
480
- autoproj: gem
481
543
  git:
482
- debian,ubuntu: git-core
483
- gentoo: dev-vcs/git
484
544
  arch: git
485
- svn:
486
- debian,ubuntu: subversion
487
- gentoo: dev-util/subversion
488
- arch: subversion
545
+ gentoo: dev-vcs/git
546
+ debian,ubuntu: git-core
489
547
  cmake:
490
- debian,ubuntu: cmake
491
- gentoo: dev-util/cmake
492
548
  arch: cmake
493
- autotools:
494
- debian,ubuntu:
495
- - automake1.9
496
- - autoconf
497
- gentoo:
498
- - sys-devel/automake:1.9
499
- - sys-devel/autoconf
500
- arch: automake autoconf
501
- lsb_release:
502
- debian,ubuntu: lsb-release
503
- gentoo: sys-apps/lsb-release
549
+ gentoo: dev-util/cmake
550
+ debian,ubuntu: cmake
551
+ build-essential:
504
552
  arch:
505
- archive:
506
- debian,ubuntu:
507
- - tar
508
- - unzip
509
553
  gentoo:
510
- - app-arch/tar
511
- - app-arch/unzip
512
- arch:
513
- - tar
514
- - unzip
554
+ debian,ubuntu: build-essential
555
+ libxslt:
556
+ arch: libxslt
557
+ gentoo: dev-libs/libxslt
558
+ debian,ubuntu: libxslt1-dev
559
+ rdoc: gem
515
560
 
516
561
  EODEFS
517
562
 
@@ -531,7 +576,7 @@ rescue Autoproj::ConfigError => e
531
576
  end
532
577
 
533
578
  # Now try to find out the name of the gem binary
534
- PACKAGES = %w{rdoc libxml2 libxslt build-essential lsb_release}
579
+ PACKAGES = %w{rdoc libxml2 libxslt zlib build-essential lsb_release}
535
580
  USER_PACKAGES = %w{autoproj}
536
581
 
537
582
  ENV['RUBYOPT'] = "-rubygems"
@@ -127,6 +127,36 @@ overrides:
127
127
  branch: experimental
128
128
  {coderay}
129
129
 
130
+ Tuning what files autoproj looks at to determine if a package should be updated
131
+ -------------------------------------------------------------------------------
132
+ When a package A depends on a package B, autoproj checks if some of the files in
133
+ B's directory are newer than the latest build of A. If it is the case, it will
134
+ trigger the build of B and then the one of A.
135
+
136
+ Autoproj has a default list of files that it should ignore. Unfortunately, it
137
+ may be that you are generating some files in the source directory that autoproj
138
+ interprets as new files and trigger builds.
139
+
140
+ If you have the impression that autoproj does too many rebuilds, run the build
141
+ once with the <tt>--list-newest-files</tt> option. For instance,
142
+
143
+ autoproj --list-newest-files fast-build
144
+ {: .cmdline}
145
+
146
+ If you find some files that should be ignored, add them either to the package
147
+ sets (i.e. autoproj/remotes/blablab/init.rb) or in autoproj/init.rb with
148
+
149
+ {coderay:: ruby}
150
+ ignore /a_regular_expression/
151
+ {coderay}
152
+
153
+ where /a_regular_expression/ is a regular expression matching your files. For
154
+ instance, to eliminate all files that have an extension in ".swp", one would do
155
+
156
+ {coderay:: ruby}
157
+ ignore /\.swp$/
158
+ {coderay}
159
+
130
160
  Building local packages
131
161
  -----------------------
132
162
 
@@ -1,9 +1,6 @@
1
- module Autoproj
2
- class ConfigError < RuntimeError; end
3
- class InternalError < RuntimeError; end
4
- end
5
-
6
1
  require "enumerator"
2
+ require 'autobuild'
3
+ require 'autoproj/base'
7
4
  require 'autoproj/version'
8
5
  require 'autoproj/manifest'
9
6
  require 'autoproj/osdeps'
@@ -23,7 +23,7 @@ module Autobuild
23
23
  raise e
24
24
  else
25
25
  # Re-call osdeps to get a proper error message
26
- osdeps, gems = Autoproj.osdeps.partition_packages([name].to_set)
26
+ osdeps, gems = Autoproj.osdeps.partition_packages([name].to_set, name => [self.name])
27
27
  Autoproj.osdeps.resolve_os_dependencies(osdeps)
28
28
  end
29
29
  end
@@ -46,22 +46,19 @@ module Autoproj
46
46
  class Reporter < Autobuild::Reporter
47
47
  def error(error)
48
48
  error_lines = error.to_s.split("\n")
49
- STDERR.puts color("Build failed: #{error_lines.shift}", :bold, :red)
50
- STDERR.puts error_lines.join("\n")
49
+ Autoproj.progress("Build failed: #{error_lines.shift}", :bold, :red)
50
+ error_lines.each do |line|
51
+ Autoproj.progress line
52
+ end
51
53
  end
52
54
  def success
53
- STDERR.puts color("Build finished successfully at #{Time.now}", :bold, :green)
55
+ Autoproj.progress("Build finished successfully at #{Time.now}", :bold, :green)
54
56
  if Autobuild.post_success_message
55
- puts Autobuild.post_success_message
57
+ Autoproj.progress Autobuild.post_success_message
56
58
  end
57
59
  end
58
60
  end
59
61
 
60
- # Displays a warning message
61
- def self.warn(message)
62
- STDERR.puts Autoproj.console.color(" WARN: #{message}", :magenta)
63
- end
64
-
65
62
  @file_stack = Array.new
66
63
 
67
64
  def self.package_name_from_options(spec)
@@ -111,6 +108,12 @@ module Autoproj
111
108
  end
112
109
  end
113
110
 
111
+ def ignore(*paths)
112
+ paths.each do |p|
113
+ Autobuild.ignore(p)
114
+ end
115
+ end
116
+
114
117
  # Common setup for packages
115
118
  def package_common(package_type, spec, &block) # :nodoc:
116
119
  package_name = Autoproj.package_name_from_options(spec)
@@ -0,0 +1,6 @@
1
+ module Autoproj
2
+ class ConfigError < RuntimeError; end
3
+ class InternalError < RuntimeError; end
4
+ end
5
+
6
+
@@ -1,4 +1,30 @@
1
+ require 'highline'
2
+ require 'utilrb/module/attr_predicate'
1
3
  module Autoproj
4
+ class << self
5
+ attr_accessor :verbose
6
+ attr_reader :console
7
+ attr_predicate :silent?, true
8
+ end
9
+ @silent = false
10
+ @verbose = false
11
+ @console = HighLine.new
12
+
13
+ def self.progress(*args)
14
+ if !silent?
15
+ if args.empty?
16
+ puts
17
+ else
18
+ STDERR.puts console.color(*args)
19
+ end
20
+ end
21
+ end
22
+
23
+ # Displays a warning message
24
+ def self.warn(message)
25
+ Autoproj.progress(" WARN: #{message}", :magenta)
26
+ end
27
+
2
28
  module CmdLine
3
29
  def self.initialize
4
30
  Autobuild::Reporting << Autoproj::Reporter.new
@@ -60,14 +86,17 @@ module Autoproj
60
86
  if Autoproj::CmdLine.update_os_dependencies.nil?
61
87
  Autoproj::CmdLine.update_os_dependencies = manifest.auto_update?
62
88
  end
89
+
90
+ # Initialize the Autoproj.osdeps object by loading the default. The
91
+ # rest is loaded later
92
+ Autoproj.osdeps = Autoproj::OSDependencies.load_default
63
93
  end
64
94
 
65
95
  def self.update_myself
66
96
  return if !Autoproj::CmdLine.update_os_dependencies?
67
97
 
68
98
  # First things first, see if we need to update ourselves
69
- osdeps = Autoproj::OSDependencies.load_default
70
- if osdeps.install(%w{autobuild autoproj})
99
+ if Autoproj.osdeps.install(%w{autobuild autoproj})
71
100
  # We updated autobuild or autoproj themselves ... Restart !
72
101
  require 'rbconfig'
73
102
  ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
@@ -75,7 +104,7 @@ module Autoproj
75
104
  end
76
105
  end
77
106
 
78
- def self.load_configuration
107
+ def self.load_configuration(silent = false)
79
108
  manifest = Autoproj.manifest
80
109
 
81
110
  # Load init.rb files. each_source must not load the source.yml file, as
@@ -85,9 +114,11 @@ module Autoproj
85
114
  end
86
115
 
87
116
  # Load the required autobuild definitions
88
- STDERR.puts color("autoproj: loading ...", :bold)
89
- if !Autoproj.reconfigure?
90
- STDERR.puts color("run 'autoproj --reconfigure' to change configuration values", :bold)
117
+ if !silent
118
+ Autoproj.progress("autoproj: loading ...", :bold)
119
+ if !Autoproj.reconfigure?
120
+ Autoproj.progress("run 'autoproj --reconfigure' to change configuration values", :bold)
121
+ end
91
122
  end
92
123
  manifest.each_autobuild_file do |source, name|
93
124
  Autoproj.import_autobuild_file source, name
@@ -109,7 +140,7 @@ module Autoproj
109
140
  Autoproj.save_config
110
141
 
111
142
  # Loads OS package definitions once and for all
112
- Autoproj.osdeps = manifest.known_os_packages
143
+ Autoproj.load_osdeps_from_package_sets
113
144
  end
114
145
 
115
146
  def self.update_configuration
@@ -131,15 +162,14 @@ module Autoproj
131
162
 
132
163
  # Update the remote sources if there are any
133
164
  if manifest.has_remote_sources?
134
- STDERR.puts color("autoproj: updating remote definitions of package sets", :bold)
165
+ Autoproj.progress("autoproj: updating remote definitions of package sets", :bold)
135
166
  # If we need to install some packages to import our remote sources, do it
136
167
  if update_os_dependencies?
137
- osdeps = OSDependencies.load_default
138
- osdeps.install(source_os_dependencies)
168
+ Autoproj.osdeps.install(source_os_dependencies)
139
169
  end
140
170
 
141
171
  manifest.update_remote_sources
142
- STDERR.puts
172
+ Autoproj.progress
143
173
  end
144
174
  end
145
175
 
@@ -186,17 +216,17 @@ module Autoproj
186
216
  sources = manifest.each_source(false).to_a
187
217
 
188
218
  if sources.empty?
189
- STDERR.puts color("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
219
+ Autoproj.progress("autoproj: no package sets defined in autoproj/manifest", :bold, :red)
190
220
  else
191
- STDERR.puts color("autoproj: available package sets", :bold)
221
+ Autoproj.progress("autoproj: available package sets", :bold)
192
222
  manifest.each_source(false) do |source|
193
223
  source_yml = source.raw_description_file
194
- STDERR.puts " #{source_yml['name']}"
224
+ Autoproj.progress " #{source_yml['name']}"
195
225
  if source.local?
196
- puts " local source in #{source.local_dir}"
226
+ Autoproj.progress " local source in #{source.local_dir}"
197
227
  else
198
- puts " from: #{source.vcs}"
199
- puts " local: #{source.local_dir}"
228
+ Autoproj.progress " from: #{source.vcs}"
229
+ Autoproj.progress " local: #{source.local_dir}"
200
230
  end
201
231
 
202
232
  lines = []
@@ -236,18 +266,18 @@ module Autoproj
236
266
  return manifest.default_packages
237
267
  end
238
268
  if selected_packages.empty? # no packages, terminate
239
- STDERR.puts
240
- STDERR.puts color("autoproj: no packages defined", :red)
269
+ Autoproj.progress
270
+ Autoproj.progress("autoproj: no packages defined", :red)
241
271
  exit 0
242
272
  end
243
273
  selected_packages = selected_packages.to_set
244
274
 
245
275
  selected_packages = manifest.expand_package_selection(selected_packages)
246
276
  if selected_packages.empty?
247
- STDERR.puts color("autoproj: wrong package selection on command line", :red)
277
+ Autoproj.progress("autoproj: wrong package selection on command line", :red)
248
278
  exit 1
249
279
  elsif Autoproj.verbose
250
- STDERR.puts "will install #{selected_packages.to_a.join(", ")}"
280
+ Autoproj.progress "will install #{selected_packages.to_a.join(", ")}"
251
281
  end
252
282
  selected_packages
253
283
  end
@@ -324,7 +354,27 @@ module Autoproj
324
354
  end
325
355
 
326
356
  if Autoproj.verbose
327
- STDERR.puts "autoproj: finished importing packages"
357
+ Autoproj.progress "autoproj: finished importing packages"
358
+ end
359
+ if Autoproj::CmdLine.list_newest?
360
+ fields = []
361
+ Rake::Task.tasks.each do |task|
362
+ if task.kind_of?(Autobuild::SourceTreeTask)
363
+ task.timestamp
364
+ fields << ["#{task.name}:", task.newest_file, task.newest_time.to_s]
365
+ end
366
+ end
367
+
368
+ field_sizes = fields.inject([0, 0, 0]) do |sizes, line|
369
+ 3.times do |i|
370
+ sizes[i] = [sizes[i], line[i].length].max
371
+ end
372
+ sizes
373
+ end
374
+ format = " %-#{field_sizes[0]}s %-#{field_sizes[1]}s at %-#{field_sizes[2]}s"
375
+ fields.each do |line|
376
+ Autoproj.progress(format % line)
377
+ end
328
378
  end
329
379
 
330
380
  return all_enabled_packages
@@ -332,9 +382,9 @@ module Autoproj
332
382
 
333
383
  def self.build_packages(selected_packages, all_enabled_packages)
334
384
  if Autoproj::CmdLine.doc?
335
- STDERR.puts color("autoproj: building and installing documentation", :bold)
385
+ Autoproj.progress("autoproj: building and installing documentation", :bold)
336
386
  else
337
- STDERR.puts color("autoproj: building and installing packages", :bold)
387
+ Autoproj.progress("autoproj: building and installing packages", :bold)
338
388
  end
339
389
 
340
390
  if Autoproj::CmdLine.update_os_dependencies?
@@ -367,15 +417,17 @@ module Autoproj
367
417
  class << self
368
418
  attr_accessor :update_os_dependencies
369
419
  attr_accessor :snapshot_dir
420
+ attr_writer :list_newest
370
421
  end
371
422
  def self.display_configuration?; !!@display_configuration end
372
423
  def self.force_re_build_with_depends?; !!@force_re_build_with_depends end
373
424
  def self.partial_build?; !!@partial_build end
374
- def self.mail_config; @mail_config end
425
+ def self.mail_config; @mail_config || Hash.new end
375
426
  def self.update_packages?; @mode == "update" || @mode == "envsh" || build? end
376
427
  def self.build?; @mode =~ /build/ end
377
428
  def self.doc?; @mode == "doc" end
378
429
  def self.snapshot?; @mode == "snapshot" end
430
+ def self.list_newest?; @list_newest end
379
431
  def self.parse_arguments(args)
380
432
  @only_status = false
381
433
  @check = false
@@ -462,6 +514,9 @@ where 'mode' is one of:
462
514
  opts.on("--with-depends", "apply rebuild and force-build to both packages selected on the command line and their dependencies") do
463
515
  force_re_build_with_depends = true
464
516
  end
517
+ opts.on("--list-newest", "for each source directory, list what is the newest file used by autoproj for dependency tracking") do
518
+ Autoproj::CmdLine.list_newest = true
519
+ end
465
520
 
466
521
  opts.on("--verbose", "verbose output") do
467
522
  Autoproj.verbose = true
@@ -663,21 +718,21 @@ where 'mode' is one of:
663
718
  end
664
719
 
665
720
  if last_was_in_sync
666
- STDERR.puts color(": local and remote are in sync", :green)
721
+ Autoproj.progress(": local and remote are in sync", :green)
667
722
  end
668
723
 
669
724
  last_was_in_sync = false
670
725
  STDERR.print "#{pkg_name}:"
671
726
 
672
727
  if lines.size == 1
673
- STDERR.puts lines.first
728
+ Autoproj.progress lines.first
674
729
  else
675
- STDERR.puts
676
- STDERR.puts lines.join("\n")
730
+ Autoproj.progress
731
+ Autoproj.progress lines.join("\n")
677
732
  end
678
733
  end
679
734
  if last_was_in_sync
680
- STDERR.puts color(": local and remote are in sync", :green)
735
+ Autoproj.progress(": local and remote are in sync", :green)
681
736
  end
682
737
  end
683
738
 
@@ -690,13 +745,13 @@ where 'mode' is one of:
690
745
  end
691
746
 
692
747
  if !sources.empty?
693
- STDERR.puts color("autoproj: displaying status of configuration", :bold)
748
+ Autoproj.progress("autoproj: displaying status of configuration", :bold)
694
749
  display_status(sources)
695
750
  STDERR.puts
696
751
  end
697
752
 
698
753
 
699
- STDERR.puts color("autoproj: displaying status of packages", :bold)
754
+ Autoproj.progress("autoproj: displaying status of packages", :bold)
700
755
  packages = packages.sort.map do |pkg_name|
701
756
  Autobuild::Package[pkg_name]
702
757
  end
@@ -796,7 +851,7 @@ manifest_source:
796
851
  # assume that we are bootstrapping from another installation directory and
797
852
  # start by copying the .gems directory
798
853
  if ENV['GEM_HOME'] && ENV['GEM_HOME'] =~ /\.gems\/?$/ && ENV['GEM_HOME'] != File.join(Dir.pwd, ".gems")
799
- STDERR.puts "autoproj: reusing bootstrap from #{File.dirname(ENV['GEM_HOME'])}"
854
+ Autoproj.progress "autoproj: reusing bootstrap from #{File.dirname(ENV['GEM_HOME'])}"
800
855
  FileUtils.cp_r ENV['GEM_HOME'], ".gems"
801
856
  ENV['GEM_HOME'] = File.join(Dir.pwd, ".gems")
802
857
 
@@ -814,7 +869,7 @@ manifest_source:
814
869
 
815
870
  if args.size == 1 # the user asks us to download a manifest
816
871
  manifest_url = args.first
817
- STDERR.puts color("autoproj: downloading manifest file #{manifest_url}", :bold)
872
+ Autoproj.progress("autoproj: downloading manifest file #{manifest_url}", :bold)
818
873
  manifest_data =
819
874
  begin open(manifest_url) { |file| file.read }
820
875
  rescue
@@ -840,7 +895,7 @@ manifest_source:
840
895
  EOSHELL
841
896
  end
842
897
 
843
- STDERR.puts <<EOTEXT
898
+ Autoproj.progress <<EOTEXT
844
899
 
845
900
  add the following line at the bottom of your .bashrc:
846
901
  source #{Dir.pwd}/env.sh
@@ -889,8 +944,8 @@ EOTEXT
889
944
  end
890
945
 
891
946
  if !result.empty?
892
- STDERR.puts pkg.name
893
- STDERR.puts " #{result.join("\n ")}"
947
+ Autoproj.progress pkg.name
948
+ Autoproj.progress " #{result.join("\n ")}"
894
949
  end
895
950
  end
896
951
  end
@@ -928,9 +983,9 @@ EOTEXT
928
983
  io.write xml.to_xml
929
984
  end
930
985
  if !manifest
931
- STDERR.puts "created #{path}"
986
+ Autoproj.progress "created #{path}"
932
987
  else
933
- STDERR.puts "modified #{path}"
988
+ Autoproj.progress "modified #{path}"
934
989
  end
935
990
  end
936
991
  end
@@ -949,10 +1004,10 @@ EOTEXT
949
1004
  package = Autobuild::Package[package_name]
950
1005
  importer = package.importer
951
1006
  if !importer
952
- STDERR.puts "cannot snapshot #{package_name} as it has no importer"
1007
+ Autoproj.progress "cannot snapshot #{package_name} as it has no importer"
953
1008
  next
954
1009
  elsif !importer.respond_to?(:snapshot)
955
- STDERR.puts "cannot snapshot #{package_name} as the #{importer.class} importer does not support it"
1010
+ Autoproj.progress "cannot snapshot #{package_name} as the #{importer.class} importer does not support it"
956
1011
  next
957
1012
  end
958
1013
 
@@ -54,6 +54,10 @@ libxslt:
54
54
  gentoo: dev-libs/libxslt
55
55
  arch: libxslt
56
56
 
57
+ zlib:
58
+ debian,ubuntu: zlib1g-dev
59
+
60
+
57
61
  autobuild: gem
58
62
  autoproj: gem
59
63
 
@@ -202,7 +202,7 @@ module Autoproj
202
202
 
203
203
  def self.resolve_one_constant(name, value, result, definitions)
204
204
  result[name] = single_expansion(value, result) do |missing_name|
205
- result[missing_name] = resolve_one_constant(missing_name, definitions.delete(missing_name), definitions)
205
+ result[missing_name] = resolve_one_constant(missing_name, definitions.delete(missing_name), result, definitions)
206
206
  end
207
207
  end
208
208
 
@@ -905,7 +905,10 @@ module Autoproj
905
905
  # file (we're not ready for that yet)
906
906
  sources = []
907
907
  each_remote_source(false) do |source|
908
- Manifest.update_source(source.vcs, source.name || source.vcs.url, source.automatic_name, source.raw_local_dir)
908
+ name = if source.present? then source.name
909
+ else source.vcs.url
910
+ end
911
+ Manifest.update_source(source.vcs, name, source.automatic_name, source.raw_local_dir)
909
912
  sources << source
910
913
  end
911
914
 
@@ -919,13 +922,35 @@ module Autoproj
919
922
  end
920
923
 
921
924
  remotes_symlinks_dir = File.join(Autoproj.config_dir, 'remotes')
922
- FileUtils.rm_rf remotes_symlinks_dir
923
- FileUtils.mkdir remotes_symlinks_dir
925
+ FileUtils.mkdir_p remotes_symlinks_dir
926
+ known_remotes = []
927
+
924
928
  # Create symbolic links from .remotes/weird_url to
925
929
  # autoproj/remotes/name. Explicitely load the source name first
926
930
  each_remote_source(false) do |source|
927
931
  source.load_name
928
- FileUtils.ln_sf source.raw_local_dir, File.join(remotes_symlinks_dir, source.name)
932
+ symlink_dest = File.join(remotes_symlinks_dir, source.name)
933
+
934
+ # Check if the current symlink is valid, and recreate it if it
935
+ # is not
936
+ if File.symlink?(symlink_dest)
937
+ dest = File.readlink(symlink_dest)
938
+ if dest != source.raw_local_dir
939
+ FileUtils.rm_f symlink_dest
940
+ end
941
+ else
942
+ FileUtils.rm_f symlink_dest
943
+ FileUtils.ln_sf source.raw_local_dir, symlink_dest
944
+ end
945
+
946
+ known_remotes << symlink_dest
947
+ end
948
+
949
+ # Now remove obsolete symlinks
950
+ Dir.glob(File.join(remotes_symlinks_dir, '*')).each do |file|
951
+ if File.symlink?(file) && !known_remotes.include?(file)
952
+ FileUtils.rm_f file
953
+ end
929
954
  end
930
955
  end
931
956
 
@@ -1090,6 +1115,16 @@ module Autoproj
1090
1115
  names.to_set
1091
1116
  end
1092
1117
 
1118
+ # Returns the package directory for the given package name
1119
+ def whereis(package_name)
1120
+ each_package_set do |layout_name, packages, _|
1121
+ if packages.include?(package_name)
1122
+ return layout_name
1123
+ end
1124
+ end
1125
+ raise ArgumentError, "cannot find #{package_name} in the current layout"
1126
+ end
1127
+
1093
1128
  # Loads the package's manifest.xml file for the current package
1094
1129
  #
1095
1130
  # Right now, the absence of a manifest makes autoproj only issue a
@@ -1130,17 +1165,6 @@ module Autoproj
1130
1165
  selected_packages.each(&:load_package_manifest)
1131
1166
  end
1132
1167
 
1133
- # Returns an OSDependencies instance that defined the known OS packages,
1134
- # as well as how to install them
1135
- def known_os_packages
1136
- osdeps = OSDependencies.load_default
1137
-
1138
- each_osdeps_file do |source, file|
1139
- osdeps.merge(OSDependencies.load(file))
1140
- end
1141
- osdeps
1142
- end
1143
-
1144
1168
  def install_os_dependencies(packages)
1145
1169
  required_os_packages = Set.new
1146
1170
  package_os_deps = Hash.new { |h, k| h[k] = Array.new }
@@ -1156,7 +1180,7 @@ module Autoproj
1156
1180
  end
1157
1181
  end
1158
1182
 
1159
- known_os_packages.install(required_os_packages, package_os_deps)
1183
+ Autoproj.osdeps.install(required_os_packages, package_os_deps)
1160
1184
  end
1161
1185
 
1162
1186
  # Package selection can be done in three ways:
@@ -1228,6 +1252,13 @@ module Autoproj
1228
1252
  attr_accessor :osdeps
1229
1253
  end
1230
1254
 
1255
+ def self.load_osdeps_from_package_sets
1256
+ manifest.each_osdeps_file do |source, file|
1257
+ osdeps.merge(OSDependencies.load(file))
1258
+ end
1259
+ osdeps
1260
+ end
1261
+
1231
1262
  class PackageManifest
1232
1263
  def self.load(package, file)
1233
1264
  doc = Nokogiri::XML(File.read(file)) do |c|
@@ -24,7 +24,8 @@ module Autoproj
24
24
 
25
25
  def ask(current_value)
26
26
  default_value = if current_value then current_value.to_s
27
- else options[:default].to_str
27
+ elsif options[:default] then options[:default].to_str
28
+ else ''
28
29
  end
29
30
 
30
31
  STDERR.print " #{doc} [#{default_value}] "
@@ -35,7 +36,7 @@ module Autoproj
35
36
  validate(answer)
36
37
 
37
38
  rescue InputError => e
38
- STDERR.puts Autoproj.console.color("invalid value: #{e.message}", :red)
39
+ Autoproj.progress("invalid value: #{e.message}", :red)
39
40
  retry
40
41
  end
41
42
 
@@ -89,7 +90,7 @@ module Autoproj
89
90
  value = configure(key)
90
91
  else
91
92
  if !seen
92
- STDERR.puts " #{@declared_options[key].doc}: #{value}"
93
+ Autoproj.progress " #{@declared_options[key].doc}: #{value}"
93
94
  @user_config[key] = [value, true]
94
95
  end
95
96
  value
@@ -2,14 +2,15 @@ require 'tempfile'
2
2
  module Autoproj
3
3
  class OSDependencies
4
4
  def self.load(file)
5
+ file = File.expand_path(file)
5
6
  begin
6
- data = YAML.load(File.read(file))
7
+ data = YAML.load(File.read(file)) || Hash.new
7
8
  verify_definitions(data)
8
9
  rescue ArgumentError => e
9
10
  raise ConfigError, "error in #{file}: #{e.message}"
10
11
  end
11
12
 
12
- OSDependencies.new(data)
13
+ OSDependencies.new(data, file)
13
14
  end
14
15
 
15
16
  class << self
@@ -31,33 +32,62 @@ module Autoproj
31
32
 
32
33
  AUTOPROJ_OSDEPS = File.join(File.expand_path(File.dirname(__FILE__)), 'default.osdeps')
33
34
  def self.load_default
34
- if @default_osdeps
35
- @default_osdeps
36
- else
37
- file = ENV['AUTOPROJ_DEFAULT_OSDEPS'] || AUTOPROJ_OSDEPS
38
- if !File.file?(file)
39
- STDERR.puts "WARN: #{file} (from AUTOPROJ_DEFAULT_OSDEPS) is not a file, falling back to #{AUTOPROJ_OSDEPS}"
40
- file = AUTOPROJ_OSDEPS
41
- end
42
- @default_osdeps = OSDependencies.load(file)
35
+ file = ENV['AUTOPROJ_DEFAULT_OSDEPS'] || AUTOPROJ_OSDEPS
36
+ if !File.file?(file)
37
+ Autoproj.progress "WARN: #{file} (from AUTOPROJ_DEFAULT_OSDEPS) is not a file, falling back to #{AUTOPROJ_OSDEPS}"
38
+ file = AUTOPROJ_OSDEPS
43
39
  end
40
+ OSDependencies.load(file)
44
41
  end
45
42
 
43
+ # The information contained in the OSdeps files, as a hash
46
44
  attr_reader :definitions
45
+ # The information as to from which osdeps file the current package
46
+ # information in +definitions+ originates. It is a mapping from the
47
+ # package name to the osdeps file' full path
48
+ attr_reader :sources
49
+
50
+ # The Gem::SpecFetcher object that should be used to query RubyGems, and
51
+ # install RubyGems packages
47
52
  def gem_fetcher
48
53
  @gem_fetcher ||= Gem::SpecFetcher.fetcher
49
54
  end
50
55
 
51
- def initialize(defs = Hash.new)
56
+ def initialize(defs = Hash.new, file = nil)
52
57
  @definitions = defs.to_hash
58
+ @sources = Hash.new
59
+ if file
60
+ defs.each_key do |package_name|
61
+ sources[package_name] = file
62
+ end
63
+ end
53
64
  end
54
65
 
66
+ # Returns the full path to the osdeps file from which the package
67
+ # definition for +package_name+ has been taken
68
+ def source_of(package_name)
69
+ sources[package_name]
70
+ end
71
+
72
+ # Merges the osdeps information of +info+ into +self+. If packages are
73
+ # defined in both OSDependencies objects, the information in +info+
74
+ # takes precedence
55
75
  def merge(info)
56
- @definitions = definitions.merge(info.definitions)
76
+ root_dir = nil
77
+ @definitions = definitions.merge(info.definitions) do |h, v1, v2|
78
+ if v1 != v2
79
+ root_dir ||= "#{Autoproj.root_dir}/"
80
+ old = source_of(h).gsub(root_dir, '')
81
+ new = info.source_of(h).gsub(root_dir, '')
82
+ Autoproj.warn("osdeps definition for #{h}, previously defined in #{old} overriden by #{new}")
83
+ end
84
+ v2
85
+ end
86
+ @sources = sources.merge(info.sources)
57
87
  end
58
88
 
59
- def self.verify_definitions(hash = nil)
60
- hash ||= definitions
89
+ # Perform some sanity checks on the given osdeps definitions
90
+ def self.verify_definitions(hash)
61
91
  hash.each do |key, value|
62
92
  if !key.kind_of?(String)
63
93
  raise ArgumentError, "invalid osdeps definition: found an #{key.class}. Don't forget to put quotes around numbers"
@@ -86,6 +116,8 @@ module Autoproj
86
116
  def self.operating_system
87
117
  if @operating_system
88
118
  return @operating_system
119
+ elsif Autoproj.has_config_key?('operating_system')
120
+ @operating_system = Autoproj.user_config('operating_system')
89
121
  elsif data = os_from_lsb
90
122
  if data[0] != "debian"
91
123
  # Fall back to reading debian_version, as
@@ -119,6 +151,8 @@ module Autoproj
119
151
  @operating_system =
120
152
  [@operating_system[0].downcase,
121
153
  @operating_system[1].map(&:downcase)]
154
+ Autoproj.change_option('operating_system', @operating_system, true)
155
+ @operating_system
122
156
  end
123
157
 
124
158
  def self.os_from_lsb
@@ -142,8 +176,8 @@ module Autoproj
142
176
  EOSCRIPT
143
177
 
144
178
  OS_PACKAGE_INSTALL = {
145
- 'debian' => 'apt-get install -y %s',
146
- 'ubuntu' => 'apt-get install -y %s',
179
+ 'debian' => 'export DEBIAN_FRONTEND=noninteractive; apt-get install -y %s',
180
+ 'ubuntu' => 'export DEBIAN_FRONTEND=noninteractive; apt-get install -y %s',
147
181
  'gentoo' => 'emerge --noreplace %s',
148
182
  'arch' => 'pacman -Sy --noconfirm %s'
149
183
  }
@@ -309,8 +343,8 @@ module Autoproj
309
343
  if !osdeps.empty?
310
344
  shell_script = generate_os_script(osdeps)
311
345
  if Autoproj.verbose
312
- STDERR.puts "Installing non-ruby OS dependencies with"
313
- STDERR.puts shell_script
346
+ Autoproj.progress "Installing non-ruby OS dependencies with"
347
+ Autoproj.progress shell_script
314
348
  end
315
349
 
316
350
  File.open('osdeps.sh', 'w') do |file|
@@ -350,8 +384,8 @@ module Autoproj
350
384
  guess_gem_program
351
385
 
352
386
  if Autoproj.verbose
353
- STDERR.puts "Installing rubygems dependencies with"
354
- STDERR.puts "gem install #{gems.join(" ")}"
387
+ Autoproj.progress "Installing rubygems dependencies with"
388
+ Autoproj.progress "gem install #{gems.join(" ")}"
355
389
  end
356
390
  Autobuild.progress "installing/updating RubyGems dependencies: #{gems.join(", ")}"
357
391
  Autobuild::Subprocess.run 'autoproj', 'osdeps', Autobuild.tool('gem'), 'install', *gems
@@ -141,7 +141,7 @@ module Autoproj
141
141
 
142
142
  output = `ldd -r #{name} 2>&1`
143
143
  if output =~ /undefined symbol/
144
- STDERR.puts Autoproj.console.color("WARN: #{name} has undefined symbols", :magenta)
144
+ Autoproj.progress("WARN: #{name} has undefined symbols", :magenta)
145
145
  end
146
146
  end
147
147
  end
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.5.7"
2
+ VERSION = "1.5.8"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 7
9
- version: 1.5.7
8
+ - 8
9
+ version: 1.5.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sylvain Joyeux
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-08 00:00:00 +02:00
17
+ date: 2010-07-15 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -214,6 +214,7 @@ files:
214
214
  - doc/guide/src/writing_manifest.page
215
215
  - lib/autoproj.rb
216
216
  - lib/autoproj/autobuild.rb
217
+ - lib/autoproj/base.rb
217
218
  - lib/autoproj/cmdline.rb
218
219
  - lib/autoproj/default.osdeps
219
220
  - lib/autoproj/manifest.rb