autoproj 1.3.4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,13 +17,26 @@ end
17
17
 
18
18
  module Autoproj
19
19
  @build_system_dependencies = Set.new
20
+
21
+ # Declare OS packages that are required to import and build the packages
22
+ #
23
+ # It is used by autoproj itself to install the importers and/or the build
24
+ # systems for the packages.
20
25
  def self.add_build_system_dependency(*names)
21
26
  @build_system_dependencies |= names.to_set
22
27
  end
23
28
  class << self
29
+ # Returns the set of OS packages that are needed to build and/or import
30
+ # the packages
31
+ #
32
+ # See Autoproj.add_build_system_dependency
24
33
  attr_reader :build_system_dependencies
25
34
  end
26
35
 
36
+ # Expand build options in +value+.
37
+ #
38
+ # The method will expand in +value+ patterns of the form $NAME, replacing
39
+ # them with the corresponding build option.
27
40
  def self.expand_environment(value)
28
41
  # Perform constant expansion on the defined environment variables,
29
42
  # including the option set
@@ -44,14 +57,22 @@ module Autoproj
44
57
  end
45
58
 
46
59
  @env_inherit = Set.new
60
+ # Returns true if the given environment variable must not be reset by the
61
+ # env.sh script, but that new values should simply be prepended to it.
62
+ #
63
+ # See Autoproj.env_inherit
47
64
  def self.env_inherit?(name)
48
65
  @env_inherit.include?(name)
49
66
  end
67
+ # Declare that the given environment variable must not be reset by the
68
+ # env.sh script, but that new values should simply be prepended to it.
69
+ #
70
+ # See Autoproj.env_inherit?
50
71
  def self.env_inherit(*names)
51
72
  @env_inherit |= names
52
73
  end
53
74
 
54
- # Set a new environment variable
75
+ # Resets the value of the given environment variable to the given
55
76
  def self.env_set(name, *value)
56
77
  Autobuild.env_clear(name)
57
78
  env_add(name, *value)
@@ -375,7 +396,11 @@ module Autoproj
375
396
  end
376
397
 
377
398
  if !vcs_spec.empty?
378
- expansions = Hash["PACKAGE" => package_name, "PACKAGE_BASENAME" => File.basename(package_name)]
399
+ expansions = Hash["PACKAGE" => package_name,
400
+ "PACKAGE_BASENAME" => File.basename(package_name),
401
+ "AUTOPROJ_ROOT" => Autoproj.root_dir,
402
+ "AUTOPROJ_CONFIG" => Autoproj.config_dir,
403
+ "AUTOPROJ_SOURCE_DIR" => local_dir]
379
404
 
380
405
  vcs_spec = expand(vcs_spec, expansions)
381
406
  vcs_spec = Autoproj.vcs_definition_to_hash(vcs_spec)
@@ -11,16 +11,36 @@ module Autoproj
11
11
 
12
12
  OSDependencies.new(data)
13
13
  end
14
+
15
+ class << self
16
+ attr_reader :aliases
17
+ end
18
+ @aliases = Hash.new
19
+
20
+ def self.alias(old_name, new_name)
21
+ @aliases[new_name] = old_name
22
+ end
23
+
24
+ def self.autodetect_ruby
25
+ ruby_package =
26
+ if RUBY_VERSION < "1.9.0" then "ruby18"
27
+ else "ruby19"
28
+ end
29
+ self.alias(ruby_package, "ruby")
30
+ end
31
+
14
32
  AUTOPROJ_OSDEPS = File.join(File.expand_path(File.dirname(__FILE__)), 'default.osdeps')
15
33
  def self.load_default
16
34
  @default_osdeps ||= OSDependencies.load(AUTOPROJ_OSDEPS)
17
35
  end
18
36
 
19
37
  attr_reader :definitions
20
- attr_reader :gem_fetcher
38
+ def gem_fetcher
39
+ @gem_fetcher ||= Gem::SpecFetcher.fetcher
40
+ end
41
+
21
42
  def initialize(defs = Hash.new)
22
43
  @definitions = defs.to_hash
23
- @gem_fetcher = Gem::SpecFetcher.fetcher
24
44
  end
25
45
 
26
46
  def merge(info)
@@ -49,6 +69,10 @@ module Autoproj
49
69
  release_string =~ /^.*([^\s]+)$/
50
70
  version = $1
51
71
  ['gentoo', [version]]
72
+ elsif File.exists?('/etc/arch-release')
73
+ codename = "Unknown"
74
+ puts "Found Arch"
75
+ ['arch', [codename]]
52
76
  else
53
77
  raise ConfigError, "Unknown operating system"
54
78
  end
@@ -83,7 +107,8 @@ module Autoproj
83
107
  OS_PACKAGE_INSTALL = {
84
108
  'debian' => 'apt-get install -y %s',
85
109
  'ubuntu' => 'apt-get install -y %s',
86
- 'gentoo' => 'emerge --noreplace %s'
110
+ 'gentoo' => 'emerge --noreplace %s',
111
+ 'arch' => 'pacman -Sy --noconfirm %s'
87
112
  }
88
113
 
89
114
  def generate_os_script(dependencies)
@@ -146,7 +171,10 @@ module Autoproj
146
171
  # call-seq:
147
172
  # partition_packages(package_names) => os_packages, gem_packages
148
173
  def partition_packages(package_set, package_osdeps = Hash.new)
149
- package_set = package_set.to_set
174
+ package_set = package_set.
175
+ map { |name| OSDependencies.aliases[name] || name }.
176
+ to_set
177
+
150
178
  osdeps, gems = [], []
151
179
  package_set.to_set.each do |name|
152
180
  pkg_def = definitions[name]
@@ -184,6 +212,19 @@ module Autoproj
184
212
  return osdeps, gems
185
213
  end
186
214
 
215
+ def guess_gem_program
216
+ if Autobuild.programs['gem']
217
+ return Autobuild.programs['gem']
218
+ end
219
+
220
+ ruby_bin = Config::CONFIG['RUBY_INSTALL_NAME']
221
+ if ruby_bin =~ /^ruby(.+)$/
222
+ Autobuild.programs['gem'] = "gem#{$1}"
223
+ else
224
+ Autobuild.programs['gem'] = "gem"
225
+ end
226
+ end
227
+
187
228
  # Requests the installation of the given set of packages
188
229
  def install(packages, package_osdeps = Hash.new)
189
230
  osdeps, gems = partition_packages(packages, package_osdeps)
@@ -223,7 +264,7 @@ module Autoproj
223
264
  if !installed.empty? && Autobuild.do_update
224
265
  # Look if we can update the package ...
225
266
  dep = Gem::Dependency.new(name, version_requirements)
226
- available = @gem_fetcher.find_matching(dep)
267
+ available = gem_fetcher.find_matching(dep)
227
268
  installed_version = installed.map(&:version).max
228
269
  available_version = available.map { |(name, v), source| v }.max
229
270
  needs_update = (available_version > installed_version)
@@ -236,12 +277,14 @@ module Autoproj
236
277
 
237
278
  # Now install what is left
238
279
  if !gems.empty?
280
+ guess_gem_program
281
+
239
282
  if Autoproj.verbose
240
283
  STDERR.puts "Installing rubygems dependencies with"
241
284
  STDERR.puts "gem install #{gems.join(" ")}"
242
285
  end
243
286
  Autobuild.progress "installing/updating RubyGems dependencies: #{gems.join(", ")}"
244
- Autobuild::Subprocess.run 'autoproj', 'osdeps', 'gem', 'install', *gems
287
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', Autobuild.tool('gem'), 'install', *gems
245
288
  did_something ||= true
246
289
  end
247
290
 
@@ -1,8 +1,10 @@
1
1
  module Autoproj
2
- BASE_DIR = File.expand_path(File.join('..', '..'), File.dirname(__FILE__))
3
-
4
2
  class UserError < RuntimeError; end
5
3
 
4
+ # Returns the root directory of the current autoproj installation.
5
+ #
6
+ # If the current directory is not in an autoproj installation,
7
+ # raises UserError.
6
8
  def self.root_dir
7
9
  dir = Dir.pwd
8
10
  while dir != "/" && !File.directory?(File.join(dir, "autoproj"))
@@ -14,36 +16,69 @@ module Autoproj
14
16
  dir
15
17
  end
16
18
 
19
+ # Returns the configuration directory for this autoproj installation.
20
+ #
21
+ # If the current directory is not in an autoproj installation,
22
+ # raises UserError.
17
23
  def self.config_dir
18
24
  File.join(root_dir, "autoproj")
19
25
  end
26
+
27
+ # Returns the build directory (prefix) for this autoproj installation.
28
+ #
29
+ # If the current directory is not in an autoproj installation, raises
30
+ # UserError.
20
31
  def self.build_dir
21
32
  File.join(root_dir, "build")
22
33
  end
23
34
 
35
+ # Returns the path to the provided configuration file.
36
+ #
37
+ # If the current directory is not in an autoproj installation, raises
38
+ # UserError.
24
39
  def self.config_file(file)
25
40
  File.join(config_dir, file)
26
41
  end
27
42
 
43
+ # Run the provided command as user
28
44
  def self.run_as_user(*args)
29
45
  if !system(*args)
30
46
  raise "failed to run #{args.join(" ")}"
31
47
  end
32
48
  end
33
49
 
50
+ # Run the provided command as root, using sudo to gain root access
34
51
  def self.run_as_root(*args)
35
52
  if !system('sudo', *args)
36
53
  raise "failed to run #{args.join(" ")} as root"
37
54
  end
38
55
  end
39
56
 
57
+ # Return the directory in which remote package set definition should be
58
+ # checked out
40
59
  def self.remotes_dir
41
60
  File.join(root_dir, ".remotes")
42
61
  end
62
+
63
+ # Return the directory in which RubyGems package should be installed
43
64
  def self.gem_home
44
65
  File.join(root_dir, ".gems")
45
66
  end
46
67
 
68
+ # Find the given program in PATH. It raises ArgumentError if the program
69
+ # can't be found
70
+ def self.find_in_path(name)
71
+ result = ENV['PATH'].split(':').find { |dir| File.file?(File.join(dir, name)) }
72
+ if !result
73
+ raise ArgumentError, "#{name} can not be found in PATH"
74
+ end
75
+ File.join(result, name)
76
+ end
77
+
78
+ # Initializes the environment variables to a "sane default"
79
+ #
80
+ # Use this in autoproj/init.rb to make sure that the environment will not
81
+ # get polluted during the build.
47
82
  def self.set_initial_env
48
83
  Autoproj.env_set 'RUBYOPT', "-rubygems"
49
84
  Autoproj.env_set 'GEM_HOME', Autoproj.gem_home
@@ -53,6 +88,7 @@ module Autoproj
53
88
  Autoproj.env_set 'LD_LIBRARY_PATH'
54
89
  end
55
90
 
91
+ # Create the env.sh script in +subdir+. In general, +subdir+ should be nil.
56
92
  def self.export_env_sh(subdir = nil)
57
93
  filename = if subdir
58
94
  File.join(Autoproj.root_dir, subdir, "env.sh")
@@ -75,6 +111,12 @@ module Autoproj
75
111
  end
76
112
  end
77
113
 
114
+ # Load a definition file given at +path+. +source+ is the package set from
115
+ # which the file is taken.
116
+ #
117
+ # If any error is detected, the backtrace will be filtered so that it is
118
+ # easier to understand by the user. Moreover, if +source+ is non-nil, the
119
+ # package set name will be mentionned.
78
120
  def self.load(source, *path)
79
121
  path = File.join(*path)
80
122
  Kernel.load path
@@ -82,6 +124,7 @@ module Autoproj
82
124
  Autoproj.filter_load_exception(e, source, path)
83
125
  end
84
126
 
127
+ # Same as #load, but runs only if the file exists.
85
128
  def self.load_if_present(source, *path)
86
129
  path = File.join(*path)
87
130
  if File.file?(path)
@@ -89,6 +132,8 @@ module Autoproj
89
132
  end
90
133
  end
91
134
 
135
+ # Look into +dir+, searching for shared libraries. For each library, display
136
+ # a warning message if this library has undefined symbols.
92
137
  def self.validate_solib_dependencies(dir, exclude_paths = [])
93
138
  Find.find(File.expand_path(dir)) do |name|
94
139
  next unless name =~ /\.so$/
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.3.4"
2
+ VERSION = "1.4.0"
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.3.4
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-14 00:00:00 +01:00
12
+ date: 2010-02-06 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,26 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: 1.5.0
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: rubyforge
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.0.3
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: gemcutter
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 0.3.0
84
+ version:
65
85
  - !ruby/object:Gem::Dependency
66
86
  name: webgen
67
87
  type: :development
@@ -90,7 +110,7 @@ dependencies:
90
110
  requirements:
91
111
  - - ">="
92
112
  - !ruby/object:Gem::Version
93
- version: 2.4.0
113
+ version: 2.5.0
94
114
  version:
95
115
  description: |-
96
116
  What is Autoproj
@@ -137,7 +157,6 @@ files:
137
157
  - doc/guide/ext/init.rb
138
158
  - doc/guide/ext/previous_next.rb
139
159
  - doc/guide/ext/rdoc_links.rb
140
- - doc/guide/src/autobuild.page
141
160
  - doc/guide/src/autoproj_bootstrap
142
161
  - doc/guide/src/customization.page
143
162
  - doc/guide/src/default.css
@@ -151,7 +170,12 @@ files:
151
170
  - doc/guide/src/images/gradient1.png
152
171
  - doc/guide/src/images/gradient2.png
153
172
  - doc/guide/src/index.page
154
- - doc/guide/src/source_yml.page
173
+ - doc/guide/src/manifest.xml
174
+ - doc/guide/src/package_sets/autobuild.page
175
+ - doc/guide/src/package_sets/importers.page
176
+ - doc/guide/src/package_sets/index.page
177
+ - doc/guide/src/package_sets/manifest-xml.page
178
+ - doc/guide/src/package_sets/osdeps.page
155
179
  - doc/guide/src/structure.page
156
180
  - lib/autoproj.rb
157
181
  - lib/autoproj/autobuild.rb