fig 0.1.57 → 0.1.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/Changes +80 -0
  2. data/VERSION +1 -1
  3. data/bin/fig-debug +12 -0
  4. data/bin/fig.bat +1 -0
  5. data/lib/fig/applicationconfiguration.rb +41 -41
  6. data/lib/fig/backtrace.rb +28 -30
  7. data/lib/fig/command.rb +52 -112
  8. data/lib/fig/command/listing.rb +207 -41
  9. data/lib/fig/command/packageload.rb +137 -0
  10. data/lib/fig/environment.rb +59 -72
  11. data/lib/fig/environmentvariables.rb +44 -0
  12. data/lib/fig/environmentvariables/caseinsensitive.rb +49 -0
  13. data/lib/fig/environmentvariables/casesensitive.rb +30 -0
  14. data/lib/fig/grammar.treetop +60 -35
  15. data/lib/fig/log4r/outputter.rb +96 -0
  16. data/lib/fig/logging.rb +2 -1
  17. data/lib/fig/logging/colorizable.rb +14 -0
  18. data/lib/fig/nosuchpackageconfigerror.rb +15 -0
  19. data/lib/fig/operatingsystem.rb +24 -13
  20. data/lib/fig/options.rb +70 -20
  21. data/lib/fig/package.rb +25 -26
  22. data/lib/fig/packagecache.rb +3 -3
  23. data/lib/fig/packagedescriptor.rb +36 -19
  24. data/lib/fig/packageparseerror.rb +7 -0
  25. data/lib/fig/parser.rb +76 -39
  26. data/lib/fig/repository.rb +131 -93
  27. data/lib/fig/retriever.rb +61 -39
  28. data/lib/fig/statement.rb +24 -2
  29. data/lib/fig/statement/archive.rb +4 -6
  30. data/lib/fig/statement/command.rb +4 -6
  31. data/lib/fig/statement/configuration.rb +7 -9
  32. data/lib/fig/statement/include.rb +49 -32
  33. data/lib/fig/statement/override.rb +7 -8
  34. data/lib/fig/statement/path.rb +4 -6
  35. data/lib/fig/statement/publish.rb +4 -11
  36. data/lib/fig/statement/resource.rb +4 -6
  37. data/lib/fig/statement/retrieve.rb +4 -6
  38. data/lib/fig/statement/set.rb +4 -6
  39. data/lib/fig/urlaccesserror.rb +4 -5
  40. metadata +52 -215
  41. data/LICENSE +0 -27
  42. data/README.md +0 -526
  43. data/TODO +0 -4
  44. data/lib/fig/packageerror.rb +0 -8
  45. data/lib/fig/windows.rb +0 -44
data/LICENSE DELETED
@@ -1,27 +0,0 @@
1
- Copyright (c) 2009-2012, Matthew Foemmel
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without
5
- modification, are permitted provided that the following conditions are met:
6
-
7
- * Redistributions of source code must retain the above copyright
8
- notice, this list of conditions and the following disclaimer.
9
-
10
- * Redistributions in binary form must reproduce the above copyright
11
- notice, this list of conditions and the following disclaimer in the
12
- documentation and/or other materials provided with the distribution.
13
-
14
- * The names of the contributors may not be used to endorse or promote
15
- products derived from this software without specific prior written
16
- permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
22
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md DELETED
@@ -1,526 +0,0 @@
1
- Description
2
- ===========
3
-
4
- Fig is a utility for configuring environments and managing dependencies across
5
- a team of developers.
6
-
7
- An "environment" in fig is a set of environment variables. A "package" is a
8
- collection of files, along with some metadata describing which environment
9
- variables should be modified when the package is included. For instance, each
10
- dependency may prepend its corresponding jar to CLASSPATH. The metadata may
11
- also list that package's lower-level Fig package dependencies.
12
-
13
- Fig recursively builds an environment consisting of package dependencies
14
- (typically specified via command-line options or a package.fig file), each of
15
- which as noted above may have its own dependencies, and optionally executes a
16
- shell command in that environment. The caller's environment is not affected.
17
-
18
- Developers can use package.fig files to specify the list of dependencies to use
19
- for different tasks. This file will typically be versioned along with the rest
20
- of the source files, ensuring that all developers on a team are using the same
21
- environments.
22
-
23
- Packages exist in two places: a "local" repository cache in the user's home
24
- directory--also called the fig-home--and a "remote" repository on a shared
25
- server. Fig will automatically download packages from the remote repository and
26
- install them in the fig-home as needed. Fig does not contact the remote
27
- repository unless it needs to. The fig-home is $HOME/.fighome, but may be
28
- changed by setting the $FIG_HOME environment variable.
29
-
30
- Fig is similar to a lot of other package/dependency-management tools. In
31
- particular, it steals a lot of ideas from Apache Ivy and Debian APT. However,
32
- unlike Ivy, fig is meant to be lightweight (no XML, no JVM startup time),
33
- language agnostic (Java doesn't get preferential treatment), and work with
34
- executables as well as libraries. And unlike APT, fig is cross platform and
35
- project-oriented.
36
-
37
- Usage
38
- =====
39
-
40
- Fig recognizes the following options:
41
-
42
- ## Flags ##
43
-
44
- -?, -h, --help display this help text
45
- -v, --version Print fig version
46
- -g, --get VARIABLE print value of environment variable VARIABLE
47
- --list-local, --list list packages in $FIG_HOME
48
- --list-configs list configurations
49
- --list-dependencies list package dependencies, recursively
50
- --list-variables list all variables defined/used by package and its dependencies
51
- --list-remote list packages in remote repo
52
- --list-tree for listings, output a tree instead of a list
53
- --list-all-configs for listings, follow all configurations of the base package
54
- --clean remove package from $FIG_HOME
55
- --publish install package in $FIG_HOME and in remote repo
56
- --publish-local install package only in $FIG_HOME
57
- -c, --config CONFIG apply configuration CONFIG, default is "default"
58
- --file FILE read fig file FILE. Use '-' for stdin. See also --no-file
59
- --no-file ignore package.fig file in current directory
60
- -p, --append VARIABLE=VALUE append (actually, prepend) VALUE to environment variable VARIABLE, delimited by separator
61
- -i, --include DESCRIPTOR include package/version:config specified in DESCRIPTOR (with any variable prepends) in environment
62
- -s, --set VARIABLE=VALUE set environment variable VARIABLE to VALUE
63
- --archive PATH include PATH archive in package (when using --publish)
64
- --resource PATH include PATH resource in package (when using --publish)
65
- -u, --update check remote repo for updates and download to $FIG_HOME as necessary
66
- -m, --update-if-missing check remote repo for updates only if package missing from $FIG_HOME
67
- -l, --login login to remote repo as a non-anonymous user
68
- --force force-overwrite existing version of a package to the remote repo
69
- --figrc PATH add PATH to configuration used for Fig
70
- --no-figrc ignore ~/.figrc
71
- --log-config PATH use PATH file as configuration for Log4r
72
- --log-level LEVEL set logging level to LEVEL
73
- (off, fatal, error, warn, info, debug, all)
74
- -- end of fig options; anything after this is used as a command to run
75
-
76
- Some of these options may also be expressed as statements in a package.fig
77
- file. For instance, `--append`, `--archive`, `--resource`, `include`.
78
-
79
- One point of frequent confusion revolves around which statements are concerned
80
- with publishing packages, and which are for downloading packages and otherwise
81
- modifying the Fig environment. The same Fig file can contain both publish
82
- (e.g., `append`, `resource`) and download (e.g., `include`) statements, but you
83
- may not want to use the same dependency file for both publishing a package and
84
- specifying that same package's dependencies, since for example its "build-time"
85
- dependencies may differ from its "include-time" dependencies. Multiple config
86
- sections may be helpful in organizing these concerns.
87
-
88
- ## Environment Variables Influencing Fig's Behavior ##
89
-
90
- FIG_FTP_THREADS Optional - Size of FTP session pool. Defaults to 16.
91
- FIG_HOME Optional - Location of local repo cache. Defaults to $HOME/.fighome.
92
- FIG_REMOTE_LOGIN Required for --login, unless $HOME/.netrc is configured.
93
- FIG_REMOTE_URL Require for operations involving the remote repository.
94
- FIG_REMOTE_USER Required for --login, unless $HOME/.netrc is configured.
95
-
96
- ## Commands affected by environment variables
97
-
98
- #### `--list-remote` ####
99
-
100
- When using the `--list-remote` command against an FTP server, fig uses a pool
101
- of FTP sessions to improve performance. By default it opens 16 connections, but
102
- that number can be overridden by setting the `FIG_FTP_THREADS` environment
103
- variable.
104
-
105
- #### `--login` ####
106
-
107
- If the `--login` option is supplied, fig will look for credentials. If
108
- environment variables `FIG_REMOTE_USER` and/or `FIG_REMOTE_PASSWORD` are
109
- defined, fig will use them instead of prompting the user. If ~/.netrc exists,
110
- with an entry corresponding to the host parsed from `FIG_REMOTE_URL`, that
111
- entry will take precedence over `FIG_REMOTE_USER` and `FIG_REMOTE_PASSWORD`.
112
- If sufficient credentials are still not found, fig will prompt for whatever is
113
- still missing, and use the accumulated credentials to authenticate against the
114
- remote server. Even if both environment variables are defined, fig will only
115
- use them if `--login` is given.
116
-
117
- Examples
118
- ========
119
-
120
- Fig lets you configure environments three different ways:
121
-
122
- * From the command line
123
- * From a "package.fig" file in the current directory
124
- * From packages included indirectly via one of the previous two methods
125
-
126
- ## Command Line ##
127
-
128
- To get started, let's define an environment variable via the command line and
129
- execute a command in the new environment. We'll set the "GREETING" variable to
130
- "Hello", then run a command that uses that variable:
131
-
132
- $ fig -s GREETING=Hello -- echo '$GREETING, World'
133
- Hello, World
134
-
135
- Also note that when running fig, the original environment isn't affected:
136
-
137
- $ echo $GREETING
138
- <nothing>
139
-
140
- Fig also lets you append environment variables using the system-specified path
141
- separator (e.g. colon on Unix, semicolon on windows). This is useful for adding
142
- directories to the PATH, LD_LIBRARY_PATH, CLASSPATH, etc. For example, let's
143
- create a "bin" directory, add a shell script to it, then include it in the
144
- PATH:
145
-
146
- $ mkdir bin
147
- $ echo 'echo $GREETING, World' > bin/hello
148
- $ chmod +x bin/hello
149
- $ fig -s GREETING=Hello -p PATH=bin -- hello
150
- Hello, World
151
-
152
- ## Fig Files ##
153
-
154
- You can also specify environment modifiers in files. Fig looks for a file
155
- called "package.fig" in the current directory and automatically processes it.
156
-
157
- This "package.fig" file implements the previous example:
158
-
159
- config default
160
- set GREETING=Hello
161
- append PATH=@/bin
162
- end
163
-
164
- Then we can just run:
165
-
166
- $ fig -- hello
167
- Hello, World
168
-
169
- NOTE: The '@' symbol in a given package.fig file (or in a published
170
- dependency's .fig file) represents the full path to that file's directory. The
171
- above example would still work if we just used "bin", but later on when we
172
- publish our project to the shared repository we'll definitely need the '@',
173
- since the project directories will live in the fig-home rather than under our
174
- current directory).
175
-
176
- A single fig file may have multiple configurations:
177
-
178
- config default
179
- set GREETING=Hello
180
- append PATH=@/bin
181
- end
182
-
183
- config french
184
- set GREETING=Bonjour
185
- append PATH=@/bin
186
- end
187
-
188
- ## Config Sections ##
189
-
190
- Configurations other than "default" can be specified using the "-c" option:
191
-
192
- $ fig -c french -- hello
193
- Bonjour, World
194
-
195
- The statements from one config section can be incorporated into another config
196
- section via an `include` statement:
197
-
198
- config default
199
- include :spanish
200
- end
201
-
202
- config spanish
203
- set GREETING="Buenas Dias"
204
- append PATH=@/bin
205
- end
206
-
207
- Note that config statements cannot be nested within a fig file. I.e. the
208
- following is _invalid_:
209
-
210
- config foo
211
- config bar
212
- end
213
- end
214
-
215
- ## Packages ##
216
-
217
- Let's share our little script with the rest of the team by bundling it into a
218
- package and publishing it. First, point the `FIG_REMOTE_URL` environment
219
- variable to the remote repository. If you just want to play around with fig,
220
- you can have it point to a local directory:
221
-
222
- $ export FIG_REMOTE_URL=file://$(pwd)/remote
223
-
224
- Before we publish our package, we'll need to tell fig which files we want to
225
- include. We do this by using the "resource" statement in our "package.fig"
226
- file:
227
-
228
- resource bin/hello
229
-
230
- config default...
231
-
232
- Now we can share the package with the rest of the team by using the `--publish`
233
- option:
234
-
235
- $ fig --publish hello/1.0.0
236
-
237
- Once the package has been published, we can include it in other environments
238
- with the `-i` or `--include` option. (For the purpose of this example, let's
239
- first move the "package.fig" file out of the way, so that it doesn't confuse
240
- fig or us.) The "hello/1.0.0" string represents the name of the package and the
241
- version number.
242
-
243
- $ mv package.fig package.bak
244
- $ fig -u -i hello/1.0.0 -- hello
245
- ...downloading files...
246
- Hello, World
247
-
248
- The `-u` (or `--update`) option tells fig to check the remote repository for
249
- packages if they aren't already installed locally (fig will never make any
250
- network connections unless this option is specified). Once the packages are
251
- downloaded, we can run the same command without the `-u` option:
252
-
253
- $ fig -i hello/1.0.0 -- hello
254
- Hello, World
255
-
256
- When including a package, you can specify a particular configuration by
257
- appending it to the package name using a colon:
258
-
259
- $ fig -i hello/1.0.0:french -- hello
260
- Bonjour, World
261
-
262
- ## Retrieves ##
263
-
264
- By default, the resources associated with a package live in the fig home
265
- directory, which defaults to "$HOME/.fighome". This doesn't always play nicely
266
- with IDE's however, so fig provides a "retrieve" statement to copy resources
267
- from the repository to the current directory.
268
-
269
- For example, let's create a package that contains a library for the "foo"
270
- programming language. Define a "package.fig" file:
271
-
272
- config default
273
- append FOOPATH=@/lib/hello.foo
274
- end
275
-
276
- Then:
277
-
278
- $ mkdir lib
279
- $ echo "print 'hello'" > lib/hello.foo
280
- $ fig --publish hello-lib/3.2.1
281
-
282
- Create a new "package.fig" file (first moving to a different directory or
283
- deleting the "package.fig" we just used for publishing):
284
-
285
- retrieve FOOPATH->lib/[package]
286
- config default
287
- include hello-lib/3.2.1
288
- end
289
-
290
- Upon a `fig --update`, each resource in FOOPATH will be copied into
291
- lib/[package], where [package] resolves to the resource's package name (minus
292
- the version).
293
-
294
- $ fig -u
295
- ...downloading...
296
- ...retrieving...
297
- $ cat lib/hello-lib/hello.foo
298
- print 'hello'
299
-
300
- Package Statement Descriptions
301
- ==============================
302
-
303
- ## `add` ##
304
-
305
- Specifies a value to be appended to a `PATH`-like environment variable, e.g.
306
- `CLASSPATH` for Java. Does not include the delimiter within the variable, just
307
- the component value.
308
-
309
- ## `append` ##
310
-
311
- Synonym for `add`.
312
-
313
- ## `archive` ##
314
-
315
- Specifies an archive file (either a local path or a URL) that is supposed to be
316
- incorporated into the package. This is different from a `resource` in that the
317
- contents will be extracted as part of installation.
318
-
319
- ## `command` ##
320
-
321
- Specifies a default command to be run for a given `config` when no command is
322
- given on the command-line.
323
-
324
- config default
325
- command echo Hello there.
326
- end
327
-
328
- Cannot be specified outside of a `config` statement. There may not be multiple
329
- commands within a given `config`.
330
-
331
- ## `config` ##
332
-
333
- A grouping of statements that specifies what is to be done. There must either
334
- be a configuration named "default" or you will always have to specify a
335
- configuration on the command-line.
336
-
337
- May not be nested. If you wish to incorporate the effects of one configuration
338
- into another, use an `include` statement.
339
-
340
- ## `include` ##
341
-
342
- Can be used in two ways: to affect configurations and to declare package
343
- dependencies.
344
-
345
- ### Pull one configuration into another ###
346
-
347
- You can get the effects of one configuration in another by using the name of
348
- the other configuration preceded by a colon:
349
-
350
- config a
351
- include :b
352
- end
353
-
354
- config b
355
- ...
356
- end
357
-
358
- ### Declare a package dependency ###
359
-
360
- States that one package should be installed prior to the current one; can
361
- specify a version.
362
-
363
- config default
364
- include somepackage/1.2.3
365
- end
366
-
367
- Dependency version conflicts can be resolved by using `override` clauses.
368
-
369
- Say you've got a "base-dependency" package. Then, in the `package.fig` for
370
- "middle-dependency-a" you have
371
-
372
- config default
373
- include base-dependency/1.2.3
374
- end
375
-
376
- And in the `package.fig` for "middle-dependency-b" you have
377
-
378
- config default
379
- include base-dependency/3.2.1
380
- end
381
-
382
- Finally, in the `package.fig` for the package you're working on you've got
383
-
384
- config default
385
- include middle-dependency-a
386
- include middle-dependency-b
387
- end
388
-
389
- This will produce a conflicting requirement on "base-dependency". Resolve this
390
- by either matching the version of one dependency to another:
391
-
392
- config default
393
- include middle-dependency-a override base-dependency/3.2.1
394
- include middle-dependency-b
395
- end
396
-
397
- Or specify the same version to both:
398
-
399
- config default
400
- include middle-dependency-a override base-dependency/2.2.2
401
- include middle-dependency-b override base-dependency/2.2.2
402
- end
403
-
404
- Multiple `override` clauses can be specified in a single `include` statement.
405
-
406
- ## `path` ##
407
-
408
- Synonym for `add`.
409
-
410
- ## `resource` ##
411
-
412
- Specifies a file (either a local path or a URL) that is supposed to be
413
- incorporated into the package. This is different from an `archive` in that the
414
- contents will not be extracted as part of installation.
415
-
416
- ## `retrieve` ##
417
-
418
- Gives the installation location for a dependency.
419
-
420
- ## `set` ##
421
-
422
- Gives the value of an environment variable. Unlike `add`/`append`/`path`, this
423
- is the complete, final value.
424
-
425
- Querying Fig Net Effects
426
- ========================
427
-
428
- If you've got a long chain of dependencies of packages, it can be challenging
429
- to figure out the full effects of it. There are a number of commands for just
430
- figuring out what things are coming from.
431
-
432
- ## `--list-dependencies` ##
433
-
434
- By itself, this will give you the total set of packages you're pulling in.
435
-
436
- For example, if you have package A which depends upon packages B and C
437
- which both depend upon package D, running
438
-
439
- fig --list-dependencies A/1.2.3
440
-
441
- will give you
442
-
443
- B/2.3.4
444
- C/3.4.5
445
- D/4.5.6
446
-
447
- If there are no dependencies and stdout is connected to a terminal you'll get:
448
-
449
- fig --list-dependencies package-with-no-dependencies/1.2.3
450
-
451
- <no dependencies>
452
-
453
- However, if stdout is not connected to a terminal:
454
-
455
- fig --list-dependencies package-with-no-dependencies/1.2.3 | cat
456
-
457
- [no output]
458
-
459
- ### `--list-tree` ###
460
-
461
- If you additionally specify `--list-tree`, you'll get a nested dependency
462
- tree:
463
-
464
- fig --list-dependencies --list-tree A/1.2.3
465
-
466
- A/1.2.3
467
- B/2.3.4
468
- D/4.5.6
469
- C/3.4.5
470
- D/4.5.6
471
-
472
- If you don't specify a package descriptor, but you've got a package.fig
473
- file in the current directory with the same dependencies as package A
474
- above, you'll get
475
-
476
- fig --list-dependencies --list-tree
477
-
478
- <unpublished>
479
- B/2.3.4
480
- D/4.5.6
481
- C/3.4.5
482
- D/4.5.6
483
-
484
- ### `--list-all-configs` ###
485
-
486
- This will follow all of the dependencies using all the configurations in the
487
- package descriptor or the package.fig file. This will not follow all
488
- configurations in all depended upon packages, only the ones reachable by one of
489
- the configurations in the starting package.
490
-
491
- Installation and Development
492
- ============================
493
-
494
- ## Installation ##
495
-
496
- gem install fig
497
-
498
- *NOTE*: When installing Fig on Windows you must first have installed the
499
- Development Kit available from http://rubyinstaller.org/downloads. Instructions
500
- for installation of the Development Kit are available at
501
- https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.
502
-
503
- ## Building the gem ##
504
-
505
- rake build
506
-
507
- ## Building a gem for ruby 1.8.7 on Windows ##
508
-
509
- You can no longer use the rakefile to produce this specific gem. You will need
510
- to create a fig.gemspec file manually. Use the list of gem dependencies found
511
- in the rakefile as a guide. There are two specific gems that need to be
512
- depended on: json v 1.4.2 and libarchive-static-ruby186. Also, the spec.files
513
- should specificly list all the source files, pathed from the base directory
514
- of the project.
515
-
516
- Community
517
- =========
518
-
519
- \#fig on irc.freenode.net
520
-
521
- [Fig Mailing List](http://groups.google.com/group/fig-user)
522
-
523
- Copyright
524
- =========
525
-
526
- Copyright (c) 2009-2012 Matthew Foemmel. See LICENSE for details.