fig18 0.1.45-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/Changes ADDED
@@ -0,0 +1,55 @@
1
+ v0.1.xx
2
+
3
+ - "file:" protocol works for FIG_REMOTE_HOME.
4
+
5
+ - Testing no longer requires ssh.
6
+
7
+
8
+ v0.1.41
9
+
10
+ - Release cleanup
11
+
12
+
13
+ v0.1.40
14
+
15
+ - Works on Mac (in conjunction with libarchive-static 1.0.1).
16
+
17
+ - Supports configuration via rc files in JSON format. These can be (in
18
+ ascending order of priority of values):
19
+ - in the repository under "_meta/figrc"
20
+ - in your home directory in ".figrc"
21
+ - specified on the command-line via the "--figrc" option
22
+
23
+ Note that values from all the above locations will be merged into a
24
+ single, net application configuration. E.g. if
25
+ <repository>/_meta/figrc contains
26
+
27
+ {"a" => 5, "b" => 7"}
28
+
29
+ and ~/.figrc contains
30
+
31
+ {"a" => 37}
32
+
33
+ then Fig will see a value for "a" of 37 and a value for "b" of 7.
34
+
35
+ Processing of ~/.figrc can be suppressed via the "--no-figrc" option.
36
+
37
+ - Supports logging via log4r. Configure via "log configuration" in the rc
38
+ files or via the "--log-config" and "--log-level" command-line options.
39
+ The configuration files must be in XML or YAML format in a way supported
40
+ by log4r and contain configuration for a "fig" logger. The "--log-level"
41
+ will override any value found in the configuration files.
42
+
43
+ - Added additional messages about activity including file download source
44
+ and destination. Try "--log-level debug". Suggestions about changes to
45
+ levels that are supported, which levels messages are emitted at, and any
46
+ additional desired logging are welcome.
47
+
48
+ - Supports "-v/--version" to emit the Fig version.
49
+
50
+ - No longer silently does nothing when no arguments are specified.
51
+
52
+ - Start of support for restricting URLs in package.fig files via a URL
53
+ whitelist; not complete yet and will likely change.
54
+
55
+ - RSpec usage has been upgraded to v2.
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2009, 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 ADDED
@@ -0,0 +1,283 @@
1
+ Description
2
+ ===========
3
+
4
+ Fig is a utility for configuring environments and managing dependencies across a team of developers.
5
+
6
+ An "environment" in fig is a set of environment variables. A "package" is a
7
+ collection of files, along with some metadata describing which environment variables
8
+ should be modified when the package is included. For instance, each dependency
9
+ may prepend its corresponding jar to CLASSPATH. The metadata may also list
10
+ that package's lower-level Fig package dependencies.
11
+
12
+ Fig recursively builds an environment consisting of package dependencies
13
+ (typically specified via command-line options or a package.fig file), each of
14
+ which as noted above may have its own dependencies, and optionally executes a
15
+ shell command in that environment. The caller's environment is not affected.
16
+
17
+ Developers can use package.fig files to specify the list of dependencies to use for
18
+ different tasks. This file will typically be versioned along with the rest of
19
+ the source files, ensuring that all developers on a team are using the same
20
+ environemnts.
21
+
22
+ Packages exist in two places: a "local" repository cache in the user's home
23
+ directory--also called the fig-home--and a "remote" repository on a shared
24
+ server. Fig will automatically download packages from the remote repository and
25
+ install them in the fig-home as needed. Fig does not contact the remote
26
+ repository unless it needs to. The fig-home is $HOME/.fighome, but may be
27
+ changed by setting the $FIG_HOME environment variable.
28
+
29
+ Fig is similar to a lot of other package/dependency-management tools. In
30
+ particular, it steals a lot of ideas from Apache Ivy and Debian APT. However,
31
+ unlike Ivy, fig is meant to be lightweight (no XML, no JVM startup time),
32
+ language agnostic (Java doesn't get preferential treatment), and work with
33
+ executables as well as libraries. And unlike APT, fig is cross platform and
34
+ project-oriented.
35
+
36
+ Installation
37
+ ============
38
+
39
+ $ gem install fig
40
+
41
+ Or, if running Ruby 1.8.x...
42
+
43
+ $ gem install fig18
44
+
45
+ Usage
46
+ =====
47
+
48
+ Fig recognizes the following options:
49
+
50
+ ### Flags ###
51
+
52
+ -?, -h, --help display this help text
53
+ -v, --version Print fig version
54
+ -p, --append VAR=VAL append (actually, prepend) VAL to environment var VAR, delimited by separator
55
+ --archive FULLPATH include FULLPATH archive in package (when using --publish)
56
+ --clean PKG remove package from $FIG_HOME
57
+ -c, --config CFG apply configuration CFG, default is 'default'
58
+ -d, --debug print debug info
59
+ --file FILE read fig file FILE. Use '-' for stdin. See also --no-file
60
+ --force force-overwrite existing version of a package to the remote repo
61
+ -g, --get VAR print value of environment variable VAR
62
+ -i, --include PKG include PKG (with any variable prepends) in environment
63
+ --list list packages in $FIG_HOME
64
+ --list-configs PKG list configurations in package
65
+ --list-remote list packages in remote repo
66
+ -l, --login login to remote repo as a non-anonymous user
67
+ --no-file ignore package.fig file in current directory
68
+ --publish PKG install PKG in $FIG_HOME and in remote repo
69
+ --publish-local PKG install package only in $FIG_HOME
70
+ --resource FULLPATH include FULLPATH resource in package (when using --publish)
71
+ -s, --set VAR=VAL set environment variable VAR to VAL
72
+ -u, --update check remote repo for updates and download to $FIG_HOME as necessary
73
+ -m, --update-if-missing check remote repo for updates only if package missing from $FIG_HOME
74
+ --figrc PATH use PATH file as .rc file for Fig
75
+ --no-figrc ignore ~/.figrc
76
+ --log-config PATH use PATH file as configuration for Log4r
77
+ --log-level LEVEL set logging level to LEVEL
78
+ (off, fatal, error, warn, info, debug, all)
79
+
80
+ -- end of fig options; everything following is a command to run in the fig environment.
81
+
82
+ Some of these options may also be expressed as statements in a package.fig file. For instance,
83
+ `--append`, `--archive`, `--resource`, `include`.
84
+
85
+ One point of frequent confusion revolves around which statements are concerned with publishing packages, and
86
+ which are for downloading packages and otherwise modifying the Fig environment. The same Fig file
87
+ can contain both publish (e.g., `append`, `resource`) and download (e.g., `include`) statements,
88
+ but you may not want to use the same
89
+ dependency file for both publishing a package and specifying that same package's dependencies,
90
+ since for example its "build-time" dependencies may differ from its "include-time" dependencies.
91
+ Multiple config sections may be helpful in organizing these concerns.
92
+
93
+ ### Environment Variables Influencing Fig's Behavior ###
94
+
95
+ `FIG_FTP_THREADS` Optional - Size of FTP session pool. Defaults to 16.
96
+ `FIG_HOME` Optional - Location of local repo cache. Defaults to $HOME/.fighome.
97
+ `FIG_REMOTE_LOGIN` Required for --login, unless $HOME/.netrc is configured.
98
+ `FIG_REMOTE_URL` Require for operations involving the remote repository.
99
+ `FIG_REMOTE_USER` Required for --login, unless $HOME/.netrc is configured.
100
+
101
+ [--list-remote] When using the `--list-remote` command against an FTP server, fig uses a pool of FTP sessions to improve
102
+ performance. By default it opens 16 connections, but that number can be overridden by setting the
103
+ `FIG_FTP_THREADS` environment variable.
104
+
105
+ [--login] If the `--login` option is supplied, fig will look for credentials. If
106
+ environment variables `FIG_REMOTE_USER` and/or `FIG_REMOTE_PASSWORD` are
107
+ defined, fig will use them instead of prompting the user. If ~/.netrc exists,
108
+ with an entry corresponding to the host parsed from `FIG_REMOTE_URL`, that
109
+ entry will take precedence over `FIG_REMOTE_USER` and `FIG_REMOTE_PASSWORD`.
110
+ If sufficient credentials are still not found, fig will prompt for whatever is
111
+ still missing, and use the accumulated credentials to authenticate against the
112
+ remote server. Even if both environment variables are defined, fig will only
113
+ use them if `--login` is given.
114
+
115
+ Examples
116
+ ========
117
+
118
+ Fig lets you configure environments three different ways:
119
+
120
+ * From the command line
121
+ * From a "package.fig" file in the current directory
122
+ * From packages included indirectly via one of the previous two methods
123
+
124
+ ### Command Line ###
125
+
126
+ To get started, let's define an environment variable via the command line and
127
+ execute a command in the new environment. We'll set the "GREETING" variable to
128
+ "Hello", then run a command that uses that variable:
129
+
130
+ $ fig -s GREETING=Hello -- echo '$GREETING, World'
131
+ Hello, World
132
+
133
+ Also note that when running fig, the original environment isn't affected:
134
+
135
+ $ echo $GREETING
136
+ <nothing>
137
+
138
+ Fig also lets you append environment variables using the system-specified path separator (e.g. colon on unix, semicolon on windows). This is useful for adding directories to the PATH, LD_LIBRARY_PATH, CLASSPATH, etc. For example, let's create a "bin" directory, add a shell script to it, then include it in the PATH:
139
+
140
+ $ mkdir bin
141
+ $ echo 'echo $GREETING, World' > bin/hello
142
+ $ chmod +x bin/hello
143
+ $ fig -s GREETING=Hello -p PATH=bin -- hello
144
+ Hello, World
145
+
146
+ ### Fig Files ###
147
+
148
+ You can also specify environment modifiers in files. Fig looks for a file called "package.fig" in the current directory and automatically processes it.
149
+ This "package.fig" file implements the previous example:
150
+
151
+ config default
152
+ set GREETING=Hello
153
+ append PATH=@/bin
154
+ end
155
+
156
+ Then we can just run:
157
+
158
+ $ fig -- hello
159
+ Hello, World
160
+
161
+ NOTE: The '@' symbol in a given package.fig file (or in a published dependency's .fig
162
+ file) represents the full path to that file's directory. The
163
+ above example would
164
+ still work if we just used "bin", but later on when we publish our project to
165
+ the shared repository we'll definitely need the '@', since the project directories will
166
+ live in the fig-home rather than under our current directory).
167
+
168
+ A single fig file may have multiple configurations:
169
+
170
+ config default
171
+ set GREETING=Hello
172
+ append PATH=@/bin
173
+ end
174
+
175
+ config french
176
+ set GREETING=Bonjour
177
+ append PATH=@/bin
178
+ end
179
+
180
+ ### Config Sections ###
181
+
182
+ Configurations other than "default" can be specified using the "-c" option:
183
+
184
+ $ fig -c french -- hello
185
+ Bonjour, World
186
+
187
+ A config section can be included in another config section:
188
+
189
+ config default
190
+ include :spanish
191
+ end
192
+
193
+ config spanish
194
+ set GREETING="Buenas Dias"
195
+ append PATH=@/bin
196
+ end
197
+
198
+ ### Packages ###
199
+
200
+ Let's share our little script with the rest of the team by bundling it into a
201
+ package and publishing it. First, point the `FIG_REMOTE_URL` environment
202
+ variable to the remote repository. If you just want to play around with fig,
203
+ you can have it point to localhost:
204
+
205
+ $ export FIG_REMOTE_URL=ssh://localhost$(pwd)/remote
206
+
207
+ Before we publish our package, we'll need to tell fig which files we want to include. We do this by using the "resource" statement in our "package.fig" file:
208
+
209
+ resource bin/hello
210
+
211
+ config default...
212
+
213
+ Now we can share the package with the rest of the team by using the `--publish` option:
214
+
215
+ $ fig --publish hello/1.0.0
216
+
217
+ Once the package has been published, we can include it in other environments
218
+ with the `-i` or `--include` option. (For the purpose of this example, let's
219
+ first move the "package.fig" file out of the way, so that it doesn't confuse
220
+ fig or us.) The "hello/1.0.0" string represents the name of the package and the
221
+ version number.
222
+
223
+ $ mv package.fig package.bak
224
+ $ fig -u -i hello/1.0.0 -- hello
225
+ ...downloading files...
226
+ Hello, World
227
+
228
+ The `-u` (or `--update`) option tells fig to check the remote repository for packages if they aren't already installed locally (fig will never make any network connections unless this option is specified). Once the packages are downloaded, we can run the same command without the `-u` option:
229
+
230
+ $ fig -i hello/1.0.0 -- hello
231
+ Hello, World
232
+
233
+ When including a package, you can specify a particular configuration by appending it to the package name using a colon:
234
+
235
+ $ fig -i hello/1.0.0:french -- hello
236
+ Bonjour, World
237
+
238
+ ### Retrieves ###
239
+
240
+ By default, the resources associated with a package live in the fig home
241
+ directory, which defaults to "$HOME/.fighome". This doesn't always play nicely with
242
+ IDE's however, so fig provides a "retrieve" statement to copy resources from the repository to
243
+ the current directory.
244
+
245
+ For example, let's create a package that contains a library for the "foo" programming language. Define a "package.fig" file:
246
+
247
+ config default
248
+ append FOOPATH=@/lib/hello.foo
249
+ end
250
+
251
+ Then:
252
+
253
+ $ mkdir lib
254
+ $ echo "print 'hello'" > lib/hello.foo
255
+ $ fig --publish hello-lib/3.2.1
256
+
257
+ Create a new "package.fig" file (first moving to a different directory or deleting the "package.fig" we just used for publishing):
258
+
259
+ retrieve FOOPATH->lib/[package]
260
+ config default
261
+ include hello-lib/3.2.1
262
+ end
263
+
264
+ Upon a `fig --update`, each resource in FOOPATH will be copied into lib/[package], where [package] resolves to the resource's
265
+ package name (minus the version).
266
+
267
+ $ fig -u
268
+ ...downloading...
269
+ ...retrieving...
270
+ $ cat lib/hello-lib/hello.foo
271
+ print 'hello'
272
+
273
+ Community
274
+ =========
275
+
276
+ \#fig on irc.freenode.net
277
+
278
+ [Fig Mailing List](http://groups.google.com/group/fig-user)
279
+
280
+ Copyright
281
+ =========
282
+
283
+ Copyright (c) 2009 Matthew Foemmel. See LICENSE for details.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.45
data/bin/fig 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'
8
+
9
+ include Fig
10
+
11
+ return_code = run_with_exception_handling(ARGV)
12
+ exit return_code
data/bin/fig-download ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # todo copied from os.rb
4
+ NOT_MODIFIED = 3
5
+ NOT_FOUND = 4
6
+ SUCCESS = 0
7
+
8
+ timestamp = ARGV[0].to_i
9
+ path = ARGV[1]
10
+
11
+ exit NOT_FOUND unless File.exist?(path)
12
+ exit NOT_MODIFIED if File.mtime(path).to_i <= timestamp
13
+
14
+ File.open(path) do |file|
15
+ while bytes = file.read(4096) do
16
+ $stdout.write(bytes)
17
+ end
18
+ end
19
+
20
+ exit SUCCESS
@@ -0,0 +1,52 @@
1
+
2
+ module Fig
3
+ class ApplicationConfiguration
4
+ def initialize(remote_repository_url)
5
+ @data = []
6
+ @remote_repository_url = remote_repository_url
7
+ clear_cached_data
8
+ end
9
+
10
+ def ensure_url_whitelist_initialized()
11
+ return if not @whitelist.nil?
12
+ whitelist = self['url_whitelist']
13
+ if whitelist.nil?
14
+ @whitelist = []
15
+ else
16
+ @whitelist = [@remote_repository_url, whitelist].flatten
17
+ end
18
+ end
19
+
20
+ def [](key)
21
+ @data.each do |dataset|
22
+ if dataset.has_key?(key)
23
+ return dataset[key]
24
+ end
25
+ end
26
+ return nil
27
+ end
28
+
29
+ def push_dataset(dataset)
30
+ @data.push(dataset)
31
+ end
32
+
33
+ def unshift_dataset(dataset)
34
+ @data.unshift(dataset)
35
+ end
36
+
37
+ # after push_dataset or unshift_dataset, call clear_cached, and lazy initialize as far as the list of things to exclude
38
+
39
+ def clear_cached_data()
40
+ @whitelist = nil
41
+ end
42
+
43
+ def url_access_allowed?(url)
44
+ ensure_url_whitelist_initialized
45
+ return true if @whitelist.empty?
46
+ @whitelist.each do |allowed_url|
47
+ return true if url.match(/\A#{Regexp.quote(allowed_url)}\b/)
48
+ end
49
+ return false
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,50 @@
1
+ class Backtrace
2
+ attr_reader :overrides
3
+
4
+ def initialize(parent, package_name, version_name, config_name)
5
+ @parent = parent
6
+ @package_name = package_name
7
+ @version_name = version_name
8
+ @config_name = config_name || 'default'
9
+ @overrides = {}
10
+ end
11
+
12
+ def collect(stack)
13
+ if @parent
14
+ @parent.collect(stack)
15
+ end
16
+ elem = ''
17
+ if @package_name
18
+ elem = @package_name
19
+ end
20
+ if @version_name
21
+ elem += '/' + @version_name
22
+ end
23
+ if @config_name
24
+ elem += ':' + @config_name
25
+ end
26
+ stack << elem
27
+ end
28
+
29
+ def add_override(package_name, version_name)
30
+ # Don't replace an existing override on the stack
31
+ return if get_override(package_name)
32
+ @overrides[package_name] = version_name
33
+ end
34
+
35
+ def get_override(package_name)
36
+ return @overrides[package_name] || (@parent ? @parent.get_override(package_name) : nil)
37
+ end
38
+
39
+ def dump(out)
40
+ stack = []
41
+ collect(stack)
42
+ i=0
43
+ for elem in stack
44
+ indent=''
45
+ i.times { indent += ' ' }
46
+ out.puts indent+elem
47
+ i += 1
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,15 @@
1
+ require 'fig/userinputerror'
2
+
3
+ module Fig
4
+ # Could not determine some kind of information from a configuration file,
5
+ # whether .figrc, log4r, package.fig, etc.
6
+ class ConfigFileError < UserInputError
7
+ def initialize(message, file)
8
+ super(message)
9
+
10
+ @file = file
11
+
12
+ return
13
+ end
14
+ end
15
+ end