autoproj 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,30 @@
1
+ = Version 1.5.5
2
+ * allow to exclude some packages on some architectures
3
+
4
+ Autobuild files can now contain
5
+ not_on 'os_name1', 'os_name2' do
6
+ ...
7
+ end
8
+ statements that will exclude any package defined in
9
+ the do ... end block if the OS is listed in the OS
10
+ names
11
+
12
+ os_name is either a plain string, in which case it has to be the main
13
+ operating system name (e.g. 'unbuntu', 'debian', ...) or a [name, version]
14
+ array.
15
+
16
+ For instance:
17
+
18
+ not_on 'ubuntu', ['debian', 'squeeze'] do
19
+ cmake_package 'not_on_ubuntu_and_debian_testing'
20
+ end
21
+
22
+ If the user tries to build one of the disabled packages, he will get a proper
23
+ error message.
24
+
25
+ * Debian unstable is now recognized by 'sid' and/or 'unstable'. It previously
26
+ had to be called 'squeeze/sid' (for the current unstable)
27
+
1
28
  = Version 1.5.4
2
29
  * better error message when a dependency does not exist
3
30
 
@@ -140,7 +140,17 @@ module Autoproj
140
140
  end
141
141
  end
142
142
 
143
- def operating_system
143
+ # Autodetects the operating system name and version
144
+ #
145
+ # +osname+ is the operating system name, all in lowercase (e.g. ubuntu,
146
+ # arch, gentoo, debian)
147
+ #
148
+ # +versions+ is a set of names that describe the OS version. It includes
149
+ # both the version number (as a string) and/or the codename if there is
150
+ # one.
151
+ #
152
+ # Examples: ['debian', ['sid', 'unstable']] or ['ubuntu', ['lucid lynx', '10.04']]
153
+ def self.operating_system
144
154
  if @operating_system
145
155
  return @operating_system
146
156
  elsif data = os_from_lsb
@@ -155,17 +165,18 @@ module Autoproj
155
165
  # Need to do some heuristics unfortunately
156
166
  @operating_system =
157
167
  if File.exists?('/etc/debian_version')
158
- codename = File.read('/etc/debian_version').strip
159
- ['debian', [codename]]
168
+ codename = [File.read('/etc/debian_version').strip]
169
+ if codename.first =~ /sid/
170
+ codename << "unstable" << "sid"
171
+ end
172
+ ['debian', codename]
160
173
  elsif File.exists?('/etc/gentoo-release')
161
174
  release_string = File.read('/etc/gentoo-release').strip
162
175
  release_string =~ /^.*([^\s]+)$/
163
176
  version = $1
164
177
  ['gentoo', [version]]
165
178
  elsif File.exists?('/etc/arch-release')
166
- codename = "Unknown"
167
- puts "Found Arch"
168
- ['arch', [codename]]
179
+ ['arch', []]
169
180
  else
170
181
  raise ConfigError, "Unknown operating system"
171
182
  end
@@ -177,7 +188,7 @@ module Autoproj
177
188
  @operating_system[1].map(&:downcase)]
178
189
  end
179
190
 
180
- def os_from_lsb
191
+ def self.os_from_lsb
181
192
  has_lsb_release = `which lsb_release`
182
193
  return unless $?.success?
183
194
 
@@ -209,7 +220,7 @@ module Autoproj
209
220
  #
210
221
  # Raises ConfigError if some packages can't be found
211
222
  def resolve_os_dependencies(dependencies)
212
- os_name, os_version = operating_system
223
+ os_name, os_version = OSDependencies.operating_system
213
224
  if !OS_PACKAGE_INSTALL.has_key?(os_name)
214
225
  raise ConfigError, "I don't know how to install packages on #{os_name}"
215
226
  end
@@ -61,7 +61,7 @@ line, instead of package names:
61
61
  autoproj build lib
62
62
  {: .commandline}
63
63
 
64
- Removing packages from the build
64
+ Removing packages from the build (<tt>exclude_packages</tt>) {#exclude_packages}
65
65
  --------------------------------
66
66
  Instead of having to list all packages that you do want to build, it is possible
67
67
  to list the packages that you don't want to build. Simply list them in the
@@ -76,7 +76,10 @@ exclude_packages:
76
76
  - pocosim-log
77
77
  {coderay}
78
78
 
79
- Using packages that are already installed
79
+ If another package, that should be built, depends on an excluded package, [an
80
+ error is generated](error_messages.html#exclusions)
81
+
82
+ Using packages that are already installed (<tt>ignore_packages</tt>)
80
83
  -----------------------------------------
81
84
 
82
85
  If some packages are already installed elsewhere, and you want to use that
@@ -95,10 +98,10 @@ ignore_packages:
95
98
  - orocos/rtt
96
99
  {coderay}
97
100
 
98
- This differs from the <tt>exclude_packages</tt> mechanism: packages listed in
99
- <tt>ignore_packages</tt> are assumed to be present even though autoproj does not manage
100
- them, while packages in <tt>exclude_packages</tt> are assumed to be absent and therefore
101
- issue an error if another package in the installation depend on them.
101
+ Unlike with <tt>exclude_packages</tt>, no error is generated for ignored
102
+ packages that are depended-upon by other packages in the build. This is because
103
+ ignore_packages is meant to list packages that are already installed outside of
104
+ autoproj, while exclude_packages lists what you do **not** want to have at all.
102
105
 
103
106
  Local overrides of version control information
104
107
  ----------------------------------------------
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Understanding autoproj error messages
3
- sort_info: 800
3
+ sort_info: 90
4
4
  ---
5
5
 
6
6
  I know nothing about a prepackaged package called 'XXXX', ...
@@ -15,3 +15,23 @@ manifest.xml](package_sets/manifest-xml.html) file. (ii)
15
15
  the package should depend on it and you should list the OS package in [the
16
16
  relevant osdeps file](package_sets/osdeps.html)
17
17
 
18
+ XXX depends on YYY, which is excluded from the build {#exclusions}
19
+ ----------------------------------------------------
20
+
21
+ The layout requires the XXX package to be built, but this package depends on YYY
22
+ and YYY has explicitely been excluded from the build.
23
+
24
+ There are two cases.
25
+
26
+ In the first case, the package has been listed in [the exclude_packages section
27
+ of autoproj/manifest](customization.html#exclude_packages). So, you will have to
28
+ find out why and either remove it from there, or add XXX to the same section.
29
+
30
+ In the second case, the package is disabled on your operating system version.
31
+ This is done in the package set's autobuild files by using the [not_on and
32
+ only_on statements](package_sets/autobuild.html#not_on_and_only_on). You will
33
+ have to either exclude the XXX package as well (either by including it in the
34
+ same not_on/only_on block, or by adding it to [the exclude_packages section
35
+ of autoproj/manifest](customization.html#exclude_packages)), or to make it so
36
+ that YYY builds on your OS, an thus remove it from the not_on/only_on block.
37
+
@@ -112,6 +112,44 @@ The 'pkg' variable in the example above is an instance of
112
112
  [Autobuild::Orogen](http://doudou.github.com/autobuild/Autobuild/Orogen.html)
113
113
  {: .block}
114
114
 
115
+ OS-specific bits (<tt>not_on</tt> and <tt>only_on</tt>) {#not_on_and_only_on}
116
+ ----------------
117
+ It is possible to have some parts of the autobuild file be OS-specific. Two
118
+ calls are made available for that.
119
+
120
+ First, if you know that some packages should not be built on some operating
121
+ systems, you should enclose their declaration in a 'not_on' statement. For
122
+ instance:
123
+
124
+ {coderay:: ruby}
125
+ not_on 'debian' do
126
+ cmake_package 'excluded_package'
127
+ end
128
+ {coderay}
129
+
130
+ It is additionally possible to select specific versions
131
+
132
+ {coderay:: ruby}
133
+ not_on 'debian', ['ubuntu', '10.04'] do
134
+ cmake_package 'excluded_package'
135
+ end
136
+ {coderay}
137
+
138
+ If, on the other hand, you want some bits to be available only **on** a specific
139
+ OS, use the only_on statement:
140
+
141
+ {coderay:: ruby}
142
+ only_on ['ubuntu', '10.04'] do
143
+ cmake_package 'only_ubuntu'
144
+ end
145
+ {coderay}
146
+
147
+ If the user tries to build a package that is excluded on his architecture, he
148
+ will get the following error message:
149
+
150
+ modules/dynamixel depends on drivers/dynamixel, which is excluded from the build: drivers/dynamixel is disabled on this operating system
151
+ {: .cmdline}
152
+
115
153
  Custom package building
116
154
  -----------------------
117
155
 
@@ -312,6 +312,41 @@ def orogen_package(options, &block)
312
312
  end
313
313
  end
314
314
 
315
+ # Declare that the packages declared in the block should not be built in the
316
+ # given operating system. OS descriptions are space-separated strings containing
317
+ # OS name and version.
318
+ #
319
+ # An error will occur if the user tries to build it on one of those
320
+ # architectures
321
+ def not_on(*architectures)
322
+ architectures = architectures.map do |name|
323
+ if name.respond_to?(:to_str)
324
+ [name]
325
+ else name
326
+ end
327
+ end
328
+
329
+ os = OSDependencies.operating_system
330
+ matching_archs = architectures.find_all { |arch| arch[0] == os[0] }
331
+ STDERR.puts matching_archs.inspect
332
+ if matching_archs.empty?
333
+ return yield
334
+ elsif matching_archs.all? { |arch| arch[1] && !os[1].include?(arch[1].downcase) }
335
+ return yield
336
+ end
337
+
338
+ # Simply get the current list of packages, yield the block, and exclude all
339
+ # packages that have been added
340
+ current_packages = Autobuild::Package.each(true).map(&:last).map(&:name).to_set
341
+ yield
342
+ new_packages = Autobuild::Package.each(true).map(&:last).map(&:name).to_set -
343
+ current_packages
344
+
345
+ new_packages.each do |pkg_name|
346
+ Autoproj.manifest.add_exclusion(pkg_name, "#{pkg_name} is disabled on this operating system")
347
+ end
348
+ end
349
+
315
350
  # Defines an import-only package, i.e. a package that is simply checked out but
316
351
  # not built in any way
317
352
  def source_package(options)
@@ -304,8 +304,8 @@ module Autoproj
304
304
  # them to the selected_packages set so that they get
305
305
  # imported as well
306
306
  pkg.dependencies.each do |dep_name|
307
- if Autoproj.manifest.excluded?(dep_name)
308
- raise ConfigError, "#{pkg.name} depends on #{dep_name}, which is explicitely excluded in the manifest"
307
+ if reason = Autoproj.manifest.exclusion_reason(dep_name)
308
+ raise ConfigError, "#{pkg.name} depends on #{dep_name}, which is excluded from the build: #{reason}"
309
309
  end
310
310
  dep_pkg = Autobuild::Package[dep_name]
311
311
  if !dep_pkg
@@ -440,6 +440,15 @@ where 'mode' is one of:
440
440
  opts.on("--[no-]update", "[do not] update already checked-out packages (build modes only)") do |value|
441
441
  do_update = value
442
442
  end
443
+ opts.on("--os", "displays the operating system as detected by autoproj") do
444
+ os = OSDependencies.operating_system
445
+ puts "name: #{os[0]}"
446
+ puts "version:"
447
+ os[1].each do |version_name|
448
+ puts " #{version_name}"
449
+ end
450
+ exit 0
451
+ end
443
452
 
444
453
  opts.on("--[no-]osdeps", "[do not] install prepackaged dependencies (build and update modes only)") do |value|
445
454
  update_os_dependencies = value
@@ -204,6 +204,13 @@ module Autoproj
204
204
  !File.exists?(File.join(raw_local_dir, "init.rb"))
205
205
  end
206
206
 
207
+ # Remote sources can be accessed through a hidden directory in
208
+ # $AUTOPROJ_ROOT/.remotes, or through a symbolic link in
209
+ # autoproj/remotes/
210
+ #
211
+ # This returns the former. See #user_local_dir for the latter.
212
+ #
213
+ # For local sources, is simply returns the path to the source directory.
207
214
  def raw_local_dir
208
215
  if local?
209
216
  return vcs.url
@@ -212,6 +219,13 @@ module Autoproj
212
219
  end
213
220
  end
214
221
 
222
+ # Remote sources can be accessed through a hidden directory in
223
+ # $AUTOPROJ_ROOT/.remotes, or through a symbolic link in
224
+ # autoproj/remotes/
225
+ #
226
+ # This returns the latter. See #raw_local_dir for the former.
227
+ #
228
+ # For local sources, is simply returns the path to the source directory.
215
229
  def user_local_dir
216
230
  if local?
217
231
  return vcs.url
@@ -247,6 +261,10 @@ module Autoproj
247
261
  end
248
262
  end
249
263
 
264
+ # Loads the source.yml file, validates it and returns it as a hash
265
+ #
266
+ # Raises InternalError if the source has not been checked out yet (it
267
+ # should have), and ConfigError if the source.yml file is not valid.
250
268
  def raw_description_file
251
269
  if !present?
252
270
  raise InternalError, "source #{vcs} has not been fetched yet, cannot load description for it"
@@ -284,6 +302,7 @@ module Autoproj
284
302
  rescue InternalError
285
303
  end
286
304
 
305
+ # Path to the source.yml file
287
306
  def source_file
288
307
  File.join(local_dir, 'source.yml')
289
308
  end
@@ -357,7 +376,8 @@ module Autoproj
357
376
  data
358
377
  end
359
378
 
360
- # Returns the default importer for this package set
379
+ # Returns the default importer definition for this package set, as a
380
+ # VCSDefinition instance
361
381
  def default_importer
362
382
  importer_definition_for('default')
363
383
  end
@@ -452,13 +472,19 @@ module Autoproj
452
472
  raise ConfigError, "#{e.message} in #{source_file}", e.backtrace
453
473
  end
454
474
 
475
+ # Returns the VCS definition for +package_name+ as defined in this
476
+ # source, or nil if the source does not have any.
477
+ #
478
+ # The definition is an instance of VCSDefinition
455
479
  def importer_definition_for(package_name)
456
- vcs_spec = version_control_field(package_name, 'version_control_field')
480
+ vcs_spec = version_control_field(package_name, 'version_control')
457
481
  if vcs_spec
458
482
  Autoproj.normalize_vcs_definition(vcs_spec)
459
483
  end
460
484
  end
461
485
 
486
+ # Enumerates the Autobuild::Package instances that are defined in this
487
+ # source
462
488
  def each_package
463
489
  if !block_given?
464
490
  return enum_for(:each_package)
@@ -472,6 +498,7 @@ module Autoproj
472
498
  end
473
499
  end
474
500
 
501
+ # Specialization of the Source class for the overrides listed in autoproj/
475
502
  class LocalSource < Source
476
503
  def initialize
477
504
  super(Autoproj.normalize_vcs_definition(:type => 'local', :url => Autoproj.config_dir))
@@ -511,8 +538,16 @@ module Autoproj
511
538
 
512
539
  PackageDefinition = Struct.new :autobuild, :user_block, :package_set, :file
513
540
 
541
+ # The Manifest class represents the information included in the main
542
+ # manifest file, and allows to manipulate it
514
543
  class Manifest
515
544
  FakePackage = Struct.new :text_name, :name, :srcdir, :importer, :updated
545
+
546
+ # Data structure used to use autobuild importers without a package, to
547
+ # import configuration data.
548
+ #
549
+ # It has to match the interface of Autobuild::Package that is relevant
550
+ # for importers
516
551
  class FakePackage
517
552
  def autoproj_name; name end
518
553
  def import
@@ -543,6 +578,8 @@ module Autoproj
543
578
  explicit_selection && explicit_selection.include?(pkg_name)
544
579
  end
545
580
 
581
+ # Loads the manifest file located at +file+ and returns the Manifest
582
+ # instance that represents it
546
583
  def self.load(file)
547
584
  begin
548
585
  data = YAML.load(File.read(file))
@@ -564,8 +601,11 @@ module Autoproj
564
601
  # A mapping from package names into PackageManifest objects
565
602
  attr_reader :package_manifests
566
603
 
604
+ # The path to the manifest file that has been loaded
567
605
  attr_reader :file
568
606
 
607
+ # True if autoproj should run an update automatically when the user
608
+ # uses" build"
569
609
  def auto_update?
570
610
  !!data['auto_update']
571
611
  end
@@ -575,6 +615,7 @@ module Autoproj
575
615
  @data = data
576
616
  @packages = Hash.new
577
617
  @package_manifests = Hash.new
618
+ @automatic_exclusions = Hash.new
578
619
 
579
620
  if Autoproj.has_config_key?('manifest_source')
580
621
  @vcs = Autoproj.normalize_vcs_definition(Autoproj.user_config('manifest_source'))
@@ -592,14 +633,47 @@ module Autoproj
592
633
  false
593
634
  end
594
635
  end
636
+
637
+ # The set of package names that are listed in the excluded_packages
638
+ # section of the manifest
639
+ def manifest_exclusions
640
+ data['exclude_packages'] || Set.new
641
+ end
642
+
643
+ # A package_name => reason map of the exclusions added with #add_exclusion.
644
+ # Exclusions listed in the manifest file are returned by #manifest_exclusions
645
+ attr_reader :automatic_exclusions
646
+
647
+ # Exclude +package_name+ from the build. +reason+ is a string describing
648
+ # why the package is to be excluded.
649
+ def add_exclusion(package_name, reason)
650
+ automatic_exclusions[package_name] = reason
651
+ end
652
+
653
+ # If +package_name+ is excluded from the build, returns a string that
654
+ # tells why. Otherwise, returns nil
655
+ #
656
+ # Packages can either be excluded because their name is listed in the
657
+ # excluded_packages section of the manifest, or because they are
658
+ # disabled on this particular operating system.
659
+ def exclusion_reason(package_name)
660
+ if manifest_exclusions.any? { |l| Regexp.new(l) =~ package_name }
661
+ "#{package_name} is listed in the excluded_packages section of the manifest"
662
+ else
663
+ automatic_exclusions[package_name]
664
+ end
665
+ end
666
+
595
667
  # True if the given package should not be built and its dependencies
596
668
  # should be considered as met.
597
669
  #
598
670
  # This is useful to avoid building packages that are of no use for the
599
671
  # user.
600
672
  def excluded?(package_name)
601
- if data['exclude_packages']
602
- data['exclude_packages'].any? { |l| Regexp.new(l) =~ package_name }
673
+ if manifest_exclusions.any? { |l| Regexp.new(l) =~ package_name }
674
+ true
675
+ elsif automatic_exclusions.any? { |pkg_name, | pkg_name == package_name }
676
+ true
603
677
  else
604
678
  false
605
679
  end
@@ -631,6 +705,7 @@ module Autoproj
631
705
  end
632
706
  end
633
707
 
708
+ # Yields each osdeps definition files that are present in our sources
634
709
  def each_osdeps_file
635
710
  if !block_given?
636
711
  return enum_for(:each_source_file)
@@ -643,6 +718,7 @@ module Autoproj
643
718
  end
644
719
  end
645
720
 
721
+ # True if some of the sources are remote sources
646
722
  def has_remote_sources?
647
723
  each_remote_source(false).any? { true }
648
724
  end
@@ -73,7 +73,17 @@ module Autoproj
73
73
  end
74
74
  end
75
75
 
76
- def operating_system
76
+ # Autodetects the operating system name and version
77
+ #
78
+ # +osname+ is the operating system name, all in lowercase (e.g. ubuntu,
79
+ # arch, gentoo, debian)
80
+ #
81
+ # +versions+ is a set of names that describe the OS version. It includes
82
+ # both the version number (as a string) and/or the codename if there is
83
+ # one.
84
+ #
85
+ # Examples: ['debian', ['sid', 'unstable']] or ['ubuntu', ['lucid lynx', '10.04']]
86
+ def self.operating_system
77
87
  if @operating_system
78
88
  return @operating_system
79
89
  elsif data = os_from_lsb
@@ -88,17 +98,18 @@ module Autoproj
88
98
  # Need to do some heuristics unfortunately
89
99
  @operating_system =
90
100
  if File.exists?('/etc/debian_version')
91
- codename = File.read('/etc/debian_version').strip
92
- ['debian', [codename]]
101
+ codename = [File.read('/etc/debian_version').strip]
102
+ if codename.first =~ /sid/
103
+ codename << "unstable" << "sid"
104
+ end
105
+ ['debian', codename]
93
106
  elsif File.exists?('/etc/gentoo-release')
94
107
  release_string = File.read('/etc/gentoo-release').strip
95
108
  release_string =~ /^.*([^\s]+)$/
96
109
  version = $1
97
110
  ['gentoo', [version]]
98
111
  elsif File.exists?('/etc/arch-release')
99
- codename = "Unknown"
100
- puts "Found Arch"
101
- ['arch', [codename]]
112
+ ['arch', []]
102
113
  else
103
114
  raise ConfigError, "Unknown operating system"
104
115
  end
@@ -110,7 +121,7 @@ module Autoproj
110
121
  @operating_system[1].map(&:downcase)]
111
122
  end
112
123
 
113
- def os_from_lsb
124
+ def self.os_from_lsb
114
125
  has_lsb_release = `which lsb_release`
115
126
  return unless $?.success?
116
127
 
@@ -142,7 +153,7 @@ module Autoproj
142
153
  #
143
154
  # Raises ConfigError if some packages can't be found
144
155
  def resolve_os_dependencies(dependencies)
145
- os_name, os_version = operating_system
156
+ os_name, os_version = OSDependencies.operating_system
146
157
  if !OS_PACKAGE_INSTALL.has_key?(os_name)
147
158
  raise ConfigError, "I don't know how to install packages on #{os_name}"
148
159
  end
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.5.4"
2
+ VERSION = "1.5.5"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 4
9
- version: 1.5.4
8
+ - 5
9
+ version: 1.5.5
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-06-15 00:00:00 +02:00
17
+ date: 2010-06-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency