autoproj 1.9.6 → 1.9.7.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,7 +105,7 @@ module Autoproj
105
105
 
106
106
  # Run the provided command as root, using sudo to gain root access
107
107
  def self.run_as_root(*args)
108
- if !system('sudo', *args)
108
+ if !system(Autobuild.tool_in_path('sudo'), *args)
109
109
  raise "failed to run #{args.join(" ")} as root"
110
110
  end
111
111
  end
@@ -0,0 +1,107 @@
1
+ module Autoproj
2
+ # Expand build options in +value+.
3
+ #
4
+ # The method will expand in +value+ patterns of the form $NAME, replacing
5
+ # them with the corresponding build option.
6
+ def self.expand_environment(value)
7
+ # Perform constant expansion on the defined environment variables,
8
+ # including the option set
9
+ options = Autoproj.option_set
10
+ options.each_key do |k|
11
+ options[k] = options[k].to_s
12
+ end
13
+ options = options.merge(option_overrides)
14
+
15
+ loop do
16
+ new_value = Autoproj.single_expansion(value, options)
17
+ if new_value == value
18
+ break
19
+ else
20
+ value = new_value
21
+ end
22
+ end
23
+ value
24
+ end
25
+
26
+ # Does a non-recursive expansion in +data+ of configuration variables
27
+ # ($VAR_NAME) listed in +definitions+
28
+ #
29
+ # If the values listed in +definitions+ also contain configuration
30
+ # variables, they do not get expanded
31
+ def self.single_expansion(data, definitions)
32
+ if !data.respond_to?(:to_str)
33
+ return data
34
+ end
35
+ definitions = { 'HOME' => ENV['HOME'] }.merge(definitions)
36
+
37
+ data = data.gsub /(.|^)\$(\w+)/ do |constant_name|
38
+ prefix = constant_name[0, 1]
39
+ if prefix == "\\"
40
+ next(constant_name[1..-1])
41
+ end
42
+ if prefix == "$"
43
+ prefix, constant_name = "", constant_name[1..-1]
44
+ else
45
+ constant_name = constant_name[2..-1]
46
+ end
47
+
48
+ if !(value = definitions[constant_name])
49
+ if !(value = Autoproj.user_config(constant_name))
50
+ if !block_given? || !(value = yield(constant_name))
51
+ raise ArgumentError, "cannot find a definition for $#{constant_name}"
52
+ end
53
+ end
54
+ end
55
+ "#{prefix}#{value}"
56
+ end
57
+ data
58
+ end
59
+
60
+ # Expand constants within +value+
61
+ #
62
+ # The list of constants is given in +definitions+. It raises ConfigError if
63
+ # some values are not found
64
+ def self.expand(value, definitions = Hash.new)
65
+ if value.respond_to?(:to_hash)
66
+ value.dup.each do |name, definition|
67
+ value[name] = expand(definition, definitions)
68
+ end
69
+ value
70
+ elsif value.respond_to?(:to_ary)
71
+ value.map { |val| expand(val, definitions) }
72
+ else
73
+ value = single_expansion(value, definitions)
74
+ if contains_expansion?(value)
75
+ raise ConfigError.new, "some expansions are not defined in #{value.inspect}"
76
+ end
77
+ value
78
+ end
79
+ end
80
+
81
+ # True if the given string contains expansions
82
+ def self.contains_expansion?(string); string =~ /\$/ end
83
+
84
+ def self.resolve_one_constant(name, value, result, definitions)
85
+ result[name] = single_expansion(value, result) do |missing_name|
86
+ result[missing_name] = resolve_one_constant(missing_name, definitions.delete(missing_name), result, definitions)
87
+ end
88
+ end
89
+
90
+ # Resolves all possible variable references from +constants+
91
+ #
92
+ # I.e. replaces variables by their values, so that no value in +constants+
93
+ # refers to variables defined in +constants+
94
+ def self.resolve_constant_definitions(constants)
95
+ constants = constants.dup
96
+ constants['HOME'] = ENV['HOME']
97
+
98
+ result = Hash.new
99
+ while !constants.empty?
100
+ name = constants.keys.first
101
+ value = constants.delete(name)
102
+ resolve_one_constant(name, value, result, constants)
103
+ end
104
+ result
105
+ end
106
+ end
107
+
@@ -0,0 +1,223 @@
1
+ module Autoproj
2
+ # Representation of a VCS definition contained in a source.yml file or in
3
+ # autoproj/manifest
4
+ class VCSDefinition
5
+ attr_reader :type
6
+ attr_reader :url
7
+ attr_reader :options
8
+
9
+ # The original spec in hash form. Set if this VCSDefinition object has
10
+ # been created using VCSDefinition.from_raw
11
+ attr_reader :raw
12
+
13
+ def initialize(type, url, options, raw = nil)
14
+ if raw && !raw.respond_to?(:to_ary)
15
+ raise ArgumentError, "wrong format for the raw field (#{raw.inspect})"
16
+ end
17
+
18
+ @type, @url, @options = type, url, options
19
+ if type != "none" && type != "local" && !Autobuild.respond_to?(type)
20
+ raise ConfigError.new, "version control #{type} is unknown to autoproj"
21
+ end
22
+ @raw = raw
23
+ end
24
+
25
+ def local?
26
+ @type == 'local'
27
+ end
28
+
29
+ def to_hash
30
+ Hash[:type => type, :url => url].merge(options)
31
+ end
32
+
33
+ # Updates the VCS specification +old+ by the information contained in
34
+ # +new+
35
+ #
36
+ # Both +old+ and +new+ are supposed to be in hash form. It is assumed
37
+ # that +old+ has already been normalized by a call to
38
+ # Autoproj.vcs_definition_to_hash. +new+ can be in "raw" form.
39
+ def self.update_raw_vcs_spec(old, new)
40
+ new = vcs_definition_to_hash(new)
41
+ if new.has_key?(:type) && (old[:type] != new[:type])
42
+ # The type changed. We replace the old definition by the new one
43
+ # completely, and we make sure that the new definition is valid
44
+ from_raw(new)
45
+ new
46
+ else
47
+ old.merge(new)
48
+ end
49
+ end
50
+
51
+ # Normalizes a VCS definition contained in a YAML file into a hash
52
+ #
53
+ # It handles custom source handler expansion, as well as the bad habit
54
+ # of forgetting a ':' at the end of a line:
55
+ #
56
+ # - package_name
57
+ # branch: value
58
+ def self.vcs_definition_to_hash(spec)
59
+ options = Hash.new
60
+
61
+ plain = Array.new
62
+ filtered_spec = Hash.new
63
+ spec.each do |key, value|
64
+ keys = key.to_s.split(/\s+/)
65
+ plain.concat(keys[0..-2])
66
+ filtered_spec[keys[-1].to_sym] = value
67
+ end
68
+ spec = filtered_spec
69
+
70
+ if plain.size > 1
71
+ raise ConfigError.new, "invalid syntax"
72
+ elsif plain.size == 1
73
+ short_url = plain.first
74
+ vcs, *url = short_url.split(':')
75
+
76
+ # Check if VCS is a known version control system or source handler
77
+ # shortcut. If it is not, look for a local directory called
78
+ # short_url
79
+ if Autobuild.respond_to?(vcs)
80
+ spec.merge!(:type => vcs, :url => url.join(':'))
81
+ elsif Autoproj.has_source_handler?(vcs)
82
+ spec = Autoproj.call_source_handler(vcs, url.join(':'), spec)
83
+ else
84
+ source_dir = File.expand_path(File.join(Autoproj.config_dir, short_url))
85
+ if !File.directory?(source_dir)
86
+ raise ConfigError.new, "'#{spec.inspect}' is neither a remote source specification, nor a local source definition"
87
+ end
88
+ spec.merge!(:type => 'local', :url => source_dir)
89
+ end
90
+ end
91
+
92
+ spec, vcs_options = Kernel.filter_options spec, :type => nil, :url => nil
93
+ spec.merge!(vcs_options)
94
+ if !spec[:url]
95
+ # Verify that none of the keys are source handlers. If it is the
96
+ # case, convert
97
+ filtered_spec = Hash.new
98
+ spec.dup.each do |key, value|
99
+ if Autoproj.has_source_handler?(key)
100
+ spec.delete(key)
101
+ spec = Autoproj.call_source_handler(key, value, spec)
102
+ break
103
+ end
104
+ end
105
+ end
106
+
107
+ spec
108
+ end
109
+
110
+ # Autoproj configuration files accept VCS definitions in three forms:
111
+ # * as a plain string, which is a relative/absolute path
112
+ # * as a plain string, which is a vcs_type:url string
113
+ # * as a hash
114
+ #
115
+ # This method returns the VCSDefinition object matching one of these
116
+ # specs. It raises ConfigError if there is no type and/or url
117
+ def self.from_raw(spec, raw_spec = [[nil, spec]])
118
+ spec = vcs_definition_to_hash(spec)
119
+ if !(spec[:type] && (spec[:type] == 'none' || spec[:url]))
120
+ raise ConfigError.new, "the source specification #{spec.inspect} misses either the VCS type or an URL"
121
+ end
122
+
123
+ spec, vcs_options = Kernel.filter_options spec, :type => nil, :url => nil
124
+ return VCSDefinition.new(spec[:type], spec[:url], vcs_options, raw_spec)
125
+ end
126
+
127
+ def ==(other_vcs)
128
+ return false if !other_vcs.kind_of?(VCSDefinition)
129
+ if local?
130
+ other_vcs.local? && url == other.url
131
+ elsif !other_vcs.local?
132
+ this_importer = create_autobuild_importer
133
+ other_importer = other_vcs.create_autobuild_importer
134
+ this_importer.repository_id == other_importer.repository_id
135
+ end
136
+ end
137
+
138
+ def self.to_absolute_url(url, root_dir = nil)
139
+ # NOTE: we MUST use nil as default argument of root_dir as we don't
140
+ # want to call Autoproj.root_dir unless completely necessary
141
+ # (to_absolute_url might be called on installations that are being
142
+ # bootstrapped, and as such don't have a root dir yet).
143
+ url = Autoproj.single_expansion(url, 'HOME' => ENV['HOME'])
144
+ if url && url !~ /^(\w+:\/)?\/|^[:\w]+\@|^(\w+\@)?[\w\.-]+:/
145
+ url = File.expand_path(url, root_dir || Autoproj.root_dir)
146
+ end
147
+ url
148
+ end
149
+
150
+ # Returns a properly configured instance of a subclass of
151
+ # Autobuild::Importer that match this VCS definition
152
+ #
153
+ # Returns nil if the VCS type is 'none'
154
+ def create_autobuild_importer
155
+ return if type == "none"
156
+
157
+ url = VCSDefinition.to_absolute_url(self.url)
158
+ Autobuild.send(type, url, options)
159
+ end
160
+
161
+ # Returns a pretty representation of this VCS definition
162
+ def to_s
163
+ if type == "none"
164
+ "none"
165
+ else
166
+ desc = "#{type}:#{url}"
167
+ if !options.empty?
168
+ desc = "#{desc} #{options.to_a.sort_by { |key, _| key.to_s }.map { |key, value| "#{key}=#{value}" }.join(" ")}"
169
+ end
170
+ desc
171
+ end
172
+ end
173
+ end
174
+
175
+ @custom_source_handlers = Hash.new
176
+
177
+ # Returns true if +vcs+ refers to a source handler name added by
178
+ # #add_source_handler
179
+ def self.has_source_handler?(vcs)
180
+ @custom_source_handlers.has_key?(vcs.to_s)
181
+ end
182
+
183
+ # Returns the source handlers associated with +vcs+
184
+ #
185
+ # Source handlers are added by Autoproj.add_source_handler. The returned
186
+ # value is an object that responds to #call(url, options) and return a VCS
187
+ # definition as a hash
188
+ def self.call_source_handler(vcs, url, options)
189
+ handler = @custom_source_handlers[vcs.to_s]
190
+ if !handler
191
+ raise ArgumentError, "there is no source handler for #{vcs}"
192
+ else
193
+ return handler.call(url, options)
194
+ end
195
+ end
196
+
197
+ # call-seq:
198
+ # Autoproj.add_source_handler name do |url, options|
199
+ # # build a hash that represent source configuration
200
+ # # and return it
201
+ # end
202
+ #
203
+ # Add a custom source handler named +name+
204
+ #
205
+ # Custom source handlers are shortcuts that can be used to represent VCS
206
+ # information. For instance, the gitorious_server_configuration method
207
+ # defines a source handler that allows to easily add new gitorious packages:
208
+ #
209
+ # gitorious_server_configuration 'GITORIOUS', 'gitorious.org'
210
+ #
211
+ # defines the "gitorious" source handler, which allows people to write
212
+ #
213
+ #
214
+ # version_control:
215
+ # - tools/orocos.rb
216
+ # gitorious: rock-toolchain/orocos-rb
217
+ # branch: test
218
+ #
219
+ #
220
+ def self.add_source_handler(name, &handler)
221
+ @custom_source_handlers[name.to_s] = lambda(&handler)
222
+ end
223
+ end
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.9.6"
2
+ VERSION = "1.9.7.rc1"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.6
5
- prerelease:
4
+ version: 1.9.7.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rock Core Developers
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-05 00:00:00.000000000 Z
12
+ date: 2014-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autobuild
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: '3.7'
85
+ version: '3.12'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: '3.7'
93
+ version: '3.12'
94
94
  description: autoproj is a manager for sets of software packages. It allows the user
95
95
  to import and build packages from source, still using the underlying distribution's
96
96
  native package manager for software that is available on it.
@@ -102,13 +102,17 @@ executables:
102
102
  - autolocate
103
103
  - autoproj
104
104
  - autoproj-bootstrap
105
+ - autoproj-cache
105
106
  - autoproj-clean
106
107
  - autoproj-create-set
108
+ - autoproj-doc
107
109
  - autoproj-envsh
108
110
  - autoproj-list
109
111
  - autoproj-locate
110
112
  - autoproj-query
111
113
  - autoproj-show
114
+ - autoproj-snapshot
115
+ - autoproj-test
112
116
  - autoproj_bootstrap
113
117
  - autoproj_bootstrap.in
114
118
  - autoproj_stress_test
@@ -129,13 +133,17 @@ files:
129
133
  - bin/autolocate
130
134
  - bin/autoproj
131
135
  - bin/autoproj-bootstrap
136
+ - bin/autoproj-cache
132
137
  - bin/autoproj-clean
133
138
  - bin/autoproj-create-set
139
+ - bin/autoproj-doc
134
140
  - bin/autoproj-envsh
135
141
  - bin/autoproj-list
136
142
  - bin/autoproj-locate
137
143
  - bin/autoproj-query
138
144
  - bin/autoproj-show
145
+ - bin/autoproj-snapshot
146
+ - bin/autoproj-test
139
147
  - bin/autoproj_bootstrap
140
148
  - bin/autoproj_bootstrap.in
141
149
  - bin/autoproj_stress_test
@@ -144,14 +152,24 @@ files:
144
152
  - lib/autoproj/base.rb
145
153
  - lib/autoproj/cmdline.rb
146
154
  - lib/autoproj/default.osdeps
155
+ - lib/autoproj/environment.rb
147
156
  - lib/autoproj/gitorious.rb
157
+ - lib/autoproj/installation_manifest.rb
158
+ - lib/autoproj/loader.rb
148
159
  - lib/autoproj/manifest.rb
160
+ - lib/autoproj/metapackage.rb
149
161
  - lib/autoproj/options.rb
150
162
  - lib/autoproj/osdeps.rb
163
+ - lib/autoproj/package_definition.rb
164
+ - lib/autoproj/package_manifest.rb
165
+ - lib/autoproj/package_selection.rb
166
+ - lib/autoproj/package_set.rb
151
167
  - lib/autoproj/query.rb
152
168
  - lib/autoproj/system.rb
153
169
  - lib/autoproj/templates/create-set/packages.autobuild
154
170
  - lib/autoproj/templates/create-set/source.yml
171
+ - lib/autoproj/variable_expansion.rb
172
+ - lib/autoproj/vcs_definition.rb
155
173
  - lib/autoproj/version.rb
156
174
  - samples/autoproj/README.txt
157
175
  - samples/autoproj/init.rb
@@ -172,11 +190,11 @@ files:
172
190
  - test/package_managers/apt-dpkg-status.noninstalled-last
173
191
  - test/package_managers/test_apt_dpkg_manager.rb
174
192
  - test/package_managers/test_gem.rb
193
+ - test/package_managers/test_pip.rb
175
194
  - test/test_debian.rb
176
195
  - test/test_manifest.rb
177
196
  - test/test_os_dependencies.rb
178
197
  - test/test_package_manifest.rb
179
- - test/package_managers/test_pip.rb
180
198
  - .gemtest
181
199
  homepage: http://rock-robotics.org/documentation/autoproj
182
200
  licenses:
@@ -192,15 +210,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
210
  requirements:
193
211
  - - ! '>='
194
212
  - !ruby/object:Gem::Version
195
- version: '0'
213
+ version: 1.9.2
196
214
  required_rubygems_version: !ruby/object:Gem::Requirement
197
215
  none: false
198
216
  requirements:
199
- - - ! '>='
217
+ - - ! '>'
200
218
  - !ruby/object:Gem::Version
201
- version: '0'
219
+ version: 1.3.1
202
220
  requirements: []
203
- rubyforge_project: autobuild
221
+ rubyforge_project:
204
222
  rubygems_version: 1.8.23
205
223
  signing_key:
206
224
  specification_version: 3