fig 0.1.57 → 0.1.59
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +80 -0
- data/VERSION +1 -1
- data/bin/fig-debug +12 -0
- data/bin/fig.bat +1 -0
- data/lib/fig/applicationconfiguration.rb +41 -41
- data/lib/fig/backtrace.rb +28 -30
- data/lib/fig/command.rb +52 -112
- data/lib/fig/command/listing.rb +207 -41
- data/lib/fig/command/packageload.rb +137 -0
- data/lib/fig/environment.rb +59 -72
- data/lib/fig/environmentvariables.rb +44 -0
- data/lib/fig/environmentvariables/caseinsensitive.rb +49 -0
- data/lib/fig/environmentvariables/casesensitive.rb +30 -0
- data/lib/fig/grammar.treetop +60 -35
- data/lib/fig/log4r/outputter.rb +96 -0
- data/lib/fig/logging.rb +2 -1
- data/lib/fig/logging/colorizable.rb +14 -0
- data/lib/fig/nosuchpackageconfigerror.rb +15 -0
- data/lib/fig/operatingsystem.rb +24 -13
- data/lib/fig/options.rb +70 -20
- data/lib/fig/package.rb +25 -26
- data/lib/fig/packagecache.rb +3 -3
- data/lib/fig/packagedescriptor.rb +36 -19
- data/lib/fig/packageparseerror.rb +7 -0
- data/lib/fig/parser.rb +76 -39
- data/lib/fig/repository.rb +131 -93
- data/lib/fig/retriever.rb +61 -39
- data/lib/fig/statement.rb +24 -2
- data/lib/fig/statement/archive.rb +4 -6
- data/lib/fig/statement/command.rb +4 -6
- data/lib/fig/statement/configuration.rb +7 -9
- data/lib/fig/statement/include.rb +49 -32
- data/lib/fig/statement/override.rb +7 -8
- data/lib/fig/statement/path.rb +4 -6
- data/lib/fig/statement/publish.rb +4 -11
- data/lib/fig/statement/resource.rb +4 -6
- data/lib/fig/statement/retrieve.rb +4 -6
- data/lib/fig/statement/set.rb +4 -6
- data/lib/fig/urlaccesserror.rb +4 -5
- metadata +52 -215
- data/LICENSE +0 -27
- data/README.md +0 -526
- data/TODO +0 -4
- data/lib/fig/packageerror.rb +0 -8
- data/lib/fig/windows.rb +0 -44
data/Changes
CHANGED
@@ -1,3 +1,83 @@
|
|
1
|
+
v0.1.59
|
2
|
+
|
3
|
+
Backwards incompatibilities:
|
4
|
+
|
5
|
+
- Specifying a config in the descriptor and --config is now an error, i.e you
|
6
|
+
can't do:
|
7
|
+
|
8
|
+
fig package/1.2.3:some_config --config some_other_config
|
9
|
+
|
10
|
+
Allowing configurations in both locations was ambiguous and the developers,
|
11
|
+
let alone users, couldn't tell which configuration would prevail.
|
12
|
+
|
13
|
+
New features:
|
14
|
+
|
15
|
+
- "--list-variables" option. This will display all variables manipulated by
|
16
|
+
Fig, following package dependencies recursively. Can have
|
17
|
+
"--list-all-configs" and "--list-tree" applied to it for tracking down
|
18
|
+
where that nasty setting of EDITOR to "emacs" comes from.
|
19
|
+
|
20
|
+
Example "--list-variables --list-tree" output:
|
21
|
+
|
22
|
+
A/1.2.3
|
23
|
+
| CLASSPATH = something:$CLASSPATH
|
24
|
+
| FROM_A = blah
|
25
|
+
'---C/5.6.7
|
26
|
+
| CLASSPATH = something_else:$CLASSPATH
|
27
|
+
| FROM_C = blah
|
28
|
+
'---B/1.2.3
|
29
|
+
CLASSPATH = planet_x:$CLASSPATH
|
30
|
+
FROM_B = blah
|
31
|
+
|
32
|
+
See README.md for more.
|
33
|
+
|
34
|
+
Suggestions for changes to the output format welcome.
|
35
|
+
|
36
|
+
- "--command-extra-args" option. Allows you to say that the rest of the fig
|
37
|
+
command-line is to be appended to the end of the command in a "command"
|
38
|
+
statement.
|
39
|
+
|
40
|
+
- The .fig file created in a repository now contains metadata about
|
41
|
+
the publishing of the package (time/user/host).
|
42
|
+
|
43
|
+
- Logging output is colorized if going to a tty on *nix. This includes
|
44
|
+
restoration of the old colorization of local package downloads/deletions.
|
45
|
+
Colors are not currently configurable.
|
46
|
+
|
47
|
+
- The primary package is now treated the same as other packages as far as
|
48
|
+
updates are concerned. Previously, if you started with a new environment,
|
49
|
+
e.g. FIG_HOME was empty, running "fig foo/1.2.3 -- echo foo" would fall
|
50
|
+
over. Even asking for updates ("fig --update foo/1.2.3 -- echo foo")
|
51
|
+
wouldn't change anything. Now the latter case will work.
|
52
|
+
|
53
|
+
- "--suppress-warning-include-statement-missing-version" option and "suppress
|
54
|
+
warnings" entry in figrc will, unsurprisingly, turn off warnings for things
|
55
|
+
like "include foo" in included packages. Note that this will NOT turn off
|
56
|
+
these warnings for the contents of a package.fig file.
|
57
|
+
|
58
|
+
The idea is that, while not having a version on an include is a bad idea,
|
59
|
+
you don't decide on the contents of your dependencies. So, this allows you
|
60
|
+
to stop Fig from complaining about things you can't control, while still
|
61
|
+
yelling at you for things that you do.
|
62
|
+
|
63
|
+
- The test suite passes on MS Windows!
|
64
|
+
|
65
|
+
Bug fixes:
|
66
|
+
|
67
|
+
- You can publish packages that have versionless includes again.
|
68
|
+
|
69
|
+
Significant Internals:
|
70
|
+
|
71
|
+
- The definition of a package descriptor has become more restrictive in the
|
72
|
+
Ruby code. This shouldn't be an issue because the Treetop grammar has
|
73
|
+
already restricted it this way; this is just a check from the Ruby side.
|
74
|
+
|
75
|
+
v0.1.58.beta.1
|
76
|
+
v0.1.58.alpha.2
|
77
|
+
v0.1.58.alpha.1
|
78
|
+
|
79
|
+
- Test releases
|
80
|
+
|
1
81
|
v0.1.57
|
2
82
|
|
3
83
|
- Logging output now goes to stderr by default, instead of stdout.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.59
|
data/bin/fig-debug
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), %w< .. lib > ))
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
require 'fig/command'
|
8
|
+
|
9
|
+
# Identical to regular fig, but doesn't use exception handling so you can see
|
10
|
+
# stack traces.
|
11
|
+
return_code = Fig::Command.new.run_fig(ARGV)
|
12
|
+
exit return_code
|
data/bin/fig.bat
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
@"ruby.exe" "%~dpn0" %*
|
@@ -1,53 +1,53 @@
|
|
1
|
-
module Fig
|
2
|
-
# Configuration for the Fig program, as opposed to the configuration for a
|
3
|
-
# package.
|
4
|
-
class ApplicationConfiguration
|
5
|
-
def initialize(remote_repository_url)
|
6
|
-
@data = []
|
7
|
-
@remote_repository_url = remote_repository_url
|
8
|
-
clear_cached_data
|
9
|
-
end
|
1
|
+
module Fig; end
|
10
2
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
3
|
+
# Configuration for the Fig program, as opposed to the configuration in a
|
4
|
+
# package.
|
5
|
+
class Fig::ApplicationConfiguration
|
6
|
+
def initialize(remote_repository_url)
|
7
|
+
@data = []
|
8
|
+
@remote_repository_url = remote_repository_url
|
9
|
+
clear_cached_data
|
10
|
+
end
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
12
|
+
def ensure_url_whitelist_initialized()
|
13
|
+
return if not @whitelist.nil?
|
14
|
+
whitelist = self['url whitelist']
|
15
|
+
if whitelist.nil?
|
16
|
+
@whitelist = []
|
17
|
+
else
|
18
|
+
@whitelist = [@remote_repository_url, whitelist].flatten
|
28
19
|
end
|
20
|
+
end
|
29
21
|
|
30
|
-
|
31
|
-
|
22
|
+
def [](key)
|
23
|
+
@data.each do |dataset|
|
24
|
+
if dataset.has_key?(key)
|
25
|
+
return dataset[key]
|
26
|
+
end
|
32
27
|
end
|
28
|
+
return nil
|
29
|
+
end
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
def push_dataset(dataset)
|
32
|
+
@data.push(dataset)
|
33
|
+
end
|
37
34
|
|
38
|
-
|
35
|
+
def unshift_dataset(dataset)
|
36
|
+
@data.unshift(dataset)
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
# after push_dataset or unshift_dataset, call clear_cached, and lazy
|
40
|
+
# initialize as far as the list of things to exclude
|
41
|
+
def clear_cached_data()
|
42
|
+
@whitelist = nil
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
return false
|
45
|
+
def url_access_allowed?(url)
|
46
|
+
ensure_url_whitelist_initialized
|
47
|
+
return true if @whitelist.empty?
|
48
|
+
@whitelist.each do |allowed_url|
|
49
|
+
return true if url.match(/\A#{Regexp.quote(allowed_url)}\b/)
|
51
50
|
end
|
51
|
+
return false
|
52
52
|
end
|
53
53
|
end
|
data/lib/fig/backtrace.rb
CHANGED
@@ -5,50 +5,48 @@ module Fig; end
|
|
5
5
|
class Fig::Backtrace
|
6
6
|
attr_reader :overrides
|
7
7
|
|
8
|
-
def initialize(parent,
|
9
|
-
@parent
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@config_name = config_name || 'default'
|
13
|
-
@overrides = {}
|
8
|
+
def initialize(parent, descriptor)
|
9
|
+
@parent = parent
|
10
|
+
@descriptor = descriptor
|
11
|
+
@overrides = {}
|
14
12
|
end
|
15
13
|
|
16
|
-
def
|
17
|
-
if @parent
|
18
|
-
@parent.collect(stack)
|
19
|
-
end
|
20
|
-
elem = ''
|
21
|
-
if @package_name
|
22
|
-
elem = @package_name
|
23
|
-
end
|
24
|
-
if @version_name
|
25
|
-
elem += '/' + @version_name
|
26
|
-
end
|
27
|
-
if @config_name
|
28
|
-
elem += ':' + @config_name
|
29
|
-
end
|
30
|
-
stack << elem
|
31
|
-
end
|
32
|
-
|
33
|
-
def add_override(package_name, version_name)
|
14
|
+
def add_override(package_name, version)
|
34
15
|
# Don't replace an existing override on the stack
|
35
16
|
return if get_override(package_name)
|
36
|
-
|
17
|
+
|
18
|
+
@overrides[package_name] = version
|
37
19
|
end
|
38
20
|
|
39
|
-
|
40
|
-
|
21
|
+
# Returns a version.
|
22
|
+
def get_override(package_name, default_version = nil)
|
23
|
+
version = @overrides[package_name]
|
24
|
+
return version if version
|
25
|
+
|
26
|
+
return @parent.get_override(package_name, default_version) if @parent
|
27
|
+
return default_version
|
41
28
|
end
|
42
29
|
|
30
|
+
# Prints a stack trace to the IO object.
|
43
31
|
def dump(out)
|
44
32
|
stack = []
|
45
33
|
collect(stack)
|
46
34
|
i=0
|
47
|
-
for
|
35
|
+
for descriptor in stack
|
48
36
|
indent=''
|
49
37
|
i.times { indent += ' ' }
|
50
|
-
out.puts indent+
|
38
|
+
out.puts indent + descriptor.to_string(:use_default_config)
|
51
39
|
i += 1
|
52
40
|
end
|
53
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def collect(stack)
|
46
|
+
if @parent
|
47
|
+
@parent.collect(stack)
|
48
|
+
end
|
49
|
+
|
50
|
+
stack << @descriptor
|
51
|
+
end
|
54
52
|
end
|
data/lib/fig/command.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'net/ftp'
|
3
|
-
require 'log4r'
|
4
3
|
require 'set'
|
5
4
|
|
6
5
|
require 'fig/environment'
|
@@ -17,17 +16,21 @@ require 'fig/statement/configuration'
|
|
17
16
|
require 'fig/statement/publish'
|
18
17
|
require 'fig/userinputerror'
|
19
18
|
|
20
|
-
#
|
19
|
+
# These are a breakout of parts of this class simply to keep the file size down.
|
20
|
+
|
21
21
|
# You will need to look in this file for any stuff related to --list-* options.
|
22
22
|
require 'fig/command/listing'
|
23
23
|
|
24
|
+
# You will need to look in this file for any stuff related to loading the
|
25
|
+
# primary Package object.
|
26
|
+
require 'fig/command/packageload'
|
27
|
+
|
24
28
|
module Fig; end
|
25
29
|
|
26
30
|
# Main program
|
27
31
|
class Fig::Command
|
28
32
|
include Fig::Command::Listing
|
29
|
-
|
30
|
-
DEFAULT_FIG_FILE = 'package.fig'
|
33
|
+
include Fig::Command::PackageLoad
|
31
34
|
|
32
35
|
def run_fig(argv)
|
33
36
|
@options = Fig::Options.new(argv)
|
@@ -40,7 +43,7 @@ class Fig::Command
|
|
40
43
|
|
41
44
|
if @options.clean?
|
42
45
|
check_required_package_descriptor('to clean')
|
43
|
-
@repository.clean(@descriptor
|
46
|
+
@repository.clean(@descriptor)
|
44
47
|
return 0
|
45
48
|
end
|
46
49
|
|
@@ -52,7 +55,7 @@ class Fig::Command
|
|
52
55
|
return publish()
|
53
56
|
end
|
54
57
|
|
55
|
-
|
58
|
+
load_package_object()
|
56
59
|
|
57
60
|
if @options.listing()
|
58
61
|
handle_post_parse_list_options()
|
@@ -63,11 +66,11 @@ class Fig::Command
|
|
63
66
|
|command| @operating_system.shell_exec command
|
64
67
|
end
|
65
68
|
elsif @descriptor
|
66
|
-
@environment.include_config(
|
67
|
-
@package, @descriptor.name, @descriptor.config, @descriptor.version, {}, nil
|
68
|
-
)
|
69
|
+
@environment.include_config(@package, @descriptor, {}, nil)
|
69
70
|
@environment.execute_config(
|
70
|
-
@package,
|
71
|
+
@package,
|
72
|
+
@descriptor,
|
73
|
+
@options.command_extra_argv || []
|
71
74
|
) { |cmd| @operating_system.shell_exec cmd }
|
72
75
|
elsif not @repository.updating?
|
73
76
|
$stderr.puts "Nothing to do.\n"
|
@@ -113,6 +116,15 @@ class Fig::Command
|
|
113
116
|
return nil
|
114
117
|
end
|
115
118
|
|
119
|
+
def check_include_statements_versions?()
|
120
|
+
return false if @options.suppress_warning_include_statement_missing_version?
|
121
|
+
|
122
|
+
suppressed_warnings = @configuration['suppress warnings']
|
123
|
+
return true if not suppressed_warnings
|
124
|
+
|
125
|
+
return ! suppressed_warnings.include?('include statement missing version')
|
126
|
+
end
|
127
|
+
|
116
128
|
def configure()
|
117
129
|
Fig::Logging.initialize_pre_configuration(@options.log_level())
|
118
130
|
|
@@ -139,21 +151,36 @@ class Fig::Command
|
|
139
151
|
@configuration,
|
140
152
|
nil, # remote_user
|
141
153
|
@options.update?,
|
142
|
-
@options.update_if_missing
|
154
|
+
@options.update_if_missing?,
|
155
|
+
check_include_statements_versions?
|
143
156
|
)
|
144
157
|
|
145
158
|
@retriever = Fig::Retriever.new('.')
|
146
159
|
|
147
|
-
|
148
|
-
at_exit { @retriever.save }
|
160
|
+
at_exit { @retriever.save_metadata() }
|
149
161
|
|
150
|
-
@environment =
|
162
|
+
@environment = prepare_environment
|
151
163
|
|
152
164
|
@options.non_command_package_statements().each do |statement|
|
153
165
|
@environment.apply_config_statement(nil, statement, nil)
|
154
166
|
end
|
155
167
|
end
|
156
168
|
|
169
|
+
def prepare_environment()
|
170
|
+
environment_variables = nil
|
171
|
+
if @options.reset_environment?
|
172
|
+
environment_variables = Fig::OperatingSystem.get_environment_variables({})
|
173
|
+
end
|
174
|
+
|
175
|
+
return Fig::Environment.new(@repository, environment_variables, @retriever)
|
176
|
+
end
|
177
|
+
|
178
|
+
def base_config()
|
179
|
+
return @options.config() ||
|
180
|
+
@descriptor && @descriptor.config ||
|
181
|
+
Fig::Package::DEFAULT_CONFIG
|
182
|
+
end
|
183
|
+
|
157
184
|
def check_required_package_descriptor(operation_description)
|
158
185
|
if not @descriptor
|
159
186
|
raise Fig::UserInputError.new(
|
@@ -172,100 +199,12 @@ class Fig::Command
|
|
172
199
|
end
|
173
200
|
end
|
174
201
|
|
175
|
-
def read_in_package_config_file(config_file)
|
176
|
-
if File.exist?(config_file)
|
177
|
-
return File.read(config_file)
|
178
|
-
else
|
179
|
-
raise Fig::UserInputError.new(%Q<File not found: "#{config_file}".>)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
202
|
def remote_operation_necessary?()
|
184
203
|
return @options.updating? ||
|
185
204
|
@options.publish? ||
|
186
205
|
@options.listing == :remote_packages
|
187
206
|
end
|
188
207
|
|
189
|
-
def load_package_config_file_contents()
|
190
|
-
package_config_file = @options.package_config_file()
|
191
|
-
|
192
|
-
if package_config_file == :none
|
193
|
-
return nil
|
194
|
-
elsif package_config_file == '-'
|
195
|
-
return $stdin.read
|
196
|
-
elsif package_config_file.nil?
|
197
|
-
if File.exist?(DEFAULT_FIG_FILE)
|
198
|
-
return File.read(DEFAULT_FIG_FILE)
|
199
|
-
end
|
200
|
-
else
|
201
|
-
return read_in_package_config_file(package_config_file)
|
202
|
-
end
|
203
|
-
|
204
|
-
return
|
205
|
-
end
|
206
|
-
|
207
|
-
def register_package_with_environment_if_not_listing()
|
208
|
-
return if @options.listing
|
209
|
-
|
210
|
-
register_package_with_environment()
|
211
|
-
|
212
|
-
return
|
213
|
-
end
|
214
|
-
|
215
|
-
def register_package_with_environment()
|
216
|
-
if @options.updating?
|
217
|
-
@package.retrieves.each do |var, path|
|
218
|
-
@environment.add_retrieve(var, path)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
@environment.register_package(@package)
|
223
|
-
@environment.apply_config(
|
224
|
-
@package,
|
225
|
-
@options.config() || @descriptor && @descriptor.config() || 'default',
|
226
|
-
nil
|
227
|
-
)
|
228
|
-
return
|
229
|
-
end
|
230
|
-
|
231
|
-
def parse_package_config_file(config_raw_text)
|
232
|
-
if config_raw_text.nil?
|
233
|
-
@package = Fig::Package.new(nil, nil, '.', [])
|
234
|
-
return
|
235
|
-
end
|
236
|
-
|
237
|
-
@package =
|
238
|
-
Fig::Parser.new(@configuration).parse_package(
|
239
|
-
nil, nil, '.', config_raw_text
|
240
|
-
)
|
241
|
-
|
242
|
-
register_package_with_environment_if_not_listing()
|
243
|
-
|
244
|
-
return
|
245
|
-
end
|
246
|
-
|
247
|
-
def load_package_file()
|
248
|
-
config_raw_text = load_package_config_file_contents()
|
249
|
-
|
250
|
-
parse_package_config_file(config_raw_text)
|
251
|
-
end
|
252
|
-
|
253
|
-
def get_package()
|
254
|
-
if @descriptor.nil?
|
255
|
-
load_package_file()
|
256
|
-
else
|
257
|
-
# TODO: complain if config file was specified on the command-line.
|
258
|
-
@package =
|
259
|
-
@repository.get_package(
|
260
|
-
@descriptor.name, @descriptor.version, :disable_updating
|
261
|
-
)
|
262
|
-
|
263
|
-
register_package_with_environment_if_not_listing()
|
264
|
-
end
|
265
|
-
|
266
|
-
return
|
267
|
-
end
|
268
|
-
|
269
208
|
def publish()
|
270
209
|
check_required_package_descriptor('to publish')
|
271
210
|
|
@@ -279,10 +218,12 @@ class Fig::Command
|
|
279
218
|
@options.archives() +
|
280
219
|
[
|
281
220
|
Fig::Statement::Configuration.new(
|
282
|
-
|
221
|
+
nil,
|
222
|
+
Fig::Package::DEFAULT_CONFIG,
|
223
|
+
@options.non_command_package_statements()
|
283
224
|
)
|
284
225
|
]
|
285
|
-
publish_statements << Fig::Statement::Publish.new(
|
226
|
+
publish_statements << Fig::Statement::Publish.new()
|
286
227
|
else
|
287
228
|
load_package_file()
|
288
229
|
if not @package.statements.empty?
|
@@ -294,10 +235,12 @@ class Fig::Command
|
|
294
235
|
end
|
295
236
|
|
296
237
|
if @options.publish?
|
297
|
-
Fig::Logging.info "Checking status of #{@descriptor.
|
238
|
+
Fig::Logging.info "Checking status of #{@descriptor.to_string()}..."
|
298
239
|
|
299
|
-
|
300
|
-
Fig::
|
240
|
+
package_description =
|
241
|
+
Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, nil)
|
242
|
+
if @repository.list_remote_packages.include?("#{package_description}")
|
243
|
+
Fig::Logging.info "#{@descriptor.to_string()} has already been published."
|
301
244
|
|
302
245
|
if not @options.force?
|
303
246
|
Fig::Logging.fatal 'Use the --force option if you really want to overwrite, or use --publish-local for testing.'
|
@@ -308,12 +251,9 @@ class Fig::Command
|
|
308
251
|
end
|
309
252
|
end
|
310
253
|
|
311
|
-
Fig::Logging.info "Publishing #{@descriptor.
|
254
|
+
Fig::Logging.info "Publishing #{@descriptor.to_string()}."
|
312
255
|
@repository.publish_package(
|
313
|
-
publish_statements,
|
314
|
-
@descriptor.name,
|
315
|
-
@descriptor.version,
|
316
|
-
@options.publish_local?
|
256
|
+
publish_statements, @descriptor, @options.publish_local?
|
317
257
|
)
|
318
258
|
|
319
259
|
return 0
|