fig 0.2.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +46 -0
- data/lib/fig.rb +1 -1
- data/lib/fig/command.rb +7 -2
- data/lib/fig/command/action.rb +15 -0
- data/lib/fig/command/action/list_dependencies.rb +5 -0
- data/lib/fig/command/action/list_variables.rb +5 -0
- data/lib/fig/command/action/role/publish.rb +5 -0
- data/lib/fig/command/options.rb +99 -8
- data/lib/fig/command/package_loader.rb +29 -16
- data/lib/fig/operating_system.rb +36 -8
- data/lib/fig/package.rb +20 -15
- data/lib/fig/package_definition_text_assembler.rb +5 -5
- data/lib/fig/repository_package_publisher.rb +2 -0
- data/lib/fig/runtime_environment.rb +48 -25
- metadata +42 -42
data/Changes
CHANGED
@@ -1,3 +1,49 @@
|
|
1
|
+
v1.0.0
|
2
|
+
|
3
|
+
New features:
|
4
|
+
|
5
|
+
- New --suppress-all-includes and --suppress-cross-package-includes options
|
6
|
+
prevent package traversal. The driving use case is retrieving individual
|
7
|
+
components of path statements. Say you have a package definition that
|
8
|
+
looked like:
|
9
|
+
|
10
|
+
config default
|
11
|
+
include something/some-version
|
12
|
+
include other/whatever
|
13
|
+
add CLASSPATH=@/foo.jar
|
14
|
+
end
|
15
|
+
|
16
|
+
You could then get the portion of CLASSPATH from the package definition
|
17
|
+
only and not any dependencies via
|
18
|
+
|
19
|
+
fig --suppress-all-includes --get CLASSPATH
|
20
|
+
|
21
|
+
If you've got multiple config blocks, you can still have intra-package
|
22
|
+
dependencies take effect:
|
23
|
+
|
24
|
+
config default
|
25
|
+
include something/some-version
|
26
|
+
include other/whatever
|
27
|
+
include :base-environment
|
28
|
+
end
|
29
|
+
|
30
|
+
config base-environment
|
31
|
+
add CLASSPATH=@/foo.jar
|
32
|
+
end
|
33
|
+
|
34
|
+
You just allow those includes to work:
|
35
|
+
|
36
|
+
fig --suppress-cross-package-includes --get CLASSPATH
|
37
|
+
|
38
|
+
- New --suppress-cleanup-of-retrieves option that stops Fig from deleting
|
39
|
+
files previously downloaded as a result of a retrieve statement. Useful if
|
40
|
+
you wish to toggle between multiple configurations rapidly without waiting
|
41
|
+
for file shuffling.
|
42
|
+
|
43
|
+
v0.2.6.beta.1
|
44
|
+
|
45
|
+
- Test release
|
46
|
+
|
1
47
|
v0.2.5
|
2
48
|
|
3
49
|
Backwards incompatibilities:
|
data/lib/fig.rb
CHANGED
data/lib/fig/command.rb
CHANGED
@@ -243,7 +243,9 @@ class Fig::Command
|
|
243
243
|
|
244
244
|
Fig::AtExit.add do
|
245
245
|
working_directory_maintainer.prepare_for_shutdown(
|
246
|
-
@base_package
|
246
|
+
@base_package &&
|
247
|
+
retrieves_should_happen? &&
|
248
|
+
! @options.suppress_cleanup_of_retrieves
|
247
249
|
)
|
248
250
|
end
|
249
251
|
|
@@ -253,7 +255,10 @@ class Fig::Command
|
|
253
255
|
end
|
254
256
|
|
255
257
|
@environment = Fig::RuntimeEnvironment.new(
|
256
|
-
@repository,
|
258
|
+
@repository,
|
259
|
+
@options.suppress_includes,
|
260
|
+
environment_variables,
|
261
|
+
working_directory_maintainer,
|
257
262
|
)
|
258
263
|
|
259
264
|
Fig::AtExit.add { @environment.check_unused_retrieves() }
|
data/lib/fig/command/action.rb
CHANGED
@@ -82,6 +82,21 @@ module Fig::Command::Action
|
|
82
82
|
return false
|
83
83
|
end
|
84
84
|
|
85
|
+
# Is this --list-dependencies?
|
86
|
+
def list_dependencies?()
|
87
|
+
return false
|
88
|
+
end
|
89
|
+
|
90
|
+
# Is this --list-variables?
|
91
|
+
def list_variables?()
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
|
95
|
+
# Is this a publish action?
|
96
|
+
def publish?()
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
|
85
100
|
# Answers whether we should reset the environment to nothing, sort of like
|
86
101
|
# the standardized environment that cron(1) creates. At present, we're only
|
87
102
|
# setting this when we're listing variables. One could imagine allowing this
|
@@ -47,6 +47,11 @@ module Fig::Command::Action::Role::Publish
|
|
47
47
|
return nil # don't care
|
48
48
|
end
|
49
49
|
|
50
|
+
# Is this a publish action?
|
51
|
+
def publish?()
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
|
50
55
|
def configure(options)
|
51
56
|
@descriptor = options.descriptor
|
52
57
|
@environment_statements = options.environment_statements
|
data/lib/fig/command/options.rb
CHANGED
@@ -42,6 +42,7 @@ class Fig::Command; end
|
|
42
42
|
|
43
43
|
# Command-line processing.
|
44
44
|
class Fig::Command::Options
|
45
|
+
attr_reader :asset_statements
|
45
46
|
attr_reader :command_extra_argv
|
46
47
|
attr_reader :config
|
47
48
|
attr_reader :descriptor
|
@@ -51,10 +52,11 @@ class Fig::Command::Options
|
|
51
52
|
attr_reader :home
|
52
53
|
attr_reader :log_config
|
53
54
|
attr_reader :log_level
|
54
|
-
attr_reader :asset_statements
|
55
55
|
attr_reader :package_definition_file
|
56
56
|
attr_reader :parser
|
57
57
|
attr_reader :shell_command
|
58
|
+
attr_reader :suppress_cleanup_of_retrieves
|
59
|
+
attr_reader :suppress_includes
|
58
60
|
attr_reader :update_lock_response
|
59
61
|
attr_reader :variable_to_get
|
60
62
|
attr_accessor :version_message
|
@@ -89,6 +91,8 @@ class Fig::Command::Options
|
|
89
91
|
end
|
90
92
|
set_up_sub_actions()
|
91
93
|
|
94
|
+
validate
|
95
|
+
|
92
96
|
actions().each {|action| action.configure(self)}
|
93
97
|
|
94
98
|
return
|
@@ -187,7 +191,7 @@ class Fig::Command::Options
|
|
187
191
|
end
|
188
192
|
|
189
193
|
def set_up_parser()
|
190
|
-
|
194
|
+
set_up_package_definition()
|
191
195
|
set_up_remote_repository_access()
|
192
196
|
set_up_commands()
|
193
197
|
set_up_environment_statements()
|
@@ -359,7 +363,7 @@ class Fig::Command::Options
|
|
359
363
|
\z
|
360
364
|
>x
|
361
365
|
|
362
|
-
def
|
366
|
+
def set_up_package_definition()
|
363
367
|
@parser.on(
|
364
368
|
'-c',
|
365
369
|
'--config CONFIG',
|
@@ -369,19 +373,31 @@ class Fig::Command::Options
|
|
369
373
|
@config = config
|
370
374
|
end
|
371
375
|
|
372
|
-
@package_definition_file = nil
|
373
376
|
@parser.on(
|
374
377
|
'--file FILE',
|
375
378
|
FILE_OPTION_VALUE_PATTERN,
|
376
379
|
%q<read package definition FILE. Use '-' for stdin. See also --no-file>
|
377
380
|
) do |path|
|
378
|
-
|
381
|
+
set_package_definition_file(path)
|
379
382
|
end
|
380
383
|
|
381
384
|
@parser.on(
|
382
385
|
'--no-file', 'ignore package.fig file in current directory'
|
383
|
-
) do
|
384
|
-
|
386
|
+
) do
|
387
|
+
set_package_definition_file(:none)
|
388
|
+
end
|
389
|
+
|
390
|
+
@parser.on(
|
391
|
+
'--suppress-all-includes', %q<don't process include statements>,
|
392
|
+
) do
|
393
|
+
set_suppress_includes(:all)
|
394
|
+
end
|
395
|
+
|
396
|
+
@parser.on(
|
397
|
+
'--suppress-cross-package-includes',
|
398
|
+
%q<don't process includes of configs from other packages>,
|
399
|
+
) do
|
400
|
+
set_suppress_includes(:cross_package)
|
385
401
|
end
|
386
402
|
|
387
403
|
return
|
@@ -486,7 +502,7 @@ class Fig::Command::Options
|
|
486
502
|
@parser.on(
|
487
503
|
'-u',
|
488
504
|
'--update',
|
489
|
-
'check remote repo for updates
|
505
|
+
'check remote repo for updates, download to $FIG_HOME and process retrieves'
|
490
506
|
) do
|
491
507
|
set_update_action(Fig::Command::Action::Update)
|
492
508
|
end
|
@@ -499,6 +515,13 @@ class Fig::Command::Options
|
|
499
515
|
set_update_action(Fig::Command::Action::UpdateIfMissing)
|
500
516
|
end
|
501
517
|
|
518
|
+
@parser.on(
|
519
|
+
'--suppress-cleanup-of-retrieves',
|
520
|
+
%q<don't delete files from unreferenced retrieves>,
|
521
|
+
) do
|
522
|
+
@suppress_cleanup_of_retrieves = true
|
523
|
+
end
|
524
|
+
|
502
525
|
@parser.on(
|
503
526
|
'-l', '--login', 'login to remote repo as a non-anonymous user'
|
504
527
|
) do
|
@@ -587,6 +610,30 @@ class Fig::Command::Options
|
|
587
610
|
return
|
588
611
|
end
|
589
612
|
|
613
|
+
def set_package_definition_file(value)
|
614
|
+
if @package_definition_file
|
615
|
+
raise Fig::Command::OptionError.new(
|
616
|
+
'Can only specify one --file/--no-file option.'
|
617
|
+
)
|
618
|
+
end
|
619
|
+
|
620
|
+
@package_definition_file = value
|
621
|
+
|
622
|
+
return
|
623
|
+
end
|
624
|
+
|
625
|
+
def set_suppress_includes(value)
|
626
|
+
if @suppress_includes
|
627
|
+
raise Fig::Command::OptionError.new(
|
628
|
+
'Can only specify one --suppress-all-includes/--suppress-cross-package-includes option.'
|
629
|
+
)
|
630
|
+
end
|
631
|
+
|
632
|
+
@suppress_includes = value
|
633
|
+
|
634
|
+
return
|
635
|
+
end
|
636
|
+
|
590
637
|
def set_update_action(update_action_class)
|
591
638
|
update_action = update_action_class.new
|
592
639
|
if @update_action
|
@@ -596,6 +643,8 @@ class Fig::Command::Options
|
|
596
643
|
end
|
597
644
|
|
598
645
|
@update_action = update_action
|
646
|
+
|
647
|
+
return
|
599
648
|
end
|
600
649
|
|
601
650
|
def new_variable_statement(option, name_value, statement_class)
|
@@ -621,6 +670,48 @@ class Fig::Command::Options
|
|
621
670
|
return statement_class.new(nil, "#{option} option", path, need_to_glob)
|
622
671
|
end
|
623
672
|
|
673
|
+
def validate()
|
674
|
+
if suppress_includes
|
675
|
+
if list_tree?
|
676
|
+
# Not conceptually incompatible, just not implemented (would need to
|
677
|
+
# handle in command/action/role/list_*)
|
678
|
+
raise Fig::Command::OptionError.new(
|
679
|
+
'Cannot use --suppress-all-includes/--suppress-cross-package-includes with --list-tree.'
|
680
|
+
)
|
681
|
+
elsif list_all_configs?
|
682
|
+
# Not conceptually incompatible, just not implemented (would need to
|
683
|
+
# handle in command/action/role/list_*)
|
684
|
+
raise Fig::Command::OptionError.new(
|
685
|
+
'Cannot use --suppress-all-includes/--suppress-cross-package-includes with --list-all-configs.'
|
686
|
+
)
|
687
|
+
elsif @base_action.list_dependencies?
|
688
|
+
raise Fig::Command::OptionError.new(
|
689
|
+
%q<It doesn't make much sense to suppress dependencies when attempting to list them.>
|
690
|
+
)
|
691
|
+
elsif @base_action.publish?
|
692
|
+
# Don't want to support broken publishes (though versionless includes
|
693
|
+
# are pretty broken).
|
694
|
+
raise Fig::Command::OptionError.new(
|
695
|
+
'Cannot use --suppress-all-includes/--suppress-cross-package-includes when publishing.'
|
696
|
+
)
|
697
|
+
end
|
698
|
+
elsif list_tree?
|
699
|
+
if ! @base_action.list_dependencies? && ! @base_action.list_variables?
|
700
|
+
raise Fig::Command::OptionError.new(
|
701
|
+
%q<The --list-tree option isn't useful without --list-dependencies/--list-variables.>
|
702
|
+
)
|
703
|
+
end
|
704
|
+
elsif list_all_configs?
|
705
|
+
if ! @base_action.list_dependencies? && ! @base_action.list_variables?
|
706
|
+
raise Fig::Command::OptionError.new(
|
707
|
+
%q<The --list-all-configs option isn't useful without --list-dependencies/--list-variables.>
|
708
|
+
)
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
return
|
713
|
+
end
|
714
|
+
|
624
715
|
def set_up_sub_actions()
|
625
716
|
if @base_action and @base_action.sub_action?
|
626
717
|
# This is a cheat because the only things with sub-actions at present are
|
@@ -4,6 +4,7 @@ require 'fig/parser'
|
|
4
4
|
module Fig; end
|
5
5
|
class Fig::Command; end
|
6
6
|
|
7
|
+
# Loads the base package.
|
7
8
|
class Fig::Command::PackageLoader
|
8
9
|
attr_reader :package_loaded_from_path
|
9
10
|
|
@@ -35,7 +36,7 @@ class Fig::Command::PackageLoader
|
|
35
36
|
if @descriptor.nil?
|
36
37
|
load_package_object_from_file()
|
37
38
|
else
|
38
|
-
|
39
|
+
set_base_package @repository.get_package(@descriptor)
|
39
40
|
end
|
40
41
|
|
41
42
|
return @base_package
|
@@ -103,30 +104,42 @@ class Fig::Command::PackageLoader
|
|
103
104
|
:source_description => source_description
|
104
105
|
)
|
105
106
|
|
106
|
-
|
107
|
-
Fig::Parser.new(
|
107
|
+
set_base_package(
|
108
|
+
Fig::Parser.new(
|
109
|
+
@application_configuration, :check_include_versions
|
110
|
+
).parse_package(
|
108
111
|
descriptor, '.', source_description, definition_text
|
109
112
|
)
|
113
|
+
)
|
110
114
|
|
111
115
|
return
|
112
116
|
end
|
113
117
|
|
114
118
|
def set_base_package_to_empty_synthetic_one()
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
119
|
+
set_base_package(
|
120
|
+
Fig::Package.new(
|
121
|
+
nil,
|
122
|
+
nil,
|
123
|
+
'synthetic',
|
124
|
+
'.',
|
125
|
+
[
|
126
|
+
Fig::Statement::Configuration.new(
|
127
|
+
nil,
|
128
|
+
%Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
|
129
|
+
@base_config,
|
130
|
+
[]
|
131
|
+
)
|
132
|
+
]
|
133
|
+
)
|
128
134
|
)
|
129
135
|
|
130
136
|
return
|
131
137
|
end
|
138
|
+
|
139
|
+
def set_base_package(package)
|
140
|
+
@base_package = package
|
141
|
+
package.set_base true
|
142
|
+
|
143
|
+
return
|
144
|
+
end
|
132
145
|
end
|
data/lib/fig/operating_system.rb
CHANGED
@@ -32,11 +32,11 @@ class Fig::OperatingSystem
|
|
32
32
|
UNIX_FILE_NAME_ILLEGAL_CHARACTERS = %w[ / ]
|
33
33
|
|
34
34
|
def self.windows?
|
35
|
-
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
35
|
+
return !! (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.unix?
|
39
|
-
!windows?
|
39
|
+
! Fig::OperatingSystem.windows?
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.file_name_illegal_characters()
|
@@ -94,7 +94,7 @@ class Fig::OperatingSystem
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def list(dir)
|
97
|
-
Dir.entries(dir) - ['.','..']
|
97
|
+
Dir.entries(dir) - ['.', '..']
|
98
98
|
end
|
99
99
|
|
100
100
|
def mtime(path)
|
@@ -442,15 +442,20 @@ class Fig::OperatingSystem
|
|
442
442
|
# .tar.gz
|
443
443
|
# .tgz
|
444
444
|
# .zip
|
445
|
-
def unpack_archive(directory,
|
445
|
+
def unpack_archive(directory, archive_path)
|
446
446
|
FileUtils.mkdir_p directory
|
447
447
|
Dir.chdir(directory) do
|
448
|
-
if ! File.exists?
|
449
|
-
raise Fig::RepositoryError.new "#{
|
448
|
+
if ! File.exists? archive_path
|
449
|
+
raise Fig::RepositoryError.new "#{archive_path} does not exist."
|
450
450
|
end
|
451
451
|
|
452
|
-
::
|
452
|
+
running_on_windows = Fig::OperatingSystem.windows?
|
453
|
+
::Archive.read_open_filename(archive_path) do |reader|
|
453
454
|
while entry = reader.next_header
|
455
|
+
if running_on_windows
|
456
|
+
check_archive_entry_for_windows entry, archive_path
|
457
|
+
end
|
458
|
+
|
454
459
|
begin
|
455
460
|
reader.extract(entry)
|
456
461
|
rescue Archive::Error => exception
|
@@ -459,7 +464,7 @@ class Fig::OperatingSystem
|
|
459
464
|
message = exception.message.sub /^Extract archive failed: /, ''
|
460
465
|
new_exception =
|
461
466
|
Fig::RepositoryError.new(
|
462
|
-
"Could not extract #{entry.pathname} from #{
|
467
|
+
"Could not extract #{entry.pathname} from #{archive_path}: #{message}"
|
463
468
|
)
|
464
469
|
|
465
470
|
new_exception.set_backtrace exception.backtrace
|
@@ -508,6 +513,29 @@ class Fig::OperatingSystem
|
|
508
513
|
NOT_MODIFIED = 3
|
509
514
|
NOT_FOUND = 4
|
510
515
|
|
516
|
+
def check_archive_entry_for_windows(entry, archive_path)
|
517
|
+
bad_type = nil
|
518
|
+
if entry.symbolic_link?
|
519
|
+
bad_type = 'symbolic link'
|
520
|
+
elsif entry.block_special?
|
521
|
+
bad_type = 'block device'
|
522
|
+
elsif entry.character_special?
|
523
|
+
bad_type = 'character device'
|
524
|
+
elsif entry.fifo?
|
525
|
+
bad_type = 'pipe'
|
526
|
+
elsif entry.socket?
|
527
|
+
bad_type = 'socket'
|
528
|
+
end
|
529
|
+
|
530
|
+
if bad_type
|
531
|
+
raise Fig::RepositoryError.new(
|
532
|
+
"Could not extract #{entry.pathname} from #{archive_path} because it is a #{bad_type}."
|
533
|
+
)
|
534
|
+
end
|
535
|
+
|
536
|
+
return
|
537
|
+
end
|
538
|
+
|
511
539
|
# path = The local path the file should be downloaded to.
|
512
540
|
# command = The command to be run on the remote host.
|
513
541
|
def ssh_download(user, host, path, command)
|
data/lib/fig/package.rb
CHANGED
@@ -36,6 +36,17 @@ class Fig::Package
|
|
36
36
|
@backtrace = nil
|
37
37
|
end
|
38
38
|
|
39
|
+
# Is this the base package?
|
40
|
+
def base?()
|
41
|
+
return @base
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_base(yea_or_nay)
|
45
|
+
@base = yea_or_nay
|
46
|
+
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
39
50
|
def [](config_name)
|
40
51
|
@statements.each do |stmt|
|
41
52
|
return stmt if stmt.is_a?(Fig::Statement::Configuration) && stmt.name == config_name
|
@@ -133,23 +144,17 @@ class Fig::Package
|
|
133
144
|
end
|
134
145
|
|
135
146
|
def to_s_with_config(config_name)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
else
|
141
|
-
string = to_s
|
142
|
-
end
|
143
|
-
|
144
|
-
if not config_name.nil? and config_name != DEFAULT_CONFIG
|
145
|
-
string += ":#{config_name}"
|
146
|
-
end
|
147
|
-
|
148
|
-
return string
|
147
|
+
displayed_config = config_name == DEFAULT_CONFIG ? nil : config_name
|
148
|
+
return Fig::PackageDescriptor.format(
|
149
|
+
name || UNPUBLISHED, version, displayed_config
|
150
|
+
)
|
149
151
|
end
|
150
152
|
|
151
|
-
|
152
|
-
|
153
|
+
# Useful for debugging; should not be used for regular output.
|
154
|
+
def to_descriptive_string_with_config(config_name)
|
155
|
+
return Fig::PackageDescriptor.format(
|
156
|
+
name, version, config_name, :use_default_config, description
|
157
|
+
)
|
153
158
|
end
|
154
159
|
|
155
160
|
private
|
@@ -31,12 +31,12 @@ class Fig::PackageDefinitionTextAssembler
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Argument can either be a single Statement or an array of them.
|
34
|
-
def add_output(statements)
|
35
|
-
@output_statements << statements
|
36
|
-
@output_statements.flatten!
|
37
|
-
|
34
|
+
def add_output(*statements)
|
38
35
|
# Version gets determined by other statements, not by existing grammar.
|
39
|
-
@output_statements
|
36
|
+
@output_statements <<
|
37
|
+
statements.reject { |s| s.is_a? Fig::Statement::GrammarVersion }
|
38
|
+
|
39
|
+
@output_statements.flatten!
|
40
40
|
|
41
41
|
return
|
42
42
|
end
|
@@ -4,6 +4,7 @@ require 'socket'
|
|
4
4
|
require 'sys/admin'
|
5
5
|
require 'tmpdir'
|
6
6
|
|
7
|
+
require 'fig/statement/synthetic_raw_text'
|
7
8
|
require 'fig'
|
8
9
|
require 'fig/at_exit'
|
9
10
|
require 'fig/file_not_found_error'
|
@@ -221,6 +222,7 @@ class Fig::RepositoryPackagePublisher
|
|
221
222
|
Fig::AtExit.add { FileUtils.rm_f(file) }
|
222
223
|
|
223
224
|
@text_assembler.add_output(
|
225
|
+
Fig::Statement::SyntheticRawText.new(nil, nil, "\n"),
|
224
226
|
Fig::Statement::Archive.new(
|
225
227
|
nil,
|
226
228
|
%Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
|
@@ -3,6 +3,7 @@ require 'stringio'
|
|
3
3
|
require 'fig/include_backtrace'
|
4
4
|
require 'fig/logging'
|
5
5
|
require 'fig/package'
|
6
|
+
require 'fig/package_descriptor'
|
6
7
|
require 'fig/repository_error'
|
7
8
|
require 'fig/statement/include'
|
8
9
|
require 'fig/statement/override'
|
@@ -21,16 +22,22 @@ class Fig::RuntimeEnvironment
|
|
21
22
|
# noun and not a verb, e.g. "retrieve path" means the value of a retrieve
|
22
23
|
# statement and not the action of retrieving a path.
|
23
24
|
|
24
|
-
def initialize(
|
25
|
-
|
26
|
-
|
25
|
+
def initialize(
|
26
|
+
repository,
|
27
|
+
suppress_includes,
|
28
|
+
variables_override,
|
29
|
+
working_directory_maintainer
|
30
|
+
)
|
31
|
+
@repository = repository
|
32
|
+
@suppress_includes = suppress_includes
|
33
|
+
@variables =
|
27
34
|
variables_override || Fig::OperatingSystem.get_environment_variables()
|
28
|
-
@retrieves
|
29
|
-
@packages
|
35
|
+
@retrieves = {}
|
36
|
+
@packages = {}
|
30
37
|
@working_directory_maintainer = working_directory_maintainer
|
31
38
|
end
|
32
39
|
|
33
|
-
# Returns the value of an
|
40
|
+
# Returns the value of an environment variable
|
34
41
|
def [](name)
|
35
42
|
return @variables[name]
|
36
43
|
end
|
@@ -94,12 +101,14 @@ class Fig::RuntimeEnvironment
|
|
94
101
|
|
95
102
|
config = package[config_name]
|
96
103
|
|
97
|
-
Fig::Logging.debug(
|
104
|
+
Fig::Logging.debug(
|
105
|
+
"Applying #{package.to_descriptive_string_with_config config_name}."
|
106
|
+
)
|
107
|
+
package.add_applied_config_name(config_name)
|
98
108
|
config.statements.each do
|
99
109
|
|statement|
|
100
110
|
apply_config_statement(package, statement, new_backtrace)
|
101
111
|
end
|
102
|
-
package.add_applied_config_name(config_name)
|
103
112
|
|
104
113
|
return
|
105
114
|
end
|
@@ -154,7 +163,32 @@ class Fig::RuntimeEnvironment
|
|
154
163
|
return
|
155
164
|
end
|
156
165
|
|
166
|
+
def check_unused_retrieves()
|
167
|
+
@retrieves.keys().sort().each do
|
168
|
+
|name|
|
169
|
+
|
170
|
+
statement = @retrieves[name]
|
171
|
+
if statement.loaded_but_not_referenced?
|
172
|
+
text, * = Fig::Unparser.determine_version_and_unparse(
|
173
|
+
[statement], :emit_as_input
|
174
|
+
)
|
175
|
+
Fig::Logging.warn \
|
176
|
+
%Q<The #{name} variable was never referenced or didn't need expansion, so "#{text.strip}"#{statement.position_string} was ignored.>
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
private
|
182
|
+
|
157
183
|
def include_config(starting_package, descriptor, backtrace)
|
184
|
+
# Because package application starts with the synthetic package for the
|
185
|
+
# command-line, we can't really disable includes, full stop. Instead, we
|
186
|
+
# use the flag on the base package to break the chain of includes.
|
187
|
+
#
|
188
|
+
# Alternative approach: We could put a flag on synthetic include statements
|
189
|
+
# that says to always apply them.
|
190
|
+
return if starting_package.base? && @suppress_includes == :all
|
191
|
+
|
158
192
|
resolved_descriptor = nil
|
159
193
|
|
160
194
|
# Check to see if this include has been overridden.
|
@@ -176,6 +210,12 @@ class Fig::RuntimeEnvironment
|
|
176
210
|
resolved_descriptor.version,
|
177
211
|
new_backtrace
|
178
212
|
)
|
213
|
+
|
214
|
+
return if \
|
215
|
+
starting_package.base? \
|
216
|
+
&& @suppress_includes == :cross_package \
|
217
|
+
&& package != starting_package
|
218
|
+
|
179
219
|
apply_config(
|
180
220
|
package,
|
181
221
|
resolved_descriptor.config || Fig::Package::DEFAULT_CONFIG,
|
@@ -185,23 +225,6 @@ class Fig::RuntimeEnvironment
|
|
185
225
|
return
|
186
226
|
end
|
187
227
|
|
188
|
-
def check_unused_retrieves()
|
189
|
-
@retrieves.keys().sort().each do
|
190
|
-
|name|
|
191
|
-
|
192
|
-
statement = @retrieves[name]
|
193
|
-
if statement.loaded_but_not_referenced?
|
194
|
-
text, * = Fig::Unparser.determine_version_and_unparse(
|
195
|
-
[statement], :emit_as_input
|
196
|
-
)
|
197
|
-
Fig::Logging.warn \
|
198
|
-
%Q<The #{name} variable was never referenced or didn't need expansion, so "#{text.strip}"#{statement.position_string} was ignored.>
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
private
|
204
|
-
|
205
228
|
def set_variable(package, statement, backtrace)
|
206
229
|
expanded_value = expand_variable_as_path_and_process_retrieves(
|
207
230
|
statement, package, backtrace
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
16
|
-
requirement: &
|
16
|
+
requirement: &19793840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.5.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19793840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &19793360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.6.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19793360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &19792900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *19792900
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: libarchive-static
|
49
|
-
requirement: &
|
49
|
+
requirement: &19792420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *19792420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: log4r
|
60
|
-
requirement: &
|
60
|
+
requirement: &19791920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.5
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *19791920
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: net-netrc
|
71
|
-
requirement: &
|
71
|
+
requirement: &19791440 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.2.2
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *19791440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: net-sftp
|
82
|
-
requirement: &
|
82
|
+
requirement: &19809640 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 2.0.4
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *19809640
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: net-ssh
|
93
|
-
requirement: &
|
93
|
+
requirement: &19809160 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 2.0.15
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *19809160
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rdoc
|
104
|
-
requirement: &
|
104
|
+
requirement: &19808580 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '3.12'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *19808580
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: sys-admin
|
115
|
-
requirement: &
|
115
|
+
requirement: &19808100 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 1.5.6
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *19808100
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: treetop
|
126
|
-
requirement: &
|
126
|
+
requirement: &19807540 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 1.4.2
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *19807540
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: open4
|
137
|
-
requirement: &
|
137
|
+
requirement: &19806720 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: 1.0.1
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *19806720
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: bundler
|
148
|
-
requirement: &
|
148
|
+
requirement: &19806240 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: 1.0.15
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *19806240
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rake
|
159
|
-
requirement: &
|
159
|
+
requirement: &19805740 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: 0.8.7
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *19805740
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: rspec
|
170
|
-
requirement: &
|
170
|
+
requirement: &19805280 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - ~>
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: '2'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *19805280
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: rspec-core
|
181
|
-
requirement: &
|
181
|
+
requirement: &19804800 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ! '>='
|
@@ -186,10 +186,10 @@ dependencies:
|
|
186
186
|
version: 2.7.1
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *19804800
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: rspec-expectations
|
192
|
-
requirement: &
|
192
|
+
requirement: &19804340 !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
195
195
|
- - ! '>='
|
@@ -197,10 +197,10 @@ dependencies:
|
|
197
197
|
version: 2.7.0
|
198
198
|
type: :development
|
199
199
|
prerelease: false
|
200
|
-
version_requirements: *
|
200
|
+
version_requirements: *19804340
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: rspec-mocks
|
203
|
-
requirement: &
|
203
|
+
requirement: &19803860 !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
206
206
|
- - ! '>='
|
@@ -208,10 +208,10 @@ dependencies:
|
|
208
208
|
version: 2.7.0
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
|
-
version_requirements: *
|
211
|
+
version_requirements: *19803860
|
212
212
|
- !ruby/object:Gem::Dependency
|
213
213
|
name: simplecov
|
214
|
-
requirement: &
|
214
|
+
requirement: &19803380 !ruby/object:Gem::Requirement
|
215
215
|
none: false
|
216
216
|
requirements:
|
217
217
|
- - ! '>='
|
@@ -219,10 +219,10 @@ dependencies:
|
|
219
219
|
version: 0.6.2
|
220
220
|
type: :development
|
221
221
|
prerelease: false
|
222
|
-
version_requirements: *
|
222
|
+
version_requirements: *19803380
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: simplecov-html
|
225
|
-
requirement: &
|
225
|
+
requirement: &19802920 !ruby/object:Gem::Requirement
|
226
226
|
none: false
|
227
227
|
requirements:
|
228
228
|
- - ! '>='
|
@@ -230,7 +230,7 @@ dependencies:
|
|
230
230
|
version: 0.5.3
|
231
231
|
type: :development
|
232
232
|
prerelease: false
|
233
|
-
version_requirements: *
|
233
|
+
version_requirements: *19802920
|
234
234
|
description: Fig is a utility for configuring environments and managing dependencies
|
235
235
|
across a team of developers. Given a list of packages and a command to run, Fig
|
236
236
|
builds environment variables named in those packages (e.g., CLASSPATH), then executes
|