autoproj 2.0.0.rc9 → 2.0.0.rc10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/bin/autoproj_bootstrap +137 -97
- data/bin/autoproj_bootstrap.in +2 -5
- data/bin/autoproj_install +136 -92
- data/bin/autoproj_install.in +1 -0
- data/lib/autoproj/autobuild.rb +4 -8
- data/lib/autoproj/cli/bootstrap.rb +1 -1
- data/lib/autoproj/cli/locate.rb +1 -1
- data/lib/autoproj/cli/main.rb +8 -2
- data/lib/autoproj/cli/status.rb +13 -6
- data/lib/autoproj/cli/update.rb +2 -2
- data/lib/autoproj/cli/versions.rb +2 -3
- data/lib/autoproj/configuration.rb +29 -7
- data/lib/autoproj/default.osdeps +1 -0
- data/lib/autoproj/ops/configuration.rb +28 -7
- data/lib/autoproj/ops/install.rb +135 -92
- data/lib/autoproj/ops/snapshot.rb +4 -4
- data/lib/autoproj/package_managers/bundler_manager.rb +84 -58
- data/lib/autoproj/version.rb +1 -1
- data/lib/autoproj/workspace.rb +35 -15
- metadata +2 -2
@@ -91,14 +91,14 @@ def initialize(manifest, options = Hash.new)
|
|
91
91
|
|
92
92
|
def snapshot_package_sets(target_dir = nil, options = Hash.new)
|
93
93
|
options = Kernel.validate_options options,
|
94
|
-
|
94
|
+
only_local: true
|
95
95
|
|
96
96
|
result = Array.new
|
97
97
|
manifest.each_package_set do |pkg_set|
|
98
98
|
next if pkg_set.local?
|
99
99
|
|
100
100
|
vcs_info =
|
101
|
-
begin pkg_set.snapshot(target_dir,
|
101
|
+
begin pkg_set.snapshot(target_dir, only_local: options[:only_local])
|
102
102
|
rescue Exception => e
|
103
103
|
error_or_warn(pkg_set, e)
|
104
104
|
next
|
@@ -130,7 +130,7 @@ def error_or_warn(package, error)
|
|
130
130
|
|
131
131
|
def snapshot_packages(packages, target_dir = nil, options = Hash.new)
|
132
132
|
options = Kernel.validate_options options,
|
133
|
-
|
133
|
+
only_local: true
|
134
134
|
|
135
135
|
result = Array.new
|
136
136
|
packages.each do |package_name|
|
@@ -148,7 +148,7 @@ def snapshot_packages(packages, target_dir = nil, options = Hash.new)
|
|
148
148
|
end
|
149
149
|
|
150
150
|
vcs_info =
|
151
|
-
begin importer.snapshot(package.autobuild, target_dir,
|
151
|
+
begin importer.snapshot(package.autobuild, target_dir, only_local: options[:only_local])
|
152
152
|
rescue Exception => e
|
153
153
|
error_or_warn(package, e)
|
154
154
|
next
|
@@ -29,21 +29,34 @@ def self.with_prerelease(*value)
|
|
29
29
|
def initialize_environment
|
30
30
|
env = ws.env
|
31
31
|
|
32
|
-
|
33
|
-
env.init_from_env 'GEM_PATH'
|
34
|
-
env.system_env['GEM_PATH'] = Gem.default_path
|
32
|
+
config = ws.config
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
env.add_path 'PATH', File.join(Gem.user_dir, 'bin')
|
35
|
+
env.add_path 'PATH', File.join(ws.prefix_dir, 'gems', 'bin')
|
36
|
+
env.add_path 'PATH', File.join(config.bundler_gem_home, 'bin')
|
37
|
+
env.add_path 'PATH', File.join(ws.dot_autoproj_dir, 'autoproj', 'bin')
|
38
|
+
env.set 'GEM_HOME', config.gems_gem_home
|
39
|
+
|
40
|
+
if !config.private_bundler? || !config.private_autoproj? || !config.private_gems?
|
41
|
+
env.set('GEM_PATH', *Gem.default_path)
|
42
|
+
end
|
43
|
+
if config.private_bundler?
|
44
|
+
Autobuild.programs['bundler'] = File.join(config.bundler_gem_home, 'bin', 'bundler')
|
45
|
+
env.add_path 'GEM_PATH', config.bundler_gem_home
|
46
|
+
else
|
47
|
+
Autobuild.programs['bundler'] = env.find_in_path('bundler')
|
38
48
|
end
|
39
49
|
|
40
50
|
env.init_from_env 'RUBYLIB'
|
41
51
|
env.inherit 'RUBYLIB'
|
52
|
+
# Sanitize the rubylib we get from the environment by removing
|
53
|
+
# anything that comes from Gem or Bundler
|
42
54
|
original_rubylib =
|
43
55
|
(env['RUBYLIB'] || "").split(File::PATH_SEPARATOR).find_all do |p|
|
44
56
|
!p.start_with?(Bundler.rubygems.gem_dir) &&
|
45
57
|
!Bundler.rubygems.gem_path.any? { |gem_p| p.start_with?(p) }
|
46
58
|
end
|
59
|
+
# And discover the system's rubylib
|
47
60
|
if system_rubylib = discover_rubylib
|
48
61
|
env.system_env['RUBYLIB'] = []
|
49
62
|
env.original_env['RUBYLIB'] = (original_rubylib - system_rubylib).join(File::PATH_SEPARATOR)
|
@@ -52,42 +65,19 @@ def initialize_environment
|
|
52
65
|
ws.config.each_reused_autoproj_installation do |p|
|
53
66
|
reused_w = ws.new(p)
|
54
67
|
reused_c = reused_w.load_config
|
55
|
-
if reused_c.private_gems?
|
56
|
-
env.add_path 'GEM_PATH', File.join(reused_w.prefix_dir, 'gems')
|
57
|
-
end
|
58
68
|
env.add_path 'PATH', File.join(reused_w.prefix_dir, 'gems', 'bin')
|
59
69
|
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
env.add_path 'GEM_PATH', gem_home
|
65
|
-
end
|
66
|
-
|
67
|
-
FileUtils.mkdir_p gem_home
|
68
|
-
gemfile = File.join(gem_home, 'Gemfile')
|
71
|
+
prefix_gems = File.join(ws.prefix_dir, "gems")
|
72
|
+
FileUtils.mkdir_p prefix_gems
|
73
|
+
gemfile = File.join(prefix_gems, 'Gemfile')
|
69
74
|
if !File.exists?(gemfile)
|
70
75
|
File.open(gemfile, 'w') do |io|
|
71
76
|
io.puts "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'autoproj', 'Gemfile')}\""
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
75
|
-
|
76
|
-
env.add_path 'PATH', Gem.bindir
|
77
|
-
env.add_path 'PATH', File.join(gem_home, 'bin')
|
78
|
-
|
79
|
-
dot_autoproj = ws.dot_autoproj_dir
|
80
|
-
if ws.config.private_bundler?
|
81
|
-
env.add_path 'PATH', File.join(dot_autoproj, 'bundler', 'bin')
|
82
|
-
env.add_path 'GEM_PATH', File.join(dot_autoproj, 'bundler')
|
83
|
-
end
|
84
|
-
env.add_path 'PATH', File.join(dot_autoproj, 'autoproj', 'bin')
|
85
|
-
if ws.config.private_autoproj?
|
86
|
-
env.add_path 'GEM_PATH', File.join(dot_autoproj, 'autoproj')
|
87
|
-
end
|
88
|
-
Autobuild.programs['bundler'] = 'bundler'
|
89
|
-
|
90
|
-
if bundle_rubylib = discover_bundle_rubylib
|
80
|
+
if bundle_rubylib = discover_bundle_rubylib(silent_errors: true)
|
91
81
|
update_env_rubylib(bundle_rubylib, system_rubylib)
|
92
82
|
end
|
93
83
|
end
|
@@ -133,6 +123,37 @@ def backup_clean(mapping)
|
|
133
123
|
end
|
134
124
|
end
|
135
125
|
|
126
|
+
def self.run_bundler_install(ws, gemfile, *options, update: true, binstubs: nil)
|
127
|
+
if update && File.file?("#{gemfile}.lock")
|
128
|
+
FileUtils.rm "#{gemfile}.lock"
|
129
|
+
end
|
130
|
+
|
131
|
+
options << "--shebang" << Gem.ruby
|
132
|
+
if binstubs
|
133
|
+
options << "--binstubs" << binstubs
|
134
|
+
end
|
135
|
+
|
136
|
+
Bundler.with_clean_env do
|
137
|
+
connections = Set.new
|
138
|
+
ws.run 'autoproj', 'osdeps',
|
139
|
+
Autobuild.tool('bundler'), 'install',
|
140
|
+
*options,
|
141
|
+
working_directory: File.dirname(gemfile), env: Hash['BUNDLE_GEMFILE' => nil, 'RUBYOPT' => nil] do |line|
|
142
|
+
|
143
|
+
case line
|
144
|
+
when /Installing (.*)/
|
145
|
+
Autobuild.message " bundler: installing #{$1}"
|
146
|
+
when /Fetching.*from (.*)/
|
147
|
+
host = $1.gsub(/\.+$/, '')
|
148
|
+
if !connections.include?(host)
|
149
|
+
Autobuild.message " bundler: connected to #{host}"
|
150
|
+
connections << host
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
136
157
|
def install(gems)
|
137
158
|
root_dir = File.join(ws.prefix_dir, 'gems')
|
138
159
|
gemfile_path = File.join(root_dir, 'Gemfile')
|
@@ -151,6 +172,17 @@ def install(gems)
|
|
151
172
|
end
|
152
173
|
end
|
153
174
|
|
175
|
+
gemfiles = []
|
176
|
+
ws.manifest.each_package_set do |source|
|
177
|
+
if source.local_dir && File.file?(pkg_set_gemfile = File.join(source.local_dir, 'Gemfile'))
|
178
|
+
gemfiles << pkg_set_gemfile
|
179
|
+
end
|
180
|
+
end
|
181
|
+
# In addition, look into overrides.d
|
182
|
+
Dir.glob(File.join(ws.config_dir, "*.gemfile")) do |gemfile_path|
|
183
|
+
gemfiles << gemfile_path
|
184
|
+
end
|
185
|
+
|
154
186
|
# Generate the gemfile and remove the lockfile
|
155
187
|
gems = gems.sort.map do |name|
|
156
188
|
name, version = parse_package_entry(name)
|
@@ -159,40 +191,30 @@ def install(gems)
|
|
159
191
|
FileUtils.mkdir_p root_dir
|
160
192
|
File.open(gemfile_path, 'w') do |io|
|
161
193
|
io.puts "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'autoproj', 'Gemfile')}\""
|
194
|
+
gemfiles.each do |gemfile|
|
195
|
+
io.puts File.read(gemfile)
|
196
|
+
end
|
162
197
|
io.puts gems
|
163
198
|
end
|
164
|
-
FileUtils.rm File.join(root_dir, 'Gemfile.lock')
|
165
199
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
Autobuild::Subprocess.run 'autoproj', 'osdeps',
|
170
|
-
Autobuild.tool('bundler'), 'install',
|
171
|
-
"--gemfile=#{gemfile_path}", *options,
|
172
|
-
"--binstubs", binstubs_path,
|
173
|
-
"--shebang", Gem.ruby,
|
174
|
-
env: Hash['BUNDLE_GEMFILE' => gemfile_path] do |line|
|
175
|
-
|
176
|
-
case line
|
177
|
-
when /Installing (.*)/
|
178
|
-
Autobuild.message " bundler: installing #{$1}"
|
179
|
-
when /Fetching.*from (.*)/
|
180
|
-
host = $1.gsub(/\.+$/, '')
|
181
|
-
if !connections.include?(host)
|
182
|
-
Autobuild.message " bundler: connected to #{host}"
|
183
|
-
connections << host
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
200
|
+
options = Array.new
|
201
|
+
if ws.config.private_gems?
|
202
|
+
options << "--path" << ws.config.gems_gem_home
|
187
203
|
end
|
188
204
|
|
205
|
+
binstubs_path = File.join(root_dir, 'bin')
|
206
|
+
self.class.run_bundler_install ws, gemfile_path, *options,
|
207
|
+
binstubs: binstubs_path
|
208
|
+
|
189
209
|
if bundle_rubylib = discover_bundle_rubylib
|
190
210
|
update_env_rubylib(bundle_rubylib)
|
191
211
|
else
|
192
|
-
raise NotCleanState, "bundler executed successfully, but the result
|
212
|
+
raise NotCleanState, "bundler executed successfully, but the result was not in a clean state"
|
193
213
|
end
|
194
214
|
|
195
215
|
rescue Exception => e
|
216
|
+
Autoproj.warn "saved the new Gemfile in #{gemfile_path}.FAILED and restored the last Gemfile version"
|
217
|
+
FileUtils.cp gemfile_path, "#{gemfile_path}.FAILED"
|
196
218
|
backup_restore(backups)
|
197
219
|
raise
|
198
220
|
ensure
|
@@ -214,15 +236,19 @@ def discover_rubylib
|
|
214
236
|
end
|
215
237
|
end
|
216
238
|
|
217
|
-
def discover_bundle_rubylib
|
239
|
+
def discover_bundle_rubylib(silent_errors: false)
|
218
240
|
require 'bundler'
|
219
241
|
gemfile = File.join(ws.prefix_dir, 'gems', 'Gemfile')
|
242
|
+
silent_redirect = Hash.new
|
243
|
+
if silent_errors
|
244
|
+
silent_redirect[:err] = '/dev/null'
|
245
|
+
end
|
220
246
|
Tempfile.open 'autoproj-rubylib' do |io|
|
221
247
|
result = Bundler.clean_system(
|
222
248
|
Hash['BUNDLE_GEMFILE' => gemfile],
|
223
249
|
Autobuild.tool('bundler'), 'exec', 'ruby', '-e', 'puts $LOAD_PATH',
|
224
|
-
out: io,
|
225
|
-
|
250
|
+
out: io, **silent_redirect)
|
251
|
+
|
226
252
|
if result
|
227
253
|
io.readlines.map { |l| l.chomp }.find_all { |l| !l.empty? }
|
228
254
|
end
|
data/lib/autoproj/version.rb
CHANGED
data/lib/autoproj/workspace.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'autoproj/ops/import'
|
2
|
+
require 'autoproj/ops/install'
|
2
3
|
|
3
4
|
module Autoproj
|
4
5
|
class Workspace < Ops::Loader
|
@@ -277,11 +278,7 @@ def install_ruby_shims
|
|
277
278
|
end
|
278
279
|
end
|
279
280
|
|
280
|
-
def update_autoproj(
|
281
|
-
options = validate_options options,
|
282
|
-
force: false, restart_on_update: true
|
283
|
-
return if !options[:force]
|
284
|
-
|
281
|
+
def update_autoproj(restart_on_update: true)
|
285
282
|
config.validate_ruby_executable
|
286
283
|
|
287
284
|
# This is a guard to avoid infinite recursion in case the user is
|
@@ -290,19 +287,29 @@ def update_autoproj(options = Hash.new)
|
|
290
287
|
return
|
291
288
|
end
|
292
289
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
290
|
+
gemfile = File.join(dot_autoproj_dir, 'autoproj', 'Gemfile')
|
291
|
+
binstubs = File.join(dot_autoproj_dir, 'autoproj', 'bin')
|
292
|
+
begin
|
293
|
+
PackageManagers::BundlerManager.run_bundler_install(
|
294
|
+
self, gemfile, binstubs: binstubs)
|
295
|
+
ensure
|
296
|
+
Ops::Install.clean_binstubs(binstubs)
|
297
|
+
end
|
298
|
+
|
299
|
+
# Find out what version of autoproj bundler locked on
|
300
|
+
autoproj = File.readlines("#{gemfile}.lock").
|
301
|
+
find_all { |l| l =~ /^\s+autoproj \(.*\)$/ }
|
302
|
+
if autoproj.size == 1
|
303
|
+
autoproj[0] =~ /^\s+autoproj \((.*)\)$/
|
304
|
+
installed_version = $1
|
305
|
+
else
|
306
|
+
raise "unexpected format for #{gemfile}.lock, cannot determine installed version of autoproj"
|
307
|
+
end
|
301
308
|
|
302
309
|
# First things first, see if we need to update ourselves
|
303
|
-
if
|
310
|
+
if (VERSION != installed_version) && restart_on_update
|
304
311
|
puts
|
305
|
-
Autoproj.message
|
312
|
+
Autoproj.message "autoproj has been updated to #{installed_version} (from #{VERSION}), restarting"
|
306
313
|
puts
|
307
314
|
|
308
315
|
# We updated autobuild or autoproj themselves ... Restart !
|
@@ -315,6 +322,19 @@ def update_autoproj(options = Hash.new)
|
|
315
322
|
end
|
316
323
|
end
|
317
324
|
|
325
|
+
def run(*args, &block)
|
326
|
+
if args.last.kind_of?(Hash)
|
327
|
+
options = args.pop
|
328
|
+
else options = Hash.new
|
329
|
+
end
|
330
|
+
options_env = options.fetch(:env, Hash.new)
|
331
|
+
options[:env] = env.resolved_env.merge(options_env)
|
332
|
+
if options_env['BUNDLE_GEMFILE']
|
333
|
+
raise
|
334
|
+
end
|
335
|
+
Autobuild::Subprocess.run(*args, options, &block)
|
336
|
+
end
|
337
|
+
|
318
338
|
def set_as_main_workspace
|
319
339
|
Autoproj.workspace = self
|
320
340
|
Autoproj.root_dir = root_dir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoproj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Joyeux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autobuild
|